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.
36 lines
918 B
Ruby
36 lines
918 B
Ruby
require "rails_helper"
|
|
|
|
describe "Documents", :admin do
|
|
context "Index" do
|
|
scenario "Answer with no documents" do
|
|
answer = create(:poll_question_answer)
|
|
document = create(:document)
|
|
|
|
visit admin_answer_documents_path(answer)
|
|
|
|
expect(page).not_to have_content(document.title)
|
|
end
|
|
|
|
scenario "Answer with documents" do
|
|
answer = create(:poll_question_answer)
|
|
document = create(:document, documentable: answer)
|
|
|
|
visit admin_answer_documents_path(answer)
|
|
|
|
expect(page).to have_content(document.title)
|
|
end
|
|
end
|
|
|
|
scenario "Remove document from answer" do
|
|
answer = create(:poll_question_answer)
|
|
document = create(:document, documentable: answer)
|
|
|
|
visit admin_answer_documents_path(answer)
|
|
expect(page).to have_content(document.title)
|
|
|
|
accept_confirm { click_link "Delete" }
|
|
|
|
expect(page).not_to have_content(document.title)
|
|
end
|
|
end
|