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.
26 lines
886 B
Ruby
26 lines
886 B
Ruby
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
|