diff options
author | Matthew Draper <matthew@trebex.net> | 2017-02-23 03:24:56 +1030 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-02-23 03:24:56 +1030 |
commit | 2e0f7baef344474b39d660db5fb0b8c9fb33dc3b (patch) | |
tree | fbca472eff4f8de89d47dc147d04ddf224e0cd9e | |
parent | a92bd65e37bb08a08fd0aaf4d12c7c6cb92c2c17 (diff) | |
parent | 02ba585f8d3fb8fcff53f22b5bbd10bcc8c8c037 (diff) | |
download | rails-2e0f7baef344474b39d660db5fb0b8c9fb33dc3b.tar.gz rails-2e0f7baef344474b39d660db5fb0b8c9fb33dc3b.tar.bz2 rails-2e0f7baef344474b39d660db5fb0b8c9fb33dc3b.zip |
Merge pull request #27572 from matthewd/prerelease-specifier
Simplify the version specifier generated by prereleases
-rw-r--r-- | railties/lib/rails/generators/app_base.rb | 11 | ||||
-rw-r--r-- | railties/test/generators/generator_test.rb | 8 |
2 files changed, 9 insertions, 10 deletions
diff --git a/railties/lib/rails/generators/app_base.rb b/railties/lib/rails/generators/app_base.rb index 49e9044e09..04f6341471 100644 --- a/railties/lib/rails/generators/app_base.rb +++ b/railties/lib/rails/generators/app_base.rb @@ -263,14 +263,13 @@ module Rails end def rails_version_specifier(gem_version = Rails.gem_version) - if gem_version.prerelease? - next_series = gem_version - next_series = next_series.bump while next_series.segments.size > 2 - - [">= #{gem_version}", "< #{next_series}"] - elsif gem_version.segments.size == 3 + if gem_version.segments.size == 3 || gem_version.release.segments.size == 3 + # ~> 1.2.3 + # ~> 1.2.3.pre4 "~> #{gem_version}" else + # ~> 1.2.3, >= 1.2.3.4 + # ~> 1.2.3, >= 1.2.3.4.pre5 patch = gem_version.segments[0, 3].join(".") ["~> #{patch}", ">= #{gem_version}"] end diff --git a/railties/test/generators/generator_test.rb b/railties/test/generators/generator_test.rb index 904bade658..4444b3a56e 100644 --- a/railties/test/generators/generator_test.rb +++ b/railties/test/generators/generator_test.rb @@ -88,12 +88,12 @@ module Rails specifier_for = -> v { generator.send(:rails_version_specifier, Gem::Version.new(v)) } assert_equal "~> 4.1.13", specifier_for["4.1.13"] - assert_equal [">= 4.1.6.rc1", "< 4.2"], specifier_for["4.1.6.rc1"] + assert_equal "~> 4.1.6.rc1", specifier_for["4.1.6.rc1"] assert_equal ["~> 4.1.7", ">= 4.1.7.1"], specifier_for["4.1.7.1"] assert_equal ["~> 4.1.7", ">= 4.1.7.1.2"], specifier_for["4.1.7.1.2"] - assert_equal [">= 4.1.7.1.rc2", "< 4.2"], specifier_for["4.1.7.1.rc2"] - assert_equal [">= 4.2.0.beta1", "< 4.3"], specifier_for["4.2.0.beta1"] - assert_equal [">= 5.0.0.beta1", "< 5.1"], specifier_for["5.0.0.beta1"] + assert_equal ["~> 4.1.7", ">= 4.1.7.1.rc2"], specifier_for["4.1.7.1.rc2"] + assert_equal "~> 4.2.0.beta1", specifier_for["4.2.0.beta1"] + assert_equal "~> 5.0.0.beta1", specifier_for["5.0.0.beta1"] end end end |