Files
nairobi/spec/system/admin/poll/active_polls_spec.rb
Javi Martín 3da4ee00b8 Simplify tests requiring admin login
We were repeating the same code over and over (with a few variants) to
setup tests which require an administrator. We can use a tag and
simplify the code.
2020-12-02 15:33:19 +01:00

38 lines
1.0 KiB
Ruby

require "rails_helper"
describe "Admin Active polls", :admin do
scenario "Add", :js do
expect(ActivePoll.first).to be nil
visit admin_polls_path
click_link "Polls description"
fill_in_ckeditor "Description", with: "Active polls description"
click_button "Save"
expect(page).to have_content "Polls description updated successfully."
expect(ActivePoll.first.description).to eq "<p>Active polls description</p>\r\n"
end
scenario "Edit", :js do
create(:active_poll, description_en: "Old description")
visit polls_path
within ".polls-description" do
expect(page).to have_content "Old description"
end
visit edit_admin_active_polls_path
fill_in_ckeditor "Description", with: "New description"
click_button "Save"
expect(page).to have_content "Polls description updated successfully."
visit polls_path
within ".polls-description" do
expect(page).not_to have_content "Old description"
expect(page).to have_content "New description"
end
end
end