Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make adding gemfile entry work even if specify only the plugin name #28062

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -432,7 +432,7 @@ def rails_app_path
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
Expand Down
15 changes: 15 additions & 0 deletions railties/test/generators/plugin_generator_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -535,6 +535,21 @@ def test_creating_plugin_in_app_directory_adds_gemfile_entry
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"
Expand Down