Commit 85e039049cba5ac1bf92e6cbba2ea1236d6892f7
1 parent
734d6fcd
Exists in
master
and in
4 other branches
Fix tests
Showing
2 changed files
with
8 additions
and
8 deletions
Show diff stats
app/models/project.rb
... | ... | @@ -86,13 +86,13 @@ class Project < ActiveRecord::Base |
86 | 86 | validate :check_limit, :repo_name |
87 | 87 | |
88 | 88 | # Scopes |
89 | - scope :without_user, ->(user) { where("id NOT IN (:ids)", ids: user.authorized_projects.map(&:id) ) } | |
90 | - scope :without_team, ->(team) { team.projects.present? ? where("id NOT IN (:ids)", ids: team.projects.map(&:id)) : scoped } | |
91 | - scope :not_in_group, ->(group) { where("id NOT IN (:ids)", ids: group.project_ids ) } | |
92 | - scope :in_team, ->(team) { where("id IN (:ids)", ids: team.projects.map(&:id)) } | |
89 | + scope :without_user, ->(user) { where("projects.id NOT IN (:ids)", ids: user.authorized_projects.map(&:id) ) } | |
90 | + scope :without_team, ->(team) { team.projects.present? ? where("projects.id NOT IN (:ids)", ids: team.projects.map(&:id)) : scoped } | |
91 | + scope :not_in_group, ->(group) { where("projects.id NOT IN (:ids)", ids: group.project_ids ) } | |
92 | + scope :in_team, ->(team) { where("projects.id IN (:ids)", ids: team.projects.map(&:id)) } | |
93 | 93 | scope :in_namespace, ->(namespace) { where(namespace_id: namespace.id) } |
94 | 94 | scope :in_group_namespace, -> { joins(:group) } |
95 | - scope :sorted_by_activity, -> { order("last_activity_at DESC") } | |
95 | + scope :sorted_by_activity, -> { order("projects.last_activity_at DESC") } | |
96 | 96 | scope :personal, ->(user) { where(namespace_id: user.namespace_id) } |
97 | 97 | scope :joined, ->(user) { where("namespace_id != ?", user.namespace_id) } |
98 | 98 | scope :public_only, -> { where(public: true) } |
... | ... | @@ -190,7 +190,7 @@ class Project < ActiveRecord::Base |
190 | 190 | end |
191 | 191 | |
192 | 192 | def last_activity_date |
193 | - last_activity_at | |
193 | + last_activity_at || updated_at | |
194 | 194 | end |
195 | 195 | |
196 | 196 | def project_id | ... | ... |
spec/models/project_spec.rb
... | ... | @@ -108,8 +108,8 @@ describe Project do |
108 | 108 | |
109 | 109 | describe 'last_activity_date' do |
110 | 110 | it 'returns the creation date of the project\'s last event if present' do |
111 | - project.stub(last_event: last_event) | |
112 | - project.last_activity_date.should == last_event.created_at | |
111 | + last_activity_event = create(:event, project: project) | |
112 | + project.last_activity_date.to_s(:db).should == last_event.created_at.to_s(:db) | |
113 | 113 | end |
114 | 114 | |
115 | 115 | it 'returns the project\'s last update date if it has no events' do | ... | ... |