Commit d246a68a242e28c106ab8916ccdc3ac2643b2d96

Authored by randx
1 parent cd3d50ca

fix project.last_activity spec

app/models/project.rb
@@ -158,7 +158,7 @@ class Project < ActiveRecord::Base @@ -158,7 +158,7 @@ class Project < ActiveRecord::Base
158 end 158 end
159 159
160 def last_activity 160 def last_activity
161 - events.order("created_at DESC").first || nil 161 + events.order("created_at ASC").last
162 end 162 end
163 163
164 def last_activity_date 164 def last_activity_date
spec/models/project_spec.rb
@@ -141,7 +141,7 @@ describe Project do @@ -141,7 +141,7 @@ describe Project do
141 let(:last_event) { double } 141 let(:last_event) { double }
142 142
143 before do 143 before do
144 - project.stub(:events).and_return( [ double, double, last_event ] ) 144 + project.stub_chain(:events, :order).and_return( [ double, double, last_event ] )
145 end 145 end
146 146
147 it { project.last_activity.should == last_event } 147 it { project.last_activity.should == last_event }