adds admin search/add/remove question to poll

This commit is contained in:
Juanjo Bazán
2016-12-26 16:19:35 +01:00
parent 8b4f519d71
commit f0156c5b5a
13 changed files with 177 additions and 6 deletions

View File

@@ -165,4 +165,81 @@ feature 'Admin polls' do
end
end
context "Questions" do
context "Poll show" do
scenario "Question list", :js do
poll = create(:poll)
question = create(:poll_question, poll: poll)
other_question = create(:poll_question)
visit admin_poll_path(poll)
click_link "Questions (1)"
expect(page).to have_content question.title
expect(page).to_not have_content other_question.title
expect(page).to_not have_content "There are no questions assigned to this poll"
end
scenario 'Add question to poll', :js do
poll = create(:poll)
question = create(:poll_question, poll: nil, title: 'Should we rebuild the city?')
visit admin_poll_path(poll)
within('#poll-resources') do
click_link 'Questions (0)'
end
expect(page).to have_content 'There are no questions assigned to this poll'
fill_in 'search-questions', with: 'rebuild'
click_button 'Search'
within('#search-questions-results') do
click_link 'Include question'
end
expect(page).to have_content 'Question added to this poll'
visit admin_poll_path(poll)
within('#poll-resources') do
click_link 'Questions (1)'
end
expect(page).to_not have_content 'There are no questions assigned to this poll'
expect(page).to have_content question.title
end
scenario 'Remove question from poll', :js do
poll = create(:poll)
question = create(:poll_question, poll: poll)
visit admin_poll_path(poll)
within('#poll-resources') do
click_link 'Questions (1)'
end
expect(page).to_not have_content 'There are no questions assigned to this poll'
expect(page).to have_content question.title
within("#poll_question_#{question.id}") do
click_link 'Remove question from poll'
end
expect(page).to have_content 'Question removed from this poll'
visit admin_poll_path(poll)
within('#poll-resources') do
click_link 'Questions (0)'
end
expect(page).to have_content 'There are no questions assigned to this poll'
expect(page).to_not have_content question.title
end
end
end
end