Don't allow to modify questions for started polls
Adding, modifiying, and/or deleting questions for an already started poll is far away from being democratic and can lead to unwanted side effects like missing votes in the results or stats. So, from now on, only modifiying questions will be possible only if the poll has not started yet.
This commit is contained in:
committed by
Javi Martín
parent
d499a6944e
commit
8a26954bc5
@@ -0,0 +1,25 @@
|
||||
require "rails_helper"
|
||||
|
||||
describe Admin::Poll::Questions::TableActionsComponent, controller: Admin::BaseController do
|
||||
before { sign_in(create(:administrator).user) }
|
||||
|
||||
it "displays the edit and destroy actions when the poll has not started" do
|
||||
question = create(:poll_question, poll: create(:poll, :future))
|
||||
|
||||
render_inline Admin::Poll::Questions::TableActionsComponent.new(question)
|
||||
|
||||
expect(page).to have_link "Edit answers"
|
||||
expect(page).to have_link "Edit"
|
||||
expect(page).to have_button "Delete"
|
||||
end
|
||||
|
||||
it "does not display the edit and destroy actions when the poll has started" do
|
||||
question = create(:poll_question, poll: create(:poll))
|
||||
|
||||
render_inline Admin::Poll::Questions::TableActionsComponent.new(question)
|
||||
|
||||
expect(page).to have_link "Edit answers"
|
||||
expect(page).not_to have_link "Edit"
|
||||
expect(page).not_to have_button "Delete"
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user