Skip to content
Browse files

Ordering gems properly and hiding some information when it's not there

  • Loading branch information...
1 parent 9fb8b7d commit 6e903fff80a52d5c0d90de8c143d7aaf04601ada @qrush qrush committed Jun 11, 2009
View
2 app/models/rubygem.rb
@@ -46,7 +46,7 @@ def to_s
end
def current_version
- versions.last
+ versions.find(:first, :order => "created_at desc, number desc")
end
def current_dependencies
View
9 app/views/rubygems/show.html.haml
@@ -29,9 +29,10 @@
%h3 Administration
%p
=link_to "Edit Gem", edit_rubygem_path(@gem)
- .block.red
- %h3 Authors
- %p= @gem.current_version.authors
+ -unless @gem.current_version.authors.empty?
+ .block.red
+ %h3 Authors
+ %p= @gem.current_version.authors
.block.red
%h3 Downloads
%p= number_with_delimiter(@gem.downloads)
@@ -47,7 +48,7 @@
=link_to_page "Wiki", @gem.linkset.wiki
=link_to_page "Mailing List", @gem.linkset.mail
=link_to_page "Bug Tracker", @gem.linkset.bugs
- -if @gem.current_dependencies
+ -unless @gem.current_dependencies.empty?
.block.red
%h3 Dependencies
%p
View
5 config/environments/test.rb
@@ -31,7 +31,10 @@
:lib => 'shoulda',
:source => 'http://gems.github.com',
:version => '>= 2.10.1'
-config.gem 'factory_girl'
+config.gem 'thoughtbot-factory_girl',
+ :lib => 'factory_girl',
+ :source => 'http://gems.github.com',
+ :version => '>= 1.2.1'
config.gem 'webrat',
:version => '>= 0.4.4'
config.gem 'cucumber',
View
BIN test/gems/test-1.0.0.gem
Binary file not shown.
View
13 test/unit/rubygem_test.rb
@@ -1,7 +1,7 @@
require File.dirname(__FILE__) + '/../test_helper'
class RubygemTest < ActiveSupport::TestCase
- context "with a rubygem" do
+ context "with a saved rubygem" do
setup do
@rubygem = Factory(:rubygem)
end
@@ -11,6 +11,12 @@ class RubygemTest < ActiveSupport::TestCase
should_have_many :versions, :dependent => :destroy
should_have_one :linkset, :dependent => :destroy
should_validate_uniqueness_of :name
+ end
+
+ context "with a rubygem" do
+ setup do
+ @rubygem = Factory.build(:rubygem)
+ end
context "with a user" do
setup do
@@ -53,6 +59,7 @@ class RubygemTest < ActiveSupport::TestCase
end
should "return name with version for #to_s" do
+ @rubygem.save
assert_equal "#{@rubygem.name} (#{@rubygem.current_version})", @rubygem.to_s
end
@@ -85,8 +92,10 @@ class RubygemTest < ActiveSupport::TestCase
should "include platform when saving version" do
spec = Rubygem.pull_spec(gem_file.path)
spec.platform = "mswin"
+ spec.date = Date.today
+
@rubygem.spec = spec
- @rubygem.build
+ @rubygem.save
version = @rubygem.current_version
assert_not_nil version

0 comments on commit 6e903ff

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