Unify tests in order to remove duplicated code

Note that we are removing a specific "context" that can be replaced
with an "if" in the previous spec.
This commit is contained in:
taitus
2025-05-16 14:43:11 +02:00
parent b7025a8135
commit 28e9832c40

View File

@@ -169,37 +169,6 @@ describe "Nested documentable" do
end end
scenario "Should show successful notice when resource filled correctly and after valid file uploads" do scenario "Should show successful notice when resource filled correctly and after valid file uploads" do
do_login_for(user, management: management_section?(path))
visit path
fill_in_required_fields(factory, path)
documentable_attach_new_file(file_fixture("empty.pdf"))
click_button submit_button_text
expect(page).to have_content notice_text
end
context "Budget investments and proposals" do
let(:factory) { (factories - [:dashboard_action]).sample }
scenario "Should show new document after successful creation with one uploaded file" do
do_login_for(user, management: management_section?(path))
visit path
fill_in_required_fields(factory, path)
documentable_attach_new_file(file_fixture("empty.pdf"))
click_button submit_button_text
expect(page).to have_content notice_text
expect(page).to have_content "Documents"
expect(page).to have_link text: "empty.pdf"
expect(page).to have_link href: /.pdf\Z/
end
scenario "Should show resource with new document after successful creation with
maximum allowed uploaded files" do
Setting["uploads.documents.max_amount"] = 3 Setting["uploads.documents.max_amount"] = 3
do_login_for(user, management: management_section?(path)) do_login_for(user, management: management_section?(path))
visit path visit path
@@ -221,7 +190,12 @@ describe "Nested documentable" do
click_button submit_button_text click_button submit_button_text
expect(page).to have_content notice_text expect(page).to have_content notice_text
if factory != :dashboard_action
expect(page).to have_content "Documents (3)" expect(page).to have_content "Documents (3)"
expect(page).to have_link href: /.pdf\Z/, count: 3
expect(page).to have_link text: "clippy.pdf"
expect(page).to have_link text: "empty.pdf"
expect(page).to have_link text: "logo.pdf"
end end
end end
end end