diff --git a/spec/features/admin/budget_investments_spec.rb b/spec/features/admin/budget_investments_spec.rb index 7e5a6be03..fb3b2e5c9 100644 --- a/spec/features/admin/budget_investments_spec.rb +++ b/spec/features/admin/budget_investments_spec.rb @@ -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,26 +613,76 @@ feature 'Admin budget investments' do expect('A Second Investment').to appear_before('C Third Investment') end - scenario 'Sort by ID' do - visit admin_budget_budget_investments_path(budget, sort_by: 'id') + context 'Ascending' do + 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('A Second Investment').to appear_before('B First Investment') + 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 - scenario 'Sort by title' do - visit admin_budget_budget_investments_path(budget, sort_by: 'title') + context 'Descending' do + 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('B First 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 + + 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 - scenario 'Sort by supports' do - visit admin_budget_budget_investments_path(budget, sort_by: 'supports') + 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') + 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') + + 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 context 'Show' do