Files
nairobi/spec/system/admin/poll/officers_spec.rb
Javi Martín 92ddcb7aef Use JavaScript in system tests by default
JavaScript is used by about 98% of web users, so by testing without it
enabled, we're only testing that the application works for a very
reduced number of users.

We proceeded this way in the past because CONSUL started using Rails 4.2
and truncating the database between JavaScript tests with database
cleaner, which made these tests terribly slow.

When we upgraded to Rails 5.1 and introduced system tests, we started
using database transactions in JavaScript tests, making these tests much
faster. So now we can use JavaScript tests everywhere without critically
slowing down our test suite.
2021-04-07 14:41:06 +02:00

34 lines
765 B
Ruby

require "rails_helper"
describe "Admin poll officers", :admin do
let!(:user) { create(:user, username: "Pedro Jose Garcia") }
let!(:officer) { create(:poll_officer) }
before do
visit admin_officers_path
end
scenario "Index" do
expect(page).to have_content officer.name
expect(page).to have_content officer.email
expect(page).not_to have_content user.name
end
scenario "Create" do
fill_in "search", with: user.email
click_button "Search"
expect(page).to have_content user.name
click_link "Add"
within("#officers") do
expect(page).to have_content user.name
end
end
scenario "Delete" do
accept_confirm { click_link "Delete position" }
expect(page).not_to have_css "#officers"
end
end