ioquatix-engines 2.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +280 -0
- data/MIT-LICENSE +21 -0
- data/README +95 -0
- data/Rakefile +199 -0
- data/about.yml +7 -0
- data/bin/rails_engines +103 -0
- data/generators/plugin_migration/USAGE +45 -0
- data/generators/plugin_migration/plugin_migration_generator.rb +78 -0
- data/generators/plugin_migration/templates/plugin_migration.erb +13 -0
- data/lib/engines.rb +185 -0
- data/lib/engines/assets.rb +38 -0
- data/lib/engines/load_engine_tasks.rake +6 -0
- data/lib/engines/plugin.rb +173 -0
- data/lib/engines/plugin/list.rb +57 -0
- data/lib/engines/plugin/migrator.rb +45 -0
- data/lib/engines/rails_extensions/action_mailer.rb +85 -0
- data/lib/engines/rails_extensions/asset_helpers.rb +149 -0
- data/lib/engines/rails_extensions/dependencies.rb +151 -0
- data/lib/engines/rails_extensions/routing.rb +88 -0
- data/lib/engines/testing.rb +87 -0
- data/lib/engines/version.rb +10 -0
- data/rails/init.rb +6 -0
- data/tasks/engines.rake +249 -0
- data/test/app/controllers/app_and_plugin_controller.rb +5 -0
- data/test/app/controllers/application.rb +18 -0
- data/test/app/controllers/namespace/app_and_plugin_controller.rb +5 -0
- data/test/app/helpers/mail_helper.rb +5 -0
- data/test/app/models/app_and_plugin_model.rb +3 -0
- data/test/app/models/notify_mail.rb +26 -0
- data/test/app/things/thing.rb +3 -0
- data/test/app/views/app_and_plugin/a_view.html.erb +1 -0
- data/test/app/views/namespace/app_and_plugin/a_view.html.erb +1 -0
- data/test/app/views/notify_mail/implicit_multipart.text.html.erb +1 -0
- data/test/app/views/notify_mail/implicit_multipart.text.plain.erb +1 -0
- data/test/app/views/notify_mail/multipart_html.html.erb +1 -0
- data/test/app/views/notify_mail/multipart_plain.html.erb +1 -0
- data/test/app/views/notify_mail/signup.text.plain.erb +5 -0
- data/test/app/views/plugin_mail/mail_from_plugin_with_application_template.text.plain.erb +1 -0
- data/test/app/views/plugin_mail/multipart_from_plugin_with_application_template_plain.html.erb +1 -0
- data/test/functional/controller_loading_test.rb +51 -0
- data/test/functional/exception_notification_compatibility_test.rb +29 -0
- data/test/functional/routes_test.rb +33 -0
- data/test/functional/view_helpers_test.rb +32 -0
- data/test/functional/view_loading_test.rb +60 -0
- data/test/lib/app_and_plugin_lib_model.rb +3 -0
- data/test/lib/engines_test_helper.rb +36 -0
- data/test/plugins/alpha_plugin/app/controllers/alpha_plugin_controller.rb +8 -0
- data/test/plugins/alpha_plugin/app/controllers/app_and_plugin_controller.rb +5 -0
- data/test/plugins/alpha_plugin/app/controllers/namespace/alpha_plugin_controller.rb +5 -0
- data/test/plugins/alpha_plugin/app/controllers/namespace/app_and_plugin_controller.rb +5 -0
- data/test/plugins/alpha_plugin/app/controllers/namespace/shared_plugin_controller.rb +5 -0
- data/test/plugins/alpha_plugin/app/controllers/shared_plugin_controller.rb +5 -0
- data/test/plugins/alpha_plugin/app/models/alpha_plugin_model.rb +3 -0
- data/test/plugins/alpha_plugin/app/models/app_and_plugin_model.rb +7 -0
- data/test/plugins/alpha_plugin/app/models/shared_plugin_model.rb +3 -0
- data/test/plugins/alpha_plugin/app/views/alpha_plugin/a_view.html.erb +1 -0
- data/test/plugins/alpha_plugin/app/views/app_and_plugin/a_view.html.erb +1 -0
- data/test/plugins/alpha_plugin/app/views/layouts/plugin_layout.erb +1 -0
- data/test/plugins/alpha_plugin/app/views/namespace/alpha_plugin/a_view.html.erb +1 -0
- data/test/plugins/alpha_plugin/app/views/namespace/app_and_plugin/a_view.html.erb +1 -0
- data/test/plugins/alpha_plugin/app/views/namespace/shared_plugin/a_view.html.erb +1 -0
- data/test/plugins/alpha_plugin/app/views/shared_plugin/a_view.html.erb +1 -0
- data/test/plugins/alpha_plugin/lib/alpha_plugin_lib_model.rb +3 -0
- data/test/plugins/alpha_plugin/lib/app_and_plugin_lib_model.rb +7 -0
- data/test/plugins/beta_plugin/app/controllers/app_and_plugin_controller.rb +5 -0
- data/test/plugins/beta_plugin/app/controllers/namespace/shared_plugin_controller.rb +5 -0
- data/test/plugins/beta_plugin/app/controllers/shared_plugin_controller.rb +5 -0
- data/test/plugins/beta_plugin/app/models/shared_plugin_model.rb +3 -0
- data/test/plugins/beta_plugin/app/views/namespace/shared_plugin/a_view.html.erb +1 -0
- data/test/plugins/beta_plugin/app/views/shared_plugin/a_view.html.erb +1 -0
- data/test/plugins/beta_plugin/init.rb +1 -0
- data/test/plugins/not_a_plugin/public/should_not_be_copied.txt +0 -0
- data/test/plugins/test_assets/app/controllers/assets_controller.rb +2 -0
- data/test/plugins/test_assets/app/views/assets/index.html.erb +3 -0
- data/test/plugins/test_assets/app/views/layouts/assets.html.erb +3 -0
- data/test/plugins/test_assets/init.rb +0 -0
- data/test/plugins/test_assets/public/file.txt +0 -0
- data/test/plugins/test_assets/public/subfolder/file_in_subfolder.txt +0 -0
- data/test/plugins/test_assets_with_assets_directory/assets/file.txt +0 -0
- data/test/plugins/test_assets_with_assets_directory/assets/subfolder/file_in_subfolder.txt +0 -0
- data/test/plugins/test_assets_with_assets_directory/init.rb +0 -0
- data/test/plugins/test_assets_with_no_subdirectory/assets/file.txt +0 -0
- data/test/plugins/test_assets_with_no_subdirectory/init.rb +0 -0
- data/test/plugins/test_code_mixing/app/things/thing.rb +3 -0
- data/test/plugins/test_code_mixing/init.rb +1 -0
- data/test/plugins/test_load_path/init.rb +0 -0
- data/test/plugins/test_migration/db/migrate/001_create_tests.rb +11 -0
- data/test/plugins/test_migration/db/migrate/002_create_others.rb +11 -0
- data/test/plugins/test_migration/db/migrate/003_create_extras.rb +11 -0
- data/test/plugins/test_migration/init.rb +0 -0
- data/test/plugins/test_plugin_mailing/app/models/plugin_mail.rb +26 -0
- data/test/plugins/test_plugin_mailing/app/views/plugin_mail/mail_from_plugin.text.plain.erb +1 -0
- data/test/plugins/test_plugin_mailing/app/views/plugin_mail/multipart_from_plugin_html.html.erb +1 -0
- data/test/plugins/test_plugin_mailing/app/views/plugin_mail/multipart_from_plugin_plain.html.erb +1 -0
- data/test/plugins/test_plugin_mailing/app/views/plugin_mail/multipart_from_plugin_with_application_template_html.html.erb +1 -0
- data/test/plugins/test_plugin_mailing/app/views/plugin_mail/multipart_from_plugin_with_application_template_plain.html.erb +1 -0
- data/test/plugins/test_plugin_mailing/init.rb +0 -0
- data/test/plugins/test_routing/app/controllers/namespace/test_routing_controller.rb +5 -0
- data/test/plugins/test_routing/app/controllers/test_routing_controller.rb +9 -0
- data/test/plugins/test_routing/init.rb +0 -0
- data/test/plugins/test_routing/routes.rb +2 -0
- data/test/plugins/test_testing/init.rb +0 -0
- data/test/plugins/test_testing/test/fixtures/testing_fixtures.yml +0 -0
- data/test/unit/action_mailer_test.rb +54 -0
- data/test/unit/arbitrary_code_mixing_test.rb +41 -0
- data/test/unit/assets_test.rb +48 -0
- data/test/unit/load_path_test.rb +58 -0
- data/test/unit/migration_test.rb +63 -0
- data/test/unit/model_and_lib_test.rb +37 -0
- data/test/unit/plugins_test.rb +11 -0
- data/test/unit/testing_test.rb +18 -0
- metadata +259 -0
@@ -0,0 +1 @@
|
|
1
|
+
<%= self.first_render %> (from beta_plugin)
|
@@ -0,0 +1 @@
|
|
1
|
+
<%= self.first_render %> (from beta_plugin)
|
@@ -0,0 +1 @@
|
|
1
|
+
# just here so that Rails recognizes this as a plugin
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
@@ -0,0 +1 @@
|
|
1
|
+
# just here so that Rails recognizes this as a plugin
|
File without changes
|
File without changes
|
@@ -0,0 +1,26 @@
|
|
1
|
+
class PluginMail < ActionMailer::Base
|
2
|
+
def mail_from_plugin(note=nil)
|
3
|
+
body(:note => note)
|
4
|
+
end
|
5
|
+
|
6
|
+
def mail_from_plugin_with_application_template(note=nil)
|
7
|
+
body(:note => note)
|
8
|
+
end
|
9
|
+
|
10
|
+
def multipart_from_plugin
|
11
|
+
content_type 'multipart/alternative'
|
12
|
+
part :content_type => "text/html", :body => render_message("multipart_from_plugin_html", {})
|
13
|
+
part "text/plain" do |p|
|
14
|
+
p.body = render_message("multipart_from_plugin_plain", {})
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
def multipart_from_plugin_with_application_template
|
19
|
+
content_type 'multipart/alternative'
|
20
|
+
part :content_type => "text/html", :body => render_message("multipart_from_plugin_with_application_template_html", {})
|
21
|
+
part "text/plain" do |p|
|
22
|
+
p.body = render_message("multipart_from_plugin_with_application_template_plain", {})
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
<%= @note %>
|
data/test/plugins/test_plugin_mailing/app/views/plugin_mail/multipart_from_plugin_html.html.erb
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
html template
|
data/test/plugins/test_plugin_mailing/app/views/plugin_mail/multipart_from_plugin_plain.html.erb
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
plain template
|
@@ -0,0 +1 @@
|
|
1
|
+
template from plugin
|
@@ -0,0 +1 @@
|
|
1
|
+
template from plugin
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
@@ -0,0 +1,54 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../test_helper'
|
2
|
+
|
3
|
+
class ActionMailerWithinApplicationTest < Test::Unit::TestCase
|
4
|
+
|
5
|
+
def test_normal_implicit_template
|
6
|
+
m = NotifyMail.create_signup("hello")
|
7
|
+
assert m.body =~ /^Signup template from application/
|
8
|
+
end
|
9
|
+
|
10
|
+
def test_action_mailer_can_get_helper
|
11
|
+
m = NotifyMail.create_signup('James')
|
12
|
+
assert m.body =~ /James/
|
13
|
+
assert m.body =~ /semaJ/ # from the helper
|
14
|
+
end
|
15
|
+
|
16
|
+
def test_multipart_mails_with_explicit_templates
|
17
|
+
m = NotifyMail.create_multipart
|
18
|
+
assert_equal 2, m.parts.length
|
19
|
+
assert_equal 'the html part of the email james', m.parts[0].body
|
20
|
+
assert_equal 'the plaintext part of the email', m.parts[1].body
|
21
|
+
end
|
22
|
+
|
23
|
+
def test_multipart_mails_with_implicit_templates
|
24
|
+
m = NotifyMail.create_implicit_multipart
|
25
|
+
assert_equal 2, m.parts.length
|
26
|
+
assert_equal 'the implicit plaintext part of the email', m.parts[0].body
|
27
|
+
assert_equal 'the implicit html part of the email james', m.parts[1].body
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
|
32
|
+
class ActionMailerWithinPluginsTest < Test::Unit::TestCase
|
33
|
+
def test_should_be_able_to_create_mails_from_plugin
|
34
|
+
m = PluginMail.create_mail_from_plugin("from_plugin")
|
35
|
+
assert_equal "from_plugin", m.body
|
36
|
+
end
|
37
|
+
|
38
|
+
def test_should_be_able_to_overload_views_within_the_application
|
39
|
+
m = PluginMail.create_mail_from_plugin_with_application_template("from_plugin")
|
40
|
+
assert_equal "from_plugin (from application)", m.body
|
41
|
+
end
|
42
|
+
|
43
|
+
def test_should_be_able_to_create_a_multipart_mail_from_within_plugin
|
44
|
+
m = PluginMail.create_multipart_from_plugin
|
45
|
+
assert_equal 2, m.parts.length
|
46
|
+
assert_equal 'html template', m.parts[0].body
|
47
|
+
assert_equal 'plain template', m.parts[1].body
|
48
|
+
end
|
49
|
+
|
50
|
+
def test_plugin_mailer_template_overriding
|
51
|
+
m = PluginMail.create_multipart_from_plugin_with_application_template
|
52
|
+
assert_equal 'plugin mail template loaded from application', m.parts[1].body
|
53
|
+
end
|
54
|
+
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../test_helper'
|
2
|
+
|
3
|
+
class ArbitraryCodeMixingTest < Test::Unit::TestCase
|
4
|
+
def setup
|
5
|
+
Engines.code_mixing_file_types = %w(controller helper)
|
6
|
+
end
|
7
|
+
|
8
|
+
def test_should_allow_setting_of_different_code_mixing_file_types
|
9
|
+
assert_nothing_raised {
|
10
|
+
Engines.mix_code_from :things
|
11
|
+
}
|
12
|
+
end
|
13
|
+
|
14
|
+
def test_should_add_new_types_to_existing_code_mixing_file_types
|
15
|
+
Engines.mix_code_from :things
|
16
|
+
assert_equal ["controller", "helper", "thing"], Engines.code_mixing_file_types
|
17
|
+
Engines.mix_code_from :other
|
18
|
+
assert_equal ["controller", "helper", "thing", "other"], Engines.code_mixing_file_types
|
19
|
+
end
|
20
|
+
|
21
|
+
def test_should_allow_setting_of_multiple_types_at_once
|
22
|
+
Engines.mix_code_from :things, :other
|
23
|
+
assert_equal ["controller", "helper", "thing", "other"], Engines.code_mixing_file_types
|
24
|
+
end
|
25
|
+
|
26
|
+
def test_should_singularize_elements_to_be_mixed
|
27
|
+
# this is the only test using mocha, so let's try to work around it
|
28
|
+
# also, this seems to be already tested with the :things in the tests above
|
29
|
+
# arg = stub(:to_s => stub(:singularize => "element"))
|
30
|
+
Engines.mix_code_from :elements
|
31
|
+
assert Engines.code_mixing_file_types.include?("element")
|
32
|
+
end
|
33
|
+
|
34
|
+
# TODO doesn't seem to work as expected?
|
35
|
+
|
36
|
+
# def test_should_successfully_mix_custom_types
|
37
|
+
# Engines.mix_code_from :things
|
38
|
+
# assert_equal 'Thing (from app)', Thing.from_app
|
39
|
+
# assert_equal 'Thing (from test_code_mixing)', Thing.from_plugin
|
40
|
+
# end
|
41
|
+
end
|
@@ -0,0 +1,48 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../test_helper'
|
2
|
+
|
3
|
+
class AssetsTest < Test::Unit::TestCase
|
4
|
+
def setup
|
5
|
+
Engines::Assets.mirror_files_for Engines.plugins[:test_assets]
|
6
|
+
end
|
7
|
+
|
8
|
+
def teardown
|
9
|
+
FileUtils.rm_r(Engines.public_directory) if File.exist?(Engines.public_directory)
|
10
|
+
end
|
11
|
+
|
12
|
+
def test_engines_has_created_base_public_file
|
13
|
+
assert File.exist?(Engines.public_directory)
|
14
|
+
end
|
15
|
+
|
16
|
+
def test_engines_has_created_README_in_public_directory
|
17
|
+
assert File.exist?(File.join(Engines.public_directory, 'README'))
|
18
|
+
end
|
19
|
+
|
20
|
+
def test_public_files_have_been_copied_from_test_assets_plugin
|
21
|
+
assert File.exist?(File.join(Engines.public_directory, 'test_assets'))
|
22
|
+
assert File.exist?(File.join(Engines.public_directory, 'test_assets', 'file.txt'))
|
23
|
+
assert File.exist?(File.join(Engines.public_directory, 'test_assets', 'subfolder'))
|
24
|
+
assert File.exist?(File.join(Engines.public_directory, 'test_assets', 'subfolder', 'file_in_subfolder.txt'))
|
25
|
+
end
|
26
|
+
|
27
|
+
def test_public_files_have_been_copied_from_test_assets_with_assets_dir_plugin
|
28
|
+
Engines::Assets.mirror_files_for Engines.plugins[:test_assets_with_assets_directory]
|
29
|
+
|
30
|
+
assert File.exist?(File.join(Engines.public_directory, 'test_assets_with_assets_directory'))
|
31
|
+
assert File.exist?(File.join(Engines.public_directory, 'test_assets_with_assets_directory', 'file.txt'))
|
32
|
+
assert File.exist?(File.join(Engines.public_directory, 'test_assets_with_assets_directory', 'subfolder'))
|
33
|
+
assert File.exist?(File.join(Engines.public_directory, 'test_assets_with_assets_directory', 'subfolder', 'file_in_subfolder.txt'))
|
34
|
+
end
|
35
|
+
|
36
|
+
def test_public_files_have_been_copied_from_test_assets_with_no_subdirectory_plugin
|
37
|
+
Engines::Assets.mirror_files_for Engines.plugins[:test_assets_with_no_subdirectory]
|
38
|
+
|
39
|
+
assert File.exist?(File.join(Engines.public_directory, 'test_assets_with_no_subdirectory'))
|
40
|
+
assert File.exist?(File.join(Engines.public_directory, 'test_assets_with_no_subdirectory', 'file.txt'))
|
41
|
+
end
|
42
|
+
|
43
|
+
def test_public_files_have_NOT_been_copied_from_plugins_without_public_or_asset_directories
|
44
|
+
Engines::Assets.mirror_files_for Engines.plugins[:alpha_plugin]
|
45
|
+
|
46
|
+
assert !File.exist?(File.join(Engines.public_directory, 'alpha_plugin'))
|
47
|
+
end
|
48
|
+
end
|
@@ -0,0 +1,58 @@
|
|
1
|
+
# Tests in this file ensure that:
|
2
|
+
#
|
3
|
+
# * the application /app/[controllers|helpers|models] and /lib
|
4
|
+
# paths preceed the corresponding plugin paths
|
5
|
+
# * the plugin paths are added to $LOAD_PATH in the order in which plugins are
|
6
|
+
# loaded
|
7
|
+
|
8
|
+
require File.dirname(__FILE__) + '/../test_helper'
|
9
|
+
|
10
|
+
class LoadPathTest < Test::Unit::TestCase
|
11
|
+
def setup
|
12
|
+
@load_path = expand_paths($LOAD_PATH)
|
13
|
+
end
|
14
|
+
|
15
|
+
# Not sure if these test actually make sense as this now essentially tests
|
16
|
+
# Rails core functionality. On the other hand Engines relies on this to some
|
17
|
+
# extend so this will choke if something important changes in Rails.
|
18
|
+
|
19
|
+
# the application app/... and lib/ directories should appear
|
20
|
+
# before any plugin directories
|
21
|
+
|
22
|
+
def test_application_app_libs_should_precede_all_plugin_app_libs
|
23
|
+
types = %w(app/controllers app/helpers app/models lib)
|
24
|
+
types.each do |t|
|
25
|
+
app_index = load_path_index(File.join(RAILS_ROOT, t))
|
26
|
+
assert_not_nil app_index, "#{t} is missing in $LOAD_PATH"
|
27
|
+
Engines.plugins.each do |plugin|
|
28
|
+
first_plugin_index = load_path_index(File.join(plugin.directory, t))
|
29
|
+
assert(app_index < first_plugin_index) unless first_plugin_index.nil?
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
# the engine directories should appear in the proper order based on
|
35
|
+
# the order they were started
|
36
|
+
|
37
|
+
def test_plugin_dirs_should_appear_in_reverse_plugin_loading_order
|
38
|
+
app_paths = %w(app/controllers/ app app/models app/helpers config lib)
|
39
|
+
app_paths.map { |p| File.join(RAILS_ROOT, p)}
|
40
|
+
plugin_paths = Engines.plugins.reverse.collect { |plugin| plugin.load_paths.reverse }.flatten
|
41
|
+
|
42
|
+
expected_paths = expand_paths(app_paths + plugin_paths)
|
43
|
+
# only look at those paths that are also present in expected_paths so
|
44
|
+
# the only difference would be in the order of the paths
|
45
|
+
actual_paths = @load_path & expected_paths
|
46
|
+
|
47
|
+
assert_equal expected_paths, actual_paths
|
48
|
+
end
|
49
|
+
|
50
|
+
protected
|
51
|
+
def expand_paths(paths)
|
52
|
+
paths.collect { |p| File.expand_path(p) }
|
53
|
+
end
|
54
|
+
|
55
|
+
def load_path_index(dir)
|
56
|
+
@load_path.index(File.expand_path(dir))
|
57
|
+
end
|
58
|
+
end
|
@@ -0,0 +1,63 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../test_helper'
|
2
|
+
require 'rails_generator'
|
3
|
+
require 'rails_generator/scripts/generate'
|
4
|
+
|
5
|
+
class MigrationsTest < Test::Unit::TestCase
|
6
|
+
|
7
|
+
@@migration_dir = "#{RAILS_ROOT}/db/migrate"
|
8
|
+
|
9
|
+
def setup
|
10
|
+
ActiveRecord::Migration.verbose = false
|
11
|
+
Engines.plugins[:test_migration].migrate(0)
|
12
|
+
end
|
13
|
+
|
14
|
+
def teardown
|
15
|
+
FileUtils.rm_r(@@migration_dir) if File.exist?(@@migration_dir)
|
16
|
+
end
|
17
|
+
|
18
|
+
def test_engine_migrations_can_run_down
|
19
|
+
assert !table_exists?('tests'), ActiveRecord::Base.connection.tables.inspect
|
20
|
+
assert !table_exists?('others'), ActiveRecord::Base.connection.tables.inspect
|
21
|
+
assert !table_exists?('extras'), ActiveRecord::Base.connection.tables.inspect
|
22
|
+
end
|
23
|
+
|
24
|
+
def test_engine_migrations_can_run_up
|
25
|
+
Engines.plugins[:test_migration].migrate(3)
|
26
|
+
assert table_exists?('tests')
|
27
|
+
assert table_exists?('others')
|
28
|
+
assert table_exists?('extras')
|
29
|
+
end
|
30
|
+
|
31
|
+
def test_engine_migrations_can_upgrade_incrementally
|
32
|
+
Engines.plugins[:test_migration].migrate(1)
|
33
|
+
assert table_exists?('tests')
|
34
|
+
assert !table_exists?('others')
|
35
|
+
assert !table_exists?('extras')
|
36
|
+
assert_equal 1, Engines::Plugin::Migrator.current_version(Engines.plugins[:test_migration])
|
37
|
+
|
38
|
+
|
39
|
+
Engines.plugins[:test_migration].migrate(2)
|
40
|
+
assert table_exists?('others')
|
41
|
+
assert_equal 2, Engines::Plugin::Migrator.current_version(Engines.plugins[:test_migration])
|
42
|
+
|
43
|
+
|
44
|
+
Engines.plugins[:test_migration].migrate(3)
|
45
|
+
assert table_exists?('extras')
|
46
|
+
assert_equal 3, Engines::Plugin::Migrator.current_version(Engines.plugins[:test_migration])
|
47
|
+
end
|
48
|
+
|
49
|
+
def test_generator_creates_plugin_migration_file
|
50
|
+
Rails::Generator::Scripts::Generate.new.run(['plugin_migration', 'test_migration'], :quiet => true)
|
51
|
+
assert migration_file, "migration file is missing"
|
52
|
+
end
|
53
|
+
|
54
|
+
private
|
55
|
+
|
56
|
+
def table_exists?(table)
|
57
|
+
ActiveRecord::Base.connection.tables.include?(table)
|
58
|
+
end
|
59
|
+
|
60
|
+
def migration_file
|
61
|
+
Dir["#{@@migration_dir}/*test_migration_to_version_3.rb"][0]
|
62
|
+
end
|
63
|
+
end
|