Commit 16ea2ec1894da1077ccd7b0e39a50b3cedd1fe2a
Exists in
spb-stable
and in
3 other branches
Merge branch 'feature/all_merge_requets' of /home/git/repositories/gitlab/gitlabhq
Showing
9 changed files
with
184 additions
and
39 deletions
Show diff stats
app/controllers/dashboard_controller.rb
@@ -50,16 +50,30 @@ class DashboardController < ApplicationController | @@ -50,16 +50,30 @@ class DashboardController < ApplicationController | ||
50 | @projects = @projects.page(params[:page]).per(30) | 50 | @projects = @projects.page(params[:page]).per(30) |
51 | end | 51 | end |
52 | 52 | ||
53 | - # Get authored or assigned open merge requests | ||
54 | def merge_requests | 53 | def merge_requests |
55 | - @merge_requests = current_user.cared_merge_requests | 54 | + @merge_requests = case params[:scope] |
55 | + when 'authored' then | ||
56 | + current_user.merge_requests | ||
57 | + when 'all' then | ||
58 | + MergeRequest.where(target_project_id: current_user.authorized_projects.pluck(:id)) | ||
59 | + else | ||
60 | + current_user.assigned_merge_requests | ||
61 | + end | ||
62 | + | ||
56 | @merge_requests = FilterContext.new(@merge_requests, params).execute | 63 | @merge_requests = FilterContext.new(@merge_requests, params).execute |
57 | @merge_requests = @merge_requests.recent.page(params[:page]).per(20) | 64 | @merge_requests = @merge_requests.recent.page(params[:page]).per(20) |
58 | end | 65 | end |
59 | 66 | ||
60 | - # Get only assigned issues | ||
61 | def issues | 67 | def issues |
62 | - @issues = current_user.assigned_issues | 68 | + @issues = case params[:scope] |
69 | + when 'authored' then | ||
70 | + current_user.issues | ||
71 | + when 'all' then | ||
72 | + Issue.where(project_id: current_user.authorized_projects.pluck(:id)) | ||
73 | + else | ||
74 | + current_user.assigned_issues | ||
75 | + end | ||
76 | + | ||
63 | @issues = FilterContext.new(@issues, params).execute | 77 | @issues = FilterContext.new(@issues, params).execute |
64 | @issues = @issues.recent.page(params[:page]).per(20) | 78 | @issues = @issues.recent.page(params[:page]).per(20) |
65 | @issues = @issues.includes(:author, :project) | 79 | @issues = @issues.includes(:author, :project) |
app/views/dashboard/issues.html.haml
1 | %h3.page-title | 1 | %h3.page-title |
2 | - Issues assigned to me | 2 | + Issues |
3 | %span.pull-right #{@issues.total_count} issues | 3 | %span.pull-right #{@issues.total_count} issues |
4 | 4 | ||
5 | %p.light | 5 | %p.light |
6 | - For all issues you should visit the project's issues page, or use the search panel to find a specific issue. | 6 | + List all issues from all project's you have access to. |
7 | %hr | 7 | %hr |
8 | 8 | ||
9 | .row | 9 | .row |
app/views/dashboard/merge_requests.html.haml
app/views/layouts/nav/_dashboard.html.haml
@@ -12,7 +12,7 @@ | @@ -12,7 +12,7 @@ | ||
12 | = nav_link(path: 'dashboard#merge_requests') do | 12 | = nav_link(path: 'dashboard#merge_requests') do |
13 | = link_to merge_requests_dashboard_path do | 13 | = link_to merge_requests_dashboard_path do |
14 | Merge Requests | 14 | Merge Requests |
15 | - %span.count= current_user.cared_merge_requests.opened.count | 15 | + %span.count= current_user.assigned_merge_requests.opened.count |
16 | = nav_link(controller: :help) do | 16 | = nav_link(controller: :help) do |
17 | = link_to "Help", help_path | 17 | = link_to "Help", help_path |
18 | 18 |
app/views/shared/_filter.html.haml
1 | = form_tag filter_path(entity), method: 'get' do | 1 | = form_tag filter_path(entity), method: 'get' do |
2 | - %fieldset | 2 | + %fieldset.scope-filter |
3 | + %ul.nav.nav-pills.nav-stacked | ||
4 | + %li{class: ("active" if params[:scope].blank?)} | ||
5 | + = link_to filter_path(entity, scope: nil) do | ||
6 | + Assigned to me | ||
7 | + %li{class: ("active" if params[:scope] == 'authored')} | ||
8 | + = link_to filter_path(entity, scope: 'authored') do | ||
9 | + Authored by me | ||
10 | + %li{class: ("active" if params[:scope] == 'all')} | ||
11 | + = link_to filter_path(entity, scope: 'all') do | ||
12 | + All | ||
13 | + | ||
14 | + %fieldset.status-filter | ||
3 | %ul.nav.nav-pills.nav-stacked | 15 | %ul.nav.nav-pills.nav-stacked |
4 | %li{class: ("active" if params[:status].blank?)} | 16 | %li{class: ("active" if params[:status].blank?)} |
5 | = link_to filter_path(entity, status: nil) do | 17 | = link_to filter_path(entity, status: nil) do |
features/dashboard/issues.feature
1 | Feature: Dashboard Issues | 1 | Feature: Dashboard Issues |
2 | Background: | 2 | Background: |
3 | Given I sign in as a user | 3 | Given I sign in as a user |
4 | + And I have authored issues | ||
4 | And I have assigned issues | 5 | And I have assigned issues |
6 | + And I have other issues | ||
5 | And I visit dashboard issues page | 7 | And I visit dashboard issues page |
6 | 8 | ||
7 | - Scenario: I should see issues list | 9 | + Scenario: I should see assigned issues |
8 | Then I should see issues assigned to me | 10 | Then I should see issues assigned to me |
11 | + | ||
12 | + Scenario: I should see authored issues | ||
13 | + When I click "Authored by me" link | ||
14 | + Then I should see issues authored by me | ||
15 | + | ||
16 | + Scenario: I should see all issues | ||
17 | + When I click "All" link | ||
18 | + Then I should see all issues |
features/dashboard/merge_requests.feature
@@ -2,7 +2,17 @@ Feature: Dashboard Merge Requests | @@ -2,7 +2,17 @@ Feature: Dashboard Merge Requests | ||
2 | Background: | 2 | Background: |
3 | Given I sign in as a user | 3 | Given I sign in as a user |
4 | And I have authored merge requests | 4 | And I have authored merge requests |
5 | + And I have assigned merge requests | ||
6 | + And I have other merge requests | ||
5 | And I visit dashboard merge requests page | 7 | And I visit dashboard merge requests page |
6 | 8 | ||
7 | - Scenario: I should see projects list | ||
8 | - Then I should see my merge requests | 9 | + Scenario: I should see assigned merge_requests |
10 | + Then I should see merge requests assigned to me | ||
11 | + | ||
12 | + Scenario: I should see authored merge_requests | ||
13 | + When I click "Authored by me" link | ||
14 | + Then I should see merge requests authored by me | ||
15 | + | ||
16 | + Scenario: I should see all merge_requests | ||
17 | + When I click "All" link | ||
18 | + Then I should see all merge requests |
features/steps/dashboard/dashboard_issues.rb
@@ -2,19 +2,73 @@ class DashboardIssues < Spinach::FeatureSteps | @@ -2,19 +2,73 @@ class DashboardIssues < Spinach::FeatureSteps | ||
2 | include SharedAuthentication | 2 | include SharedAuthentication |
3 | include SharedPaths | 3 | include SharedPaths |
4 | 4 | ||
5 | - Then 'I should see issues assigned to me' do | ||
6 | - issues = @user.issues | ||
7 | - issues.each do |issue| | ||
8 | - page.should have_content(issue.title[0..10]) | ||
9 | - page.should have_content(issue.project.name) | ||
10 | - page.should have_link(issue.project.name) | 5 | + step 'I should see issues assigned to me' do |
6 | + should_see(assigned_issue) | ||
7 | + should_not_see(authored_issue) | ||
8 | + should_not_see(other_issue) | ||
9 | + end | ||
10 | + | ||
11 | + step 'I should see issues authored by me' do | ||
12 | + should_see(authored_issue) | ||
13 | + should_not_see(assigned_issue) | ||
14 | + should_not_see(other_issue) | ||
15 | + end | ||
16 | + | ||
17 | + step 'I should see all issues' do | ||
18 | + should_see(authored_issue) | ||
19 | + should_see(assigned_issue) | ||
20 | + should_see(other_issue) | ||
21 | + end | ||
22 | + | ||
23 | + step 'I have authored issues' do | ||
24 | + authored_issue | ||
25 | + end | ||
26 | + | ||
27 | + step 'I have assigned issues' do | ||
28 | + assigned_issue | ||
29 | + end | ||
30 | + | ||
31 | + step 'I have other issues' do | ||
32 | + other_issue | ||
33 | + end | ||
34 | + | ||
35 | + step 'I click "Authored by me" link' do | ||
36 | + within ".scope-filter" do | ||
37 | + click_link 'Authored by me' | ||
11 | end | 38 | end |
12 | end | 39 | end |
13 | 40 | ||
14 | - And 'I have assigned issues' do | ||
15 | - project = create :project | ||
16 | - project.team << [@user, :master] | 41 | + step 'I click "All" link' do |
42 | + within ".scope-filter" do | ||
43 | + click_link 'All' | ||
44 | + end | ||
45 | + end | ||
46 | + | ||
47 | + def should_see(issue) | ||
48 | + page.should have_content(issue.title[0..10]) | ||
49 | + end | ||
50 | + | ||
51 | + def should_not_see(issue) | ||
52 | + page.should_not have_content(issue.title[0..10]) | ||
53 | + end | ||
54 | + | ||
55 | + def assigned_issue | ||
56 | + @assigned_issue ||= create :issue, assignee: current_user, project: project | ||
57 | + end | ||
58 | + | ||
59 | + def authored_issue | ||
60 | + @authored_issue ||= create :issue, author: current_user, project: project | ||
61 | + end | ||
62 | + | ||
63 | + def other_issue | ||
64 | + @other_issue ||= create :issue, project: project | ||
65 | + end | ||
17 | 66 | ||
18 | - 2.times { create :issue, author: @user, assignee: @user, project: project } | 67 | + def project |
68 | + @project ||= begin | ||
69 | + project =create :project_with_code | ||
70 | + project.team << [current_user, :master] | ||
71 | + project | ||
72 | + end | ||
19 | end | 73 | end |
20 | end | 74 | end |
features/steps/dashboard/dashboard_merge_requests.rb
@@ -2,28 +2,73 @@ class DashboardMergeRequests < Spinach::FeatureSteps | @@ -2,28 +2,73 @@ class DashboardMergeRequests < Spinach::FeatureSteps | ||
2 | include SharedAuthentication | 2 | include SharedAuthentication |
3 | include SharedPaths | 3 | include SharedPaths |
4 | 4 | ||
5 | - Then 'I should see my merge requests' do | ||
6 | - merge_requests = @user.merge_requests | ||
7 | - merge_requests.each do |mr| | ||
8 | - page.should have_content(mr.title[0..10]) | ||
9 | - page.should have_content(mr.target_project.name) | ||
10 | - page.should have_content(mr.source_project.name) | 5 | + step 'I should see merge requests assigned to me' do |
6 | + should_see(assigned_merge_request) | ||
7 | + should_not_see(authored_merge_request) | ||
8 | + should_not_see(other_merge_request) | ||
9 | + end | ||
10 | + | ||
11 | + step 'I should see merge requests authored by me' do | ||
12 | + should_see(authored_merge_request) | ||
13 | + should_not_see(assigned_merge_request) | ||
14 | + should_not_see(other_merge_request) | ||
15 | + end | ||
16 | + | ||
17 | + step 'I should see all merge requests' do | ||
18 | + should_see(authored_merge_request) | ||
19 | + should_see(assigned_merge_request) | ||
20 | + should_see(other_merge_request) | ||
21 | + end | ||
22 | + | ||
23 | + step 'I have authored merge requests' do | ||
24 | + authored_merge_request | ||
25 | + end | ||
26 | + | ||
27 | + step 'I have assigned merge requests' do | ||
28 | + assigned_merge_request | ||
29 | + end | ||
30 | + | ||
31 | + step 'I have other merge requests' do | ||
32 | + other_merge_request | ||
33 | + end | ||
34 | + | ||
35 | + step 'I click "Authored by me" link' do | ||
36 | + within ".scope-filter" do | ||
37 | + click_link 'Authored by me' | ||
38 | + end | ||
39 | + end | ||
40 | + | ||
41 | + step 'I click "All" link' do | ||
42 | + within ".scope-filter" do | ||
43 | + click_link 'All' | ||
11 | end | 44 | end |
12 | end | 45 | end |
13 | 46 | ||
14 | - And 'I have authored merge requests' do | ||
15 | - project1_source = create :project | ||
16 | - project1_target= create :project | ||
17 | - project2_source = create :project | ||
18 | - project2_target = create :project | 47 | + def should_see(merge_request) |
48 | + page.should have_content(merge_request.title[0..10]) | ||
49 | + end | ||
19 | 50 | ||
51 | + def should_not_see(merge_request) | ||
52 | + page.should_not have_content(merge_request.title[0..10]) | ||
53 | + end | ||
20 | 54 | ||
21 | - project1_source.team << [@user, :master] | ||
22 | - project1_target.team << [@user, :master] | ||
23 | - project2_source.team << [@user, :master] | ||
24 | - project2_target.team << [@user, :master] | 55 | + def assigned_merge_request |
56 | + @assigned_merge_request ||= create :merge_request, assignee: current_user, target_project: project | ||
57 | + end | ||
58 | + | ||
59 | + def authored_merge_request | ||
60 | + @authored_merge_request ||= create :merge_request, author: current_user, target_project: project | ||
61 | + end | ||
62 | + | ||
63 | + def other_merge_request | ||
64 | + @other_merge_request ||= create :merge_request, target_project: project | ||
65 | + end | ||
25 | 66 | ||
26 | - merge_request1 = create :merge_request, author: @user, source_project: project1_source, target_project: project1_target | ||
27 | - merge_request2 = create :merge_request, author: @user, source_project: project2_source, target_project: project2_target | 67 | + def project |
68 | + @project ||= begin | ||
69 | + project =create :project_with_code | ||
70 | + project.team << [current_user, :master] | ||
71 | + project | ||
72 | + end | ||
28 | end | 73 | end |
29 | end | 74 | end |