Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge pull request #307 from cldwalker/sort_versions

Fix version sorting on rubygems#show, closes #295
  • Loading branch information...
commit 3d322d0e7afd7ef6c85088d1a1ccb95644b4dadc 2 parents 6e50bff + cc98e4e
@sferik sferik authored
View
2  app/models/rubygem.rb
@@ -91,7 +91,7 @@ def all_errors(version = nil)
end
def public_versions(limit = nil)
- versions.published(limit).by_position
+ versions.by_position.published(limit)
end
def hosted?
View
19 test/functional/rubygems_controller_test.rb
@@ -278,8 +278,11 @@ class RubygemsControllerTest < ActionController::TestCase
context "On GET to show with a gem that has multiple versions" do
setup do
@rubygem = Factory(:rubygem)
- @older_version = Factory(:version, :number => "1.0.0", :rubygem => @rubygem, :created_at => 2.minutes.ago)
- @latest_version = Factory(:version, :number => "2.0.0", :rubygem => @rubygem, :created_at => 1.minute.ago)
+ @versions = [
+ Factory(:version, :number => "2.0.0rc1", :rubygem => @rubygem, :created_at => 1.day.ago),
+ Factory(:version, :number => "1.9.9", :rubygem => @rubygem, :created_at => 1.minute.ago),
+ Factory(:version, :number => "1.9.9.rc4", :rubygem => @rubygem, :created_at => 2.days.ago)
+ ]
get :show, :id => @rubygem.to_param
end
@@ -288,13 +291,21 @@ class RubygemsControllerTest < ActionController::TestCase
should assign_to :rubygem
should "render info about the gem" do
assert_contain @rubygem.name
- assert_contain @latest_version.number
- assert_contain @latest_version.built_at.to_date.to_formatted_s(:long)
+ assert_contain @versions[0].number
+ assert_contain @versions[0].built_at.to_date.to_formatted_s(:long)
assert_contain "Versions"
assert_contain @rubygem.versions.last.number
assert_contain @rubygem.versions.last.built_at.to_date.to_formatted_s(:long)
end
+
+ should "render versions in correct order" do
+ assert_select("div.versions > ol > li") do |elements|
+ elements.each_with_index do |elem, index|
+ assert_select elem, "a", @versions[index].number
+ end
+ end
+ end
end
context "On GET to show for a gem with no versions" do

0 comments on commit 3d322d0

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