Merge pull request #3131 from consul/documents-title

[Backport] Documents title
This commit is contained in:
Alberto
2018-12-27 13:13:45 +01:00
committed by GitHub
2 changed files with 34 additions and 7 deletions

View File

@@ -1,9 +1,9 @@
<div id="documents" class="documents"> <% if documents.any? %>
<div id="documents" class="documents">
<h2><%= t("documents.title") %>&nbsp;<span>(<%= documents.count %>)</span></h2> <h2><%= t("documents.title") %>&nbsp;<span>(<%= documents.count %>)</span></h2>
<% if documents.any? %>
<ul class="no-bullet document-link"> <ul class="no-bullet document-link">
<%= render partial: "documents/document", collection: documents %> <%= render partial: "documents/document", collection: documents %>
</ul> </ul>
<% end %> </div>
</div> <% end %>

View File

@@ -68,6 +68,33 @@ shared_examples "documentable" do |documentable_factory_name,
end end
describe "When allow attached documents setting is enabled" do
before do
Setting['feature.allow_attached_documents'] = true
end
after do
Setting['feature.allow_attached_documents'] = false
end
scenario "Documents list should be available" do
login_as(user)
visit send(documentable_path, arguments)
expect(page).to have_css("#documents")
expect(page).to have_content("Documents (1)")
end
scenario "Documents list increase documents number" do
create(:document, documentable: documentable, user: documentable.author)
login_as(user)
visit send(documentable_path, arguments)
expect(page).to have_css("#documents")
expect(page).to have_content("Documents (2)")
end
end
describe "When allow attached documents setting is disabled" do describe "When allow attached documents setting is disabled" do
before do before do
Setting['feature.allow_attached_documents'] = false Setting['feature.allow_attached_documents'] = false
@@ -101,7 +128,7 @@ shared_examples "documentable" do |documentable_factory_name,
expect(page).to have_content "Document was deleted successfully." expect(page).to have_content "Document was deleted successfully."
end end
scenario "Should update documents tab count after successful deletion" do scenario "Should hide documents tab if there is no documents" do
login_as documentable.author login_as documentable.author
visit send(documentable_path, arguments) visit send(documentable_path, arguments)
@@ -110,7 +137,7 @@ shared_examples "documentable" do |documentable_factory_name,
click_on "Destroy document" click_on "Destroy document"
end end
expect(page).to have_content "Documents (0)" expect(page).not_to have_content "Documents (0)"
end end
scenario "Should redirect to documentable path after successful deletion" do scenario "Should redirect to documentable path after successful deletion" do