Files
grecia/spec/support/common_actions/attachables.rb
taitus 82dac1225c Simplify tests by setting "max documents allowed" to 1
Note that this commit also applies a similar change to the
imageable_attach_new_file method by removing an unnecessary variable.

In order to testing with more than 1 max documents allowed we
keep one test with this value.
2025-06-06 17:18:15 +02:00

52 lines
1.2 KiB
Ruby

module Attachables
def imageable_attach_new_file(path, success: true)
click_link "Add image"
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
def documentable_attach_new_file(path, success: true)
click_link "Add new document"
attach_file "Choose document", path
within ".document-fields" do
if success
expect(page).to have_css ".loading-bar.complete"
else
expect(page).to have_css ".loading-bar.errors"
end
end
end
def admin_section?(path)
path.starts_with?("/admin/")
end
def management_section?(path)
path.starts_with?("/management/")
end
def edit_path?(path)
path.ends_with?("/edit")
end
def fill_in_required_fields(factory, path)
return if edit_path?(path)
case factory
when :budget then fill_in_budget
when :budget_investment then fill_in_budget_investment
when :dashboard_action then fill_in_dashboard_action
when :proposal then fill_in_proposal
end
end
end