aboutsummaryrefslogtreecommitdiffstats
path: root/railties
diff options
context:
space:
mode:
authorYves Senn <yves.senn@gmail.com>2014-08-27 12:30:35 +0200
committerYves Senn <yves.senn@gmail.com>2014-08-27 12:30:35 +0200
commitb9b521306c47d65bdbe18ec31a7b784adbfd1849 (patch)
treeef81fbcc10606fbfae875560ae5c0c8f78c7b88b /railties
parent20e7f08ecc22983183909ec60771b929a4c2af16 (diff)
downloadrails-b9b521306c47d65bdbe18ec31a7b784adbfd1849.tar.gz
rails-b9b521306c47d65bdbe18ec31a7b784adbfd1849.tar.bz2
rails-b9b521306c47d65bdbe18ec31a7b784adbfd1849.zip
fix broken `gem` method with non-String arguments. Closes #16709.
This was caused by #15327.
Diffstat (limited to 'railties')
-rw-r--r--railties/CHANGELOG.md7
-rw-r--r--railties/lib/rails/generators/actions.rb10
-rw-r--r--railties/test/generators/actions_test.rb10
3 files changed, 23 insertions, 4 deletions
diff --git a/railties/CHANGELOG.md b/railties/CHANGELOG.md
index 2a09ccf61a..038fe9df5f 100644
--- a/railties/CHANGELOG.md
+++ b/railties/CHANGELOG.md
@@ -1,3 +1,10 @@
+* 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
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/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