Don't allow to modify answer's documents for started polls
This commit is contained in:
committed by
Javi Martín
parent
245594f32b
commit
4c8f247de7
@@ -0,0 +1,19 @@
|
||||
require "rails_helper"
|
||||
|
||||
describe Admin::Poll::Questions::Answers::Documents::IndexComponent do
|
||||
before { sign_in(create(:administrator).user) }
|
||||
let(:future_answer) { create(:poll_question_answer, poll: create(:poll, :future)) }
|
||||
let(:current_answer) { create(:poll_question_answer, poll: create(:poll)) }
|
||||
|
||||
it "displays the 'Add new document' link when the poll has not started" do
|
||||
render_inline Admin::Poll::Questions::Answers::Documents::IndexComponent.new(future_answer)
|
||||
|
||||
expect(page).to have_link "Add new document"
|
||||
end
|
||||
|
||||
it "does not display the 'Add new document' link when the poll has started" do
|
||||
render_inline Admin::Poll::Questions::Answers::Documents::IndexComponent.new(current_answer)
|
||||
|
||||
expect(page).not_to have_link "Add new document"
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,27 @@
|
||||
require "rails_helper"
|
||||
|
||||
describe Admin::Poll::Questions::Answers::Documents::TableActionsComponent, controller: Admin::BaseController do
|
||||
before { sign_in(create(:administrator).user) }
|
||||
let(:future_answer) { create(:poll_question_answer, poll: create(:poll, :future)) }
|
||||
let(:current_answer) { create(:poll_question_answer, poll: create(:poll)) }
|
||||
|
||||
it "displays the destroy action when the poll has not started" do
|
||||
document = create(:document, documentable: future_answer)
|
||||
|
||||
render_inline Admin::Poll::Questions::Answers::Documents::TableActionsComponent.new(document)
|
||||
|
||||
expect(page).to have_link "Download file"
|
||||
expect(page).to have_button "Delete"
|
||||
expect(page).not_to have_link "Edit"
|
||||
end
|
||||
|
||||
it "does not display the destroy action when the poll has started" do
|
||||
document = create(:document, documentable: current_answer)
|
||||
|
||||
render_inline Admin::Poll::Questions::Answers::Documents::TableActionsComponent.new(document)
|
||||
|
||||
expect(page).to have_link "Download file"
|
||||
expect(page).not_to have_button "Delete"
|
||||
expect(page).not_to have_link "Edit"
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user