Skip to content
Browse files

Renamed Rubygem#public_versions_with_extra to Rubygem#public_versions…

…_with_extra_version and made method more clear
  • Loading branch information...
1 parent 0aeec18 commit 512e76fe5eb04d1d345adef13176e4d96ca8b0a4 @rkneufeld rkneufeld committed Jan 28, 2012
Showing with 12 additions and 9 deletions.
  1. +1 −1 app/controllers/versions_controller.rb
  2. +4 −2 app/models/rubygem.rb
  3. +7 −6 test/unit/rubygem_test.rb
View
2 app/controllers/versions_controller.rb
@@ -7,7 +7,7 @@ def index
def show
@latest_version = Version.find_from_slug!(@rubygem.id, params[:id])
- @versions = @rubygem.public_versions_with_extra(5, @latest_version)
+ @versions = @rubygem.public_versions_with_extra_version(@latest_version)
render "rubygems/show"
end
View
6 app/models/rubygem.rb
@@ -92,8 +92,10 @@ def public_versions(limit = nil)
versions.published(limit).by_position
end
- def public_versions_with_extra(limit = nil, extra)
- (public_versions(limit) << extra).uniq.sort_by(&:position)
+ def public_versions_with_extra_version(extra_version)
+ versions = public_versions(5)
+ versions << extra_version
+ versions.uniq.sort_by(&:position)
end
def hosted?
View
13 test/unit/rubygem_test.rb
@@ -119,24 +119,25 @@ class RubygemTest < ActiveSupport::TestCase
assert_equal indexed_v1.reload, @rubygem.reload.versions.most_recent
end
- context "#public_versions_with_extra" do
+ context "#public_versions_with_extra_version" do
setup do
@first_version = Factory(:version, :rubygem => @rubygem, :number => '1.0.0', :position => 1)
@extra_version = Factory(:version, :rubygem => @rubygem, :number => '0.1.0', :position => 2)
end
should "include public versions" do
- assert @rubygem.public_versions_with_extra(1,@extra_version).include?(@first_version)
+ assert @rubygem.public_versions_with_extra_version(@extra_version).include?(@first_version)
end
should "include extra version" do
- assert @rubygem.public_versions_with_extra(1,@extra_version).include?(@extra_version)
+ stub(@rubygem).public_versions { [@first_version] }
+ assert @rubygem.public_versions_with_extra_version(@extra_version).include?(@extra_version)
end
should "maintain proper ordering" do
- versions = @rubygem.public_versions_with_extra(1,@extra_version)
+ versions = @rubygem.public_versions_with_extra_version(@extra_version)
assert_equal versions, versions.sort_by(&:position)
end
should "not duplicate versions" do
- versions = @rubygem.public_versions_with_extra(1,@first_version)
- assert_equal 1, versions.count
+ versions = @rubygem.public_versions_with_extra_version(@first_version)
+ assert_equal versions.count, versions.uniq.count
end
end
end

0 comments on commit 512e76f

Please sign in to comment.
Something went wrong with that request. Please try again.