diff --git a/vendor/plugins/engines/.gitignore b/vendor/plugins/engines/.gitignore
new file mode 100644
index 00000000..721bd7de
--- /dev/null
+++ b/vendor/plugins/engines/.gitignore
@@ -0,0 +1,3 @@
+.DS_Store
+test_app
+doc
\ No newline at end of file
diff --git a/vendor/plugins/engines/CHANGELOG b/vendor/plugins/engines/CHANGELOG
index 51cc51fa..20e9b34d 100644
--- a/vendor/plugins/engines/CHANGELOG
+++ b/vendor/plugins/engines/CHANGELOG
@@ -1,3 +1,19 @@
+= EDGE
+
+* Samuel Williams (http://www.oriontransfer.co.nz/):
+ Thanks to Tekin for his patches.
+ Updated migrations system to tie in more closely with the current rails mechanism.
+ Rake task for updating database schema info
+ rake db:migrate:upgrade_plugin_migrations
+ Please see http://engines.lighthouseapp.com/projects/10178-engines-plugin/tickets/17 for more information.
+
+* Refactored the view loading to work with changes in Edge Rails
+
+* Fixed integration of plugin migrations with the new, default timestamped migrations in Edge Rails
+
+* Refactored tests into the plugin itself - the plugin can now generate its own test_app harness and run tests within it.
+
+
= 2.0.0 - (ANOTHER) MASSIVE INTERNAL REFACTORING
* Engines now conforms to the new plugin loading mechanism, delegating plugin load order and lots of other things to Rails itself.
diff --git a/vendor/plugins/engines/MIT-LICENSE b/vendor/plugins/engines/MIT-LICENSE
index 17a3b22b..2718d6d4 100644
--- a/vendor/plugins/engines/MIT-LICENSE
+++ b/vendor/plugins/engines/MIT-LICENSE
@@ -1,4 +1,4 @@
-Copyright (c) 2007 James Adam
+Copyright (c) 2008 James Adam
The MIT License
diff --git a/vendor/plugins/engines/README b/vendor/plugins/engines/README
index 27a8b10e..e2610134 100644
--- a/vendor/plugins/engines/README
+++ b/vendor/plugins/engines/README
@@ -23,7 +23,7 @@ In addition to the regular set of plugin-supported files (lib, init.rb, tasks, g
Include these files in an app directory just like you would in a normal Rails application. If you need to override a method, view or partial, create the corresponding file in your main app directory and it will be used instead.
* Controllers & Helpers: See Engines::RailsExtensions::Dependencies for more information.
-* Views: See Engines::RailsExtensions::Templates for more information.
+* Views: now handled almost entirely by ActionView itself (see Engines::Plugin#add_plugin_view_paths for more information)
=== Models
@@ -60,4 +60,24 @@ The engines plugin enhances and adds to the suite of default rake tasks for work
rake -T
-to see the set of rake tasks available.
\ No newline at end of file
+to see the set of rake tasks available.
+
+= Testing the engines plugin itself
+
+Because of the way the engines plugin modifies Rails, the simplest way to consistently test it against multiple versions is by generating a test harness application - a full Rails application that includes tests to verify the engines plugin behaviour in a real, running environment.
+
+Run the tests like this:
+
+ $ cd engines
+ $ rake test
+
+This will generate a test_app directory within the engines plugin (using the default 'rails' command), import tests and code into that application and then run the test suite.
+
+If you wish to test against a specific version of Rails, run the tests with the RAILS environment variable set to the local directory containing your Rails checkout
+
+ $ rake test RAILS=/Users/james/Code/rails_edge_checkout
+
+Alternatively, you can clone the latest version of Rails ('edge rails') from github like so:
+
+ $ rake test RAILS=edge
+
diff --git a/vendor/plugins/engines/Rakefile b/vendor/plugins/engines/Rakefile
index 00456e9f..540eb5b6 100644
--- a/vendor/plugins/engines/Rakefile
+++ b/vendor/plugins/engines/Rakefile
@@ -29,4 +29,185 @@ task :cruise do
['db:migrate', 'test', 'test:plugins'].each do |t|
Rake::Task[t].invoke
end
-end
\ No newline at end of file
+end
+
+task :clean => [:clobber_doc, "test:clean"]
+
+namespace :test do
+
+ # Yields a block with STDOUT and STDERR silenced. If you *really* want
+ # to output something, the block is yielded with the original output
+ # streams, i.e.
+ #
+ # silence do |o, e|
+ # puts 'hello!' # no output produced
+ # o.puts 'hello!' # output on STDOUT
+ # end
+ #
+ # (based on silence_stream in ActiveSupport.)
+ def silence
+ yield(STDOUT, STDERR) if ENV['VERBOSE']
+ streams = [STDOUT, STDERR]
+ actual_stdout = STDOUT.dup
+ actual_stderr = STDERR.dup
+ streams.each do |s|
+ s.reopen(RUBY_PLATFORM =~ /mswin/ ? 'NUL:' : '/dev/null')
+ s.sync = true
+ end
+ yield actual_stdout, actual_stderr
+ ensure
+ STDOUT.reopen(actual_stdout)
+ STDERR.reopen(actual_stderr)
+ end
+
+ def test_app_dir
+ File.join(File.dirname(__FILE__), 'test_app')
+ end
+
+ def run(cmd)
+ cmd = cmd.join(" && ") if cmd.is_a?(Array)
+ system(cmd) || raise("failed running '#{cmd}'")
+ end
+
+ desc 'Remove the test application'
+ task :clean do
+ FileUtils.rm_r(test_app_dir) if File.exist?(test_app_dir)
+ end
+
+ desc 'Build the test rails application (use RAILS=[edge,] to test against specific version)'
+ task :generate_app do
+ silence do |out, err|
+ out.puts "> Creating test application at #{test_app_dir}"
+
+ if ENV['RAILS']
+ vendor_dir = File.join(test_app_dir, 'vendor')
+ FileUtils.mkdir_p vendor_dir
+
+ if ENV['RAILS'] == 'edge'
+ out.puts " Cloning Edge Rails from GitHub"
+ run "cd #{vendor_dir} && git clone --depth 1 git://github.com/rails/rails.git"
+ elsif ENV['RAILS'] =~ /\d\.\d\.\d/
+ if ENV['CURL']
+ out.puts " Cloning Rails Tag #{ENV['RAILS']} from GitHub using curl and tar"
+ run ["cd #{vendor_dir}",
+ "mkdir rails",
+ "cd rails",
+ "curl -s -L http://github.com/rails/rails/tarball/#{ENV['RAILS']} | tar xzv --strip-components 1"]
+ else
+ out.puts " Cloning Rails Tag #{ENV['RAILS']} from GitHub (can be slow - set CURL=true to use curl)"
+ run ["cd #{vendor_dir}",
+ "git clone git://github.com/rails/rails.git",
+ "cd rails",
+ "git pull",
+ "git checkout v#{ENV['RAILS']}"]
+ end
+ elsif File.exist?(ENV['RAILS'])
+ out.puts " Linking rails from #{ENV['RAILS']}"
+ run "cd #{vendor_dir} && ln -s #{ENV['RAILS']} rails"
+ else
+ raise "Couldn't build test application from '#{ENV['RAILS']}'"
+ end
+
+ out.puts " generating rails default directory structure"
+ run "ruby #{File.join(vendor_dir, 'rails', 'railties', 'bin', 'rails')} #{test_app_dir}"
+ else
+ version = `rails --version`.chomp.split.last
+ out.puts " building rails using the 'rails' command (rails version: #{version})"
+ run "rails #{test_app_dir}"
+ end
+
+ # get the database config and schema in place
+ out.puts " writing database.yml"
+ require 'yaml'
+ File.open(File.join(test_app_dir, 'config', 'database.yml'), 'w') do |f|
+ f.write(%w(development test).inject({}) do |h, env|
+ h[env] = {"adapter" => "sqlite3", "database" => "engines_#{env}.sqlite3"} ; h
+ end.to_yaml)
+ end
+ out.puts " installing exception_notification plugin"
+ run "cd #{test_app_dir} && ./script/plugin install exception_notification"
+ end
+ end
+
+ # We can't link the plugin, as it needs to be present for script/generate to find
+ # the plugin generator.
+ # TODO: find and +1/create issue for loading generators from symlinked plugins
+ desc 'Mirror the engines plugin into the test application'
+ task :copy_engines_plugin do
+ puts "> Copying engines plugin into test application"
+ engines_plugin = File.join(test_app_dir, "vendor", "plugins", "engines")
+ FileUtils.rm_r(engines_plugin) if File.exist?(engines_plugin)
+ FileUtils.mkdir_p(engines_plugin)
+ FileList["*"].exclude("test_app").each do |file|
+ FileUtils.cp_r(file, engines_plugin)
+ end
+ end
+
+ def insert_line(line, options)
+ line = line + "\n"
+ target_file = File.join(test_app_dir, options[:into])
+ lines = File.readlines(target_file)
+ return if lines.include?(line)
+
+ if options[:after]
+ if options[:after].is_a?(String)
+ after_line = options[:after] + "\n"
+ else
+ after_line = lines.find { |l| l =~ options[:after] }
+ raise "couldn't find a line matching #{options[:after].inspect} in #{target_file}" unless after_line
+ end
+ index = lines.index(after_line)
+ raise "couldn't find line '#{after_line}' in #{target_file}" unless index
+ lines.insert(index + 1, line)
+ else
+ lines << line
+ end
+ File.open(target_file, 'w') { |f| f.write lines.join }
+ end
+
+ def mirror_test_files(src, dest=nil)
+ destination_dir = File.join(*([test_app_dir, dest].compact))
+ FileUtils.cp_r(File.join(File.dirname(__FILE__), 'test', src), destination_dir)
+ end
+
+ 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"
+ 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/)
+
+ insert_line("require 'engines_test_helper'", :into => 'test/test_helper.rb')
+
+ puts "> Mirroring test application files into #{test_app_dir}"
+ mirror_test_files('app')
+ mirror_test_files('lib')
+ mirror_test_files('plugins', 'vendor')
+ mirror_test_files('unit', 'test')
+ mirror_test_files('functional', 'test')
+ end
+
+ desc 'Prepare the engines test environment'
+ task :test_app do
+ version_tag = File.join(test_app_dir, 'RAILS_VERSION')
+ existing_version = File.read(version_tag).chomp rescue 'unknown'
+ if existing_version == ENV['RAILS']
+ puts "> Reusing existing test application (#{ENV['RAILS']})"
+ else
+ puts "> Recreating test application"
+ Rake::Task["test:clean"].invoke
+ Rake::Task["test:generate_app"].invoke
+
+ File.open(version_tag, "w") { |f| f.write ENV['RAILS'] }
+ end
+ end
+end
+
+task :test => "test:mirror_engine_files" do
+ puts "> Loading the test application environment and running tests"
+ # We use exec here to replace the current running rake process
+ exec("cd #{test_app_dir} && rake db:migrate && rake")
+end
diff --git a/vendor/plugins/engines/about.yml b/vendor/plugins/engines/about.yml
index 272003e4..619bd5a9 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.0.0-RC1
\ No newline at end of file
+version: 2.1.0
\ No newline at end of file
diff --git a/vendor/plugins/engines/boot.rb b/vendor/plugins/engines/boot.rb
index 50fadc0e..f80f2b17 100644
--- a/vendor/plugins/engines/boot.rb
+++ b/vendor/plugins/engines/boot.rb
@@ -1,8 +1,7 @@
begin
require 'rails/version'
- unless Rails::VERSION::MAJOR >= 2 ||
- (Rails::VERSION::MAJOR >= 1 && Rails::VERSION::MINOR >= 99)
- raise "This version of the engines plugin requires Rails 2.0 or later!"
+ 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!"
end
end
diff --git a/vendor/plugins/engines/generators/plugin_migration/plugin_migration_generator.rb b/vendor/plugins/engines/generators/plugin_migration/plugin_migration_generator.rb
index 6606e19b..5944ae23 100644
--- a/vendor/plugins/engines/generators/plugin_migration/plugin_migration_generator.rb
+++ b/vendor/plugins/engines/generators/plugin_migration/plugin_migration_generator.rb
@@ -2,11 +2,15 @@
# within the database.
class PluginMigrationGenerator < Rails::Generator::Base
+ # 255 characters max for Windows NTFS (http://en.wikipedia.org/wiki/Filename)
+ # minus 14 for timestamp, minus some extra chars for dot, underscore, file
+ # extension. So let's have 230.
+ MAX_FILENAME_LENGTH = 230
+
def initialize(runtime_args, runtime_options={})
super
@options = {:assigns => {}}
-
- ensure_plugin_schema_table_exists
+ ensure_schema_table_exists
get_plugins_to_migrate(runtime_args)
if @plugins_to_migrate.empty?
@@ -25,11 +29,10 @@ def manifest
end
protected
-
- # Create the plugin schema table if it doesn't already exist. See
- # Engines::RailsExtensions::Migrations#initialize_schema_information_with_engine_additions
- def ensure_plugin_schema_table_exists
- ActiveRecord::Base.connection.initialize_schema_information
+
+ # Create the schema table if it doesn't already exist.
+ def ensure_schema_table_exists
+ ActiveRecord::Base.connection.initialize_schema_migrations_table
end
# Determine all the plugins which have migrations that aren't present
@@ -69,11 +72,27 @@ def get_plugins_to_migrate(plugin_names)
@options[:assigns][:current_versions] = @current_versions
end
- # Construct a unique migration name based on the plugins involved and the
- # versions they should reach after this migration is run.
+ # Returns a migration name. If the descriptive migration name based on the
+ # plugin names involved is shorter than 230 characters that one will be
+ # used. Otherwise a shorter name will be returned.
def build_migration_name
+ returning descriptive_migration_name do |name|
+ name.replace short_migration_name if name.length > MAX_FILENAME_LENGTH
+ end
+ end
+
+ # Construct a unique migration name based on the plugins involved and the
+ # versions they should reach after this migration is run. The name constructed
+ # needs to be lowercase
+ def descriptive_migration_name
@plugins_to_migrate.map do |plugin|
"#{plugin.name}_to_version_#{@new_versions[plugin.name]}"
- end.join("_and_")
- end
+ end.join("_and_").downcase
+ end
+
+ # Short migration name that will be used if the descriptive_migration_name
+ # exceeds 230 characters
+ def short_migration_name
+ 'plugin_migrations'
+ end
end
\ No newline at end of file
diff --git a/vendor/plugins/engines/init.rb b/vendor/plugins/engines/init.rb
index 508e909c..df945263 100644
--- a/vendor/plugins/engines/init.rb
+++ b/vendor/plugins/engines/init.rb
@@ -1 +1,5 @@
-Engines.init if defined? :Engines
+# 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
diff --git a/vendor/plugins/engines/lib/engines.rb b/vendor/plugins/engines/lib/engines.rb
index 06a1e68c..04c22da8 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(active_record action_mailer asset_helpers routing migrations dependencies)
+ self.rails_extensions = %w(action_mailer asset_helpers routing migrations dependencies)
# The name of the public directory to mirror public engine assets into.
# Defaults to RAILS_ROOT/public/plugin_assets.
@@ -131,18 +131,23 @@ def select_existing_paths(paths)
def mix_code_from(*types)
self.code_mixing_file_types += types.map { |x| x.to_s.singularize }
end
-
+
# A general purpose method to mirror a directory (+source+) into a destination
# directory, including all files and subdirectories. Files will not be mirrored
# if they are identical already (checked via FileUtils#identical?).
def mirror_files_from(source, destination)
return unless File.directory?(source)
-
+
# TODO: use Rake::FileList#pathmap?
source_files = Dir[source + "/**/*"]
source_dirs = source_files.select { |d| File.directory?(d) }
- source_files -= source_dirs
-
+ source_files -= source_dirs
+
+ unless source_files.empty?
+ base_target_dir = File.join(destination, File.dirname(source_files.first).gsub(source, ''))
+ FileUtils.mkdir_p(base_target_dir)
+ end
+
source_dirs.each do |dir|
# strip down these paths so we have simple, relative paths we can
# add to the destination
@@ -153,7 +158,7 @@ def mirror_files_from(source, destination)
raise "Could not create directory #{target_dir}: \n" + e
end
end
-
+
source_files.each do |file|
begin
target = File.join(destination, file.gsub(source, ''))
diff --git a/vendor/plugins/engines/lib/engines/assets.rb b/vendor/plugins/engines/lib/engines/assets.rb
index a9e9cf83..d0553299 100644
--- a/vendor/plugins/engines/lib/engines/assets.rb
+++ b/vendor/plugins/engines/lib/engines/assets.rb
@@ -14,7 +14,7 @@ def initialize_base_public_directory
dir = Engines.public_directory
unless File.exist?(dir)
Engines.logger.debug "Creating public engine files directory '#{dir}'"
- FileUtils.mkdir(dir)
+ FileUtils.mkdir_p(dir)
end
readme = File.join(dir, "README")
File.open(readme, 'w') { |f| f.puts @@readme } unless File.exist?(readme)
diff --git a/vendor/plugins/engines/lib/engines/plugin.rb b/vendor/plugins/engines/lib/engines/plugin.rb
index 42b5eb8e..bb540ae7 100644
--- a/vendor/plugins/engines/lib/engines/plugin.rb
+++ b/vendor/plugins/engines/lib/engines/plugin.rb
@@ -110,11 +110,15 @@ def migration_directory
# Returns the version number of the latest migration for this plugin. Returns
# nil if this plugin has no migrations.
def latest_migration
+ migrations.last
+ end
+
+ # Returns the version numbers of all migrations for this plugin.
+ def migrations
migrations = Dir[migration_directory+"/*.rb"]
- return nil if migrations.empty?
- migrations.map { |p| File.basename(p) }.sort.last.match(/0*(\d+)\_/)[1].to_i
+ migrations.map { |p| File.basename(p).match(/0*(\d+)\_/)[1].to_i }.sort
end
-
+
# Migrate this plugin to the given version. See Engines::Plugin::Migrator for more
# information.
def migrate(version = nil)
diff --git a/vendor/plugins/engines/lib/engines/plugin/migrator.rb b/vendor/plugins/engines/lib/engines/plugin/migrator.rb
index 3871c037..05379d99 100644
--- a/vendor/plugins/engines/lib/engines/plugin/migrator.rb
+++ b/vendor/plugins/engines/lib/engines/plugin/migrator.rb
@@ -12,49 +12,30 @@ class Engines::Plugin::Migrator < ActiveRecord::Migrator
# We need to be able to set the 'current' engine being migrated.
cattr_accessor :current_plugin
- # Runs the migrations from a plugin, up (or down) to the version given
- def self.migrate_plugin(plugin, version)
- self.current_plugin = plugin
- migrate(plugin.migration_directory, version)
- end
-
- # Returns the name of the table used to store schema information about
- # installed plugins.
- #
- # See Engines.schema_info_table for more details.
- def self.schema_info_table_name
- ActiveRecord::Base.wrapped_table_name Engines.schema_info_table
- end
-
- # Returns the current version of the given plugin
- def self.current_version(plugin=current_plugin)
- result = ActiveRecord::Base.connection.select_one(<<-ESQL
- SELECT version FROM #{schema_info_table_name}
- WHERE plugin_name = '#{plugin.name}'
- ESQL
- )
- if result
- result["version"].to_i
- else
- # There probably isn't an entry for this engine in the migration info table.
- # We need to create that entry, and set the version to 0
- ActiveRecord::Base.connection.execute(<<-ESQL
- INSERT INTO #{schema_info_table_name} (version, plugin_name)
- VALUES (0,'#{plugin.name}')
- ESQL
- )
- 0
+ class << self
+ # Runs the migrations from a plugin, up (or down) to the version given
+ def migrate_plugin(plugin, version)
+ self.current_plugin = plugin
+ return if current_version(plugin) == version
+ migrate(plugin.migration_directory, version)
+ end
+
+ def current_version(plugin=current_plugin)
+ # Delete migrations that don't match .. to_i will work because the number comes first
+ ::ActiveRecord::Base.connection.select_values(
+ "SELECT version FROM #{schema_migrations_table_name}"
+ ).delete_if{ |v| v.match(/-#{plugin.name}/) == nil }.map(&:to_i).max || 0
end
end
-
- # Sets the version of the plugin in Engines::Plugin::Migrator.current_plugin to
- # the given version.
- def set_schema_version(version)
- ActiveRecord::Base.connection.update(<<-ESQL
- UPDATE #{self.class.schema_info_table_name}
- SET version = #{down? ? version.to_i - 1 : version.to_i}
- WHERE plugin_name = '#{self.current_plugin.name}'
- ESQL
- )
+
+ def migrated
+ sm_table = self.class.schema_migrations_table_name
+ ::ActiveRecord::Base.connection.select_values(
+ "SELECT version FROM #{sm_table}"
+ ).delete_if{ |v| v.match(/-#{current_plugin.name}/) == nil }.map(&:to_i).sort
+ end
+
+ def record_version_state_after_migrating(version)
+ super(version.to_s + "-" + current_plugin.name)
end
end
diff --git a/vendor/plugins/engines/lib/engines/rails_extensions/action_mailer.rb b/vendor/plugins/engines/lib/engines/rails_extensions/action_mailer.rb
index 6fee4db4..32198d8e 100644
--- a/vendor/plugins/engines/lib/engines/rails_extensions/action_mailer.rb
+++ b/vendor/plugins/engines/lib/engines/rails_extensions/action_mailer.rb
@@ -16,9 +16,6 @@
module Engines::RailsExtensions::ActionMailer
def self.included(base) #:nodoc:
base.class_eval do
- # TODO commented this out because it seems to break ActionMailer
- # how can this be fixed?
-
alias_method_chain :template_path, :engine_additions
alias_method_chain :initialize_template_class, :engine_additions
end
@@ -70,7 +67,7 @@ def initialize_template_class_with_engine_additions(assigns)
#
# ActionView::Base.new(ActionController::Base.view_paths.dup, assigns, self)
renderer = initialize_template_class_without_engine_additions(assigns)
- renderer.view_paths = ActionController::Base.view_paths.dup
+ renderer.view_paths.unshift(*ActionController::Base.view_paths.dup)
renderer
end
end
diff --git a/vendor/plugins/engines/lib/engines/rails_extensions/active_record.rb b/vendor/plugins/engines/lib/engines/rails_extensions/active_record.rb
deleted file mode 100644
index 676926ac..00000000
--- a/vendor/plugins/engines/lib/engines/rails_extensions/active_record.rb
+++ /dev/null
@@ -1,24 +0,0 @@
-# Here we add a single helpful method to ActiveRecord::Base. This method may be deprecated
-# in the future, since support for the Module#config mechanism which required it has
-# also been dropped.
-module Engines::RailsExtensions::ActiveRecord
- # NOTE: Currently the Migrations system will ALWAYS wrap given table names
- # in the prefix/suffix, so any table name set via ActiveRecord::Base#set_table_name,
- # for instance will always get wrapped in the process of migration. For this
- # reason, whatever value you give to the config will be wrapped when set_table_name
- # is used in the model.
- #
- # This method is useful for determining the actual name (including prefix and
- # suffix) that Rails will use for a model, given a particular set_table_name
- # parameter.
- def wrapped_table_name(name)
- table_name_prefix + name + table_name_suffix
- end
-
-end
-
-module ::ActiveRecord #:nodoc:
- class Base #:nodoc:
- extend Engines::RailsExtensions::ActiveRecord
- end
-end
diff --git a/vendor/plugins/engines/lib/engines/rails_extensions/dependencies.rb b/vendor/plugins/engines/lib/engines/rails_extensions/dependencies.rb
index 82473419..9c7804e6 100644
--- a/vendor/plugins/engines/lib/engines/rails_extensions/dependencies.rb
+++ b/vendor/plugins/engines/lib/engines/rails_extensions/dependencies.rb
@@ -102,7 +102,7 @@ def require_or_load_with_engine_additions(file_name, const_path=nil)
# if we recognise this type
# (this regexp splits out the module/filename from any instances of app/#{type}, so that
# modules are still respected.)
- if file_name =~ /^(.*app\/#{file_type}s\/)?(.*_#{file_type})(\.rb)?$/
+ if file_name =~ /^(.*app\/#{file_type}s\/)+(.*_#{file_type})(\.rb)?$/
base_name = $2
# ... go through the plugins from first started to last, so that
# code with a high precedence (started later) will override lower precedence
@@ -140,6 +140,6 @@ def require_or_load_with_engine_additions(file_name, const_path=nil)
end
end
-module ::Dependencies #:nodoc:
+module ActiveSupport::Dependencies #:nodoc:
include Engines::RailsExtensions::Dependencies
-end
\ No newline at end of file
+end
diff --git a/vendor/plugins/engines/lib/engines/rails_extensions/migrations.rb b/vendor/plugins/engines/lib/engines/rails_extensions/migrations.rb
index 1fddf584..7f51cb84 100644
--- a/vendor/plugins/engines/lib/engines/rails_extensions/migrations.rb
+++ b/vendor/plugins/engines/lib/engines/rails_extensions/migrations.rb
@@ -32,8 +32,8 @@
# |- lib/
# |- db/
# |-migrate/
-# |- 001_do_something.rb
-# |- 002_and_something_else.rb
+# |- 20081105123419_add_some_new_feature.rb
+# |- 20081107144959_and_something_else.rb
# |- ...
#
# When you install a plugin which contains migrations, you are undertaking a
@@ -44,8 +44,8 @@
#
# == An example
#
-# For example, our current application is at version 14 (according to the
-# +schema_info+ table), when we decide that we want to add a tagging plugin. The
+# For example, our current application is at version 20081106164503 (according to the
+# +schema_migrations+ table), when we decide that we want to add a tagging plugin. The
# tagging plugin chosen includes migrations to create the tables it requires
# (say, _tags_ and _taggings_, for instance), along with the models and helpers
# one might expect.
@@ -57,14 +57,14 @@
#
# $ script/generate plugin_migration
# exists db/migrate
-# create db/migrate/015_migrate_tagging_plugin_to_version_3.rb
+# create db/migrate/20081108120415_my_plugin_to_version_20081107144959.rb
#
-# This migration will take our application to version 15, and contains the following,
-# typical migration code:
+# This migration will take our application to version 20081108120415, and contains the
+# following, typical migration code:
#
-# class MigrateTaggingPluginToVersion3 < ActiveRecord::Migration
+# class TaggingToVersion20081107144959 < ActiveRecord::Migration
# def self.up
-# Engines.plugins[:tagging].migrate(3)
+# Engines.plugins[:tagging].migrate(20081107144959)
# end
# def self.down
# Engines.plugins[:tagging].migrate(0)
@@ -72,8 +72,8 @@
# end
#
# When we migrate our application up, using rake db:migrate as normal,
-# the plugin will be migrated up to its latest version (3 in this example). If we
-# ever decide to migrate the application back to the state it was in at version 14,
+# the plugin will be migrated up to its latest version (20081108120415 in this example). If we
+# ever decide to migrate the application back to the state it was in at version 20081106164503,
# the plugin migrations will be taken back down to version 0 (which, typically,
# would remove all tables the plugin migrations define).
#
@@ -88,21 +88,21 @@
#
# $ script/generate plugin_migration
# exists db/migrate
-# create db/migrate/023_migrate_tagging_plugin_to_version_5.rb
+# create db/migrate/20081210131437_tagging_to_version_20081201172034.rb
#
# The contents of this migration are:
#
-# class MigrateTaggingPluginToVersion3 < ActiveRecord::Migration
+# class TaggingToVersion20081108120415 < ActiveRecord::Migration
# def self.up
-# Engines.plugins[:tagging].migrate(5)
+# Engines.plugins[:tagging].migrate(20081201172034)
# end
# def self.down
-# Engines.plugins[:tagging].migrate(3)
+# Engines.plugins[:tagging].migrate(20081107144959)
# end
# end
#
-# Notice that if we were to migrate down to revision 22 or lower, the tagging plugin
-# will be migrated back down to version 3 - the version we were previously at.
+# Notice that if we were to migrate down to revision 20081108120415 or lower, the tagging plugin
+# will be migrated back down to version 20081107144959 - the version we were previously at.
#
#
# = Creating migrations in plugins
@@ -118,44 +118,16 @@
#
# Engines.plugins[:whatever].migrate(version)
#
-# ---
#
-# The Engines::RailsExtensions::Migrations module defines extensions for Rails'
-# migration systems. Specifically:
+# = Upgrading from previous versions of the engines plugin
#
-# * Adding a hook to initialize_schema_information to create the plugin schema
-# info table.
+# Thanks to the tireless work of the plugin developer community, we can now relying on the migration
+# mechanism in Rails 2.1+ to do much of the plugin migration work for us. This also means that we
+# don't need a seperate schema_info table for plugins.
#
-module Engines::RailsExtensions::Migrations
- def self.included(base) # :nodoc:
- base.class_eval { alias_method_chain :initialize_schema_information, :engine_additions }
- end
-
- # Create the schema tables, and ensure that the plugin schema table
- # is also initialized. The plugin schema info table is defined by
- # Engines::Plugin::Migrator.schema_info_table_name.
- def initialize_schema_information_with_engine_additions
- initialize_schema_information_without_engine_additions
-
- # create the plugin schema stuff.
- begin
- execute <<-ESQL
- CREATE TABLE #{Engines::Plugin::Migrator.schema_info_table_name}
- (plugin_name #{type_to_sql(:string)}, version #{type_to_sql(:integer)})
- ESQL
- rescue ActiveRecord::StatementInvalid
- # Schema has been initialized
- end
- end
-end
-
-module ::ActiveRecord #:nodoc:
- module ConnectionAdapters #:nodoc:
- module SchemaStatements #:nodoc:
- include Engines::RailsExtensions::Migrations
- end
- end
-end
-
-# Set ActiveRecord to ignore the plugin schema table by default
-::ActiveRecord::SchemaDumper.ignore_tables << Engines.schema_info_table
\ No newline at end of file
+# To update your application, run
+#
+# rake db:migrate:upgrade_plugin_migrations
+#
+# This will ensure that migration information is carried over into the main schema_migrations table.
+#
\ 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
index 5415c94e..c7429d04 100644
--- a/vendor/plugins/engines/lib/engines/rails_extensions/routing.rb
+++ b/vendor/plugins/engines/lib/engines/rails_extensions/routing.rb
@@ -8,13 +8,13 @@
# == 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. In your plugin, you simply include a routes.rb
-# file like the one below at the root of your plugin:
+# very simply, as it turns out. Include a routes.rb file like the one below
+# at the root of your plugin (along-side init.rb and lib/):
#
-# connect "/login", :controller => "my_plugin/account", :action => "login"
+# connect "/login", :controller => "account", :action => "login"
#
# # add a named route
-# logout "/logout", :controller => "my_plugin/account", :action => "logout"
+# logout "/logout", :controller => "account", :action => "logout"
#
# # some restful stuff
# resources :things do |t|
diff --git a/vendor/plugins/engines/lib/engines/testing.rb b/vendor/plugins/engines/lib/engines/testing.rb
index 2b3bdc99..f7833c38 100644
--- a/vendor/plugins/engines/lib/engines/testing.rb
+++ b/vendor/plugins/engines/lib/engines/testing.rb
@@ -81,7 +81,7 @@ def self.setup_plugin_fixtures(plugins = Engines.plugins.by_precedence)
# Sets the fixture path used by Test::Unit::TestCase to the temporary
# directory which contains all plugin fixtures.
def self.set_fixture_path
- Test::Unit::TestCase.fixture_path = self.temporary_fixtures_directory
+ ActiveSupport::TestCase.fixture_path = self.temporary_fixtures_directory
$LOAD_PATH.unshift self.temporary_fixtures_directory
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 42b4c8cb..553209bc 100644
--- a/vendor/plugins/engines/tasks/engines.rake
+++ b/vendor/plugins/engines/tasks/engines.rake
@@ -2,20 +2,22 @@
# handy for modifying existing Rails rake tasks.
# Credit for the original snippet of code goes to Jeremy Kemper
# http://pastie.caboo.se/9620
-unless Rake::TaskManager.methods.include?(:redefine_task)
+unless Rake::TaskManager.methods.include?('redefine_task')
module Rake
module TaskManager
def redefine_task(task_class, args, &block)
- task_name, deps = resolve_args(args)
+ task_name, arg_names, deps = resolve_args([args])
task_name = task_class.scope_name(@scope, task_name)
deps = [deps] unless deps.respond_to?(:to_ary)
deps = deps.collect {|d| d.to_s }
task = @tasks[task_name.to_s] = task_class.new(task_name, self)
task.application = self
- @last_comment = nil
+ task.add_description(@last_description)
+ @last_description = nil
task.enhance(deps, &block)
task
end
+
end
class Task
class << self
@@ -41,6 +43,80 @@ namespace :db do
end
end
+ desc 'For engines coming from Rails version < 2.0 or for those previously updated to work with Sven Fuch\'s fork of engines, you need to upgrade the schema info table'
+ task :upgrade_plugin_migrations => :environment do
+ svens_fork_table_name = 'plugin_schema_migrations'
+
+ # Check if app was previously using Sven's fork
+ if ActiveRecord::Base.connection.table_exists?(svens_fork_table_name)
+ old_sm_table = svens_fork_table_name
+ else
+ old_sm_table = ActiveRecord::Migrator.proper_table_name(Engines.schema_info_table)
+ end
+
+ unless ActiveRecord::Base.connection.table_exists?(old_sm_table)
+ abort "Cannot find old migration table - assuming nothing needs to be done"
+ end
+
+ # There are two forms of the engines schema info - pre-fix_plugin_migrations and post
+ # We need to figure this out before we continue.
+
+ results = ActiveRecord::Base.connection.select_rows(
+ "SELECT version, plugin_name FROM #{old_sm_table}"
+ ).uniq
+
+ def insert_new_version(plugin_name, version)
+ version_string = "#{version}-#{plugin_name}"
+ new_sm_table = ActiveRecord::Migrator.schema_migrations_table_name
+
+ # Check if the row already exists for some reason - maybe run this task more than once.
+ return if ActiveRecord::Base.connection.select_rows("SELECT * FROM #{new_sm_table} WHERE version = #{version_string.dump}").size > 0
+
+ puts "Inserting new version #{version} for plugin #{plugin_name}.."
+ ActiveRecord::Base.connection.insert("INSERT INTO #{new_sm_table} (version) VALUES (#{version_string.dump})")
+ end
+
+ # We need to figure out if they already used "fix_plugin_migrations"
+ versions = {}
+ results.each do |r|
+ versions[r[1]] ||= []
+ versions[r[1]] << r[0].to_i
+ end
+
+ if versions.values.find{ |v| v.size > 1 } == nil
+ puts "Fixing migration info"
+ # We only have one listed migration per plugin - this is pre-fix_plugin_migrations,
+ # so we build all versions required. In this case, all migrations should
+ versions.each do |plugin_name, version|
+ version = version[0] # There is only one version
+
+ # We have to make an assumption that numeric migrations won't get this long..
+ # I'm not sure if there is a better assumption, it should work in all
+ # current cases.. (touch wood..)
+ if version.to_s.size < "YYYYMMDDHHMMSS".size
+ # Insert version records for each migration
+ (1..version).each do |v|
+ insert_new_version(plugin_name, v)
+ end
+ else
+ # If the plugin is new-format "YYYYMMDDHHMMSS", we just copy it across...
+ # The case in which this occurs is very rare..
+ insert_new_version(plugin_name, version)
+ end
+ end
+ else
+ puts "Moving migration info"
+ # We have multiple migrations listed per plugin - thus we can assume they have
+ # already applied fix_plugin_migrations - we just copy it across verbatim
+ versions.each do |plugin_name, version|
+ version.each { |v| insert_new_version(plugin_name, v) }
+ end
+ end
+
+ puts "Migration info successfully migrated - removing old schema info table"
+ ActiveRecord::Base.connection.drop_table(old_sm_table)
+ end
+
desc 'Migrate a specified plugin.'
task({:plugin => :environment}, :name, :version) do |task, args|
name = args[:name] || ENV['NAME']
@@ -51,7 +127,7 @@ namespace :db do
else
puts "Plugin #{name} does not exist."
end
- end
+ end
end
end
@@ -172,5 +248,5 @@ Report any issues on http://dev.rails-engines.org. Thanks!
# Patch the default plugin testing task to have setup_plugin_fixtures as a prerequisite
Rake::Task["test:plugins"].prerequisites << "test:plugins:setup_plugin_fixtures"
- end
-end
\ No newline at end of file
+ end
+end
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 00000000..90b13ff1
--- /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/application.rb b/vendor/plugins/engines/test/app/controllers/application.rb
new file mode 100644
index 00000000..72bf6fc3
--- /dev/null
+++ b/vendor/plugins/engines/test/app/controllers/application.rb
@@ -0,0 +1,18 @@
+# Filters added to this controller apply to all controllers in the application.
+# Likewise, all the methods added will be available for all controllers.
+
+class ApplicationController < ActionController::Base
+ 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
+
+ def rescue_action(e) raise e end;
+
+ helper :all # include all helpers, all the time
+
+ # See ActionController::RequestForgeryProtection for details
+ # Uncomment the :secret if you're not using the cookie session store
+ protect_from_forgery # :secret => 'b955354e438fc4ba070083505af94518'
+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 00000000..05f9049e
--- /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 00000000..9e081e75
--- /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 00000000..f0fe903c
--- /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 00000000..899fc1a4
--- /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 00000000..ae6fbbf3
--- /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 00000000..03e2bf81
--- /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 00000000..03e2bf81
--- /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 00000000..042b5c4e
--- /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 00000000..552acc1e
--- /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 00000000..135488b1
--- /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 00000000..e0050461
--- /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 00000000..5aaf46e9
--- /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 00000000..67a6b8fa
--- /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 00000000..284e450f
--- /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 00000000..2500ee6a
--- /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 < Test::Unit::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 00000000..23a264a4
--- /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 < Test::Unit::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/routes_test.rb b/vendor/plugins/engines/test/functional/routes_test.rb
new file mode 100644
index 00000000..733dd39f
--- /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 00000000..9ca0fbd3
--- /dev/null
+++ b/vendor/plugins/engines/test/functional/view_helpers_test.rb
@@ -0,0 +1,31 @@
+require File.dirname(__FILE__) + '/../test_helper'
+
+class ViewHelpersTest < ActionController::TestCase
+ tests AssetsController
+
+ def setup
+ get :index
+ end
+
+ # TODO: refactor this to use assert_select
+ def test_plugin_javascript_helpers
+ attrs = { :type => "text/javascript" }
+ assert_tag :script, :attributes => attrs.update(:src => "/plugin_assets/test_assets/javascripts/file.1.js")
+ assert_tag :script, :attributes => attrs.update(:src => "/plugin_assets/test_assets/javascripts/file2.js")
+ end
+
+ def test_plugin_stylesheet_helpers
+ attrs = { :media => "screen", :rel => "stylesheet", :type => "text/css" }
+ assert_tag :link, :attributes => attrs.update(:href => "/plugin_assets/test_assets/stylesheets/file.1.css")
+ assert_tag :link, :attributes => attrs.update(:href => "/plugin_assets/test_assets/stylesheets/file2.css")
+ end
+
+ def test_plugin_image_helpers
+ assert_tag :img, :attributes => { :src => "/plugin_assets/test_assets/images/image.png", :alt => "Image" }
+ end
+
+ def test_plugin_layouts
+ get :index
+ assert_tag :div, :attributes => { :id => "assets_layout" }
+ end
+end
\ No newline at end of file
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 00000000..3f098ccf
--- /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 < Test::Unit::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 00000000..6ffe178a
--- /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 00000000..47bd2bbf
--- /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/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 00000000..736d59b8
--- /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 00000000..c41d6edd
--- /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 00000000..5edf81b5
--- /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 00000000..7431a36b
--- /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 00000000..fb162bcf
--- /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 00000000..00539bb8
--- /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 00000000..cde71b8d
--- /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 00000000..92e6e625
--- /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 00000000..e2ef43db
--- /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 00000000..1ad69458
--- /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 00000000..791a6fab
--- /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 00000000..878e07c2
--- /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 00000000..1ad69458
--- /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 00000000..1ad69458
--- /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 00000000..f144ab39
--- /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 00000000..f144ab39
--- /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 00000000..0ce4f91b
--- /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 00000000..645a70c8
--- /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/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 00000000..2e779897
--- /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 00000000..971c7d56
--- /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 00000000..ddd9dbed
--- /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 00000000..bfde227d
--- /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 00000000..77b5a153
--- /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 00000000..77b5a153
--- /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 00000000..b4c4b0e1
--- /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/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 00000000..e69de29b
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 00000000..db5de2e6
--- /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 00000000..c6e3638f
--- /dev/null
+++ b/vendor/plugins/engines/test/plugins/test_assets/app/views/assets/index.html.erb
@@ -0,0 +1,3 @@
+<%= 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" %>
\ No newline at end of file
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 00000000..b7da375e
--- /dev/null
+++ b/vendor/plugins/engines/test/plugins/test_assets/app/views/layouts/assets.html.erb
@@ -0,0 +1,3 @@
+
+ <%= yield %>
+
\ 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 00000000..e69de29b
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 00000000..e69de29b
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 00000000..e69de29b
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 00000000..e69de29b
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 00000000..e69de29b
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 00000000..e69de29b
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 00000000..e69de29b
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 00000000..e69de29b
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 00000000..535d988e
--- /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 00000000..b4c4b0e1
--- /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 00000000..e69de29b
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 00000000..804a0cd2
--- /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 00000000..756aca65
--- /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 00000000..fb5b6c20
--- /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 00000000..e69de29b
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 00000000..4f366163
--- /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 00000000..2b496062
--- /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 00000000..46291d8f
--- /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 00000000..f690dbaa
--- /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 00000000..795f0d50
--- /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 00000000..795f0d50
--- /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 00000000..e69de29b
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 00000000..29d7bdbd
--- /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 00000000..ac3164a4
--- /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/init.rb b/vendor/plugins/engines/test/plugins/test_routing/init.rb
new file mode 100644
index 00000000..e69de29b
diff --git a/vendor/plugins/engines/test/plugins/test_routing/routes.rb b/vendor/plugins/engines/test/plugins/test_routing/routes.rb
new file mode 100644
index 00000000..dbcfafdd
--- /dev/null
+++ b/vendor/plugins/engines/test/plugins/test_routing/routes.rb
@@ -0,0 +1,2 @@
+map.connect 'routes/:action', :controller => "test_routing"
+plugin_route 'somespace/routes/:action', :controller => "namespace/test_routing"
\ 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 00000000..e69de29b
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 00000000..e69de29b
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 00000000..fc3e7566
--- /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 00000000..4b862f35
--- /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 00000000..3332c533
--- /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 00000000..4fa3698f
--- /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 00000000..65835016
--- /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 config 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 00000000..eae7fe7d
--- /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 00000000..e5aa773b
--- /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 00000000..f8627bce
--- /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/testing_test.rb b/vendor/plugins/engines/test/unit/testing_test.rb
new file mode 100644
index 00000000..77aa6f35
--- /dev/null
+++ b/vendor/plugins/engines/test/unit/testing_test.rb
@@ -0,0 +1,18 @@
+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')
+ 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