Refactor sorting specs to work with direction
This commit is contained in:
committed by
Javi Martín
parent
747b8295b1
commit
0affaaee7e
@@ -603,7 +603,7 @@ feature 'Admin budget investments' do
|
||||
create(:budget_investment, title: 'C Third Investment', cached_votes_up: 10, budget: budget)
|
||||
end
|
||||
|
||||
scenario "Default sorting" do
|
||||
scenario "Default" do
|
||||
create(:budget_investment, title: 'D Fourth Investment', cached_votes_up: 50, budget: budget)
|
||||
|
||||
visit admin_budget_budget_investments_path(budget)
|
||||
@@ -613,12 +613,59 @@ feature 'Admin budget investments' do
|
||||
expect('A Second Investment').to appear_before('C Third Investment')
|
||||
end
|
||||
|
||||
context 'Ascending' do
|
||||
scenario 'Sort by ID' do
|
||||
visit admin_budget_budget_investments_path(budget, sort_by: 'id')
|
||||
visit admin_budget_budget_investments_path(budget, sort_by: 'id', direction: 'asc')
|
||||
|
||||
expect('B First Investment').to appear_before('A Second Investment')
|
||||
expect('A Second Investment').to appear_before('C Third Investment')
|
||||
end
|
||||
|
||||
scenario 'Sort by title' do
|
||||
visit admin_budget_budget_investments_path(budget, sort_by: 'title', direction: 'asc')
|
||||
|
||||
expect('A Second Investment').to appear_before('B First Investment')
|
||||
expect('B First Investment').to appear_before('C Third Investment')
|
||||
end
|
||||
|
||||
scenario 'Sort by supports' do
|
||||
visit admin_budget_budget_investments_path(budget, sort_by: 'supports', direction: 'asc')
|
||||
|
||||
expect('C Third Investment').to appear_before('A Second Investment')
|
||||
expect('A Second Investment').to appear_before('B First Investment')
|
||||
end
|
||||
end
|
||||
|
||||
context 'Descending' do
|
||||
scenario 'Sort by ID' do
|
||||
visit admin_budget_budget_investments_path(budget, sort_by: 'id', direction: 'desc')
|
||||
|
||||
expect('C Third Investment').to appear_before('A Second Investment')
|
||||
expect('A Second Investment').to appear_before('B First Investment')
|
||||
end
|
||||
|
||||
scenario 'Sort by title' do
|
||||
visit admin_budget_budget_investments_path(budget, sort_by: 'title', direction: 'desc')
|
||||
|
||||
expect('C Third Investment').to appear_before('B First Investment')
|
||||
expect('B First Investment').to appear_before('A Second Investment')
|
||||
end
|
||||
|
||||
scenario 'Sort by supports' do
|
||||
visit admin_budget_budget_investments_path(budget, sort_by: 'supports', direction: 'desc')
|
||||
|
||||
expect('B First Investment').to appear_before('A Second Investment')
|
||||
expect('A Second Investment').to appear_before('C Third Investment')
|
||||
end
|
||||
end
|
||||
|
||||
context 'With no direction provided sorts ascending' do
|
||||
scenario 'Sort by ID' do
|
||||
visit admin_budget_budget_investments_path(budget, sort_by: 'id')
|
||||
|
||||
expect('B First Investment').to appear_before('A Second Investment')
|
||||
expect('A Second Investment').to appear_before('C Third Investment')
|
||||
end
|
||||
|
||||
scenario 'Sort by title' do
|
||||
visit admin_budget_budget_investments_path(budget, sort_by: 'title')
|
||||
@@ -630,11 +677,14 @@ feature 'Admin budget investments' do
|
||||
scenario 'Sort by supports' do
|
||||
visit admin_budget_budget_investments_path(budget, sort_by: 'supports')
|
||||
|
||||
expect('B First Investment').to appear_before('A Second Investment')
|
||||
expect('A Second Investment').to appear_before('C Third Investment')
|
||||
expect('C Third Investment').to appear_before('A Second Investment')
|
||||
expect('A Second Investment').to appear_before('B First Investment')
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
end
|
||||
|
||||
context 'Show' do
|
||||
|
||||
scenario 'Show the investment details' do
|
||||
|
||||
Reference in New Issue
Block a user