Commit 0f79620c authored by Rubén Dávila's avatar Rubén Dávila

Little refactor plus some specs.

parent 4d345bc4
...@@ -410,18 +410,12 @@ class ApplicationController < ActionController::Base ...@@ -410,18 +410,12 @@ class ApplicationController < ActionController::Base
def set_default_sort def set_default_sort
controller_name = params[:controller].sub(/Controller\Z/, '').underscore controller_name = params[:controller].sub(/Controller\Z/, '').underscore
cookie_suffix = "_sort_#{controller_name}" cookie_suffix = "_sort_#{controller_name}"
key = if @project key = "#{(@project || @group || current_user).cookie_key}#{cookie_suffix}"
"#{@project.cookie_key}#{cookie_suffix}"
elsif @group cookies[key] ||= 'id_desc'
"#{@group.cookie_key}#{cookie_suffix}" cookies[key] = params[:sort] if params[:sort].present?
else
"#{current_user.cookie_key}#{cookie_suffix}"
end
cookies[key] ||= 'id_desc'
cookies[key] = params[:sort] if params[:sort].present?
params[:sort] = cookies[key] params[:sort] = cookies[key]
end end
end end
...@@ -41,3 +41,19 @@ Feature: Dashboard ...@@ -41,3 +41,19 @@ Feature: Dashboard
And user with name "John Doe" left project "Shop" And user with name "John Doe" left project "Shop"
When I visit dashboard activity page When I visit dashboard activity page
Then I should see "John Doe left project Shop" event 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"
...@@ -59,6 +59,14 @@ Feature: Project Issues ...@@ -59,6 +59,14 @@ Feature: Project Issues
And I sort the list by "Last updated" And I sort the list by "Last updated"
Then I should see "Release 0.4" at the top 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 @javascript
Scenario: I search issue Scenario: I search issue
Given I fill in issue search with "Re" Given I fill in issue search with "Re"
......
...@@ -84,6 +84,14 @@ Feature: Project Merge Requests ...@@ -84,6 +84,14 @@ Feature: Project Merge Requests
And I sort the list by "Last updated" And I sort the list by "Last updated"
Then I should see "Bug NS-04" at the top 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 @javascript
Scenario: Visiting Merge Requests after commenting on diffs Scenario: Visiting Merge Requests after commenting on diffs
Given project "Shop" have "Bug NS-05" open merge request with diffs inside Given project "Shop" have "Bug NS-05" open merge request with diffs inside
......
...@@ -2,6 +2,7 @@ class Spinach::Features::Dashboard < Spinach::FeatureSteps ...@@ -2,6 +2,7 @@ class Spinach::Features::Dashboard < Spinach::FeatureSteps
include SharedAuthentication include SharedAuthentication
include SharedPaths include SharedPaths
include SharedProject include SharedProject
include SharedIssuable
step 'I should see "New Project" link' do step 'I should see "New Project" link' do
expect(page).to have_link "New project" expect(page).to have_link "New project"
......
...@@ -106,6 +106,19 @@ module SharedIssuable ...@@ -106,6 +106,19 @@ module SharedIssuable
edit_issuable edit_issuable
end 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) def create_issuable_for_project(project_name:, title:, type: :issue)
project = Project.find_by(name: project_name) project = Project.find_by(name: project_name)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment