Commit f0644590867da88a662095e11f4d0833381e672c
Exists in
master
and in
4 other branches
Merge pull request #2107 from AlexDenisov/projects_count_at_dashboard
Projects count at dashboard
Showing
4 changed files
with
18 additions
and
1 deletions
Show diff stats
app/models/project.rb
@@ -73,6 +73,7 @@ class Project < ActiveRecord::Base | @@ -73,6 +73,7 @@ class Project < ActiveRecord::Base | ||
73 | scope :public_only, where(private_flag: false) | 73 | scope :public_only, where(private_flag: false) |
74 | scope :without_user, ->(user) { where("id NOT IN (:ids)", ids: user.projects.map(&:id) ) } | 74 | scope :without_user, ->(user) { where("id NOT IN (:ids)", ids: user.projects.map(&:id) ) } |
75 | scope :not_in_group, ->(group) { where("id NOT IN (:ids)", ids: group.project_ids ) } | 75 | scope :not_in_group, ->(group) { where("id NOT IN (:ids)", ids: group.project_ids ) } |
76 | + scope :authorized_for, ->(user) { joins(:users_projects) { where(user_id: user.id) } } | ||
76 | 77 | ||
77 | class << self | 78 | class << self |
78 | def active | 79 | def active |
app/views/dashboard/_groups.html.haml
features/dashboard/dashboard.feature
@@ -15,6 +15,12 @@ Feature: Dashboard | @@ -15,6 +15,12 @@ Feature: Dashboard | ||
15 | And I visit dashboard page | 15 | And I visit dashboard page |
16 | Then I should see groups list | 16 | Then I should see groups list |
17 | 17 | ||
18 | + Scenario: I should see correct projects count | ||
19 | + Given I have group with projects | ||
20 | + And group has a projects that does not belongs to me | ||
21 | + When I visit dashboard page | ||
22 | + Then I should see 1 project at group list | ||
23 | + | ||
18 | Scenario: I should see last push widget | 24 | Scenario: I should see last push widget |
19 | Then I should see last push widget | 25 | Then I should see last push widget |
20 | And I click "Create Merge Request" link | 26 | And I click "Create Merge Request" link |
features/steps/dashboard/dashboard.rb
@@ -103,4 +103,14 @@ class Dashboard < Spinach::FeatureSteps | @@ -103,4 +103,14 @@ class Dashboard < Spinach::FeatureSteps | ||
103 | page.should have_link group.name | 103 | page.should have_link group.name |
104 | end | 104 | end |
105 | end | 105 | end |
106 | + | ||
107 | + And 'group has a projects that does not belongs to me' do | ||
108 | + @forbidden_project1 = create(:project, group: @group) | ||
109 | + @forbidden_project2 = create(:project, group: @group) | ||
110 | + end | ||
111 | + | ||
112 | + Then 'I should see 1 project at group list' do | ||
113 | + page.find('span.last_activity/span').should have_content('1') | ||
114 | + end | ||
115 | + | ||
106 | end | 116 | end |