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

Use stable branch for --edge option when possible

This alleviates the need to update the code when there is a new stable
branch (for example, as done in #41454).
This commit is contained in:
Jonathan Hefner 2021-03-07 16:45:37 -06:00 committed by GitHub
parent c431432f93
commit 7762770805
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 30 additions and 5 deletions

View file

@ -276,8 +276,9 @@ module Rails
GemfileEntry.path("rails", Rails::Generators::RAILS_DEV_PATH)
]
elsif options.edge?
edge_branch = Rails.gem_version.prerelease? ? "main" : [*Rails.gem_version.segments.first(2), "stable"].join("-")
[
GemfileEntry.github("rails", "rails/rails", "main")
GemfileEntry.github("rails", "rails/rails", edge_branch)
]
elsif options.main?
[

View file

@ -863,8 +863,20 @@ class AppGeneratorTest < Rails::Generators::TestCase
end
def test_edge_option
generator([destination_root], edge: true, skip_webpack_install: true)
run_generator_instance
Rails.stub(:gem_version, Gem::Version.new("2.1.0")) do
generator([destination_root], edge: true, skip_webpack_install: true)
run_generator_instance
end
assert_equal 1, @bundle_commands.count("install")
assert_file "Gemfile", %r{^gem\s+["']rails["'],\s+github:\s+["']#{Regexp.escape("rails/rails")}["'],\s+branch:\s+["']2-1-stable["']$}
end
def test_edge_option_during_alpha
Rails.stub(:gem_version, Gem::Version.new("2.1.0.alpha")) do
generator([destination_root], edge: true, skip_webpack_install: true)
run_generator_instance
end
assert_equal 1, @bundle_commands.count("install")
assert_file "Gemfile", %r{^gem\s+["']rails["'],\s+github:\s+["']#{Regexp.escape("rails/rails")}["'],\s+branch:\s+["']main["']$}

View file

@ -250,8 +250,20 @@ class PluginGeneratorTest < Rails::Generators::TestCase
end
def test_edge_option
generator([destination_root], edge: true)
run_generator_instance
Rails.stub(:gem_version, Gem::Version.new("2.1.0")) do
generator([destination_root], edge: true)
run_generator_instance
end
assert_empty @bundle_commands
assert_file "Gemfile", %r{^gem\s+["']rails["'],\s+github:\s+["']#{Regexp.escape("rails/rails")}["'],\s+branch:\s+["']2-1-stable["']$}
end
def test_edge_option_during_alpha
Rails.stub(:gem_version, Gem::Version.new("2.1.0.alpha")) do
generator([destination_root], edge: true)
run_generator_instance
end
assert_empty @bundle_commands
assert_file "Gemfile", %r{^gem\s+["']rails["'],\s+github:\s+["']#{Regexp.escape("rails/rails")}["'],\s+branch:\s+["']main["']$}