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.
This commit is contained in:
@@ -2,9 +2,8 @@ module Attachables
|
|||||||
def imageable_attach_new_file(path, success: true)
|
def imageable_attach_new_file(path, success: true)
|
||||||
click_link "Add image"
|
click_link "Add image"
|
||||||
within "#nested-image" do
|
within "#nested-image" do
|
||||||
image = find(".image-fields")
|
|
||||||
attach_file "Choose image", path
|
attach_file "Choose image", path
|
||||||
within image do
|
within ".image-fields" do
|
||||||
if success
|
if success
|
||||||
expect(page).to have_css(".loading-bar.complete")
|
expect(page).to have_css(".loading-bar.complete")
|
||||||
else
|
else
|
||||||
@@ -16,11 +15,9 @@ module Attachables
|
|||||||
|
|
||||||
def documentable_attach_new_file(path, success: true)
|
def documentable_attach_new_file(path, success: true)
|
||||||
click_link "Add new document"
|
click_link "Add new document"
|
||||||
|
|
||||||
document = all(".document-fields").last
|
|
||||||
attach_file "Choose document", path
|
attach_file "Choose document", path
|
||||||
|
|
||||||
within document do
|
within ".document-fields" do
|
||||||
if success
|
if success
|
||||||
expect(page).to have_css ".loading-bar.complete"
|
expect(page).to have_css ".loading-bar.complete"
|
||||||
else
|
else
|
||||||
|
|||||||
@@ -53,6 +53,7 @@ describe "Nested documentable" do
|
|||||||
context "New and edit path" do
|
context "New and edit path" do
|
||||||
describe "When allow attached documents setting is enabled" do
|
describe "When allow attached documents setting is enabled" do
|
||||||
before do
|
before do
|
||||||
|
Setting["uploads.documents.max_amount"] = 1
|
||||||
create(:administrator, user: user) if admin_section?(path)
|
create(:administrator, user: user) if admin_section?(path)
|
||||||
documentable.update!(author: user) if edit_path?(path)
|
documentable.update!(author: user) if edit_path?(path)
|
||||||
end
|
end
|
||||||
@@ -69,9 +70,7 @@ describe "Nested documentable" do
|
|||||||
do_login_for(user, management: management_section?(path))
|
do_login_for(user, management: management_section?(path))
|
||||||
visit path
|
visit path
|
||||||
|
|
||||||
documentable.class.max_documents_allowed.times.each do
|
click_link "Add new document"
|
||||||
click_link "Add new document"
|
|
||||||
end
|
|
||||||
|
|
||||||
expect(page).not_to have_css "#new_document_link"
|
expect(page).not_to have_css "#new_document_link"
|
||||||
end
|
end
|
||||||
@@ -87,9 +86,7 @@ describe "Nested documentable" do
|
|||||||
do_login_for(user, management: management_section?(path))
|
do_login_for(user, management: management_section?(path))
|
||||||
visit path
|
visit path
|
||||||
|
|
||||||
documentable.class.max_documents_allowed.times.each do
|
documentable_attach_new_file(file_fixture("empty.pdf"))
|
||||||
documentable_attach_new_file(file_fixture("empty.pdf"))
|
|
||||||
end
|
|
||||||
|
|
||||||
expect(page).to have_css ".max-documents-notice"
|
expect(page).to have_css ".max-documents-notice"
|
||||||
expect(page).to have_content "Remove document"
|
expect(page).to have_content "Remove document"
|
||||||
@@ -99,9 +96,7 @@ describe "Nested documentable" do
|
|||||||
do_login_for(user, management: management_section?(path))
|
do_login_for(user, management: management_section?(path))
|
||||||
visit path
|
visit path
|
||||||
|
|
||||||
documentable.class.max_documents_allowed.times.each do
|
click_link "Add new document"
|
||||||
click_link "Add new document"
|
|
||||||
end
|
|
||||||
|
|
||||||
all("a", text: "Cancel").last.click
|
all("a", text: "Cancel").last.click
|
||||||
|
|
||||||
@@ -259,13 +254,20 @@ describe "Nested documentable" do
|
|||||||
|
|
||||||
scenario "Should show resource with new document after successful creation with
|
scenario "Should show resource with new document after successful creation with
|
||||||
maximum allowed uploaded files" do
|
maximum allowed uploaded files" do
|
||||||
|
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
|
||||||
|
|
||||||
fill_in_required_fields(factory, path)
|
fill_in_required_fields(factory, path)
|
||||||
|
|
||||||
%w[clippy empty logo].take(documentable.class.max_documents_allowed).each do |filename|
|
%w[clippy empty logo].each do |filename|
|
||||||
documentable_attach_new_file(file_fixture("#{filename}.pdf"))
|
click_link "Add new document"
|
||||||
|
|
||||||
|
attach_file "Choose document", file_fixture("#{filename}.pdf")
|
||||||
|
|
||||||
|
within all(".document-fields").last do
|
||||||
|
expect(page).to have_css ".loading-bar.complete"
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
expect(page).not_to have_link "Add new document"
|
expect(page).not_to have_link "Add new document"
|
||||||
@@ -273,7 +275,7 @@ 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
|
||||||
expect(page).to have_content "Documents (#{documentable.class.max_documents_allowed})"
|
expect(page).to have_content "Documents (3)"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user