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)
|
create(:budget_investment, title: 'C Third Investment', cached_votes_up: 10, budget: budget)
|
||||||
end
|
end
|
||||||
|
|
||||||
scenario "Default sorting" do
|
scenario "Default" do
|
||||||
create(:budget_investment, title: 'D Fourth Investment', cached_votes_up: 50, budget: budget)
|
create(:budget_investment, title: 'D Fourth Investment', cached_votes_up: 50, budget: budget)
|
||||||
|
|
||||||
visit admin_budget_budget_investments_path(budget)
|
visit admin_budget_budget_investments_path(budget)
|
||||||
@@ -613,26 +613,76 @@ feature 'Admin budget investments' do
|
|||||||
expect('A Second Investment').to appear_before('C Third Investment')
|
expect('A Second Investment').to appear_before('C Third Investment')
|
||||||
end
|
end
|
||||||
|
|
||||||
scenario 'Sort by ID' do
|
context 'Ascending' do
|
||||||
visit admin_budget_budget_investments_path(budget, sort_by: 'id')
|
scenario 'Sort by ID' do
|
||||||
|
visit admin_budget_budget_investments_path(budget, sort_by: 'id', direction: 'asc')
|
||||||
|
|
||||||
expect('C Third Investment').to appear_before('A Second Investment')
|
expect('B First Investment').to appear_before('A Second Investment')
|
||||||
expect('A Second Investment').to appear_before('B First 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
|
end
|
||||||
|
|
||||||
scenario 'Sort by title' do
|
context 'Descending' do
|
||||||
visit admin_budget_budget_investments_path(budget, sort_by: 'title')
|
scenario 'Sort by ID' do
|
||||||
|
visit admin_budget_budget_investments_path(budget, sort_by: 'id', direction: 'desc')
|
||||||
|
|
||||||
expect('A Second Investment').to appear_before('B First Investment')
|
expect('C Third Investment').to appear_before('A Second Investment')
|
||||||
expect('B First Investment').to appear_before('C Third 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
|
end
|
||||||
|
|
||||||
scenario 'Sort by supports' do
|
context 'With no direction provided sorts ascending' do
|
||||||
visit admin_budget_budget_investments_path(budget, sort_by: 'supports')
|
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('B First Investment').to appear_before('A Second Investment')
|
||||||
expect('A Second Investment').to appear_before('C Third 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')
|
||||||
|
|
||||||
|
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')
|
||||||
|
|
||||||
|
expect('C Third Investment').to appear_before('A Second Investment')
|
||||||
|
expect('A Second Investment').to appear_before('B First Investment')
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'Show' do
|
context 'Show' do
|
||||||
|
|||||||
Reference in New Issue
Block a user