diff options
-rw-r--r-- | railties/CHANGELOG.md | 4 | ||||
-rw-r--r-- | railties/lib/rails/generators/actions.rb | 2 | ||||
-rw-r--r-- | railties/test/generators/actions_test.rb | 9 |
3 files changed, 14 insertions, 1 deletions
diff --git a/railties/CHANGELOG.md b/railties/CHANGELOG.md index d9d0136ad8..f5392d0f9d 100644 --- a/railties/CHANGELOG.md +++ b/railties/CHANGELOG.md @@ -1,3 +1,7 @@ +* Fix using `add_source` with a block after using `gem` in a custom generator. + + *Will Fisher* + ## Rails 5.0.0.beta1 (December 18, 2015) ## * No changes. diff --git a/railties/lib/rails/generators/actions.rb b/railties/lib/rails/generators/actions.rb index 5bbd2f1aed..cd83175da8 100644 --- a/railties/lib/rails/generators/actions.rb +++ b/railties/lib/rails/generators/actions.rb @@ -75,7 +75,7 @@ module Rails in_root do if block - append_file "Gemfile", "source #{quote(source)} do", force: true + append_file "Gemfile", "\nsource #{quote(source)} do", force: true @in_group = true instance_eval(&block) @in_group = false diff --git a/railties/test/generators/actions_test.rb b/railties/test/generators/actions_test.rb index 2f42ce894b..a1a17d90d8 100644 --- a/railties/test/generators/actions_test.rb +++ b/railties/test/generators/actions_test.rb @@ -52,6 +52,15 @@ class ActionsTest < Rails::Generators::TestCase assert_file 'Gemfile', /source 'http:\/\/gems\.github\.com' do\n gem 'rspec-rails'\nend/ end + def test_add_source_with_block_adds_source_to_gemfile_after_gem + run_generator + action :gem, 'will-paginate' + action :add_source, 'http://gems.github.com' do + gem 'rspec-rails' + end + assert_file 'Gemfile', /gem 'will-paginate'\nsource 'http:\/\/gems\.github\.com' do\n gem 'rspec-rails'\nend/ + end + def test_gem_should_put_gem_dependency_in_gemfile run_generator action :gem, 'will-paginate' |