Set maximum number of documents on proposal and budget investments. Show alert on documents tab when maximum reached. Hide upload button when maximum reached.

This commit is contained in:
Senén Rodero Rodríguez
2017-07-21 18:44:33 +02:00
parent 462931845b
commit 6b61cbe35c
10 changed files with 46 additions and 6 deletions

View File

@@ -25,6 +25,15 @@ shared_examples "documentable" do |documentable_factory_name, documentable_path,
end
end
scenario "Should not display upload document button when maximum number of documents reached " do
create_list(:document, 3, documentable: documentable)
visit send(documentable_path, arguments)
within "##{dom_id(documentable)}" do
expect(page).not_to have_link("Upload document")
end
end
scenario "Should display upload document button when user is logged in and is documentable owner" do
login_as(user)
@@ -58,6 +67,15 @@ shared_examples "documentable" do |documentable_factory_name, documentable_path,
let!(:document) { create(:document, documentable: documentable, user: documentable.author)}
scenario "Should display maximum number of documents alert when reached" do
create_list(:document, 2, documentable: documentable)
visit send(documentable_path, arguments)
within "#tab-documents" do
expect(page).to have_content "You have reached the maximum number of documents allowed! You have to delete one before you can upload another."
end
end
describe "Download action" do
scenario "Should be able to anyone" do