Files
grecia/spec/features/admin/proposals_spec.rb
Javi Martín 307cf24846 Use describe on feature tests
The `type: :feature` is automatically detected by RSpec because these
tests are inside the `spec/features` folder. Using `feature` re-adds a
`type: :feature` to these files, which will result in a conflict when we
upgrade to Rails 5.1's system tests.

Because of this change, we also need to change `background` to `before`
or else these tests will fail.
2019-05-28 16:36:54 +02:00

60 lines
1.7 KiB
Ruby

require "rails_helper"
describe "Admin proposals" do
before do
login_as create(:administrator).user
end
it_behaves_like "admin_milestoneable",
:proposal,
"admin_proposal_path"
context "Index" do
scenario "Search" do
create(:proposal, title: "Make Pluto a planet again")
create(:proposal, title: "Build a monument to honour CONSUL developers")
visit admin_root_path
within("#side_menu") { click_link "Proposals" }
expect(page).to have_content "Make Pluto a planet again"
expect(page).to have_content "Build a monument"
fill_in "search", with: "Pluto"
click_button "Search"
expect(page).to have_content "Make Pluto a planet again"
expect(page).not_to have_content "Build a monument"
end
end
context "Show" do
scenario "View proposal" do
create(:proposal, title: "Create a chaotic future", summary: "Chaos isn't controlled")
visit admin_proposals_path
click_link "Create a chaotic future"
expect(page).to have_content "Chaos isn't controlled"
expect(page).not_to have_content "This proposal has reached the required supports"
expect(page).not_to have_link "Create question"
end
scenario "Successful proposals show create question button" do
successful_proposals = create_successful_proposals
admin = create(:administrator)
login_as(admin.user)
visit admin_proposals_path
successful_proposals.each do |proposal|
visit admin_proposal_path(proposal)
expect(page).to have_content "This proposal has reached the required supports"
expect(page).to have_link "Add this proposal to a poll to be voted"
end
end
end
end