Unify attachables methods
This commit is contained in:
@@ -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 }
|
Dir["./spec/support/common_actions/custom/*.rb"].each { |f| require f }
|
||||||
|
|
||||||
module CommonActions
|
module CommonActions
|
||||||
|
include Attachables
|
||||||
include Budgets
|
include Budgets
|
||||||
include Comments
|
include Comments
|
||||||
include Cookies
|
include Cookies
|
||||||
include Debates
|
include Debates
|
||||||
include Documents
|
|
||||||
include Emails
|
include Emails
|
||||||
include GraphQLAPI
|
include GraphQLAPI
|
||||||
include Images
|
|
||||||
include Maps
|
include Maps
|
||||||
include Notifications
|
include Notifications
|
||||||
include Polls
|
include Polls
|
||||||
|
|||||||
31
spec/support/common_actions/attachables.rb
Normal file
31
spec/support/common_actions/attachables.rb
Normal file
@@ -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
|
||||||
@@ -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
|
|
||||||
@@ -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
|
|
||||||
@@ -162,7 +162,7 @@ describe "Nested documentable" do
|
|||||||
do_login_for(user, management: management_section?)
|
do_login_for(user, management: management_section?)
|
||||||
visit path
|
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"
|
expect(page).to have_css ".loading-bar.errors"
|
||||||
end
|
end
|
||||||
@@ -186,7 +186,7 @@ describe "Nested documentable" do
|
|||||||
do_login_for(user, management: management_section?)
|
do_login_for(user, management: management_section?)
|
||||||
visit path
|
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)
|
cached_attachment_field = find("input[name$='[cached_attachment]']", visible: :hidden)
|
||||||
expect(cached_attachment_field.value).to be_empty
|
expect(cached_attachment_field.value).to be_empty
|
||||||
|
|||||||
@@ -96,7 +96,7 @@ describe "Nested imageable" do
|
|||||||
end
|
end
|
||||||
|
|
||||||
scenario "Should not update image cached_attachment field after invalid file upload" do
|
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)
|
cached_attachment_field = find("input[name$='[cached_attachment]']", visible: :hidden)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user