adds spending proposals to admin

This commit is contained in:
Juanjo Bazán
2016-01-11 13:24:42 +01:00
committed by Juanjo Bazán
parent 7c92a92537
commit 3f05864a16
8 changed files with 198 additions and 0 deletions

View File

@@ -0,0 +1,100 @@
require 'rails_helper'
feature 'Admin spending proposals' do
background do
admin = create(:administrator)
login_as(admin.user)
end
scenario 'Index shows spending proposals' do
spending_proposal = create(:spending_proposal)
visit admin_spending_proposals_path
expect(page).to have_content(spending_proposal.title)
end
scenario 'Accept' do
spending_proposal = create(:spending_proposal)
visit admin_spending_proposals_path
click_link 'Accept'
expect(page).to_not have_content(spending_proposal.title)
click_link 'Accepted'
expect(page).to have_content(spending_proposal.title)
expect(spending_proposal.reload).to be_accepted
end
scenario 'Reject' do
spending_proposal = create(:spending_proposal)
visit admin_spending_proposals_path
click_link 'Reject'
expect(page).to_not have_content(spending_proposal.title)
click_link('Rejected')
expect(page).to have_content(spending_proposal.title)
expect(spending_proposal.reload).to be_rejected
end
scenario "Current filter is properly highlighted" do
visit admin_spending_proposals_path
expect(page).to_not have_link('Unresolved')
expect(page).to have_link('Accepted')
expect(page).to have_link('Rejected')
visit admin_spending_proposals_path(filter: 'unresolved')
expect(page).to_not have_link('Unresolved')
expect(page).to have_link('Accepted')
expect(page).to have_link('Rejected')
visit admin_spending_proposals_path(filter: 'accepted')
expect(page).to have_link('Unresolved')
expect(page).to_not have_link('Accepted')
expect(page).to have_link('Rejected')
visit admin_spending_proposals_path(filter: 'rejected')
expect(page).to have_link('Accepted')
expect(page).to have_link('Unresolved')
expect(page).to_not have_link('Rejected')
end
scenario "Filtering proposals" do
create(:spending_proposal, title: "Recent spending proposal")
create(:spending_proposal, title: "Good spending proposal", resolution: "accepted")
create(:spending_proposal, title: "Bad spending proposal", resolution: "rejected")
visit admin_spending_proposals_path(filter: 'unresolved')
expect(page).to have_content('Recent spending proposal')
expect(page).to_not have_content('Good spending proposal')
expect(page).to_not have_content('Bad spending proposal')
visit admin_spending_proposals_path(filter: 'accepted')
expect(page).to have_content('Good spending proposal')
expect(page).to_not have_content('Recent spending proposal')
expect(page).to_not have_content('Bad spending proposal')
visit admin_spending_proposals_path(filter: 'rejected')
expect(page).to have_content('Bad spending proposal')
expect(page).to_not have_content('Good spending proposal')
expect(page).to_not have_content('Recent spending proposal')
end
scenario "Action links remember the pagination setting and the filter" do
per_page = Kaminari.config.default_per_page
(per_page + 2).times { create(:spending_proposal, resolution: "accepted") }
visit admin_spending_proposals_path(filter: 'accepted', page: 2)
click_on('Reject', match: :first, exact: true)
expect(current_url).to include('filter=accepted')
expect(current_url).to include('page=2')
end
end