diff options
| author | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2013-12-24 18:59:00 +0000 |
|---|---|---|
| committer | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2013-12-24 18:59:00 +0000 |
| commit | 16ea2ec1894da1077ccd7b0e39a50b3cedd1fe2a (patch) | |
| tree | ed3b98f4951bc4933047168e9f8c43776a33b2f8 | |
| parent | a16d755813a9cf567d842a9f252d40e65902d52b (diff) | |
| parent | b1970e0cf1271a8263a7ccf6b2aa8abb7ae59b2d (diff) | |
| download | gitlab-ce-16ea2ec1894da1077ccd7b0e39a50b3cedd1fe2a.tar.gz | |
Merge branch 'feature/all_merge_requets' of /home/git/repositories/gitlab/gitlabhq
| -rw-r--r-- | app/controllers/dashboard_controller.rb | 22 | ||||
| -rw-r--r-- | app/views/dashboard/issues.html.haml | 4 | ||||
| -rw-r--r-- | app/views/dashboard/merge_requests.html.haml | 2 | ||||
| -rw-r--r-- | app/views/layouts/nav/_dashboard.html.haml | 2 | ||||
| -rw-r--r-- | app/views/shared/_filter.html.haml | 14 | ||||
| -rw-r--r-- | features/dashboard/issues.feature | 12 | ||||
| -rw-r--r-- | features/dashboard/merge_requests.feature | 14 | ||||
| -rw-r--r-- | features/steps/dashboard/dashboard_issues.rb | 74 | ||||
| -rw-r--r-- | features/steps/dashboard/dashboard_merge_requests.rb | 79 |
9 files changed, 184 insertions, 39 deletions
diff --git a/app/controllers/dashboard_controller.rb b/app/controllers/dashboard_controller.rb index aaab4b40c4c..70dd3fff9a0 100644 --- a/app/controllers/dashboard_controller.rb +++ b/app/controllers/dashboard_controller.rb @@ -50,16 +50,30 @@ class DashboardController < ApplicationController @projects = @projects.page(params[:page]).per(30) end - # Get authored or assigned open merge requests def merge_requests - @merge_requests = current_user.cared_merge_requests + @merge_requests = case params[:scope] + when 'authored' then + current_user.merge_requests + when 'all' then + MergeRequest.where(target_project_id: current_user.authorized_projects.pluck(:id)) + else + current_user.assigned_merge_requests + end + @merge_requests = FilterContext.new(@merge_requests, params).execute @merge_requests = @merge_requests.recent.page(params[:page]).per(20) end - # Get only assigned issues def issues - @issues = current_user.assigned_issues + @issues = case params[:scope] + when 'authored' then + current_user.issues + when 'all' then + Issue.where(project_id: current_user.authorized_projects.pluck(:id)) + else + current_user.assigned_issues + end + @issues = FilterContext.new(@issues, params).execute @issues = @issues.recent.page(params[:page]).per(20) @issues = @issues.includes(:author, :project) diff --git a/app/views/dashboard/issues.html.haml b/app/views/dashboard/issues.html.haml index 82880d5ef63..bda5b7c9147 100644 --- a/app/views/dashboard/issues.html.haml +++ b/app/views/dashboard/issues.html.haml @@ -1,9 +1,9 @@ %h3.page-title - Issues assigned to me + Issues %span.pull-right #{@issues.total_count} issues %p.light - For all issues you should visit the project's issues page, or use the search panel to find a specific issue. + List all issues from all project's you have access to. %hr .row diff --git a/app/views/dashboard/merge_requests.html.haml b/app/views/dashboard/merge_requests.html.haml index 9c96edeefd5..74d02336bb8 100644 --- a/app/views/dashboard/merge_requests.html.haml +++ b/app/views/dashboard/merge_requests.html.haml @@ -4,7 +4,7 @@ %p.light - Only merge requests created by you or assigned to you are listed here. + List all merge requests from all project's you have access to. %hr .row .span3 diff --git a/app/views/layouts/nav/_dashboard.html.haml b/app/views/layouts/nav/_dashboard.html.haml index cae24c3170d..12fd49e609f 100644 --- a/app/views/layouts/nav/_dashboard.html.haml +++ b/app/views/layouts/nav/_dashboard.html.haml @@ -12,7 +12,7 @@ = nav_link(path: 'dashboard#merge_requests') do = link_to merge_requests_dashboard_path do Merge Requests - %span.count= current_user.cared_merge_requests.opened.count + %span.count= current_user.assigned_merge_requests.opened.count = nav_link(controller: :help) do = link_to "Help", help_path diff --git a/app/views/shared/_filter.html.haml b/app/views/shared/_filter.html.haml index 2f051cea48b..d48a8d6c1dd 100644 --- a/app/views/shared/_filter.html.haml +++ b/app/views/shared/_filter.html.haml @@ -1,5 +1,17 @@ = form_tag filter_path(entity), method: 'get' do - %fieldset + %fieldset.scope-filter + %ul.nav.nav-pills.nav-stacked + %li{class: ("active" if params[:scope].blank?)} + = link_to filter_path(entity, scope: nil) do + Assigned to me + %li{class: ("active" if params[:scope] == 'authored')} + = link_to filter_path(entity, scope: 'authored') do + Authored by me + %li{class: ("active" if params[:scope] == 'all')} + = link_to filter_path(entity, scope: 'all') do + All + + %fieldset.status-filter %ul.nav.nav-pills.nav-stacked %li{class: ("active" if params[:status].blank?)} = link_to filter_path(entity, status: nil) do diff --git a/features/dashboard/issues.feature b/features/dashboard/issues.feature index 895b89aa38a..d316b2d9205 100644 --- a/features/dashboard/issues.feature +++ b/features/dashboard/issues.feature @@ -1,8 +1,18 @@ Feature: Dashboard Issues Background: Given I sign in as a user + And I have authored issues And I have assigned issues + And I have other issues And I visit dashboard issues page - Scenario: I should see issues list + Scenario: I should see assigned issues Then I should see issues assigned to me + + Scenario: I should see authored issues + When I click "Authored by me" link + Then I should see issues authored by me + + Scenario: I should see all issues + When I click "All" link + Then I should see all issues diff --git a/features/dashboard/merge_requests.feature b/features/dashboard/merge_requests.feature index cad65b0d79a..de560300735 100644 --- a/features/dashboard/merge_requests.feature +++ b/features/dashboard/merge_requests.feature @@ -2,7 +2,17 @@ Feature: Dashboard Merge Requests Background: Given I sign in as a user And I have authored merge requests + And I have assigned merge requests + And I have other merge requests And I visit dashboard merge requests page - Scenario: I should see projects list - Then I should see my merge requests + Scenario: I should see assigned merge_requests + Then I should see merge requests assigned to me + + Scenario: I should see authored merge_requests + When I click "Authored by me" link + Then I should see merge requests authored by me + + Scenario: I should see all merge_requests + When I click "All" link + Then I should see all merge requests diff --git a/features/steps/dashboard/dashboard_issues.rb b/features/steps/dashboard/dashboard_issues.rb index fcf4296ad11..47d83f73ed2 100644 --- a/features/steps/dashboard/dashboard_issues.rb +++ b/features/steps/dashboard/dashboard_issues.rb @@ -2,19 +2,73 @@ class DashboardIssues < Spinach::FeatureSteps include SharedAuthentication include SharedPaths - Then 'I should see issues assigned to me' do - issues = @user.issues - issues.each do |issue| - page.should have_content(issue.title[0..10]) - page.should have_content(issue.project.name) - page.should have_link(issue.project.name) + step 'I should see issues assigned to me' do + should_see(assigned_issue) + should_not_see(authored_issue) + should_not_see(other_issue) + end + + step 'I should see issues authored by me' do + should_see(authored_issue) + should_not_see(assigned_issue) + should_not_see(other_issue) + end + + step 'I should see all issues' do + should_see(authored_issue) + should_see(assigned_issue) + should_see(other_issue) + end + + step 'I have authored issues' do + authored_issue + end + + step 'I have assigned issues' do + assigned_issue + end + + step 'I have other issues' do + other_issue + end + + step 'I click "Authored by me" link' do + within ".scope-filter" do + click_link 'Authored by me' end end - And 'I have assigned issues' do - project = create :project - project.team << [@user, :master] + step 'I click "All" link' do + within ".scope-filter" do + click_link 'All' + end + end + + def should_see(issue) + page.should have_content(issue.title[0..10]) + end + + def should_not_see(issue) + page.should_not have_content(issue.title[0..10]) + end + + def assigned_issue + @assigned_issue ||= create :issue, assignee: current_user, project: project + end + + def authored_issue + @authored_issue ||= create :issue, author: current_user, project: project + end + + def other_issue + @other_issue ||= create :issue, project: project + end - 2.times { create :issue, author: @user, assignee: @user, project: project } + def project + @project ||= begin + project =create :project_with_code + project.team << [current_user, :master] + project + end end end diff --git a/features/steps/dashboard/dashboard_merge_requests.rb b/features/steps/dashboard/dashboard_merge_requests.rb index 6c1fa39f081..3c35462a8db 100644 --- a/features/steps/dashboard/dashboard_merge_requests.rb +++ b/features/steps/dashboard/dashboard_merge_requests.rb @@ -2,28 +2,73 @@ class DashboardMergeRequests < Spinach::FeatureSteps include SharedAuthentication include SharedPaths - Then 'I should see my merge requests' do - merge_requests = @user.merge_requests - merge_requests.each do |mr| - page.should have_content(mr.title[0..10]) - page.should have_content(mr.target_project.name) - page.should have_content(mr.source_project.name) + step 'I should see merge requests assigned to me' do + should_see(assigned_merge_request) + should_not_see(authored_merge_request) + should_not_see(other_merge_request) + end + + step 'I should see merge requests authored by me' do + should_see(authored_merge_request) + should_not_see(assigned_merge_request) + should_not_see(other_merge_request) + end + + step 'I should see all merge requests' do + should_see(authored_merge_request) + should_see(assigned_merge_request) + should_see(other_merge_request) + end + + step 'I have authored merge requests' do + authored_merge_request + end + + step 'I have assigned merge requests' do + assigned_merge_request + end + + step 'I have other merge requests' do + other_merge_request + end + + step 'I click "Authored by me" link' do + within ".scope-filter" do + click_link 'Authored by me' + end + end + + step 'I click "All" link' do + within ".scope-filter" do + click_link 'All' end end - And 'I have authored merge requests' do - project1_source = create :project - project1_target= create :project - project2_source = create :project - project2_target = create :project + def should_see(merge_request) + page.should have_content(merge_request.title[0..10]) + end + def should_not_see(merge_request) + page.should_not have_content(merge_request.title[0..10]) + end - project1_source.team << [@user, :master] - project1_target.team << [@user, :master] - project2_source.team << [@user, :master] - project2_target.team << [@user, :master] + def assigned_merge_request + @assigned_merge_request ||= create :merge_request, assignee: current_user, target_project: project + end + + def authored_merge_request + @authored_merge_request ||= create :merge_request, author: current_user, target_project: project + end + + def other_merge_request + @other_merge_request ||= create :merge_request, target_project: project + end - merge_request1 = create :merge_request, author: @user, source_project: project1_source, target_project: project1_target - merge_request2 = create :merge_request, author: @user, source_project: project2_source, target_project: project2_target + def project + @project ||= begin + project =create :project_with_code + project.team << [current_user, :master] + project + end end end |
