Remove duplicated code in imageable and documentable attach file methods
This commit is contained in:
@@ -1,23 +1,18 @@
|
|||||||
module Attachables
|
module Attachables
|
||||||
def imageable_attach_new_file(path, success: true)
|
def imageable_attach_new_file(path, success: true)
|
||||||
click_link "Add image"
|
attach_new_file("Add image", "nested-image", "image", "Choose image", path, success)
|
||||||
within "#nested-image" do
|
|
||||||
attach_file "Choose image", path
|
|
||||||
within ".image-fields" 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
|
||||||
|
|
||||||
def documentable_attach_new_file(path, success: true)
|
def documentable_attach_new_file(path, success: true)
|
||||||
click_link "Add new document"
|
attach_new_file("Add new document", "nested-documents", "document", "Choose document", path, success)
|
||||||
within "#nested-documents" do
|
end
|
||||||
attach_file "Choose document", path
|
|
||||||
within ".document-fields" do
|
def attach_new_file(link_text, wrapper_id, field_class, input_label, path, success)
|
||||||
|
click_link link_text
|
||||||
|
|
||||||
|
within "##{wrapper_id}" do
|
||||||
|
attach_file input_label, path
|
||||||
|
within ".#{field_class}-fields" do
|
||||||
if success
|
if success
|
||||||
expect(page).to have_css ".loading-bar.complete"
|
expect(page).to have_css ".loading-bar.complete"
|
||||||
else
|
else
|
||||||
|
|||||||
Reference in New Issue
Block a user