Files
nairobi/spec/system/admin/poll/active_polls_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

38 lines
1.0 KiB
Ruby

require "rails_helper"
describe "Admin Active polls", :admin do
scenario "Add" 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" 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