Commit 85e03904 authored by Andrey Kumanyaev's avatar Andrey Kumanyaev

Fix tests

parent 734d6fcd
...@@ -86,13 +86,13 @@ class Project < ActiveRecord::Base ...@@ -86,13 +86,13 @@ class Project < ActiveRecord::Base
validate :check_limit, :repo_name validate :check_limit, :repo_name
# Scopes # Scopes
scope :without_user, ->(user) { where("id NOT IN (:ids)", ids: user.authorized_projects.map(&:id) ) } scope :without_user, ->(user) { where("projects.id NOT IN (:ids)", ids: user.authorized_projects.map(&:id) ) }
scope :without_team, ->(team) { team.projects.present? ? where("id NOT IN (:ids)", ids: team.projects.map(&:id)) : scoped } scope :without_team, ->(team) { team.projects.present? ? where("projects.id NOT IN (:ids)", ids: team.projects.map(&:id)) : scoped }
scope :not_in_group, ->(group) { where("id NOT IN (:ids)", ids: group.project_ids ) } scope :not_in_group, ->(group) { where("projects.id NOT IN (:ids)", ids: group.project_ids ) }
scope :in_team, ->(team) { where("id IN (:ids)", ids: team.projects.map(&:id)) } scope :in_team, ->(team) { where("projects.id IN (:ids)", ids: team.projects.map(&:id)) }
scope :in_namespace, ->(namespace) { where(namespace_id: namespace.id) } scope :in_namespace, ->(namespace) { where(namespace_id: namespace.id) }
scope :in_group_namespace, -> { joins(:group) } scope :in_group_namespace, -> { joins(:group) }
scope :sorted_by_activity, -> { order("last_activity_at DESC") } scope :sorted_by_activity, -> { order("projects.last_activity_at DESC") }
scope :personal, ->(user) { where(namespace_id: user.namespace_id) } scope :personal, ->(user) { where(namespace_id: user.namespace_id) }
scope :joined, ->(user) { where("namespace_id != ?", user.namespace_id) } scope :joined, ->(user) { where("namespace_id != ?", user.namespace_id) }
scope :public_only, -> { where(public: true) } scope :public_only, -> { where(public: true) }
...@@ -190,7 +190,7 @@ class Project < ActiveRecord::Base ...@@ -190,7 +190,7 @@ class Project < ActiveRecord::Base
end end
def last_activity_date def last_activity_date
last_activity_at last_activity_at || updated_at
end end
def project_id def project_id
......
...@@ -108,8 +108,8 @@ describe Project do ...@@ -108,8 +108,8 @@ describe Project do
describe 'last_activity_date' do describe 'last_activity_date' do
it 'returns the creation date of the project\'s last event if present' do it 'returns the creation date of the project\'s last event if present' do
project.stub(last_event: last_event) last_activity_event = create(:event, project: project)
project.last_activity_date.should == last_event.created_at project.last_activity_date.to_s(:db).should == last_event.created_at.to_s(:db)
end end
it 'returns the project\'s last update date if it has no events' do it 'returns the project\'s last update date if it has no events' do
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment