Files
nairobi/spec/system/admin/poll/questions/answers/documents/documents_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

36 lines
923 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", :js 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