diff --git a/spec/shared/system/nested_imageable.rb b/spec/shared/system/nested_imageable.rb index 123a54425..d039fdfe4 100644 --- a/spec/shared/system/nested_imageable.rb +++ b/spec/shared/system/nested_imageable.rb @@ -252,59 +252,3 @@ shared_examples "nested imageable" do |imageable_factory_name, path, imageable_p end end end - -def do_login_for(user) - common_do_login_for(user, management: management) -end - -def imageable_redirected_to_resource_show_or_navigate_to - case imageable.class.to_s - when "Budget" - visit edit_admin_budget_path(Budget.last) - when "Proposal" - click_on "Not now, go to my proposal" rescue Capybara::ElementNotFound - end -end - -def imageable_attach_new_file(path, success = true) - click_link "Add image" - within "#nested-image" do - image = find(".image") - attach_file "Choose image", path - within image do - if success - expect(page).to have_css(".loading-bar.complete") - else - expect(page).to have_css(".loading-bar.errors") - end - end - end -end - -def imageable_fill_new_valid_proposal - fill_in_new_proposal_title with: "Proposal title" - fill_in "Proposal summary", with: "Proposal summary" - check :proposal_terms_of_service -end - -def imageable_fill_new_valid_budget - fill_in "Name", with: "Budget name" -end - -def imageable_fill_new_valid_budget_investment - fill_in_new_investment_title with: "Budget investment title" - fill_in_ckeditor "Description", with: "Budget investment description" - check :budget_investment_terms_of_service -end - -def expect_image_has_title(title) - image = find(".image") - - within image do - expect(find("input[name$='[title]']").value).to eq title - end -end - -def show_caption_for?(imageable_factory_name) - imageable_factory_name != "budget" -end diff --git a/spec/support/common_actions.rb b/spec/support/common_actions.rb index 8085637d8..623829431 100644 --- a/spec/support/common_actions.rb +++ b/spec/support/common_actions.rb @@ -6,6 +6,7 @@ module CommonActions include Debates include Documents include Emails + include Images include Maps include Notifications include Polls diff --git a/spec/support/common_actions/images.rb b/spec/support/common_actions/images.rb new file mode 100644 index 000000000..b5fd9430b --- /dev/null +++ b/spec/support/common_actions/images.rb @@ -0,0 +1,57 @@ +module Images + def do_login_for(user) + common_do_login_for(user, management: management) + end + + def imageable_redirected_to_resource_show_or_navigate_to + case imageable.class.to_s + when "Budget" + visit edit_admin_budget_path(Budget.last) + when "Proposal" + click_on "Not now, go to my proposal" rescue Capybara::ElementNotFound + end + end + + def imageable_attach_new_file(path, success = true) + click_link "Add image" + within "#nested-image" do + image = find(".image") + attach_file "Choose image", path + within image do + if success + expect(page).to have_css(".loading-bar.complete") + else + expect(page).to have_css(".loading-bar.errors") + end + end + end + end + + def imageable_fill_new_valid_proposal + fill_in_new_proposal_title with: "Proposal title" + fill_in "Proposal summary", with: "Proposal summary" + check :proposal_terms_of_service + end + + def imageable_fill_new_valid_budget + fill_in "Name", with: "Budget name" + end + + def imageable_fill_new_valid_budget_investment + fill_in_new_investment_title with: "Budget investment title" + fill_in_ckeditor "Description", with: "Budget investment description" + check :budget_investment_terms_of_service + end + + def expect_image_has_title(title) + image = find(".image") + + within image do + expect(find("input[name$='[title]']").value).to eq title + end + end + + def show_caption_for?(imageable_factory_name) + imageable_factory_name != "budget" + end +end