Merge pull request #2046 from wairbut-m2c/aperez-removable-admin-answer-images

Removable answer's associated images
This commit is contained in:
Alberto
2018-05-03 17:24:48 +02:00
committed by GitHub
5 changed files with 77 additions and 6 deletions

View File

@@ -7,8 +7,60 @@ feature 'Images' do
login_as(admin.user)
end
pending "Index"
pending "Create"
pending "Destroy"
context 'Index' do
scenario 'Answer with no images' do
answer = create(:poll_question_answer,
question: create(:poll_question))
end
visit admin_answer_images_path(answer)
expect(page).to_not have_css("img[title='']")
end
scenario 'Answer with images' do
answer = create(:poll_question_answer,
question: create(:poll_question))
image = create(:image, imageable: answer)
visit admin_answer_images_path(answer)
expect(page).to have_css("img[title='#{image.title}']")
expect(page).to have_content(image.title)
end
end
scenario 'Add image to answer', :js do
answer = create(:poll_question_answer,
question: create(:poll_question))
image = create(:image)
visit admin_answer_images_path(answer)
expect(page).to_not have_css("img[title='clippy.jpg']")
expect(page).to_not have_content('clippy.jpg')
visit new_admin_answer_image_path(answer)
imageable_attach_new_file(image, 'spec/fixtures/files/clippy.jpg')
click_button 'Save image'
expect(page).to have_css("img[title='clippy.jpg']")
expect(page).to have_content('clippy.jpg')
end
scenario 'Remove image from answer', :js do
answer = create(:poll_question_answer,
question: create(:poll_question))
image = create(:image, imageable: answer)
visit admin_answer_images_path(answer)
expect(page).to have_css("img[title='#{image.title}']")
expect(page).to have_content(image.title)
accept_confirm 'Are you sure?' do
click_link 'Remove image'
end
expect(page).to_not have_css("img[title='#{image.title}']")
expect(page).to_not have_content(image.title)
end
end