diff --git a/app/models/update.rb b/app/models/update.rb index a3067630e..b39fe9d02 100644 --- a/app/models/update.rb +++ b/app/models/update.rb @@ -1,4 +1,5 @@ class Update < ActiveRecord::Base attr_accessible :body, :subject, :user_id belongs_to :user + default_scope order("created_at desc") end diff --git a/spec/models/update_spec.rb b/spec/models/update_spec.rb index d1cc5c3f9..7704bed71 100644 --- a/spec/models/update_spec.rb +++ b/spec/models/update_spec.rb @@ -1,5 +1,9 @@ require 'spec_helper' describe Update do - pending "add some examples to (or delete) #{__FILE__}" + it "should be sorted in reverse order" do + Update.create! :subject => "first entry", :body => "blah", :user_id => 1 + Update.create! :subject => "second entry", :body => "blah", :user_id => 1 + Update.first.subject.should == "second entry" + end end