diff options
author | Rubén Dávila <rdavila84@gmail.com> | 2016-01-21 12:54:10 -0500 |
---|---|---|
committer | Rubén Dávila <rdavila84@gmail.com> | 2016-01-21 12:54:10 -0500 |
commit | 0f79620ccb049dc8146ab3c639f993122329eb83 (patch) | |
tree | 34c3e63a5624c1aaee605be20fc410bba16422fb | |
parent | 4d345bc4003022ca22b5e7f42069c5a6bde41b6c (diff) | |
download | gitlab-ce-0f79620ccb049dc8146ab3c639f993122329eb83.tar.gz |
Little refactor plus some specs.
-rw-r--r-- | app/controllers/application_controller.rb | 18 | ||||
-rw-r--r-- | features/dashboard/dashboard.feature | 16 | ||||
-rw-r--r-- | features/project/issues/issues.feature | 8 | ||||
-rw-r--r-- | features/project/merge_requests.feature | 8 | ||||
-rw-r--r-- | features/steps/dashboard/dashboard.rb | 1 | ||||
-rw-r--r-- | features/steps/shared/issuable.rb | 13 |
6 files changed, 52 insertions, 12 deletions
diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 4c4e2ac3d3c..9df37a677c0 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -410,18 +410,12 @@ class ApplicationController < ActionController::Base def set_default_sort controller_name = params[:controller].sub(/Controller\Z/, '').underscore - cookie_suffix = "_sort_#{controller_name}" - - key = if @project - "#{@project.cookie_key}#{cookie_suffix}" - elsif @group - "#{@group.cookie_key}#{cookie_suffix}" - else - "#{current_user.cookie_key}#{cookie_suffix}" - end - - cookies[key] ||= 'id_desc' - cookies[key] = params[:sort] if params[:sort].present? + cookie_suffix = "_sort_#{controller_name}" + + key = "#{(@project || @group || current_user).cookie_key}#{cookie_suffix}" + + cookies[key] ||= 'id_desc' + cookies[key] = params[:sort] if params[:sort].present? params[:sort] = cookies[key] end end diff --git a/features/dashboard/dashboard.feature b/features/dashboard/dashboard.feature index b667b587c5b..9060e9d0ad2 100644 --- a/features/dashboard/dashboard.feature +++ b/features/dashboard/dashboard.feature @@ -41,3 +41,19 @@ Feature: Dashboard And user with name "John Doe" left project "Shop" When I visit dashboard activity page Then I should see "John Doe left project Shop" event + + @javascript + Scenario: Sorting Issues + Given I visit dashboard issues page + And I sort the list by "Oldest updated" + And I visit dashboard activity page + And I visit dashboard issues page + Then The list should be sorted by "Oldest updated" + + @javascript + Scenario: Sorting Merge Requests + Given I visit dashboard merge requests page + And I sort the list by "Oldest updated" + And I visit dashboard activity page + And I visit dashboard merge requests page + Then The list should be sorted by "Oldest updated" diff --git a/features/project/issues/issues.feature b/features/project/issues/issues.feature index 1502b0952cd..c1ae10f89c9 100644 --- a/features/project/issues/issues.feature +++ b/features/project/issues/issues.feature @@ -60,6 +60,14 @@ Feature: Project Issues Then I should see "Release 0.4" at the top @javascript + Scenario: Visiting Issues after being sorted the list + Given I visit project "Shop" issues page + And I sort the list by "Oldest updated" + And I visit my project's home page + And I visit project "Shop" issues page + Then The list should be sorted by "Oldest updated" + + @javascript Scenario: I search issue Given I fill in issue search with "Re" Then I should see "Release 0.4" in issues diff --git a/features/project/merge_requests.feature b/features/project/merge_requests.feature index f1629a26f10..55c17ad0c15 100644 --- a/features/project/merge_requests.feature +++ b/features/project/merge_requests.feature @@ -85,6 +85,14 @@ Feature: Project Merge Requests Then I should see "Bug NS-04" at the top @javascript + Scenario: Visiting Merge Requests after being sorted the list + Given I visit project "Shop" merge requests page + And I sort the list by "Oldest updated" + And I visit my project's home page + And I visit project "Shop" merge requests page + Then The list should be sorted by "Oldest updated" + + @javascript Scenario: Visiting Merge Requests after commenting on diffs Given project "Shop" have "Bug NS-05" open merge request with diffs inside And I visit merge request page "Bug NS-05" diff --git a/features/steps/dashboard/dashboard.rb b/features/steps/dashboard/dashboard.rb index 63f0ec2b6e8..5062e348844 100644 --- a/features/steps/dashboard/dashboard.rb +++ b/features/steps/dashboard/dashboard.rb @@ -2,6 +2,7 @@ class Spinach::Features::Dashboard < Spinach::FeatureSteps include SharedAuthentication include SharedPaths include SharedProject + include SharedIssuable step 'I should see "New Project" link' do expect(page).to have_link "New project" diff --git a/features/steps/shared/issuable.rb b/features/steps/shared/issuable.rb index 4c5f7488efb..25c2b476f43 100644 --- a/features/steps/shared/issuable.rb +++ b/features/steps/shared/issuable.rb @@ -106,6 +106,19 @@ module SharedIssuable edit_issuable end + step 'I sort the list by "Oldest updated"' do + find('button.dropdown-toggle.btn').click + page.within('ul.dropdown-menu.dropdown-menu-align-right li') do + click_link "Oldest updated" + end + end + + step 'The list should be sorted by "Oldest updated"' do + page.within('div.dropdown.inline.prepend-left-10') do + expect(page.find('button.dropdown-toggle.btn')).to have_content('Oldest updated') + end + end + def create_issuable_for_project(project_name:, title:, type: :issue) project = Project.find_by(name: project_name) |