Merge pull request #2107 from AlexDenisov/projects_count_at_dashboard
Projects count at dashboard
This commit is contained in:
commit
f064459086
4 changed files with 18 additions and 1 deletions
|
@ -73,6 +73,7 @@ class Project < ActiveRecord::Base
|
||||||
scope :public_only, where(private_flag: false)
|
scope :public_only, where(private_flag: false)
|
||||||
scope :without_user, ->(user) { where("id NOT IN (:ids)", ids: user.projects.map(&:id) ) }
|
scope :without_user, ->(user) { where("id NOT IN (:ids)", ids: user.projects.map(&:id) ) }
|
||||||
scope :not_in_group, ->(group) { where("id NOT IN (:ids)", ids: group.project_ids ) }
|
scope :not_in_group, ->(group) { where("id NOT IN (:ids)", ids: group.project_ids ) }
|
||||||
|
scope :authorized_for, ->(user) { joins(:users_projects) { where(user_id: user.id) } }
|
||||||
|
|
||||||
class << self
|
class << self
|
||||||
def active
|
def active
|
||||||
|
|
|
@ -17,4 +17,4 @@
|
||||||
→
|
→
|
||||||
%span.last_activity
|
%span.last_activity
|
||||||
%strong Projects:
|
%strong Projects:
|
||||||
%span= group.projects.count
|
%span= group.projects.authorized_for(current_user).count
|
||||||
|
|
|
@ -15,6 +15,12 @@ Feature: Dashboard
|
||||||
And I visit dashboard page
|
And I visit dashboard page
|
||||||
Then I should see groups list
|
Then I should see groups list
|
||||||
|
|
||||||
|
Scenario: I should see correct projects count
|
||||||
|
Given I have group with projects
|
||||||
|
And group has a projects that does not belongs to me
|
||||||
|
When I visit dashboard page
|
||||||
|
Then I should see 1 project at group list
|
||||||
|
|
||||||
Scenario: I should see last push widget
|
Scenario: I should see last push widget
|
||||||
Then I should see last push widget
|
Then I should see last push widget
|
||||||
And I click "Create Merge Request" link
|
And I click "Create Merge Request" link
|
||||||
|
|
|
@ -103,4 +103,14 @@ class Dashboard < Spinach::FeatureSteps
|
||||||
page.should have_link group.name
|
page.should have_link group.name
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
And 'group has a projects that does not belongs to me' do
|
||||||
|
@forbidden_project1 = create(:project, group: @group)
|
||||||
|
@forbidden_project2 = create(:project, group: @group)
|
||||||
|
end
|
||||||
|
|
||||||
|
Then 'I should see 1 project at group list' do
|
||||||
|
page.find('span.last_activity/span').should have_content('1')
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue