diff --git a/spec/support/common_actions.rb b/spec/support/common_actions.rb index b12fe944c..07586dd5e 100644 --- a/spec/support/common_actions.rb +++ b/spec/support/common_actions.rb @@ -2,14 +2,13 @@ Dir["./spec/support/common_actions/*.rb"].each { |f| require f } Dir["./spec/support/common_actions/custom/*.rb"].each { |f| require f } module CommonActions + include Attachables include Budgets include Comments include Cookies include Debates - include Documents include Emails include GraphQLAPI - include Images include Maps include Notifications include Polls diff --git a/spec/support/common_actions/attachables.rb b/spec/support/common_actions/attachables.rb new file mode 100644 index 000000000..c6df4f705 --- /dev/null +++ b/spec/support/common_actions/attachables.rb @@ -0,0 +1,31 @@ +module Attachables + def imageable_attach_new_file(path, success: true) + click_link "Add image" + within "#nested-image" do + image = find(".image-fields") + 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 documentable_attach_new_file(path, success: true) + click_link "Add new document" + + document = all(".document-fields").last + attach_file "Choose document", path + + within document do + if success + expect(page).to have_css ".loading-bar.complete" + else + expect(page).to have_css ".loading-bar.errors" + end + end + end +end diff --git a/spec/support/common_actions/documents.rb b/spec/support/common_actions/documents.rb deleted file mode 100644 index e26cf5756..000000000 --- a/spec/support/common_actions/documents.rb +++ /dev/null @@ -1,16 +0,0 @@ -module Documents - def documentable_attach_new_file(path, success = true) - click_link "Add new document" - - document = all(".document-fields").last - attach_file "Choose document", path - - within document do - if success - expect(page).to have_css ".loading-bar.complete" - else - expect(page).to have_css ".loading-bar.errors" - end - end - end -end diff --git a/spec/support/common_actions/images.rb b/spec/support/common_actions/images.rb deleted file mode 100644 index df59a48cb..000000000 --- a/spec/support/common_actions/images.rb +++ /dev/null @@ -1,16 +0,0 @@ -module Images - def imageable_attach_new_file(path, success = true) - click_link "Add image" - within "#nested-image" do - image = find(".image-fields") - 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 -end diff --git a/spec/system/nested_documentable_spec.rb b/spec/system/nested_documentable_spec.rb index 19642ac15..283e2fc5c 100644 --- a/spec/system/nested_documentable_spec.rb +++ b/spec/system/nested_documentable_spec.rb @@ -162,7 +162,7 @@ describe "Nested documentable" do do_login_for(user, management: management_section?) visit path - documentable_attach_new_file(file_fixture("logo_header.gif"), false) + documentable_attach_new_file(file_fixture("logo_header.gif"), success: false) expect(page).to have_css ".loading-bar.errors" end @@ -186,7 +186,7 @@ describe "Nested documentable" do do_login_for(user, management: management_section?) visit path - documentable_attach_new_file(file_fixture("logo_header.gif"), false) + documentable_attach_new_file(file_fixture("logo_header.gif"), success: false) cached_attachment_field = find("input[name$='[cached_attachment]']", visible: :hidden) expect(cached_attachment_field.value).to be_empty diff --git a/spec/system/nested_imageable_spec.rb b/spec/system/nested_imageable_spec.rb index 3cf048407..072ba42d8 100644 --- a/spec/system/nested_imageable_spec.rb +++ b/spec/system/nested_imageable_spec.rb @@ -96,7 +96,7 @@ describe "Nested imageable" do end scenario "Should not update image cached_attachment field after invalid file upload" do - imageable_attach_new_file(file_fixture("logo_header.png"), false) + imageable_attach_new_file(file_fixture("logo_header.png"), success: false) cached_attachment_field = find("input[name$='[cached_attachment]']", visible: :hidden)