diff options
author | Eric Davis <edavis@littlestreamsoftware.com> | 2009-09-13 17:14:35 +0000 |
---|---|---|
committer | Eric Davis <edavis@littlestreamsoftware.com> | 2009-09-13 17:14:35 +0000 |
commit | 7b0cb6aba8715aff00519f200060fbf46ae9bb97 (patch) | |
tree | c4dc3bcac1a48020c2afef87094056a9a5e06b6f /vendor | |
parent | fb349dc4abe283481984c67cd1287312f128dbfc (diff) | |
download | redmine-7b0cb6aba8715aff00519f200060fbf46ae9bb97.tar.gz redmine-7b0cb6aba8715aff00519f200060fbf46ae9bb97.zip |
Upgraded to Rails 2.3.4 (#3597)
* Ran the Rails upgrade
* Upgraded to Rails Engines 2.3.2
* Added a plugin to let Engines override application views.
* Converted tests to use the new classes:
** ActionController::TestCase for functional
** ActiveSupport::TestCase for units
* Converted ActiveRecord::Error message to a string.
* ActiveRecord grouping returns an ordered hash which doesn't have #sort!
* Updated the I18n storage_units format.
* Added some default initializers from a fresh rails app
* Changed the order of check_box_tags and hidden_field_tags. The hidden tag
needs to appear first in Rails 2.3, otherwise it will override any value in
the check_box_tag.
* Removed the custom handler for when the cookie store is tampered with.
Rails 2.3 removed the TamperedWithCookie exception and instead Rails will not
load the data from it when it's been tampered with (e.g. no user login).
* Fixed mail layouts, 2.3 has problems with implicit multipart emails that
use layouts. Also removed some custom Redmine mailer code.
* Fixed a bug that occurred in tests where the "required" span tag would be
added to the :field_status translation. This resulted in an email string of:
<li>Status<span class="required"> *</span><span class="required"> *</span>
Instead of:
<li>Status: New</li>
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@2887 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'vendor')
107 files changed, 993 insertions, 243 deletions
diff --git a/vendor/plugins/engines/Rakefile b/vendor/plugins/engines/Rakefile index b9640226c..6c621deeb 100644 --- a/vendor/plugins/engines/Rakefile +++ b/vendor/plugins/engines/Rakefile @@ -172,16 +172,29 @@ namespace :test do desc 'Update the plugin and tests files in the test application from the plugin' task :mirror_engine_files => [:test_app, :copy_engines_plugin] do - puts "> Modifying default config files to load engines plugin" + puts "> Tweaking generated application to be suitable for testing" + + # Replace the Rails plugin loader with the engines one. insert_line("require File.join(File.dirname(__FILE__), '../vendor/plugins/engines/boot')", :into => 'config/environment.rb', :after => "require File.join(File.dirname(__FILE__), 'boot')") - - insert_line('map.from_plugin :test_routing', :into => 'config/routes.rb', - :after => /\AActionController::Routing::Routes/) - + + # Add the engines test helper to handle fixtures & stuff. insert_line("require 'engines_test_helper'", :into => 'test/test_helper.rb') + # Run engine plugin tests when running the application + insert_line("task :test => ['test:engines:all']", :into => 'Rakefile') + + # We want exceptions to be raised + insert_line("def rescue_action(e) raise e end;", + :into => "app/controllers/application_controller.rb", + :after => "class ApplicationController < ActionController::Base") + + # We need this method to test where actions are being rendered from. + insert_line("include RenderInformation", + :into => "app/controllers/application_controller.rb", + :after => "class ApplicationController < ActionController::Base") + puts "> Mirroring test application files into #{test_app_dir}" mirror_test_files('app') mirror_test_files('lib') diff --git a/vendor/plugins/engines/about.yml b/vendor/plugins/engines/about.yml index 619bd5a93..13f55ec97 100644 --- a/vendor/plugins/engines/about.yml +++ b/vendor/plugins/engines/about.yml @@ -4,4 +4,4 @@ homepage: http://www.rails-engines.org summary: Enhances the plugin mechanism to perform more flexible sharing description: The Rails Engines plugin allows the sharing of almost any type of code or asset that you could use in a Rails application, including controllers, models, stylesheets, and views. license: MIT -version: 2.1.0
\ No newline at end of file +version: 2.3.2
\ No newline at end of file diff --git a/vendor/plugins/engines/boot.rb b/vendor/plugins/engines/boot.rb index f80f2b17b..1c55e2139 100644 --- a/vendor/plugins/engines/boot.rb +++ b/vendor/plugins/engines/boot.rb @@ -1,7 +1,7 @@ begin require 'rails/version' - unless Rails::VERSION::MAJOR >= 2 && Rails::VERSION::MINOR >= 2 && Rails::VERSION::TINY >= 0 - raise "This version of the engines plugin requires Rails 2.2.0 or later!" + unless Rails::VERSION::MAJOR >= 2 && Rails::VERSION::MINOR >= 3 && Rails::VERSION::TINY >= 2 + raise "This version of the engines plugin requires Rails 2.3.2 or later!" end end diff --git a/vendor/plugins/engines/init.rb b/vendor/plugins/engines/init.rb index df9452632..28418166a 100644 --- a/vendor/plugins/engines/init.rb +++ b/vendor/plugins/engines/init.rb @@ -1,5 +1,5 @@ # Only call Engines.init once, in the after_initialize block so that Rails # plugin reloading works when turned on config.after_initialize do - Engines.init if defined? :Engines -end + Engines.init(initializer) if defined? :Engines +end
\ No newline at end of file diff --git a/vendor/plugins/engines/lib/engines.rb b/vendor/plugins/engines/lib/engines.rb index cb97e4702..d601710b0 100644 --- a/vendor/plugins/engines/lib/engines.rb +++ b/vendor/plugins/engines/lib/engines.rb @@ -43,7 +43,7 @@ module Engines # List of extensions to load, can be changed in init.rb before calling Engines.init mattr_accessor :rails_extensions - self.rails_extensions = %w(action_mailer asset_helpers form_tag_helpers routing migrations dependencies) + self.rails_extensions = %w(asset_helpers form_tag_helpers migrations dependencies) # The name of the public directory to mirror public engine assets into. # Defaults to <tt>RAILS_ROOT/public/plugin_assets</tt>. @@ -68,7 +68,7 @@ module Engines mattr_accessor :disable_application_code_loading self.disable_application_code_loading = false - # Set this ti true if code should not be mixed (i.e. it will be loaded + # Set this to true if code should not be mixed (i.e. it will be loaded # from the first valid path on $LOAD_PATH) mattr_accessor :disable_code_mixing self.disable_code_mixing = false @@ -81,7 +81,7 @@ module Engines self.code_mixing_file_types = %w(controller helper) class << self - def init + def init(initializer) load_extensions Engines::Assets.initialize_base_public_directory end @@ -124,9 +124,9 @@ module Engines # and that they are placed within plugin/app/things (the pluralized form of 'thing'). # # It's important to note that you'll also want to ensure that the "things" are - # on your load path in your plugin's init.rb: + # on your load path by including them in Rails load path mechanism, e.g. in init.rb: # - # Rails.plugins[:my_plugin].code_paths << "app/things" + # ActiveSupport::Dependencies.load_paths << File.join(File.dirname(__FILE__), 'app', 'things')) # def mix_code_from(*types) self.code_mixing_file_types += types.map { |x| x.to_s.singularize } diff --git a/vendor/plugins/engines/lib/engines/plugin.rb b/vendor/plugins/engines/lib/engines/plugin.rb index 488bcd4bc..c52bbb0ce 100644 --- a/vendor/plugins/engines/lib/engines/plugin.rb +++ b/vendor/plugins/engines/lib/engines/plugin.rb @@ -4,23 +4,9 @@ # # Engines.plugins[:plugin_name] # -# If this plugin contains paths in directories other than <tt>app/controllers</tt>, -# <tt>app/helpers</tt>, <tt>app/models</tt> and <tt>components</tt>, authors can -# declare this by adding extra paths to #code_paths: -# -# Rails.plugin[:my_plugin].code_paths << "app/sweepers" << "vendor/my_lib" -# # Other properties of the Plugin instance can also be set. module Engines class Plugin < Rails::Plugin - # Plugins can add code paths to this attribute in init.rb if they - # need plugin directories to be added to the load path, i.e. - # - # plugin.code_paths << 'app/other_classes' - # - # Defaults to ["app/controllers", "app/helpers", "app/models", "components"] - attr_accessor :code_paths - # Plugins can add paths to this attribute in init.rb if they need # controllers loaded from additional locations. attr_accessor :controller_paths @@ -32,16 +18,6 @@ module Engines attr_accessor :public_directory protected - - # The default set of code paths which will be added to $LOAD_PATH - # and Dependencies.load_paths - def default_code_paths - # lib will actually be removed from the load paths when we call - # uniq! in #inject_into_load_paths, but it's important to keep it - # around (for the documentation tasks, for instance). - %w(app/controllers app/helpers app/models components lib) - end - # The default set of code paths which will be added to the routing system def default_controller_paths %w(app/controllers components) @@ -58,41 +34,23 @@ module Engines def initialize(directory) super directory - @code_paths = default_code_paths @controller_paths = default_controller_paths @public_directory = default_public_directory end - # Returns a list of paths this plugin wishes to make available in $LOAD_PATH - # - # Overwrites the correspondend method in the superclass - def load_paths - report_nonexistant_or_empty_plugin! unless valid? - select_existing_paths :code_paths - end - # Extends the superclass' load method to additionally mirror public assets def load(initializer) return if loaded? super initializer - add_plugin_view_paths add_plugin_locale_paths Assets.mirror_files_for(self) end - # for code_paths and controller_paths select those paths that actually - # exist in the plugin's directory + # select those paths that actually exist in the plugin's directory def select_existing_paths(name) Engines.select_existing_paths(self.send(name).map { |p| File.join(directory, p) }) end - def add_plugin_view_paths - view_path = File.join(directory, 'app', 'views') - if File.exist?(view_path) - ActionController::Base.prepend_view_path(view_path) # push it just underneath the app - end - end - def add_plugin_locale_paths locale_path = File.join(directory, 'locales') return unless File.exists?(locale_path) @@ -112,11 +70,6 @@ module Engines "#{File.basename(Engines.public_directory)}/#{name}" end - # The path to this plugin's routes file - def routes_path - File.join(directory, "routes.rb") - end - # The directory containing this plugin's migrations (<tt>plugin/db/migrate</tt>) def migration_directory File.join(self.directory, 'db', 'migrate') diff --git a/vendor/plugins/engines/lib/engines/plugin/loader.rb b/vendor/plugins/engines/lib/engines/plugin/loader.rb index a5be5967b..e316e4750 100644 --- a/vendor/plugins/engines/lib/engines/plugin/loader.rb +++ b/vendor/plugins/engines/lib/engines/plugin/loader.rb @@ -5,14 +5,7 @@ module Engines def register_plugin_as_loaded(plugin) super plugin Engines.plugins << plugin - register_to_routing(plugin) end - - # Registers the plugin's controller_paths for the routing system. - def register_to_routing(plugin) - initializer.configuration.controller_paths += plugin.select_existing_paths(:controller_paths) - initializer.configuration.controller_paths.uniq! - end end end end
\ No newline at end of file diff --git a/vendor/plugins/engines/lib/engines/rails_extensions/action_mailer.rb b/vendor/plugins/engines/lib/engines/rails_extensions/action_mailer.rb deleted file mode 100644 index 32198d8e9..000000000 --- a/vendor/plugins/engines/lib/engines/rails_extensions/action_mailer.rb +++ /dev/null @@ -1,82 +0,0 @@ -# The way ActionMailer is coded in terms of finding templates is very restrictive, to the point -# where all templates for rendering must exist under the single base path. This is difficult to -# work around without re-coding significant parts of the action mailer code. -# -# --- -# -# The MailTemplates module overrides two (private) methods from ActionMailer to enable mail -# templates within plugins: -# -# [+template_path+] which now produces the contents of #template_paths -# [+initialize_template_class+] which now find the first matching template and creates -# an ActionVew::Base instance with the correct view_paths -# -# Ideally ActionMailer would use the same template-location logic as ActionView, and the same -# view paths as ActionController::Base.view_paths, but it currently does not. -module Engines::RailsExtensions::ActionMailer - def self.included(base) #:nodoc: - base.class_eval do - alias_method_chain :template_path, :engine_additions - alias_method_chain :initialize_template_class, :engine_additions - end - end - - private - - #-- - # ActionMailer::Base#create uses two mechanisms to determine the proper template file(s) - # to load. Firstly, it searches within the template_root for files that much the explicit - # (or implicit) part encodings (like signup.text.plain.erb for the signup action). - # This is how implicit multipart emails are built, by the way. - # - # Secondly, it then creates an ActionMailer::Base instance with it's view_paths parameter - # set to the template_root, so that ActionMailer will then take over rendering the - # templates. - # - # Ideally, ActionMailer would pass the same set of view paths as it gets in a normal - # request (i.e. ActionController::Base.view_paths), so that all possible view paths - # were searched. However, this seems to introduce some problems with helper modules. - # - # So instead, and because we have to fool these two independent parts of ActionMailer, - # we fudge with the mechanisms it uses to find the templates (via template_paths, and - # template_path_with_engine_additions), and then intercept the creation of the ActionView - # instance so we can set the view_paths (in initialize_template_class_with_engine_additions). - #++ - - # Returns all possible template paths for the current mailer, including those - # within the loaded plugins. - def template_paths - paths = Engines.plugins.by_precedence.map { |p| "#{p.directory}/app/views/#{mailer_name}" } - paths.unshift(template_path_without_engine_additions) unless Engines.disable_application_view_loading - paths - end - - # Return something that Dir[] can glob against. This method is called in - # ActionMailer::Base#create! and used as part of an argument to Dir. We can - # take advantage of this by using some of the features of Dir.glob to search - # multiple paths for matching files. - def template_path_with_engine_additions - "{#{template_paths.join(",")}}" - end - - # Return an instance of ActionView::Base with the view paths set to all paths - # in ActionController::Base.view_paths (i.e. including all plugin view paths) - def initialize_template_class_with_engine_additions(assigns) - # I'd like to just return this, but I get problems finding methods in helper - # modules if the method implemention from the regular class is not called - # - # ActionView::Base.new(ActionController::Base.view_paths.dup, assigns, self) - renderer = initialize_template_class_without_engine_additions(assigns) - renderer.view_paths.unshift(*ActionController::Base.view_paths.dup) - renderer - end -end - -# We don't need to do this if ActionMailer hasn't been loaded. -if Object.const_defined?(:ActionMailer) - module ::ActionMailer #:nodoc: - class Base #:nodoc: - include Engines::RailsExtensions::ActionMailer - end - end -end
\ No newline at end of file diff --git a/vendor/plugins/engines/lib/engines/rails_extensions/routing.rb b/vendor/plugins/engines/lib/engines/rails_extensions/routing.rb deleted file mode 100644 index aed85ffbc..000000000 --- a/vendor/plugins/engines/lib/engines/rails_extensions/routing.rb +++ /dev/null @@ -1,83 +0,0 @@ -# Effective use of Rails' routes can help create a tidy and elegant set of URLs, -# and is a significant part of creating an external API for your web application. -# -# When developing plugins which contain controllers, it seems obvious that including -# the corresponding routes would be extremely useful. This is particularly true -# when exposing RESTful resources using the new REST-ian features of Rails. -# -# == Including routes in your plugin -# -# The engines plugin makes it possible to include a set of routes within your plugin -# very simply, as it turns out. Include a <tt>routes.rb</tt> file like the one below -# at the root of your plugin (along-side <tt>init.rb</tt> and <tt>lib/</tt>): -# -# connect "/login", :controller => "account", :action => "login" -# -# # add a named route -# logout "/logout", :controller => "account", :action => "logout" -# -# # some restful stuff -# resources :things do |t| -# t.resources :other_things -# end -# -# Everywhere in a normal <tt>RAILS_ROOT/config/routes.rb</tt> file -# where you might have <tt>map.connect</tt>, you just use <tt>connect</tt> in your -# plugin's <tt>routes.rb</tt>. -# -# === Hooking it up in your application -# -# While it would be possible to have each plugin's routes automagically included into -# the application's route set, to do so would actually be a stunningly bad idea. Route -# priority is the key issue here. You, the application developer, needs to be in complete -# control when it comes to specifying the priority of routes in your application, since -# the ordering of your routes directly affects how Rails will interpret incoming requests. -# -# To add plugin routes into your application's <tt>routes.rb</tt> file, you need to explicitly -# map them in using the Engines::RailsExtensions::Routing#from_plugin method: -# -# ApplicationController::Routing::Routes.draw do |map| -# -# map.connect "/app_stuff", :controller => "application_thing" # etc... -# -# # This line includes the routes from the given plugin at this point, giving you -# # control over the priority of your application routes -# map.from_plugin :your_plugin -# -# map.connect ":controller/:action/:id" -# end -# -# By including routes in plugins which have controllers, you can now share in a simple way -# a compact and elegant URL scheme which corresponds to those controllers. -# -# --- -# -# The Engines::RailsExtensions::Routing module defines extensions to Rails' -# routing (ActionController::Routing) mechanism such that routes can be loaded -# from a given plugin. -# -# The key method is Engines::RailsExtensions::Routing#from_plugin, which can be called -# within your application's <tt>config/routes.rb</tt> file to load plugin routes at that point. -# -module Engines::RailsExtensions::Routing - # Loads the set of routes from within a plugin and evaluates them at this - # point within an application's main <tt>routes.rb</tt> file. - # - # Plugin routes are loaded from <tt><plugin_root>/routes.rb</tt>. - def from_plugin(name) - map = self # to make 'map' available within the plugin route file - routes_path = Engines.plugins[name].routes_path - eval(IO.read(routes_path), binding, routes_path) if File.file?(routes_path) - end -end - - -module ::ActionController #:nodoc: - module Routing #:nodoc: - class RouteSet #:nodoc: - class Mapper #:nodoc: - include Engines::RailsExtensions::Routing - end - end - end -end diff --git a/vendor/plugins/engines/lib/engines/testing.rb b/vendor/plugins/engines/lib/engines/testing.rb index f7833c385..c411f8335 100644 --- a/vendor/plugins/engines/lib/engines/testing.rb +++ b/vendor/plugins/engines/lib/engines/testing.rb @@ -67,10 +67,14 @@ module Engines::Testing # This method is called by the engines-supplied plugin testing rake tasks def self.setup_plugin_fixtures(plugins = Engines.plugins.by_precedence) + # First, clear the directory + Dir.glob("#{self.temporary_fixtures_directory}/*.yml").each{|fixture| File.delete(fixture)} + # Copy all plugin fixtures, and then the application fixtures, into this directory plugins.each do |plugin| plugin_fixtures_directory = File.join(plugin.directory, "test", "fixtures") - if File.directory?(plugin_fixtures_directory) + plugin_app_directory = File.join(plugin.directory, "app") + if File.directory?(plugin_app_directory) && File.directory?(plugin_fixtures_directory) Engines.mirror_files_from(plugin_fixtures_directory, self.temporary_fixtures_directory) end end @@ -84,4 +88,14 @@ module Engines::Testing ActiveSupport::TestCase.fixture_path = self.temporary_fixtures_directory $LOAD_PATH.unshift self.temporary_fixtures_directory end + + # overridden test should be in test/{unit,functional,integration}/{plugin_name}/{test_name} + def self.override_tests_from_app + filename = caller.first.split(":").first + plugin_name = filename.split("/")[-4] + test_kind = filename.split("/")[-2] + override_file = File.expand_path(File.join(File.dirname(filename), "..", "..", "..", "..", "..", "test", + test_kind, plugin_name, File.basename(filename))) + load(override_file) if File.exist?(override_file) + end end
\ No newline at end of file diff --git a/vendor/plugins/engines/tasks/engines.rake b/vendor/plugins/engines/tasks/engines.rake index 0ffd7e6e7..48e317066 100644 --- a/vendor/plugins/engines/tasks/engines.rake +++ b/vendor/plugins/engines/tasks/engines.rake @@ -118,10 +118,10 @@ namespace :db do end desc 'Migrate a specified plugin.' - task({:plugin => :environment}, :name, :version) do |task, args| - name = args[:name] || ENV['NAME'] + task(:plugin => :environment) do + name = ENV['NAME'] if plugin = Engines.plugins[name] - version = args[:version] || ENV['VERSION'] + version = ENV['VERSION'] puts "Migrating #{plugin.name} to " + (version ? "version #{version}" : 'latest version') + " ..." plugin.migrate(version ? version.to_i : nil) else @@ -152,8 +152,8 @@ end # this is just a modification of the original task in railties/lib/tasks/documentation.rake, # because the default task doesn't support subdirectories like <plugin>/app or -# <plugin>/component. These tasks now include every file under a plugin's code paths (see -# Plugin#code_paths). +# <plugin>/component. These tasks now include every file under a plugin's load paths (see +# Plugin#load_paths). namespace :doc do plugins = FileList['vendor/plugins/**'].collect { |plugin| File.basename(plugin) } @@ -172,9 +172,9 @@ namespace :doc do options << '--line-numbers' << '--inline-source' options << '-T html' - # Include every file in the plugin's code_paths (see Plugin#code_paths) + # Include every file in the plugin's load_paths (see Plugin#load_paths) if Engines.plugins[plugin] - files.include("#{plugin_base}/{#{Engines.plugins[plugin].code_paths.join(",")}}/**/*.rb") + files.include("#{plugin_base}/{#{Engines.plugins[plugin].load_paths.join(",")}}/**/*.rb") end if File.exists?("#{plugin_base}/README") files.include("#{plugin_base}/README") @@ -217,6 +217,34 @@ Report any issues on http://dev.rails-engines.org. Thanks! -~===============( ... as you were ... )============================~-} end + namespace :engines do + + def engine_plugins + Dir["vendor/plugins/*"].select { |f| File.directory?(File.join(f, "app")) }.map { |f| File.basename(f) }.join(",") + end + + desc "Run tests from within engines plugins (plugins with an 'app' directory)" + task :all => [:units, :functionals, :integration] + + desc "Run unit tests from within engines plugins (plugins with an 'app' directory)" + Rake::TestTask.new(:units => "test:plugins:setup_plugin_fixtures") do |t| + t.pattern = "vendor/plugins/{#{ENV['PLUGIN'] || engine_plugins}}/test/unit/**/*_test.rb" + t.verbose = true + end + + desc "Run functional tests from within engines plugins (plugins with an 'app' directory)" + Rake::TestTask.new(:functionals => "test:plugins:setup_plugin_fixtures") do |t| + t.pattern = "vendor/plugins/{#{ENV['PLUGIN'] || engine_plugins}}/test/functional/**/*_test.rb" + t.verbose = true + end + + desc "Run integration tests from within engines plugins (plugins with an 'app' directory)" + Rake::TestTask.new(:integration => "test:plugins:setup_plugin_fixtures") do |t| + t.pattern = "vendor/plugins/{#{ENV['PLUGIN'] || engine_plugins}}/test/integration/**/*_test.rb" + t.verbose = true + end + end + namespace :plugins do desc "Run the plugin tests in vendor/plugins/**/test (or specify with PLUGIN=name)" diff --git a/vendor/plugins/engines/test/app/controllers/app_and_plugin_controller.rb b/vendor/plugins/engines/test/app/controllers/app_and_plugin_controller.rb new file mode 100644 index 000000000..90b13ff1f --- /dev/null +++ b/vendor/plugins/engines/test/app/controllers/app_and_plugin_controller.rb @@ -0,0 +1,5 @@ +class AppAndPluginController < ApplicationController + def an_action + render_class_and_action 'from app' + end +end diff --git a/vendor/plugins/engines/test/app/controllers/namespace/app_and_plugin_controller.rb b/vendor/plugins/engines/test/app/controllers/namespace/app_and_plugin_controller.rb new file mode 100644 index 000000000..05f9049e9 --- /dev/null +++ b/vendor/plugins/engines/test/app/controllers/namespace/app_and_plugin_controller.rb @@ -0,0 +1,5 @@ +class Namespace::AppAndPluginController < ApplicationController + def an_action + render_class_and_action 'from app' + end +end diff --git a/vendor/plugins/engines/test/app/helpers/mail_helper.rb b/vendor/plugins/engines/test/app/helpers/mail_helper.rb new file mode 100644 index 000000000..9e081e75f --- /dev/null +++ b/vendor/plugins/engines/test/app/helpers/mail_helper.rb @@ -0,0 +1,5 @@ +module MailHelper + def do_something_helpful(var) + var.to_s.reverse + end +end
\ No newline at end of file diff --git a/vendor/plugins/engines/test/app/models/app_and_plugin_model.rb b/vendor/plugins/engines/test/app/models/app_and_plugin_model.rb new file mode 100644 index 000000000..f0fe903c4 --- /dev/null +++ b/vendor/plugins/engines/test/app/models/app_and_plugin_model.rb @@ -0,0 +1,3 @@ +class AppAndPluginModel < ActiveRecord::Base + def self.report_location; TestHelper::report_location(__FILE__); end +end
\ No newline at end of file diff --git a/vendor/plugins/engines/test/app/models/notify_mail.rb b/vendor/plugins/engines/test/app/models/notify_mail.rb new file mode 100644 index 000000000..899fc1a40 --- /dev/null +++ b/vendor/plugins/engines/test/app/models/notify_mail.rb @@ -0,0 +1,26 @@ +class NotifyMail < ActionMailer::Base + + helper :mail + + def signup(txt) + body(:name => txt) + end + + def multipart + recipients 'some_address@email.com' + subject 'multi part email' + from "another_user@email.com" + content_type 'multipart/alternative' + + part :content_type => "text/html", :body => render_message("multipart_html", {}) + part "text/plain" do |p| + p.body = render_message("multipart_plain", {}) + end + end + + def implicit_multipart + recipients 'some_address@email.com' + subject 'multi part email' + from "another_user@email.com" + end +end
\ No newline at end of file diff --git a/vendor/plugins/engines/test/app/things/thing.rb b/vendor/plugins/engines/test/app/things/thing.rb new file mode 100644 index 000000000..ae6fbbf30 --- /dev/null +++ b/vendor/plugins/engines/test/app/things/thing.rb @@ -0,0 +1,3 @@ +class Thing + def self.from_app; TestHelper::report_location(__FILE__); end +end
\ No newline at end of file diff --git a/vendor/plugins/engines/test/app/views/app_and_plugin/a_view.html.erb b/vendor/plugins/engines/test/app/views/app_and_plugin/a_view.html.erb new file mode 100644 index 000000000..03e2bf81d --- /dev/null +++ b/vendor/plugins/engines/test/app/views/app_and_plugin/a_view.html.erb @@ -0,0 +1 @@ +<%= TestHelper.view_path_for __FILE__ %> (from app)
\ No newline at end of file diff --git a/vendor/plugins/engines/test/app/views/namespace/app_and_plugin/a_view.html.erb b/vendor/plugins/engines/test/app/views/namespace/app_and_plugin/a_view.html.erb new file mode 100644 index 000000000..03e2bf81d --- /dev/null +++ b/vendor/plugins/engines/test/app/views/namespace/app_and_plugin/a_view.html.erb @@ -0,0 +1 @@ +<%= TestHelper.view_path_for __FILE__ %> (from app)
\ No newline at end of file diff --git a/vendor/plugins/engines/test/app/views/notify_mail/implicit_multipart.text.html.erb b/vendor/plugins/engines/test/app/views/notify_mail/implicit_multipart.text.html.erb new file mode 100644 index 000000000..042b5c4ef --- /dev/null +++ b/vendor/plugins/engines/test/app/views/notify_mail/implicit_multipart.text.html.erb @@ -0,0 +1 @@ +the implicit html part of the email <%= do_something_helpful("semaj") %>
\ No newline at end of file diff --git a/vendor/plugins/engines/test/app/views/notify_mail/implicit_multipart.text.plain.erb b/vendor/plugins/engines/test/app/views/notify_mail/implicit_multipart.text.plain.erb new file mode 100644 index 000000000..552acc1ea --- /dev/null +++ b/vendor/plugins/engines/test/app/views/notify_mail/implicit_multipart.text.plain.erb @@ -0,0 +1 @@ +the implicit plaintext part of the email
\ No newline at end of file diff --git a/vendor/plugins/engines/test/app/views/notify_mail/multipart_html.html.erb b/vendor/plugins/engines/test/app/views/notify_mail/multipart_html.html.erb new file mode 100644 index 000000000..135488b17 --- /dev/null +++ b/vendor/plugins/engines/test/app/views/notify_mail/multipart_html.html.erb @@ -0,0 +1 @@ +the html part of the email <%= do_something_helpful("semaj") %>
\ No newline at end of file diff --git a/vendor/plugins/engines/test/app/views/notify_mail/multipart_plain.html.erb b/vendor/plugins/engines/test/app/views/notify_mail/multipart_plain.html.erb new file mode 100644 index 000000000..e0050461c --- /dev/null +++ b/vendor/plugins/engines/test/app/views/notify_mail/multipart_plain.html.erb @@ -0,0 +1 @@ +the plaintext part of the email
\ No newline at end of file diff --git a/vendor/plugins/engines/test/app/views/notify_mail/signup.text.plain.erb b/vendor/plugins/engines/test/app/views/notify_mail/signup.text.plain.erb new file mode 100644 index 000000000..5aaf46e97 --- /dev/null +++ b/vendor/plugins/engines/test/app/views/notify_mail/signup.text.plain.erb @@ -0,0 +1,5 @@ +Signup template from application + +Here's a local variable set in the Mail object: <%= @name %>. + +And here's a method called in a mail helper: <%= do_something_helpful(@name) %> diff --git a/vendor/plugins/engines/test/app/views/plugin_mail/mail_from_plugin_with_application_template.text.plain.erb b/vendor/plugins/engines/test/app/views/plugin_mail/mail_from_plugin_with_application_template.text.plain.erb new file mode 100644 index 000000000..67a6b8fa2 --- /dev/null +++ b/vendor/plugins/engines/test/app/views/plugin_mail/mail_from_plugin_with_application_template.text.plain.erb @@ -0,0 +1 @@ +<%= @note %> (from application)
\ No newline at end of file diff --git a/vendor/plugins/engines/test/app/views/plugin_mail/multipart_from_plugin_with_application_template_plain.html.erb b/vendor/plugins/engines/test/app/views/plugin_mail/multipart_from_plugin_with_application_template_plain.html.erb new file mode 100644 index 000000000..284e450f6 --- /dev/null +++ b/vendor/plugins/engines/test/app/views/plugin_mail/multipart_from_plugin_with_application_template_plain.html.erb @@ -0,0 +1 @@ +plugin mail template loaded from application
\ No newline at end of file diff --git a/vendor/plugins/engines/test/functional/controller_loading_test.rb b/vendor/plugins/engines/test/functional/controller_loading_test.rb new file mode 100644 index 000000000..d51bc0007 --- /dev/null +++ b/vendor/plugins/engines/test/functional/controller_loading_test.rb @@ -0,0 +1,51 @@ +# Tests in this file ensure that: +# +# * plugin controller actions are found +# * actions defined in application controllers take precedence over those in plugins +# * actions in controllers in subsequently loaded plugins take precendence over those in previously loaded plugins +# * this works for actions in namespaced controllers accordingly + +require File.dirname(__FILE__) + '/../test_helper' + +class ControllerLoadingTest < ActionController::TestCase + def setup + @request = ActionController::TestRequest.new + @response = ActionController::TestResponse.new + end + + # plugin controller actions should be found + + def test_WITH_an_action_defined_only_in_a_plugin_IT_should_use_this_action + get_action_on_controller :an_action, :alpha_plugin + assert_response_body 'rendered in AlphaPluginController#an_action' + end + + def test_WITH_an_action_defined_only_in_a_namespaced_plugin_controller_IT_should_use_this_action + get_action_on_controller :an_action, :alpha_plugin, :namespace + assert_response_body 'rendered in Namespace::AlphaPluginController#an_action' + end + + # app takes precedence over plugins + + def test_WITH_an_action_defined_in_both_app_and_plugin_IT_should_use_the_one_in_app + get_action_on_controller :an_action, :app_and_plugin + assert_response_body 'rendered in AppAndPluginController#an_action (from app)' + end + + def test_WITH_an_action_defined_in_namespaced_controllers_in_both_app_and_plugin_IT_should_use_the_one_in_app + get_action_on_controller :an_action, :app_and_plugin, :namespace + assert_response_body 'rendered in Namespace::AppAndPluginController#an_action (from app)' + end + + # subsequently loaded plugins take precendence over previously loaded plugins + + def test_WITH_an_action_defined_in_two_plugin_controllers_IT_should_use_the_latter_of_both + get_action_on_controller :an_action, :shared_plugin + assert_response_body 'rendered in SharedPluginController#an_action (from beta_plugin)' + end + + def test_WITH_an_action_defined_in_two_namespaced_plugin_controllers_IT_should_use_the_latter_of_both + get_action_on_controller :an_action, :shared_plugin, :namespace + assert_response_body 'rendered in Namespace::SharedPluginController#an_action (from beta_plugin)' + end +end diff --git a/vendor/plugins/engines/test/functional/exception_notification_compatibility_test.rb b/vendor/plugins/engines/test/functional/exception_notification_compatibility_test.rb new file mode 100644 index 000000000..309330659 --- /dev/null +++ b/vendor/plugins/engines/test/functional/exception_notification_compatibility_test.rb @@ -0,0 +1,29 @@ +require File.dirname(__FILE__) + '/../test_helper' + +class ExceptionNotificationCompatibilityTest < ActionController::TestCase + ExceptionNotifier.exception_recipients = %w(joe@schmoe.com bill@schmoe.com) + class SimpleController < ApplicationController + include ExceptionNotifiable + local_addresses.clear + consider_all_requests_local = false + def index + begin + raise "Fail!" + rescue Exception => e + rescue_action_in_public(e) + end + end + end + + def setup + @controller = SimpleController.new + @request = ActionController::TestRequest.new + @response = ActionController::TestResponse.new + end + + def test_should_work + assert_nothing_raised do + get :index + end + end +end
\ No newline at end of file diff --git a/vendor/plugins/engines/test/functional/locale_loading_test.rb b/vendor/plugins/engines/test/functional/locale_loading_test.rb new file mode 100644 index 000000000..21c8c7f94 --- /dev/null +++ b/vendor/plugins/engines/test/functional/locale_loading_test.rb @@ -0,0 +1,26 @@ +# Tests in this file ensure that: +# +# * translations in the application take precedence over those in plugins +# * translations in subsequently loaded plugins take precendence over those in previously loaded plugins + +require File.dirname(__FILE__) + '/../test_helper' + +class LocaleLoadingTest < ActionController::TestCase + def setup + @request = ActionController::TestRequest.new + @response = ActionController::TestResponse.new + end + + # app takes precedence over plugins + + def test_WITH_a_translation_defined_in_both_app_and_plugin_IT_should_find_the_one_in_app + assert_equal I18n.t('hello'), 'Hello world' + end + + # subsequently loaded plugins take precendence over previously loaded plugins + + def test_WITH_a_translation_defined_in_two_plugins_IT_should_find_the_latter_of_both + assert_equal I18n.t('plugin'), 'beta' + end +end + diff --git a/vendor/plugins/engines/test/functional/routes_test.rb b/vendor/plugins/engines/test/functional/routes_test.rb new file mode 100644 index 000000000..733dd39f5 --- /dev/null +++ b/vendor/plugins/engines/test/functional/routes_test.rb @@ -0,0 +1,29 @@ +# Tests in this file ensure that: +# +# * Routes from plugins can be routed to +# * Named routes can be defined within a plugin + +require File.dirname(__FILE__) + '/../test_helper' + +class RoutesTest < ActionController::TestCase + tests TestRoutingController + + def test_WITH_a_route_defined_in_a_plugin_IT_should_route_it + path = '/routes/an_action' + opts = {:controller => 'test_routing', :action => 'an_action'} + assert_routing path, opts + assert_recognizes opts, path # not sure what exactly the difference is, but it won't hurt either + end + + def test_WITH_a_route_for_a_namespaced_controller_defined_in_a_plugin_IT_should_route_it + path = 'somespace/routes/an_action' + opts = {:controller => 'namespace/test_routing', :action => 'an_action'} + assert_routing path, opts + assert_recognizes opts, path + end + + def test_should_properly_generate_named_routes + get :test_named_routes_from_plugin + assert_response_body '/somespace/routes' + end +end
\ No newline at end of file diff --git a/vendor/plugins/engines/test/functional/view_helpers_test.rb b/vendor/plugins/engines/test/functional/view_helpers_test.rb new file mode 100644 index 000000000..5448ffeb7 --- /dev/null +++ b/vendor/plugins/engines/test/functional/view_helpers_test.rb @@ -0,0 +1,37 @@ +require File.dirname(__FILE__) + '/../test_helper' + +class ViewHelpersTest < ActionController::TestCase + tests AssetsController + + def setup + get :index + end + + def test_plugin_javascript_helpers + base_selector = "script[type='text/javascript']" + js_dir = "/plugin_assets/test_assets/javascripts" + assert_select "#{base_selector}[src='#{js_dir}/file.1.js']" + assert_select "#{base_selector}[src='#{js_dir}/file2.js']" + end + + def test_plugin_stylesheet_helpers + base_selector = "link[media='screen'][rel='stylesheet'][type='text/css']" + css_dir = "/plugin_assets/test_assets/stylesheets" + assert_select "#{base_selector}[href='#{css_dir}/file.1.css']" + assert_select "#{base_selector}[href='#{css_dir}/file2.css']" + end + + def test_plugin_image_helpers + assert_select "img[src='/plugin_assets/test_assets/images/image.png'][alt='Image']" + end + + def test_plugin_layouts + get :index + assert_select "div[id='assets_layout']" + end + + def test_plugin_image_submit_helpers + assert_select "input[src='/plugin_assets/test_assets/images/image.png'][type='image']" + end + +end diff --git a/vendor/plugins/engines/test/functional/view_loading_test.rb b/vendor/plugins/engines/test/functional/view_loading_test.rb new file mode 100644 index 000000000..28d47546a --- /dev/null +++ b/vendor/plugins/engines/test/functional/view_loading_test.rb @@ -0,0 +1,60 @@ +# Tests in this file ensure that: +# +# * plugin views are found +# * views in the application take precedence over those in plugins +# * views in subsequently loaded plugins take precendence over those in previously loaded plugins +# * this works for namespaced views accordingly + +require File.dirname(__FILE__) + '/../test_helper' + +class ViewLoadingTest < ActionController::TestCase + def setup + @request = ActionController::TestRequest.new + @response = ActionController::TestResponse.new + end + + # plugin views should be found + + def test_WITH_a_view_defined_only_in_a_plugin_IT_should_find_the_view + get_action_on_controller :a_view, :alpha_plugin + assert_response_body 'alpha_plugin/a_view' + end + + def test_WITH_a_namespaced_view_defined_only_in_a_plugin_IT_should_find_the_view + get_action_on_controller :a_view, :alpha_plugin, :namespace + assert_response_body 'namespace/alpha_plugin/a_view' + end + + # app takes precedence over plugins + + def test_WITH_a_view_defined_in_both_app_and_plugin_IT_should_find_the_one_in_app + get_action_on_controller :a_view, :app_and_plugin + assert_response_body 'app_and_plugin/a_view (from app)' + end + + def test_WITH_a_namespaced_view_defined_in_both_app_and_plugin_IT_should_find_the_one_in_app + get_action_on_controller :a_view, :app_and_plugin, :namespace + assert_response_body 'namespace/app_and_plugin/a_view (from app)' + end + + # subsequently loaded plugins take precendence over previously loaded plugins + + def test_WITH_a_view_defined_in_two_plugins_IT_should_find_the_latter_of_both + get_action_on_controller :a_view, :shared_plugin + assert_response_body 'shared_plugin/a_view (from beta_plugin)' + end + + def test_WITH_a_namespaced_view_defined_in_two_plugins_IT_should_find_the_latter_of_both + get_action_on_controller :a_view, :shared_plugin, :namespace + assert_response_body 'namespace/shared_plugin/a_view (from beta_plugin)' + end + + # layouts loaded from plugins + + def test_should_be_able_to_load_a_layout_from_a_plugin + get_action_on_controller :action_with_layout, :alpha_plugin + assert_response_body 'rendered in AlphaPluginController#action_with_layout (with plugin layout)' + end + +end +
\ No newline at end of file diff --git a/vendor/plugins/engines/test/lib/app_and_plugin_lib_model.rb b/vendor/plugins/engines/test/lib/app_and_plugin_lib_model.rb new file mode 100644 index 000000000..6ffe178a7 --- /dev/null +++ b/vendor/plugins/engines/test/lib/app_and_plugin_lib_model.rb @@ -0,0 +1,3 @@ +class AppAndPluginLibModel < ActiveRecord::Base + def self.report_location; TestHelper::report_location(__FILE__); end +end
\ No newline at end of file diff --git a/vendor/plugins/engines/test/lib/engines_test_helper.rb b/vendor/plugins/engines/test/lib/engines_test_helper.rb new file mode 100644 index 000000000..47bd2bbfd --- /dev/null +++ b/vendor/plugins/engines/test/lib/engines_test_helper.rb @@ -0,0 +1,42 @@ +module TestHelper + def self.report_location(path) + [RAILS_ROOT + '/', 'vendor/plugins/'].each { |part| path.sub! part, ''} + path = path.split('/') + location, subject = path.first, path.last + if subject.sub! '.rb', '' + subject = subject.classify + else + subject.sub! '.html.erb', '' + end + "#{subject} (from #{location})" + end + + def self.view_path_for path + [RAILS_ROOT + '/', 'vendor/plugins/', '.html.erb'].each { |part| path.sub! part, ''} + parts = path.split('/') + parts[(parts.index('views')+1)..-1].join('/') + end +end + +class Test::Unit::TestCase + # Add more helper methods to be used by all tests here... + def get_action_on_controller(*args) + action = args.shift + with_controller *args + get action + end + + def with_controller(controller, namespace = nil) + classname = controller.to_s.classify + 'Controller' + classname = namespace.to_s.classify + '::' + classname unless namespace.nil? + @controller = classname.constantize.new + end + + def assert_response_body(expected) + assert_equal expected, @response.body + end +end + +# Because we're testing this behaviour, we actually want these features on! +Engines.disable_application_view_loading = false +Engines.disable_application_code_loading = false diff --git a/vendor/plugins/engines/test/lib/render_information.rb b/vendor/plugins/engines/test/lib/render_information.rb new file mode 100644 index 000000000..0deb5d9d3 --- /dev/null +++ b/vendor/plugins/engines/test/lib/render_information.rb @@ -0,0 +1,7 @@ +module RenderInformation + def render_class_and_action(note = nil, options={}) + text = "rendered in #{self.class.name}##{params[:action]}" + text += " (#{note})" unless note.nil? + render options.update(:text => text) + end +end
\ No newline at end of file diff --git a/vendor/plugins/engines/test/plugins/alpha_plugin/app/controllers/alpha_plugin_controller.rb b/vendor/plugins/engines/test/plugins/alpha_plugin/app/controllers/alpha_plugin_controller.rb new file mode 100644 index 000000000..736d59b83 --- /dev/null +++ b/vendor/plugins/engines/test/plugins/alpha_plugin/app/controllers/alpha_plugin_controller.rb @@ -0,0 +1,8 @@ +class AlphaPluginController < ApplicationController + def an_action + render_class_and_action + end + def action_with_layout + render_class_and_action(nil, :layout => "plugin_layout") + end +end diff --git a/vendor/plugins/engines/test/plugins/alpha_plugin/app/controllers/app_and_plugin_controller.rb b/vendor/plugins/engines/test/plugins/alpha_plugin/app/controllers/app_and_plugin_controller.rb new file mode 100644 index 000000000..c41d6edd1 --- /dev/null +++ b/vendor/plugins/engines/test/plugins/alpha_plugin/app/controllers/app_and_plugin_controller.rb @@ -0,0 +1,5 @@ +class AppAndPluginController < ApplicationController + def an_action + render_class_and_action 'from alpha_plugin' + end +end diff --git a/vendor/plugins/engines/test/plugins/alpha_plugin/app/controllers/namespace/alpha_plugin_controller.rb b/vendor/plugins/engines/test/plugins/alpha_plugin/app/controllers/namespace/alpha_plugin_controller.rb new file mode 100644 index 000000000..5edf81b53 --- /dev/null +++ b/vendor/plugins/engines/test/plugins/alpha_plugin/app/controllers/namespace/alpha_plugin_controller.rb @@ -0,0 +1,5 @@ +class Namespace::AlphaPluginController < ApplicationController + def an_action + render_class_and_action + end +end
\ No newline at end of file diff --git a/vendor/plugins/engines/test/plugins/alpha_plugin/app/controllers/namespace/app_and_plugin_controller.rb b/vendor/plugins/engines/test/plugins/alpha_plugin/app/controllers/namespace/app_and_plugin_controller.rb new file mode 100644 index 000000000..7431a36b6 --- /dev/null +++ b/vendor/plugins/engines/test/plugins/alpha_plugin/app/controllers/namespace/app_and_plugin_controller.rb @@ -0,0 +1,5 @@ +class Namespace::AppAndPluginController < ApplicationController + def an_action + render_class_and_action 'from alpha_plugin' + end +end diff --git a/vendor/plugins/engines/test/plugins/alpha_plugin/app/controllers/namespace/shared_plugin_controller.rb b/vendor/plugins/engines/test/plugins/alpha_plugin/app/controllers/namespace/shared_plugin_controller.rb new file mode 100644 index 000000000..fb162bcf6 --- /dev/null +++ b/vendor/plugins/engines/test/plugins/alpha_plugin/app/controllers/namespace/shared_plugin_controller.rb @@ -0,0 +1,5 @@ +class Namespace::SharedPluginController < ApplicationController + def an_action + render_class_and_action 'from alpha_plugin' + end +end diff --git a/vendor/plugins/engines/test/plugins/alpha_plugin/app/controllers/shared_plugin_controller.rb b/vendor/plugins/engines/test/plugins/alpha_plugin/app/controllers/shared_plugin_controller.rb new file mode 100644 index 000000000..00539bb8c --- /dev/null +++ b/vendor/plugins/engines/test/plugins/alpha_plugin/app/controllers/shared_plugin_controller.rb @@ -0,0 +1,5 @@ +class SharedEngineController < ApplicationController + def an_action + render_class_and_action 'from alpha_engine' + end +end diff --git a/vendor/plugins/engines/test/plugins/alpha_plugin/app/models/alpha_plugin_model.rb b/vendor/plugins/engines/test/plugins/alpha_plugin/app/models/alpha_plugin_model.rb new file mode 100644 index 000000000..cde71b8d0 --- /dev/null +++ b/vendor/plugins/engines/test/plugins/alpha_plugin/app/models/alpha_plugin_model.rb @@ -0,0 +1,3 @@ +class AlphaPluginModel < ActiveRecord::Base + def self.report_location; TestHelper::report_location(__FILE__); end +end
\ No newline at end of file diff --git a/vendor/plugins/engines/test/plugins/alpha_plugin/app/models/app_and_plugin_model.rb b/vendor/plugins/engines/test/plugins/alpha_plugin/app/models/app_and_plugin_model.rb new file mode 100644 index 000000000..92e6e625f --- /dev/null +++ b/vendor/plugins/engines/test/plugins/alpha_plugin/app/models/app_and_plugin_model.rb @@ -0,0 +1,7 @@ +class AppAndPluginModel < ActiveRecord::Base + def self.report_location; TestHelper::report_location(__FILE__); end + + def defined_only_in_alpha_plugin_version + # should not be defined as the model in app/models takes precedence + end +end
\ No newline at end of file diff --git a/vendor/plugins/engines/test/plugins/alpha_plugin/app/models/shared_plugin_model.rb b/vendor/plugins/engines/test/plugins/alpha_plugin/app/models/shared_plugin_model.rb new file mode 100644 index 000000000..e2ef43db7 --- /dev/null +++ b/vendor/plugins/engines/test/plugins/alpha_plugin/app/models/shared_plugin_model.rb @@ -0,0 +1,3 @@ +class SharedPluginModel < ActiveRecord::Base + def self.report_location; TestHelper::report_location(__FILE__); end +end
\ No newline at end of file diff --git a/vendor/plugins/engines/test/plugins/alpha_plugin/app/views/alpha_plugin/a_view.html.erb b/vendor/plugins/engines/test/plugins/alpha_plugin/app/views/alpha_plugin/a_view.html.erb new file mode 100644 index 000000000..1ad694584 --- /dev/null +++ b/vendor/plugins/engines/test/plugins/alpha_plugin/app/views/alpha_plugin/a_view.html.erb @@ -0,0 +1 @@ +<%= TestHelper.view_path_for __FILE__ %>
\ No newline at end of file diff --git a/vendor/plugins/engines/test/plugins/alpha_plugin/app/views/app_and_plugin/a_view.html.erb b/vendor/plugins/engines/test/plugins/alpha_plugin/app/views/app_and_plugin/a_view.html.erb new file mode 100644 index 000000000..791a6fab4 --- /dev/null +++ b/vendor/plugins/engines/test/plugins/alpha_plugin/app/views/app_and_plugin/a_view.html.erb @@ -0,0 +1 @@ +<%= TestHelper.view_path_for __FILE__ %> (from a_view)
\ No newline at end of file diff --git a/vendor/plugins/engines/test/plugins/alpha_plugin/app/views/layouts/plugin_layout.erb b/vendor/plugins/engines/test/plugins/alpha_plugin/app/views/layouts/plugin_layout.erb new file mode 100644 index 000000000..878e07c2c --- /dev/null +++ b/vendor/plugins/engines/test/plugins/alpha_plugin/app/views/layouts/plugin_layout.erb @@ -0,0 +1 @@ +<%= yield %> (with plugin layout)
\ No newline at end of file diff --git a/vendor/plugins/engines/test/plugins/alpha_plugin/app/views/namespace/alpha_plugin/a_view.html.erb b/vendor/plugins/engines/test/plugins/alpha_plugin/app/views/namespace/alpha_plugin/a_view.html.erb new file mode 100644 index 000000000..1ad694584 --- /dev/null +++ b/vendor/plugins/engines/test/plugins/alpha_plugin/app/views/namespace/alpha_plugin/a_view.html.erb @@ -0,0 +1 @@ +<%= TestHelper.view_path_for __FILE__ %>
\ No newline at end of file diff --git a/vendor/plugins/engines/test/plugins/alpha_plugin/app/views/namespace/app_and_plugin/a_view.html.erb b/vendor/plugins/engines/test/plugins/alpha_plugin/app/views/namespace/app_and_plugin/a_view.html.erb new file mode 100644 index 000000000..1ad694584 --- /dev/null +++ b/vendor/plugins/engines/test/plugins/alpha_plugin/app/views/namespace/app_and_plugin/a_view.html.erb @@ -0,0 +1 @@ +<%= TestHelper.view_path_for __FILE__ %>
\ No newline at end of file diff --git a/vendor/plugins/engines/test/plugins/alpha_plugin/app/views/namespace/shared_plugin/a_view.html.erb b/vendor/plugins/engines/test/plugins/alpha_plugin/app/views/namespace/shared_plugin/a_view.html.erb new file mode 100644 index 000000000..f144ab394 --- /dev/null +++ b/vendor/plugins/engines/test/plugins/alpha_plugin/app/views/namespace/shared_plugin/a_view.html.erb @@ -0,0 +1 @@ +<%= TestHelper.view_path_for __FILE__ %> (from alpha_plugin)
\ No newline at end of file diff --git a/vendor/plugins/engines/test/plugins/alpha_plugin/app/views/shared_plugin/a_view.html.erb b/vendor/plugins/engines/test/plugins/alpha_plugin/app/views/shared_plugin/a_view.html.erb new file mode 100644 index 000000000..f144ab394 --- /dev/null +++ b/vendor/plugins/engines/test/plugins/alpha_plugin/app/views/shared_plugin/a_view.html.erb @@ -0,0 +1 @@ +<%= TestHelper.view_path_for __FILE__ %> (from alpha_plugin)
\ No newline at end of file diff --git a/vendor/plugins/engines/test/plugins/alpha_plugin/lib/alpha_plugin_lib_model.rb b/vendor/plugins/engines/test/plugins/alpha_plugin/lib/alpha_plugin_lib_model.rb new file mode 100644 index 000000000..0ce4f91bb --- /dev/null +++ b/vendor/plugins/engines/test/plugins/alpha_plugin/lib/alpha_plugin_lib_model.rb @@ -0,0 +1,3 @@ +class AlphaPluginLibModel < ActiveRecord::Base + def self.report_location; TestHelper::report_location(__FILE__); end +end
\ No newline at end of file diff --git a/vendor/plugins/engines/test/plugins/alpha_plugin/lib/app_and_plugin_lib_model.rb b/vendor/plugins/engines/test/plugins/alpha_plugin/lib/app_and_plugin_lib_model.rb new file mode 100644 index 000000000..645a70c83 --- /dev/null +++ b/vendor/plugins/engines/test/plugins/alpha_plugin/lib/app_and_plugin_lib_model.rb @@ -0,0 +1,7 @@ +class AppAndPluginLibModel < ActiveRecord::Base + def self.report_location; TestHelper::report_location(__FILE__); end + + def defined_only_in_alpha_plugin_version + # should not be defined + end +end
\ No newline at end of file diff --git a/vendor/plugins/engines/test/plugins/alpha_plugin/locales/en.yml b/vendor/plugins/engines/test/plugins/alpha_plugin/locales/en.yml new file mode 100644 index 000000000..76d39d315 --- /dev/null +++ b/vendor/plugins/engines/test/plugins/alpha_plugin/locales/en.yml @@ -0,0 +1,3 @@ +en: + hello: "Hello from alfa" + plugin: "alfa" diff --git a/vendor/plugins/engines/test/plugins/beta_plugin/app/controllers/app_and_plugin_controller.rb b/vendor/plugins/engines/test/plugins/beta_plugin/app/controllers/app_and_plugin_controller.rb new file mode 100644 index 000000000..2e7798976 --- /dev/null +++ b/vendor/plugins/engines/test/plugins/beta_plugin/app/controllers/app_and_plugin_controller.rb @@ -0,0 +1,5 @@ +class AppAndPluginController < ApplicationController + def an_action + render_class_and_action 'from beta_plugin' + end +end diff --git a/vendor/plugins/engines/test/plugins/beta_plugin/app/controllers/namespace/shared_plugin_controller.rb b/vendor/plugins/engines/test/plugins/beta_plugin/app/controllers/namespace/shared_plugin_controller.rb new file mode 100644 index 000000000..971c7d563 --- /dev/null +++ b/vendor/plugins/engines/test/plugins/beta_plugin/app/controllers/namespace/shared_plugin_controller.rb @@ -0,0 +1,5 @@ +class Namespace::SharedPluginController < ApplicationController + def an_action + render_class_and_action 'from beta_plugin' + end +end diff --git a/vendor/plugins/engines/test/plugins/beta_plugin/app/controllers/shared_plugin_controller.rb b/vendor/plugins/engines/test/plugins/beta_plugin/app/controllers/shared_plugin_controller.rb new file mode 100644 index 000000000..ddd9dbede --- /dev/null +++ b/vendor/plugins/engines/test/plugins/beta_plugin/app/controllers/shared_plugin_controller.rb @@ -0,0 +1,5 @@ +class SharedPluginController < ApplicationController + def an_action + render_class_and_action 'from beta_plugin' + end +end diff --git a/vendor/plugins/engines/test/plugins/beta_plugin/app/models/shared_plugin_model.rb b/vendor/plugins/engines/test/plugins/beta_plugin/app/models/shared_plugin_model.rb new file mode 100644 index 000000000..bfde227d1 --- /dev/null +++ b/vendor/plugins/engines/test/plugins/beta_plugin/app/models/shared_plugin_model.rb @@ -0,0 +1,3 @@ +class SharedPluginModel < ActiveRecord::Base + def self.report_location; TestHelper::report_location(__FILE__); end +end
\ No newline at end of file diff --git a/vendor/plugins/engines/test/plugins/beta_plugin/app/views/namespace/shared_plugin/a_view.html.erb b/vendor/plugins/engines/test/plugins/beta_plugin/app/views/namespace/shared_plugin/a_view.html.erb new file mode 100644 index 000000000..77b5a1538 --- /dev/null +++ b/vendor/plugins/engines/test/plugins/beta_plugin/app/views/namespace/shared_plugin/a_view.html.erb @@ -0,0 +1 @@ +<%= TestHelper.view_path_for __FILE__ %> (from beta_plugin)
\ No newline at end of file diff --git a/vendor/plugins/engines/test/plugins/beta_plugin/app/views/shared_plugin/a_view.html.erb b/vendor/plugins/engines/test/plugins/beta_plugin/app/views/shared_plugin/a_view.html.erb new file mode 100644 index 000000000..77b5a1538 --- /dev/null +++ b/vendor/plugins/engines/test/plugins/beta_plugin/app/views/shared_plugin/a_view.html.erb @@ -0,0 +1 @@ +<%= TestHelper.view_path_for __FILE__ %> (from beta_plugin)
\ No newline at end of file diff --git a/vendor/plugins/engines/test/plugins/beta_plugin/init.rb b/vendor/plugins/engines/test/plugins/beta_plugin/init.rb new file mode 100644 index 000000000..b4c4b0e1d --- /dev/null +++ b/vendor/plugins/engines/test/plugins/beta_plugin/init.rb @@ -0,0 +1 @@ +# just here so that Rails recognizes this as a plugin
\ No newline at end of file diff --git a/vendor/plugins/engines/test/plugins/beta_plugin/locales/en.yml b/vendor/plugins/engines/test/plugins/beta_plugin/locales/en.yml new file mode 100644 index 000000000..f49279cca --- /dev/null +++ b/vendor/plugins/engines/test/plugins/beta_plugin/locales/en.yml @@ -0,0 +1,3 @@ +en: + hello: "Hello from beta" + plugin: "beta" diff --git a/vendor/plugins/engines/test/plugins/not_a_plugin/public/should_not_be_copied.txt b/vendor/plugins/engines/test/plugins/not_a_plugin/public/should_not_be_copied.txt new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/vendor/plugins/engines/test/plugins/not_a_plugin/public/should_not_be_copied.txt diff --git a/vendor/plugins/engines/test/plugins/test_assets/app/controllers/assets_controller.rb b/vendor/plugins/engines/test/plugins/test_assets/app/controllers/assets_controller.rb new file mode 100644 index 000000000..db5de2e6a --- /dev/null +++ b/vendor/plugins/engines/test/plugins/test_assets/app/controllers/assets_controller.rb @@ -0,0 +1,2 @@ +class AssetsController < ApplicationController +end
\ No newline at end of file diff --git a/vendor/plugins/engines/test/plugins/test_assets/app/views/assets/index.html.erb b/vendor/plugins/engines/test/plugins/test_assets/app/views/assets/index.html.erb new file mode 100644 index 000000000..8340f76d1 --- /dev/null +++ b/vendor/plugins/engines/test/plugins/test_assets/app/views/assets/index.html.erb @@ -0,0 +1,4 @@ +<%= image_tag 'image.png', :plugin => 'test_assets' %> +<%= javascript_include_tag 'file.1.js', 'file2', :plugin => "test_assets" %> +<%= stylesheet_link_tag 'file.1.css', 'file2', :plugin => "test_assets" %> +<%= image_submit_tag 'image.png', :plugin => "test_assets" %> diff --git a/vendor/plugins/engines/test/plugins/test_assets/app/views/layouts/assets.html.erb b/vendor/plugins/engines/test/plugins/test_assets/app/views/layouts/assets.html.erb new file mode 100644 index 000000000..b7da375e9 --- /dev/null +++ b/vendor/plugins/engines/test/plugins/test_assets/app/views/layouts/assets.html.erb @@ -0,0 +1,3 @@ +<div id="assets_layout"> + <%= yield %> +</div>
\ No newline at end of file diff --git a/vendor/plugins/engines/test/plugins/test_assets/init.rb b/vendor/plugins/engines/test/plugins/test_assets/init.rb new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/vendor/plugins/engines/test/plugins/test_assets/init.rb diff --git a/vendor/plugins/engines/test/plugins/test_assets/public/file.txt b/vendor/plugins/engines/test/plugins/test_assets/public/file.txt new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/vendor/plugins/engines/test/plugins/test_assets/public/file.txt diff --git a/vendor/plugins/engines/test/plugins/test_assets/public/subfolder/file_in_subfolder.txt b/vendor/plugins/engines/test/plugins/test_assets/public/subfolder/file_in_subfolder.txt new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/vendor/plugins/engines/test/plugins/test_assets/public/subfolder/file_in_subfolder.txt diff --git a/vendor/plugins/engines/test/plugins/test_assets_with_assets_directory/assets/file.txt b/vendor/plugins/engines/test/plugins/test_assets_with_assets_directory/assets/file.txt new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/vendor/plugins/engines/test/plugins/test_assets_with_assets_directory/assets/file.txt diff --git a/vendor/plugins/engines/test/plugins/test_assets_with_assets_directory/assets/subfolder/file_in_subfolder.txt b/vendor/plugins/engines/test/plugins/test_assets_with_assets_directory/assets/subfolder/file_in_subfolder.txt new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/vendor/plugins/engines/test/plugins/test_assets_with_assets_directory/assets/subfolder/file_in_subfolder.txt diff --git a/vendor/plugins/engines/test/plugins/test_assets_with_assets_directory/init.rb b/vendor/plugins/engines/test/plugins/test_assets_with_assets_directory/init.rb new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/vendor/plugins/engines/test/plugins/test_assets_with_assets_directory/init.rb diff --git a/vendor/plugins/engines/test/plugins/test_assets_with_no_subdirectory/assets/file.txt b/vendor/plugins/engines/test/plugins/test_assets_with_no_subdirectory/assets/file.txt new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/vendor/plugins/engines/test/plugins/test_assets_with_no_subdirectory/assets/file.txt diff --git a/vendor/plugins/engines/test/plugins/test_assets_with_no_subdirectory/init.rb b/vendor/plugins/engines/test/plugins/test_assets_with_no_subdirectory/init.rb new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/vendor/plugins/engines/test/plugins/test_assets_with_no_subdirectory/init.rb diff --git a/vendor/plugins/engines/test/plugins/test_code_mixing/app/things/thing.rb b/vendor/plugins/engines/test/plugins/test_code_mixing/app/things/thing.rb new file mode 100644 index 000000000..535d988e6 --- /dev/null +++ b/vendor/plugins/engines/test/plugins/test_code_mixing/app/things/thing.rb @@ -0,0 +1,3 @@ +class Thing + def self.from_plugin; TestHelper::report_location(__FILE__); end +end
\ No newline at end of file diff --git a/vendor/plugins/engines/test/plugins/test_code_mixing/init.rb b/vendor/plugins/engines/test/plugins/test_code_mixing/init.rb new file mode 100644 index 000000000..b4c4b0e1d --- /dev/null +++ b/vendor/plugins/engines/test/plugins/test_code_mixing/init.rb @@ -0,0 +1 @@ +# just here so that Rails recognizes this as a plugin
\ No newline at end of file diff --git a/vendor/plugins/engines/test/plugins/test_load_path/init.rb b/vendor/plugins/engines/test/plugins/test_load_path/init.rb new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/vendor/plugins/engines/test/plugins/test_load_path/init.rb diff --git a/vendor/plugins/engines/test/plugins/test_migration/db/migrate/001_create_tests.rb b/vendor/plugins/engines/test/plugins/test_migration/db/migrate/001_create_tests.rb new file mode 100644 index 000000000..804a0cd2d --- /dev/null +++ b/vendor/plugins/engines/test/plugins/test_migration/db/migrate/001_create_tests.rb @@ -0,0 +1,11 @@ +class CreateTests < ActiveRecord::Migration + def self.up + create_table 'tests' do |t| + t.column 'name', :string + end + end + + def self.down + drop_table 'tests' + end +end diff --git a/vendor/plugins/engines/test/plugins/test_migration/db/migrate/002_create_others.rb b/vendor/plugins/engines/test/plugins/test_migration/db/migrate/002_create_others.rb new file mode 100644 index 000000000..756aca653 --- /dev/null +++ b/vendor/plugins/engines/test/plugins/test_migration/db/migrate/002_create_others.rb @@ -0,0 +1,11 @@ +class CreateOthers < ActiveRecord::Migration + def self.up + create_table 'others' do |t| + t.column 'name', :string + end + end + + def self.down + drop_table 'others' + end +end diff --git a/vendor/plugins/engines/test/plugins/test_migration/db/migrate/003_create_extras.rb b/vendor/plugins/engines/test/plugins/test_migration/db/migrate/003_create_extras.rb new file mode 100644 index 000000000..fb5b6c205 --- /dev/null +++ b/vendor/plugins/engines/test/plugins/test_migration/db/migrate/003_create_extras.rb @@ -0,0 +1,11 @@ +class CreateExtras < ActiveRecord::Migration + def self.up + create_table 'extras' do |t| + t.column 'name', :string + end + end + + def self.down + drop_table 'extras' + end +end diff --git a/vendor/plugins/engines/test/plugins/test_migration/init.rb b/vendor/plugins/engines/test/plugins/test_migration/init.rb new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/vendor/plugins/engines/test/plugins/test_migration/init.rb diff --git a/vendor/plugins/engines/test/plugins/test_plugin_mailing/app/models/plugin_mail.rb b/vendor/plugins/engines/test/plugins/test_plugin_mailing/app/models/plugin_mail.rb new file mode 100644 index 000000000..4f3661639 --- /dev/null +++ b/vendor/plugins/engines/test/plugins/test_plugin_mailing/app/models/plugin_mail.rb @@ -0,0 +1,26 @@ +class PluginMail < ActionMailer::Base + def mail_from_plugin(note=nil) + body(:note => note) + end + + def mail_from_plugin_with_application_template(note=nil) + body(:note => note) + end + + def multipart_from_plugin + content_type 'multipart/alternative' + part :content_type => "text/html", :body => render_message("multipart_from_plugin_html", {}) + part "text/plain" do |p| + p.body = render_message("multipart_from_plugin_plain", {}) + end + end + + def multipart_from_plugin_with_application_template + content_type 'multipart/alternative' + part :content_type => "text/html", :body => render_message("multipart_from_plugin_with_application_template_html", {}) + part "text/plain" do |p| + p.body = render_message("multipart_from_plugin_with_application_template_plain", {}) + end + end + +end
\ No newline at end of file diff --git a/vendor/plugins/engines/test/plugins/test_plugin_mailing/app/views/plugin_mail/mail_from_plugin.erb b/vendor/plugins/engines/test/plugins/test_plugin_mailing/app/views/plugin_mail/mail_from_plugin.erb new file mode 100644 index 000000000..2b4960625 --- /dev/null +++ b/vendor/plugins/engines/test/plugins/test_plugin_mailing/app/views/plugin_mail/mail_from_plugin.erb @@ -0,0 +1 @@ +<%= @note %>
\ No newline at end of file diff --git a/vendor/plugins/engines/test/plugins/test_plugin_mailing/app/views/plugin_mail/multipart_from_plugin_html.html.erb b/vendor/plugins/engines/test/plugins/test_plugin_mailing/app/views/plugin_mail/multipart_from_plugin_html.html.erb new file mode 100644 index 000000000..46291d8f0 --- /dev/null +++ b/vendor/plugins/engines/test/plugins/test_plugin_mailing/app/views/plugin_mail/multipart_from_plugin_html.html.erb @@ -0,0 +1 @@ +html template
\ No newline at end of file diff --git a/vendor/plugins/engines/test/plugins/test_plugin_mailing/app/views/plugin_mail/multipart_from_plugin_plain.html.erb b/vendor/plugins/engines/test/plugins/test_plugin_mailing/app/views/plugin_mail/multipart_from_plugin_plain.html.erb new file mode 100644 index 000000000..f690dbaac --- /dev/null +++ b/vendor/plugins/engines/test/plugins/test_plugin_mailing/app/views/plugin_mail/multipart_from_plugin_plain.html.erb @@ -0,0 +1 @@ +plain template
\ No newline at end of file diff --git a/vendor/plugins/engines/test/plugins/test_plugin_mailing/app/views/plugin_mail/multipart_from_plugin_with_application_template_html.html.erb b/vendor/plugins/engines/test/plugins/test_plugin_mailing/app/views/plugin_mail/multipart_from_plugin_with_application_template_html.html.erb new file mode 100644 index 000000000..795f0d508 --- /dev/null +++ b/vendor/plugins/engines/test/plugins/test_plugin_mailing/app/views/plugin_mail/multipart_from_plugin_with_application_template_html.html.erb @@ -0,0 +1 @@ +template from plugin
\ No newline at end of file diff --git a/vendor/plugins/engines/test/plugins/test_plugin_mailing/app/views/plugin_mail/multipart_from_plugin_with_application_template_plain.html.erb b/vendor/plugins/engines/test/plugins/test_plugin_mailing/app/views/plugin_mail/multipart_from_plugin_with_application_template_plain.html.erb new file mode 100644 index 000000000..795f0d508 --- /dev/null +++ b/vendor/plugins/engines/test/plugins/test_plugin_mailing/app/views/plugin_mail/multipart_from_plugin_with_application_template_plain.html.erb @@ -0,0 +1 @@ +template from plugin
\ No newline at end of file diff --git a/vendor/plugins/engines/test/plugins/test_plugin_mailing/init.rb b/vendor/plugins/engines/test/plugins/test_plugin_mailing/init.rb new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/vendor/plugins/engines/test/plugins/test_plugin_mailing/init.rb diff --git a/vendor/plugins/engines/test/plugins/test_routing/app/controllers/namespace/test_routing_controller.rb b/vendor/plugins/engines/test/plugins/test_routing/app/controllers/namespace/test_routing_controller.rb new file mode 100644 index 000000000..29d7bdbd4 --- /dev/null +++ b/vendor/plugins/engines/test/plugins/test_routing/app/controllers/namespace/test_routing_controller.rb @@ -0,0 +1,5 @@ +class Namespace::TestRoutingController < ApplicationController + def routed_action + render_class_and_action + end +end
\ No newline at end of file diff --git a/vendor/plugins/engines/test/plugins/test_routing/app/controllers/test_routing_controller.rb b/vendor/plugins/engines/test/plugins/test_routing/app/controllers/test_routing_controller.rb new file mode 100644 index 000000000..ac3164a4f --- /dev/null +++ b/vendor/plugins/engines/test/plugins/test_routing/app/controllers/test_routing_controller.rb @@ -0,0 +1,9 @@ +class TestRoutingController < ApplicationController + def routed_action + render_class_and_action + end + + def test_named_routes_from_plugin + render :text => plugin_route_path(:action => "index") + end +end
\ No newline at end of file diff --git a/vendor/plugins/engines/test/plugins/test_routing/config/routes.rb b/vendor/plugins/engines/test/plugins/test_routing/config/routes.rb new file mode 100644 index 000000000..dbc49f960 --- /dev/null +++ b/vendor/plugins/engines/test/plugins/test_routing/config/routes.rb @@ -0,0 +1,4 @@ +ActionController::Routing::Routes.draw do |map| + map.connect 'routes/:action', :controller => "test_routing" + map.plugin_route 'somespace/routes/:action', :controller => "namespace/test_routing" +end
\ No newline at end of file diff --git a/vendor/plugins/engines/test/plugins/test_routing/init.rb b/vendor/plugins/engines/test/plugins/test_routing/init.rb new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/vendor/plugins/engines/test/plugins/test_routing/init.rb diff --git a/vendor/plugins/engines/test/plugins/test_testing/app/README.txt b/vendor/plugins/engines/test/plugins/test_testing/app/README.txt new file mode 100644 index 000000000..784e4fe28 --- /dev/null +++ b/vendor/plugins/engines/test/plugins/test_testing/app/README.txt @@ -0,0 +1 @@ +Fixtures are only copied from plugins with an +app+ directory, but git needs this directory to be non-empty
\ No newline at end of file diff --git a/vendor/plugins/engines/test/plugins/test_testing/init.rb b/vendor/plugins/engines/test/plugins/test_testing/init.rb new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/vendor/plugins/engines/test/plugins/test_testing/init.rb diff --git a/vendor/plugins/engines/test/plugins/test_testing/test/fixtures/testing_fixtures.yml b/vendor/plugins/engines/test/plugins/test_testing/test/fixtures/testing_fixtures.yml new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/vendor/plugins/engines/test/plugins/test_testing/test/fixtures/testing_fixtures.yml diff --git a/vendor/plugins/engines/test/plugins/test_testing/test/unit/override_test.rb b/vendor/plugins/engines/test/plugins/test_testing/test/unit/override_test.rb new file mode 100644 index 000000000..4c4c42a2c --- /dev/null +++ b/vendor/plugins/engines/test/plugins/test_testing/test/unit/override_test.rb @@ -0,0 +1,13 @@ +require File.expand_path(File.join(File.dirname(__FILE__), *%w[.. .. .. .. .. test test_helper])) + +class OverrideTest < ActiveSupport::TestCase + def test_overrides_from_the_application_should_work + flunk "this test should be overridden by the app" + end + + def test_tests_within_the_plugin_should_still_run + assert true, "non-overridden plugin tests should still run" + end +end + +Engines::Testing.override_tests_from_app
\ No newline at end of file diff --git a/vendor/plugins/engines/test/unit/action_mailer_test.rb b/vendor/plugins/engines/test/unit/action_mailer_test.rb new file mode 100644 index 000000000..fc3e75661 --- /dev/null +++ b/vendor/plugins/engines/test/unit/action_mailer_test.rb @@ -0,0 +1,54 @@ +require File.dirname(__FILE__) + '/../test_helper' + +class ActionMailerWithinApplicationTest < Test::Unit::TestCase + + def test_normal_implicit_template + m = NotifyMail.create_signup("hello") + assert m.body =~ /^Signup template from application/ + end + + def test_action_mailer_can_get_helper + m = NotifyMail.create_signup('James') + assert m.body =~ /James/ + assert m.body =~ /semaJ/ # from the helper + end + + def test_multipart_mails_with_explicit_templates + m = NotifyMail.create_multipart + assert_equal 2, m.parts.length + assert_equal 'the html part of the email james', m.parts[0].body + assert_equal 'the plaintext part of the email', m.parts[1].body + end + + def test_multipart_mails_with_implicit_templates + m = NotifyMail.create_implicit_multipart + assert_equal 2, m.parts.length + assert_equal 'the implicit plaintext part of the email', m.parts[0].body + assert_equal 'the implicit html part of the email james', m.parts[1].body + end +end + + +class ActionMailerWithinPluginsTest < Test::Unit::TestCase + def test_should_be_able_to_create_mails_from_plugin + m = PluginMail.create_mail_from_plugin("from_plugin") + assert_equal "from_plugin", m.body + end + + def test_should_be_able_to_overload_views_within_the_application + m = PluginMail.create_mail_from_plugin_with_application_template("from_plugin") + assert_equal "from_plugin (from application)", m.body + end + + def test_should_be_able_to_create_a_multipart_mail_from_within_plugin + m = PluginMail.create_multipart_from_plugin + assert_equal 2, m.parts.length + assert_equal 'html template', m.parts[0].body + assert_equal 'plain template', m.parts[1].body + end + + def test_plugin_mailer_template_overriding + m = PluginMail.create_multipart_from_plugin_with_application_template + assert_equal 'plugin mail template loaded from application', m.parts[1].body + end +end
\ No newline at end of file diff --git a/vendor/plugins/engines/test/unit/arbitrary_code_mixing_test.rb b/vendor/plugins/engines/test/unit/arbitrary_code_mixing_test.rb new file mode 100644 index 000000000..4b862f35b --- /dev/null +++ b/vendor/plugins/engines/test/unit/arbitrary_code_mixing_test.rb @@ -0,0 +1,41 @@ +require File.dirname(__FILE__) + '/../test_helper' + +class ArbitraryCodeMixingTest < Test::Unit::TestCase + def setup + Engines.code_mixing_file_types = %w(controller helper) + end + + def test_should_allow_setting_of_different_code_mixing_file_types + assert_nothing_raised { + Engines.mix_code_from :things + } + end + + def test_should_add_new_types_to_existing_code_mixing_file_types + Engines.mix_code_from :things + assert_equal ["controller", "helper", "thing"], Engines.code_mixing_file_types + Engines.mix_code_from :other + assert_equal ["controller", "helper", "thing", "other"], Engines.code_mixing_file_types + end + + def test_should_allow_setting_of_multiple_types_at_once + Engines.mix_code_from :things, :other + assert_equal ["controller", "helper", "thing", "other"], Engines.code_mixing_file_types + end + + def test_should_singularize_elements_to_be_mixed + # this is the only test using mocha, so let's try to work around it + # also, this seems to be already tested with the :things in the tests above + # arg = stub(:to_s => stub(:singularize => "element")) + Engines.mix_code_from :elements + assert Engines.code_mixing_file_types.include?("element") + end + + # TODO doesn't seem to work as expected? + + # def test_should_successfully_mix_custom_types + # Engines.mix_code_from :things + # assert_equal 'Thing (from app)', Thing.from_app + # assert_equal 'Thing (from test_code_mixing)', Thing.from_plugin + # end +end
\ No newline at end of file diff --git a/vendor/plugins/engines/test/unit/assets_test.rb b/vendor/plugins/engines/test/unit/assets_test.rb new file mode 100644 index 000000000..3332c533e --- /dev/null +++ b/vendor/plugins/engines/test/unit/assets_test.rb @@ -0,0 +1,52 @@ +require File.dirname(__FILE__) + '/../test_helper' + +class AssetsTest < Test::Unit::TestCase + def setup + Engines::Assets.mirror_files_for Engines.plugins[:test_assets] + end + + def teardown + FileUtils.rm_r(Engines.public_directory) if File.exist?(Engines.public_directory) + end + + def test_engines_has_created_base_public_file + assert File.exist?(Engines.public_directory) + end + + def test_engines_has_created_README_in_public_directory + assert File.exist?(File.join(Engines.public_directory, 'README')) + end + + def test_public_files_have_been_copied_from_test_assets_plugin + assert File.exist?(File.join(Engines.public_directory, 'test_assets')) + assert File.exist?(File.join(Engines.public_directory, 'test_assets', 'file.txt')) + assert File.exist?(File.join(Engines.public_directory, 'test_assets', 'subfolder')) + assert File.exist?(File.join(Engines.public_directory, 'test_assets', 'subfolder', 'file_in_subfolder.txt')) + end + + def test_engines_has_not_created_duplicated_file_structure + assert !File.exists?(File.join(Engines.public_directory, "test_assets", RAILS_ROOT)) + end + + def test_public_files_have_been_copied_from_test_assets_with_assets_dir_plugin + Engines::Assets.mirror_files_for Engines.plugins[:test_assets_with_assets_directory] + + assert File.exist?(File.join(Engines.public_directory, 'test_assets_with_assets_directory')) + assert File.exist?(File.join(Engines.public_directory, 'test_assets_with_assets_directory', 'file.txt')) + assert File.exist?(File.join(Engines.public_directory, 'test_assets_with_assets_directory', 'subfolder')) + assert File.exist?(File.join(Engines.public_directory, 'test_assets_with_assets_directory', 'subfolder', 'file_in_subfolder.txt')) + end + + def test_public_files_have_been_copied_from_test_assets_with_no_subdirectory_plugin + Engines::Assets.mirror_files_for Engines.plugins[:test_assets_with_no_subdirectory] + + assert File.exist?(File.join(Engines.public_directory, 'test_assets_with_no_subdirectory')) + assert File.exist?(File.join(Engines.public_directory, 'test_assets_with_no_subdirectory', 'file.txt')) + end + + def test_public_files_have_NOT_been_copied_from_plugins_without_public_or_asset_directories + Engines::Assets.mirror_files_for Engines.plugins[:alpha_plugin] + + assert !File.exist?(File.join(Engines.public_directory, 'alpha_plugin')) + end +end
\ No newline at end of file diff --git a/vendor/plugins/engines/test/unit/backwards_compat_test.rb b/vendor/plugins/engines/test/unit/backwards_compat_test.rb new file mode 100644 index 000000000..4fa3698f2 --- /dev/null +++ b/vendor/plugins/engines/test/unit/backwards_compat_test.rb @@ -0,0 +1,8 @@ +require File.dirname(__FILE__) + '/../test_helper' + +class BackwardsCompatibilityTest < Test::Unit::TestCase + def test_rails_module_plugin_method_should_delegate_to_engines_plugins + assert_nothing_raised { Rails.plugins } + assert_equal Engines.plugins, Rails.plugins + end +end
\ No newline at end of file diff --git a/vendor/plugins/engines/test/unit/load_path_test.rb b/vendor/plugins/engines/test/unit/load_path_test.rb new file mode 100644 index 000000000..c26d331c3 --- /dev/null +++ b/vendor/plugins/engines/test/unit/load_path_test.rb @@ -0,0 +1,58 @@ +# Tests in this file ensure that: +# +# * the application /app/[controllers|helpers|models] and /lib +# paths preceed the corresponding plugin paths +# * the plugin paths are added to $LOAD_PATH in the order in which plugins are +# loaded + +require File.dirname(__FILE__) + '/../test_helper' + +class LoadPathTest < Test::Unit::TestCase + def setup + @load_path = expand_paths($LOAD_PATH) + end + + # Not sure if these test actually make sense as this now essentially tests + # Rails core functionality. On the other hand Engines relies on this to some + # extend so this will choke if something important changes in Rails. + + # the application app/... and lib/ directories should appear + # before any plugin directories + + def test_application_app_libs_should_precede_all_plugin_app_libs + types = %w(app/controllers app/helpers app/models lib) + types.each do |t| + app_index = load_path_index(File.join(RAILS_ROOT, t)) + assert_not_nil app_index, "#{t} is missing in $LOAD_PATH" + Engines.plugins.each do |plugin| + first_plugin_index = load_path_index(File.join(plugin.directory, t)) + assert(app_index < first_plugin_index) unless first_plugin_index.nil? + end + end + end + + # the engine directories should appear in the proper order based on + # the order they were started + + def test_plugin_dirs_should_appear_in_reverse_plugin_loading_order + app_paths = %w(app/controllers/ app app/models app/helpers lib) + app_paths.map { |p| File.join(RAILS_ROOT, p)} + plugin_paths = Engines.plugins.reverse.collect { |plugin| plugin.load_paths.reverse }.flatten + + expected_paths = expand_paths(app_paths + plugin_paths) + # only look at those paths that are also present in expected_paths so + # the only difference would be in the order of the paths + actual_paths = @load_path & expected_paths + + assert_equal expected_paths, actual_paths + end + + protected + def expand_paths(paths) + paths.collect { |p| File.expand_path(p) } + end + + def load_path_index(dir) + @load_path.index(File.expand_path(dir)) + end +end
\ No newline at end of file diff --git a/vendor/plugins/engines/test/unit/migration_test.rb b/vendor/plugins/engines/test/unit/migration_test.rb new file mode 100644 index 000000000..eae7fe7d4 --- /dev/null +++ b/vendor/plugins/engines/test/unit/migration_test.rb @@ -0,0 +1,63 @@ +require File.dirname(__FILE__) + '/../test_helper' +require 'rails_generator' +require 'rails_generator/scripts/generate' + +class MigrationsTest < Test::Unit::TestCase + + @@migration_dir = "#{RAILS_ROOT}/db/migrate" + + def setup + ActiveRecord::Migration.verbose = false + Engines.plugins[:test_migration].migrate(0) + end + + def teardown + FileUtils.rm_r(@@migration_dir) if File.exist?(@@migration_dir) + end + + def test_engine_migrations_can_run_down + assert !table_exists?('tests'), ActiveRecord::Base.connection.tables.inspect + assert !table_exists?('others'), ActiveRecord::Base.connection.tables.inspect + assert !table_exists?('extras'), ActiveRecord::Base.connection.tables.inspect + end + + def test_engine_migrations_can_run_up + Engines.plugins[:test_migration].migrate(3) + assert table_exists?('tests') + assert table_exists?('others') + assert table_exists?('extras') + end + + def test_engine_migrations_can_upgrade_incrementally + Engines.plugins[:test_migration].migrate(1) + assert table_exists?('tests') + assert !table_exists?('others') + assert !table_exists?('extras') + assert_equal 1, Engines::Plugin::Migrator.current_version(Engines.plugins[:test_migration]) + + + Engines.plugins[:test_migration].migrate(2) + assert table_exists?('others') + assert_equal 2, Engines::Plugin::Migrator.current_version(Engines.plugins[:test_migration]) + + + Engines.plugins[:test_migration].migrate(3) + assert table_exists?('extras') + assert_equal 3, Engines::Plugin::Migrator.current_version(Engines.plugins[:test_migration]) + end + + def test_generator_creates_plugin_migration_file + Rails::Generator::Scripts::Generate.new.run(['plugin_migration', 'test_migration'], :quiet => true) + assert migration_file, "migration file is missing" + end + + private + + def table_exists?(table) + ActiveRecord::Base.connection.tables.include?(table) + end + + def migration_file + Dir["#{@@migration_dir}/*test_migration_to_version_3.rb"][0] + end +end
\ No newline at end of file diff --git a/vendor/plugins/engines/test/unit/model_and_lib_test.rb b/vendor/plugins/engines/test/unit/model_and_lib_test.rb new file mode 100644 index 000000000..e5aa773ba --- /dev/null +++ b/vendor/plugins/engines/test/unit/model_and_lib_test.rb @@ -0,0 +1,37 @@ +require File.dirname(__FILE__) + '/../test_helper' + +class ModelAndLibTest < Test::Unit::TestCase + + def test_WITH_a_model_defined_only_in_a_plugin_IT_should_load_the_model + assert_equal 'AlphaPluginModel (from alpha_plugin)', AlphaPluginModel.report_location + end + + def test_WITH_a_model_defined_only_in_a_plugin_lib_dir_IT_should_load_the_model + assert_equal 'AlphaPluginLibModel (from alpha_plugin)', AlphaPluginLibModel.report_location + end + + # app takes precedence over plugins + + def test_WITH_a_model_defined_in_both_app_and_plugin_IT_should_load_the_one_in_app + assert_equal 'AppAndPluginModel (from app)', AppAndPluginModel.report_location + assert_raises(NoMethodError) { AppAndPluginLibModel.defined_only_in_alpha_engine_version } + end + + def test_WITH_a_model_defined_in_both_app_and_plugin_lib_dirs_IT_should_load_the_one_in_app + assert_equal 'AppAndPluginLibModel (from lib)', AppAndPluginLibModel.report_location + assert_raises(NoMethodError) { AppAndPluginLibModel.defined_only_in_alpha_engine_version } + end + + # subsequently loaded plugins take precendence over previously loaded plugins + + # TODO + # + # this does work when we rely on $LOAD_PATH while it won't work when we use + # Dependency constant autoloading. This somewhat confusing difference has + # been there since at least Rails 1.2.x. See http://www.ruby-forum.com/topic/134529 + + def test_WITH_a_model_defined_in_two_plugins_IT_should_load_the_latter_of_both + require 'shared_plugin_model' + assert_equal SharedPluginModel.report_location, 'SharedPluginModel (from beta_plugin)' + end +end
\ No newline at end of file diff --git a/vendor/plugins/engines/test/unit/plugins_test.rb b/vendor/plugins/engines/test/unit/plugins_test.rb new file mode 100644 index 000000000..f8627bcee --- /dev/null +++ b/vendor/plugins/engines/test/unit/plugins_test.rb @@ -0,0 +1,11 @@ +require File.dirname(__FILE__) + '/../test_helper' + +class PluginsTest < Test::Unit::TestCase + + def test_should_allow_access_to_plugins_by_strings_or_symbols + p = Engines.plugins["alpha_plugin"] + q = Engines.plugins[:alpha_plugin] + assert_kind_of Engines::Plugin, p + assert_equal p, q + end +end
\ No newline at end of file diff --git a/vendor/plugins/engines/test/unit/test_testing/override_test.rb b/vendor/plugins/engines/test/unit/test_testing/override_test.rb new file mode 100644 index 000000000..ea58a51c3 --- /dev/null +++ b/vendor/plugins/engines/test/unit/test_testing/override_test.rb @@ -0,0 +1,7 @@ +require File.join(File.dirname(__FILE__), *%w[.. .. test_helper]) + +class OverrideTest < ActiveSupport::TestCase + def test_overrides_from_the_application_should_work + assert true, "overriding plugin tests from the application should work" + end +end
\ No newline at end of file diff --git a/vendor/plugins/engines/test/unit/testing_test.rb b/vendor/plugins/engines/test/unit/testing_test.rb new file mode 100644 index 000000000..c0c37ed40 --- /dev/null +++ b/vendor/plugins/engines/test/unit/testing_test.rb @@ -0,0 +1,19 @@ +require File.dirname(__FILE__) + '/../test_helper' + +class TestingTest < Test::Unit::TestCase + def setup + Engines::Testing.set_fixture_path + @filename = File.join(Engines::Testing.temporary_fixtures_directory, 'testing_fixtures.yml') + File.delete(@filename) if File.exists?(@filename) + end + + def teardown + File.delete(@filename) if File.exists?(@filename) + end + + def test_should_copy_fixtures_files_to_tmp_directory + assert !File.exists?(@filename) + Engines::Testing.setup_plugin_fixtures + assert File.exists?(@filename) + end +end
\ No newline at end of file diff --git a/vendor/plugins/prepend_engine_views/init.rb b/vendor/plugins/prepend_engine_views/init.rb new file mode 100644 index 000000000..cbf0e89a9 --- /dev/null +++ b/vendor/plugins/prepend_engine_views/init.rb @@ -0,0 +1,21 @@ +module PrependEngineViews + def self.included(base) + base.send(:include, InstanceMethods) + base.class_eval do + alias_method_chain :add_engine_view_paths, :prepend + end + end + + module InstanceMethods + # Patch Rails so engine's views are prepended to the view_path, + # thereby letting plugins override application views + def add_engine_view_paths_with_prepend + paths = ActionView::PathSet.new(engines.collect(&:view_path)) + ActionController::Base.view_paths.unshift(*paths) + ActionMailer::Base.view_paths.unshift(*paths) if configuration.frameworks.include?(:action_mailer) + end + end +end + +Rails::Plugin::Loader.send :include, PrependEngineViews + |