Add sorting options for Admin::BudgetInvestments (#2336)

This commit is contained in:
Angel Perez
2018-01-24 12:54:08 -04:00
parent d30d2b0dd8
commit e04dc5b8f2
7 changed files with 65 additions and 1 deletions

View File

@@ -359,6 +359,36 @@ feature 'Admin budget investments' do
end
end
context 'Sorting' do
background do
@budget = create(:budget)
@investment_1 = create(:budget_investment, title: "BBBB", cached_votes_up: 50, budget: @budget)
@investment_2 = create(:budget_investment, title: "AAAA", cached_votes_up: 25, budget: @budget)
@investment_3 = create(:budget_investment, title: "CCCC", cached_votes_up: 10, budget: @budget)
end
scenario 'Sort by ID' do
visit admin_budget_budget_investments_path(@budget, sort_by: 'id')
expect(@investment_1.title).to appear_before(@investment_2.title)
expect(@investment_2.title).to appear_before(@investment_3.title)
end
scenario 'Sort by title' do
visit admin_budget_budget_investments_path(@budget, sort_by: 'title')
expect(@investment_2.title).to appear_before(@investment_1.title)
expect(@investment_1.title).to appear_before(@investment_3.title)
end
scenario 'Sort by supports' do
visit admin_budget_budget_investments_path(@budget, sort_by: 'supports')
expect(@investment_3.title).to appear_before(@investment_2.title)
expect(@investment_2.title).to appear_before(@investment_1.title)
end
end
context 'Show' do
background do
@administrator = create(:administrator, user: create(:user, username: 'Ana', email: 'ana@admins.org'))