From fc61bca31d899f359671d4b58bceb8b9d6555aa7 Mon Sep 17 00:00:00 2001 From: Robin Dupret Date: Tue, 25 Feb 2014 14:57:23 +0100 Subject: Avoid namespacing routes inside engines Since #11544, invoking the controller generator, any generated route is namespaced according to the class_path method. Since a mountable plugin is namespaced, creating a controller inside would generate a namespaced route based on the engine's name. The controller generator now relies on regular_class_path which does not contain the class hierarchy but the given path. Fixes #14079. --- railties/test/generators/plugin_generator_test.rb | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'railties/test') diff --git a/railties/test/generators/plugin_generator_test.rb b/railties/test/generators/plugin_generator_test.rb index 932cd75bcb..b2fc3a2a4f 100644 --- a/railties/test/generators/plugin_generator_test.rb +++ b/railties/test/generators/plugin_generator_test.rb @@ -355,6 +355,18 @@ class PluginGeneratorTest < Rails::Generators::TestCase FileUtils.rm gemfile_path end + def test_generating_controller_inside_mountable_engine + run_generator [destination_root, "--mountable"] + + capture(:stdout) do + `#{destination_root}/bin/rails g controller admin/dashboard foo` + end + + assert_file "config/routes.rb" do |contents| + assert_match(/namespace :admin/, contents) + assert_no_match(/namespace :bukkit/, contents) + end + end protected def action(*args, &block) -- cgit v1.2.3 From 2dd2fcf89673afbcf95240ecebaf34826a195164 Mon Sep 17 00:00:00 2001 From: Prem Sichanugrist Date: Tue, 18 Feb 2014 16:13:23 -0500 Subject: Introduce `Rails.gem_version` This method return `Gem::Version.new(Rails.version)`, suggesting a more reliable way to perform version comparison. Example: Rails.version #=> "4.1.2" Rails.gem_version #=> # Rails.version > "4.1.10" #=> false Rails.gem_version > Gem::Version.new("4.1.10") #=> true Gem::Requirement.new("~> 4.1.2") =~ Rails.gem_version #=> true This was originally introduced as `.version` by @charliesome in #8501 but got reverted in #10002 since it was not backward compatible. Also, updating template for `rake update_versions`. --- railties/test/version_test.rb | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 railties/test/version_test.rb (limited to 'railties/test') diff --git a/railties/test/version_test.rb b/railties/test/version_test.rb new file mode 100644 index 0000000000..f270d8f0c9 --- /dev/null +++ b/railties/test/version_test.rb @@ -0,0 +1,12 @@ +require 'abstract_unit' + +class VersionTest < ActiveSupport::TestCase + def test_rails_version_returns_a_string + assert Rails.version.is_a? String + end + + def test_rails_gem_version_returns_a_correct_gem_version_object + assert Rails.gem_version.is_a? Gem::Version + assert_equal Rails.version, Rails.gem_version.to_s + end +end -- cgit v1.2.3 From 9c53b8b89f0b4aec5a2ec3611cefae8e7b6514a5 Mon Sep 17 00:00:00 2001 From: Robin Dupret Date: Sat, 8 Mar 2014 15:51:49 +0100 Subject: Make the rails:template rake task load initializers Templates could rely on irregular inflections or external libraries for instance so we should load the application's initializers when running the rails:template task. The introducing commit of this feature is f7f11361 ; the initializers have never been loaded invoking this task. Fixes #12133. --- railties/test/application/rake_test.rb | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'railties/test') diff --git a/railties/test/application/rake_test.rb b/railties/test/application/rake_test.rb index 317e73245c..e8c8de9f73 100644 --- a/railties/test/application/rake_test.rb +++ b/railties/test/application/rake_test.rb @@ -271,5 +271,16 @@ module ApplicationTests end end end + + def test_template_load_initializers + app_file "config/initializers/dummy.rb", "puts 'Hello, World!'" + app_file "template.rb", "" + + output = Dir.chdir(app_path) do + `bundle exec rake rails:template LOCATION=template.rb` + end + + assert_match(/Hello, World!/, output) + end end end -- cgit v1.2.3