Merge branch 'master' into iagirre-remove-documents-questions

This commit is contained in:
Raimond Garcia
2017-10-06 01:02:56 +02:00
committed by GitHub
29 changed files with 294 additions and 186 deletions

View File

@@ -1,21 +1,23 @@
shared_examples "nested imageable" do |imageable_factory_name, path, imageable_path_arguments, fill_resource_method_name, submit_button, imageable_success_notice|
shared_examples "nested imageable" do |imageable_factory_name, path, imageable_path_arguments, fill_resource_method_name, submit_button, imageable_success_notice, has_many_images=false|
include ActionView::Helpers
include ImagesHelper
include ImageablesHelper
let!(:administrator) { create(:user) }
let!(:user) { create(:user, :level_two) }
let!(:administrator) { create(:administrator, user: user) }
let!(:arguments) { {} }
let!(:imageable) { create(imageable_factory_name, author: user) }
let!(:imageable) { create(imageable_factory_name) }
before do
create(:administrator, user: administrator)
if imageable_path_arguments
imageable_path_arguments.each do |argument_name, path_to_value|
arguments.merge!("#{argument_name}": imageable.send(path_to_value))
end
end
if imageable.respond_to?(:author)
imageable.update(author: user)
end
end
describe "at #{path}" do
@@ -66,7 +68,11 @@ shared_examples "nested imageable" do |imageable_factory_name, path, imageable_p
image_input = find(".image").find("input[type=file]", visible: false)
attach_file(image_input[:id], "spec/fixtures/files/clippy.jpg", make_visible: true)
expect(find("##{imageable_factory_name}_image_attributes_title").value).to eq "Title"
if has_many_images
expect(find("input[id$='_title']").value).to eq "Title"
else
expect(find("##{imageable_factory_name}_image_attributes_title").value).to eq "Title"
end
end
scenario "Should update loading bar style after valid file upload", :js do
@@ -78,7 +84,7 @@ shared_examples "nested imageable" do |imageable_factory_name, path, imageable_p
expect(page).to have_selector ".loading-bar.complete"
end
scenario "Should update loading bar style after unvalid file upload", :js do
scenario "Should update loading bar style after invalid file upload", :js do
login_as user
visit send(path, arguments)
@@ -112,8 +118,12 @@ shared_examples "nested imageable" do |imageable_factory_name, path, imageable_p
click_link "Add image"
click_on submit_button
within "#nested-image .image" do
expect(page).to have_content("can't be blank", count: 2)
if has_many_images
#Pending. Review soon and test
else
within "#nested-image .image" do
expect(page).to have_content("can't be blank", count: 2)
end
end
end
@@ -159,8 +169,12 @@ shared_examples "nested imageable" do |imageable_factory_name, path, imageable_p
click_on submit_button
imageable_redirected_to_resource_show_or_navigate_to
expect(page).to have_selector "figure img"
expect(page).to have_selector "figure figcaption"
if has_many_images
#Pending. Review soon and test
else
expect(page).to have_selector "figure img"
expect(page).to have_selector "figure figcaption"
end
end
if path.include? "edit"