Merge branch 'master' into dashboard
This commit is contained in:
@@ -1,63 +1,69 @@
|
||||
require 'rails_helper'
|
||||
require "rails_helper"
|
||||
|
||||
feature 'Answers' do
|
||||
feature "Answers" do
|
||||
|
||||
background do
|
||||
admin = create(:administrator)
|
||||
login_as admin.user
|
||||
end
|
||||
|
||||
scenario 'Create' do
|
||||
it_behaves_like "translatable",
|
||||
"poll_question_answer",
|
||||
"edit_admin_answer_path",
|
||||
%w[title],
|
||||
{ "description" => :ckeditor }
|
||||
|
||||
scenario "Create" do
|
||||
question = create(:poll_question)
|
||||
title = 'Whatever the question may be, the answer is always 42'
|
||||
title = "Whatever the question may be, the answer is always 42"
|
||||
description = "The Hitchhiker's Guide To The Universe"
|
||||
|
||||
visit admin_question_path(question)
|
||||
click_link 'Add answer'
|
||||
click_link "Add answer"
|
||||
|
||||
fill_in 'poll_question_answer_title_en', with: title
|
||||
fill_in 'poll_question_answer_description_en', with: description
|
||||
fill_in "Answer", with: title
|
||||
fill_in "Description", with: description
|
||||
|
||||
click_button 'Save'
|
||||
click_button "Save"
|
||||
|
||||
expect(page).to have_content(title)
|
||||
expect(page).to have_content(description)
|
||||
end
|
||||
|
||||
scenario 'Create second answer and place after the first one' do
|
||||
scenario "Create second answer and place after the first one" do
|
||||
question = create(:poll_question)
|
||||
answer = create(:poll_question_answer, title: 'First', question: question, given_order: 1)
|
||||
title = 'Second'
|
||||
answer = create(:poll_question_answer, title: "First", question: question, given_order: 1)
|
||||
title = "Second"
|
||||
description = "Description"
|
||||
|
||||
visit admin_question_path(question)
|
||||
click_link 'Add answer'
|
||||
click_link "Add answer"
|
||||
|
||||
fill_in 'poll_question_answer_title_en', with: title
|
||||
fill_in 'poll_question_answer_description_en', with: description
|
||||
fill_in "Answer", with: title
|
||||
fill_in "Description", with: description
|
||||
|
||||
click_button 'Save'
|
||||
click_button "Save"
|
||||
|
||||
expect(page.body.index('First')).to be < page.body.index('Second')
|
||||
expect(page.body.index("First")).to be < page.body.index("Second")
|
||||
end
|
||||
|
||||
scenario 'Update' do
|
||||
scenario "Update" do
|
||||
question = create(:poll_question)
|
||||
answer = create(:poll_question_answer, question: question, title: "Answer title", given_order: 2)
|
||||
answer2 = create(:poll_question_answer, question: question, title: "Another title", given_order: 1)
|
||||
|
||||
visit admin_answer_path(answer)
|
||||
|
||||
click_link 'Edit answer'
|
||||
click_link "Edit answer"
|
||||
|
||||
old_title = answer.title
|
||||
new_title = 'Ex Machina'
|
||||
new_title = "Ex Machina"
|
||||
|
||||
fill_in 'poll_question_answer_title_en', with: new_title
|
||||
fill_in "Answer", with: new_title
|
||||
|
||||
click_button 'Save'
|
||||
click_button "Save"
|
||||
|
||||
expect(page).to have_content('Changes saved')
|
||||
expect(page).to have_content("Changes saved")
|
||||
expect(page).to have_content(new_title)
|
||||
|
||||
visit admin_question_path(question)
|
||||
|
||||
@@ -0,0 +1,44 @@
|
||||
require "rails_helper"
|
||||
|
||||
feature "Documents" do
|
||||
|
||||
background do
|
||||
admin = create(:administrator)
|
||||
login_as(admin.user)
|
||||
end
|
||||
|
||||
context "Index" do
|
||||
scenario "Answer with no documents" do
|
||||
answer = create(:poll_question_answer, question: create(:poll_question))
|
||||
document = create(:document)
|
||||
|
||||
visit admin_answer_documents_path(answer)
|
||||
|
||||
expect(page).not_to have_content(document.title)
|
||||
end
|
||||
|
||||
scenario "Answer with documents" do
|
||||
answer = create(:poll_question_answer, question: create(:poll_question))
|
||||
document = create(:document, documentable: answer)
|
||||
|
||||
visit admin_answer_documents_path(answer)
|
||||
|
||||
expect(page).to have_content(document.title)
|
||||
end
|
||||
end
|
||||
|
||||
scenario "Remove document from answer", :js do
|
||||
answer = create(:poll_question_answer, question: create(:poll_question))
|
||||
document = create(:document, documentable: answer)
|
||||
|
||||
visit admin_answer_documents_path(answer)
|
||||
expect(page).to have_content(document.title)
|
||||
|
||||
accept_confirm "Are you sure?" do
|
||||
click_link "Delete"
|
||||
end
|
||||
|
||||
expect(page).not_to have_content(document.title)
|
||||
end
|
||||
|
||||
end
|
||||
@@ -1,23 +1,23 @@
|
||||
require 'rails_helper'
|
||||
require "rails_helper"
|
||||
|
||||
feature 'Images' do
|
||||
feature "Images" do
|
||||
|
||||
background do
|
||||
admin = create(:administrator)
|
||||
login_as(admin.user)
|
||||
end
|
||||
|
||||
context 'Index' do
|
||||
scenario 'Answer with no images' do
|
||||
context "Index" do
|
||||
scenario "Answer with no images" do
|
||||
answer = create(:poll_question_answer,
|
||||
question: create(:poll_question))
|
||||
|
||||
visit admin_answer_images_path(answer)
|
||||
|
||||
expect(page).to_not have_css("img[title='']")
|
||||
expect(page).not_to have_css("img[title='']")
|
||||
end
|
||||
|
||||
scenario 'Answer with images' do
|
||||
scenario "Answer with images" do
|
||||
answer = create(:poll_question_answer,
|
||||
question: create(:poll_question))
|
||||
image = create(:image, imageable: answer)
|
||||
@@ -29,24 +29,24 @@ feature 'Images' do
|
||||
end
|
||||
end
|
||||
|
||||
scenario 'Add image to answer', :js do
|
||||
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')
|
||||
expect(page).not_to have_css("img[title='clippy.jpg']")
|
||||
expect(page).not_to have_content("clippy.jpg")
|
||||
|
||||
visit new_admin_answer_image_path(answer)
|
||||
imageable_attach_new_file(image, Rails.root.join('spec/fixtures/files/clippy.jpg'))
|
||||
click_button 'Save image'
|
||||
imageable_attach_new_file(image, Rails.root.join("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')
|
||||
expect(page).to have_content("clippy.jpg")
|
||||
end
|
||||
|
||||
scenario 'Remove image from answer', :js do
|
||||
scenario "Remove image from answer", :js do
|
||||
answer = create(:poll_question_answer,
|
||||
question: create(:poll_question))
|
||||
image = create(:image, imageable: answer)
|
||||
@@ -55,12 +55,12 @@ feature 'Images' do
|
||||
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'
|
||||
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)
|
||||
expect(page).not_to have_css("img[title='#{image.title}']")
|
||||
expect(page).not_to have_content(image.title)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
require 'rails_helper'
|
||||
require "rails_helper"
|
||||
|
||||
feature 'Videos' do
|
||||
feature "Videos" do
|
||||
|
||||
background do
|
||||
admin = create(:administrator)
|
||||
@@ -21,8 +21,8 @@ feature 'Videos' do
|
||||
|
||||
click_link "Add video"
|
||||
|
||||
fill_in 'poll_question_answer_video_title', with: video_title
|
||||
fill_in 'poll_question_answer_video_url', with: video_url
|
||||
fill_in "poll_question_answer_video_title", with: video_title
|
||||
fill_in "poll_question_answer_video_url", with: video_url
|
||||
|
||||
click_button "Save"
|
||||
|
||||
|
||||
Reference in New Issue
Block a user