1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

Merge pull request #28062 from y-yagi/make_adding_gemfile_entry_work_even_if_specify_only_the_plugin_name

Make adding gemfile entry work even if specify only the plugin name
This commit is contained in:
Rafael França 2017-02-24 10:30:33 -05:00 committed by GitHub
commit d273984203
2 changed files with 16 additions and 1 deletions

View file

@ -432,7 +432,7 @@ end
end
def inside_application?
rails_app_path && app_path =~ /^#{rails_app_path}/
rails_app_path && destination_root.start_with?(rails_app_path.to_s)
end
def relative_path

View file

@ -536,6 +536,21 @@ class PluginGeneratorTest < Rails::Generators::TestCase
FileUtils.rm gemfile_path
end
def test_creating_plugin_only_specify_plugin_name_in_app_directory_adds_gemfile_entry
# simulate application existence
gemfile_path = "#{Rails.root}/Gemfile"
Object.const_set("APP_PATH", Rails.root)
FileUtils.touch gemfile_path
FileUtils.cd(destination_root)
run_generator ["bukkits"]
assert_file gemfile_path, /gem 'bukkits', path: 'bukkits'/
ensure
Object.send(:remove_const, "APP_PATH")
FileUtils.rm gemfile_path
end
def test_skipping_gemfile_entry
# simulate application existence
gemfile_path = "#{Rails.root}/Gemfile"