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

51 lines
1.3 KiB
Ruby

require "rails_helper"
describe "Admin Active polls" do
before do
admin = create(:administrator)
login_as(admin.user)
end
it_behaves_like "translatable",
"active_poll",
"edit_admin_active_polls_path",
[],
{ "description" => :ckeditor }
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