diff options
Diffstat (limited to 'railties')
-rw-r--r-- | railties/CHANGELOG.md | 9 | ||||
-rw-r--r-- | railties/lib/rails/gem_version.rb | 2 | ||||
-rw-r--r-- | railties/lib/rails/generators/actions.rb | 10 | ||||
-rw-r--r-- | railties/lib/rails/generators/test_unit/job/job_generator.rb | 13 | ||||
-rw-r--r-- | railties/lib/rails/generators/test_unit/job/templates/unit_test.rb.erb | 9 | ||||
-rw-r--r-- | railties/lib/rails/tasks/statistics.rake | 3 | ||||
-rw-r--r-- | railties/test/application/configuration_test.rb | 2 | ||||
-rw-r--r-- | railties/test/application/initializers/frameworks_test.rb | 4 | ||||
-rw-r--r-- | railties/test/application/middleware_test.rb | 2 | ||||
-rw-r--r-- | railties/test/commands/dbconsole_test.rb | 11 | ||||
-rw-r--r-- | railties/test/generators/actions_test.rb | 10 | ||||
-rw-r--r-- | railties/test/generators/generators_test_helper.rb | 2 |
12 files changed, 60 insertions, 17 deletions
diff --git a/railties/CHANGELOG.md b/railties/CHANGELOG.md index 2a09ccf61a..7d6521b2a8 100644 --- a/railties/CHANGELOG.md +++ b/railties/CHANGELOG.md @@ -1,6 +1,13 @@ +* Fix a bug in the `gem` method for Rails templates when non-String options + are used. + + Fixes #16709. + + *Yves Senn* + * The [web-console](https://github.com/rails/web-console) gem is now installed by default for new applications. It can help you debug - development exceptions by spawnig an interactive console in its cause + development exceptions by spawning an interactive console in its cause binding. *Ryan Dao*, *Genadi Samokovarov*, *Guillermo Iguaran* diff --git a/railties/lib/rails/gem_version.rb b/railties/lib/rails/gem_version.rb index c7397c4f15..672b78c599 100644 --- a/railties/lib/rails/gem_version.rb +++ b/railties/lib/rails/gem_version.rb @@ -8,7 +8,7 @@ module Rails MAJOR = 4 MINOR = 2 TINY = 0 - PRE = "alpha" + PRE = "beta1" STRING = [MAJOR, MINOR, TINY, PRE].compact.join(".") end diff --git a/railties/lib/rails/generators/actions.rb b/railties/lib/rails/generators/actions.rb index 4709914947..b2c9d12996 100644 --- a/railties/lib/rails/generators/actions.rb +++ b/railties/lib/rails/generators/actions.rb @@ -268,11 +268,13 @@ module Rails # Surround string with single quotes if there is no quotes. # Otherwise fall back to double quotes - def quote(str) - if str.include?("'") - str.inspect + def quote(value) + return value.inspect unless value.is_a? String + + if value.include?("'") + value.inspect else - "'#{str}'" + "'#{value}'" end end end diff --git a/railties/lib/rails/generators/test_unit/job/job_generator.rb b/railties/lib/rails/generators/test_unit/job/job_generator.rb new file mode 100644 index 0000000000..05d9fde280 --- /dev/null +++ b/railties/lib/rails/generators/test_unit/job/job_generator.rb @@ -0,0 +1,13 @@ +require 'rails/generators/test_unit' + +module TestUnit # :nodoc: + module Generators # :nodoc: + class JobGenerator < Base # :nodoc: + check_class_collision suffix: 'JobTest' + + def create_test_file + template 'unit_test.rb.erb', File.join('test/job', class_path, "#{file_name}_test.rb") + end + end + end +end diff --git a/railties/lib/rails/generators/test_unit/job/templates/unit_test.rb.erb b/railties/lib/rails/generators/test_unit/job/templates/unit_test.rb.erb new file mode 100644 index 0000000000..6200218313 --- /dev/null +++ b/railties/lib/rails/generators/test_unit/job/templates/unit_test.rb.erb @@ -0,0 +1,9 @@ +require 'test_helper' + +<% module_namespacing do -%> +class <%= class_name %>JobTest < ActiveSupport::TestCase + # test "the truth" do + # assert true + # end +end +<% end -%> diff --git a/railties/lib/rails/tasks/statistics.rake b/railties/lib/rails/tasks/statistics.rake index ae5a7d2759..b94cd244be 100644 --- a/railties/lib/rails/tasks/statistics.rake +++ b/railties/lib/rails/tasks/statistics.rake @@ -4,6 +4,7 @@ STATS_DIRECTORIES = [ %w(Controllers app/controllers), %w(Helpers app/helpers), + %w(Jobs app/jobs), %w(Models app/models), %w(Mailers app/mailers), %w(Javascripts app/assets/javascripts), @@ -24,4 +25,4 @@ desc "Report code statistics (KLOCs, etc) from the application or engine" task :stats do require 'rails/code_statistics' CodeStatistics.new(*STATS_DIRECTORIES).to_s -end
\ No newline at end of file +end diff --git a/railties/test/application/configuration_test.rb b/railties/test/application/configuration_test.rb index e661b6f4cc..db2106aed3 100644 --- a/railties/test/application/configuration_test.rb +++ b/railties/test/application/configuration_test.rb @@ -118,7 +118,7 @@ module ApplicationTests test "Rails::Application responds to paths" do require "#{app_path}/config/environment" assert_respond_to AppTemplate::Application, :paths - assert_equal AppTemplate::Application.paths["app/views"].expanded, ["#{app_path}/app/views"] + assert_equal ["#{app_path}/app/views"], AppTemplate::Application.paths["app/views"].expanded end test "the application root is set correctly" do diff --git a/railties/test/application/initializers/frameworks_test.rb b/railties/test/application/initializers/frameworks_test.rb index ae550331bd..2d45c9b53f 100644 --- a/railties/test/application/initializers/frameworks_test.rb +++ b/railties/test/application/initializers/frameworks_test.rb @@ -35,8 +35,8 @@ module ApplicationTests require "#{app_path}/config/environment" expanded_path = File.expand_path("app/views", app_path) - assert_equal ActionController::Base.view_paths[0].to_s, expanded_path - assert_equal ActionMailer::Base.view_paths[0].to_s, expanded_path + assert_equal expanded_path, ActionController::Base.view_paths[0].to_s + assert_equal expanded_path, ActionMailer::Base.view_paths[0].to_s end test "allows me to configure default url options for ActionMailer" do diff --git a/railties/test/application/middleware_test.rb b/railties/test/application/middleware_test.rb index 33eb034b1c..a905598d80 100644 --- a/railties/test/application/middleware_test.rb +++ b/railties/test/application/middleware_test.rb @@ -83,7 +83,7 @@ module ApplicationTests add_to_config "config.ssl_options = { host: 'example.com' }" boot! - assert_equal Rails.application.middleware.first.args, [{host: 'example.com'}] + assert_equal [{host: 'example.com'}], Rails.application.middleware.first.args end test "removing Active Record omits its middleware" do diff --git a/railties/test/commands/dbconsole_test.rb b/railties/test/commands/dbconsole_test.rb index ede08e7b86..a3cd1eb0ed 100644 --- a/railties/test/commands/dbconsole_test.rb +++ b/railties/test/commands/dbconsole_test.rb @@ -28,7 +28,7 @@ class Rails::DBConsoleTest < ActiveSupport::TestCase } } app_db_config(config_sample) do - assert_equal Rails::DBConsole.new.config, config_sample["test"] + assert_equal config_sample["test"], Rails::DBConsole.new.config end end @@ -79,22 +79,23 @@ class Rails::DBConsoleTest < ActiveSupport::TestCase end def test_env - assert_equal Rails::DBConsole.new.environment, "test" + assert_equal "test", Rails::DBConsole.new.environment ENV['RAILS_ENV'] = nil ENV['RACK_ENV'] = nil Rails.stub(:respond_to?, false) do - assert_equal Rails::DBConsole.new.environment, "development" + assert_equal "development", Rails::DBConsole.new.environment ENV['RACK_ENV'] = "rack_env" - assert_equal Rails::DBConsole.new.environment, "rack_env" + assert_equal "rack_env", Rails::DBConsole.new.environment ENV['RAILS_ENV'] = "rails_env" - assert_equal Rails::DBConsole.new.environment, "rails_env" + assert_equal "rails_env", Rails::DBConsole.new.environment end ensure ENV['RAILS_ENV'] = "test" + ENV['RACK_ENV'] = nil end def test_rails_env_is_development_when_argument_is_dev diff --git a/railties/test/generators/actions_test.rb b/railties/test/generators/actions_test.rb index a4337926d1..2206e389b5 100644 --- a/railties/test/generators/actions_test.rb +++ b/railties/test/generators/actions_test.rb @@ -79,6 +79,16 @@ class ActionsTest < Rails::Generators::TestCase assert_file 'Gemfile', /gem 'rspec', github: 'dchelimsky\/rspec', tag: '1\.2\.9\.rc1'/ end + def test_gem_with_non_string_options + run_generator + + action :gem, 'rspec', require: false + action :gem, 'rspec-rails', group: [:development, :test] + + assert_file 'Gemfile', /^gem 'rspec', require: false$/ + assert_file 'Gemfile', /^gem 'rspec-rails', group: \[:development, :test\]$/ + end + def test_gem_falls_back_to_inspect_if_string_contains_single_quote run_generator diff --git a/railties/test/generators/generators_test_helper.rb b/railties/test/generators/generators_test_helper.rb index e7990de754..6cc91f166b 100644 --- a/railties/test/generators/generators_test_helper.rb +++ b/railties/test/generators/generators_test_helper.rb @@ -7,7 +7,7 @@ module Rails class << self remove_possible_method :root def root - @root ||= File.expand_path('../../fixtures', __FILE__) + @root ||= Pathname.new(File.expand_path('../../fixtures', __FILE__)) end end end |