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.
36 lines
796 B
Ruby
36 lines
796 B
Ruby
require "rails_helper"
|
|
|
|
describe "Admin poll officers" do
|
|
|
|
before do
|
|
@admin = create(:administrator)
|
|
@user = create(:user, username: "Pedro Jose Garcia")
|
|
@officer = create(:poll_officer)
|
|
login_as(@admin.user)
|
|
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", :js do
|
|
fill_in "email", 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
|
|
click_link "Delete position"
|
|
|
|
expect(page).not_to have_css "#officers"
|
|
end
|
|
|
|
end |