Adapt 'show' view for open questions without options
- Prevent creating options for open questions - Skip rendering the options table when none exist
This commit is contained in:
@@ -20,6 +20,8 @@ describe Abilities::Administrator do
|
||||
let(:future_poll) { create(:poll, :future) }
|
||||
let(:current_poll_question) { create(:poll_question) }
|
||||
let(:future_poll_question) { create(:poll_question, poll: future_poll) }
|
||||
let(:future_poll_question_open) { create(:poll_question_open, poll: future_poll) }
|
||||
let(:future_poll_question_option_open) { future_poll_question_open.question_options.new }
|
||||
let(:current_poll_question_option) { create(:poll_question_option) }
|
||||
let(:future_poll_question_option) { create(:poll_question_option, poll: future_poll) }
|
||||
let(:current_poll_option_video) { create(:poll_option_video, option: current_poll_question_option) }
|
||||
@@ -143,6 +145,9 @@ describe Abilities::Administrator do
|
||||
it { should_not be_able_to(:create, current_poll_question_option) }
|
||||
it { should_not be_able_to(:update, current_poll_question_option) }
|
||||
it { should_not be_able_to(:destroy, current_poll_question_option) }
|
||||
it { should_not be_able_to(:create, future_poll_question_option_open) }
|
||||
it { should_not be_able_to(:update, future_poll_question_option_open) }
|
||||
it { should_not be_able_to(:destroy, future_poll_question_option_open) }
|
||||
|
||||
it { should be_able_to(:create, future_poll_option_video) }
|
||||
it { should be_able_to(:update, future_poll_option_video) }
|
||||
|
||||
@@ -89,6 +89,8 @@ describe "Admin poll questions", :admin do
|
||||
expect(page).to have_content "Question with unique answer"
|
||||
expect(page).to have_content "Unique answer"
|
||||
expect(page).not_to have_content "Maximum number of votes"
|
||||
expect(page).to have_link "Add answer"
|
||||
expect(page).to have_table "Valid answers"
|
||||
end
|
||||
|
||||
scenario "Multiple" do
|
||||
@@ -106,6 +108,8 @@ describe "Admin poll questions", :admin do
|
||||
expect(page).to have_content "Question with multiple answers"
|
||||
expect(page).to have_content "Multiple answers"
|
||||
expect(page).to have_text "Maximum number of votes 6", normalize_ws: true
|
||||
expect(page).to have_link "Add answer"
|
||||
expect(page).to have_table "Valid answers"
|
||||
end
|
||||
|
||||
scenario "Open-ended" do
|
||||
@@ -122,6 +126,8 @@ describe "Admin poll questions", :admin do
|
||||
expect(page).to have_content "What do you want?"
|
||||
expect(page).to have_content "Open-ended"
|
||||
expect(page).not_to have_content "Maximum number of votes"
|
||||
expect(page).not_to have_link "Add answer"
|
||||
expect(page).not_to have_table "Valid answers"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user