@@ -89,6 +89,10 @@ a {
|
||||
&.warning:hover {
|
||||
color: #000;
|
||||
}
|
||||
|
||||
&.medium {
|
||||
font-size: $small-font-size;
|
||||
}
|
||||
}
|
||||
|
||||
.button.hollow {
|
||||
@@ -2314,61 +2318,48 @@ table {
|
||||
// 20. Documents
|
||||
// -------------
|
||||
|
||||
.documents-list {
|
||||
.documents {
|
||||
|
||||
table {
|
||||
border: 0;
|
||||
h2 {
|
||||
font-size: rem-calc(24);
|
||||
|
||||
span {
|
||||
color: #4f4f4f;
|
||||
font-weight: normal;
|
||||
}
|
||||
}
|
||||
|
||||
td {
|
||||
ul li {
|
||||
padding-top: $line-height / 2;
|
||||
|
||||
&:not(:first-child) {
|
||||
border-top: 1px solid $highlight;
|
||||
}
|
||||
}
|
||||
|
||||
.document-link {
|
||||
background: $highlight-soft;
|
||||
border: 2px solid $highlight;
|
||||
border-radius: rem-calc(5);
|
||||
display: block;
|
||||
margin: $line-height / 2 0;
|
||||
padding: 0 $line-height / 2;
|
||||
position: relative;
|
||||
|
||||
@include breakpoint(small) {
|
||||
float: left;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
@include breakpoint(medium) {
|
||||
float: none;
|
||||
}
|
||||
|
||||
a {
|
||||
width: 100%;
|
||||
word-wrap: break-word;
|
||||
}
|
||||
|
||||
&:first-child {
|
||||
padding-left: $line-height * 1.5;
|
||||
|
||||
@include breakpoint(small) {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
@include breakpoint(medium) {
|
||||
width: 70%;
|
||||
}
|
||||
|
||||
@include breakpoint(large) {
|
||||
width: 80%;
|
||||
}
|
||||
}
|
||||
|
||||
&:first-child::before {
|
||||
.icon-document {
|
||||
color: #007bb7;
|
||||
content: 'G';
|
||||
font-family: "icons" !important;
|
||||
display: inline-block;
|
||||
font-size: rem-calc(24);
|
||||
left: rem-calc(6);
|
||||
position: absolute;
|
||||
top: 0;
|
||||
|
||||
@include breakpoint(small) {
|
||||
padding-top: rem-calc(12);
|
||||
}
|
||||
|
||||
@include breakpoint(medium) {
|
||||
padding-top: rem-calc(22);
|
||||
}
|
||||
line-height: $line-height;
|
||||
vertical-align: middle;
|
||||
}
|
||||
|
||||
p {
|
||||
margin-bottom: 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -457,7 +457,6 @@
|
||||
line-height: rem-calc(30);
|
||||
}
|
||||
|
||||
.document-link,
|
||||
.video-link {
|
||||
background: $highlight-soft;
|
||||
border: 1px solid $highlight;
|
||||
@@ -470,21 +469,14 @@
|
||||
word-wrap: break-word;
|
||||
}
|
||||
|
||||
[class^="icon-"] {
|
||||
.icon-video {
|
||||
color: #cc181e;
|
||||
display: inline-block;
|
||||
font-size: rem-calc(24);
|
||||
line-height: $line-height;
|
||||
vertical-align: middle;
|
||||
}
|
||||
|
||||
.icon-document {
|
||||
color: #007bb7;
|
||||
}
|
||||
|
||||
.icon-video {
|
||||
color: #cc181e;
|
||||
}
|
||||
|
||||
p {
|
||||
margin-bottom: 0;
|
||||
}
|
||||
|
||||
@@ -17,14 +17,6 @@
|
||||
</h3>
|
||||
<% end %>
|
||||
</li>
|
||||
<li class="tabs-title">
|
||||
<%= link_to "#tab-documents" do %>
|
||||
<h3>
|
||||
<%= t("documents.tab") %>
|
||||
(<%= @investment.documents.count %>)
|
||||
</h3>
|
||||
<% end %>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -51,6 +51,10 @@
|
||||
</p>
|
||||
<% end %>
|
||||
|
||||
<%= render 'documents/documents',
|
||||
documents: investment.documents,
|
||||
max_documents_allowed: Budget::Investment.max_documents_allowed %>
|
||||
|
||||
<%= render 'shared/tags', taggable: investment %>
|
||||
|
||||
<% if investment.external_url.present? %>
|
||||
|
||||
@@ -19,11 +19,4 @@
|
||||
comment_flags: @comment_flags,
|
||||
display_comments_count: false } %>
|
||||
</div>
|
||||
|
||||
<div class="tabs-panel" id="tab-documents">
|
||||
<%= render 'documents/documents',
|
||||
documents: @investment.documents,
|
||||
max_documents_allowed: Budget::Investment.max_documents_allowed %>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
@@ -1,24 +1,20 @@
|
||||
<table>
|
||||
<tbody>
|
||||
<tr id="<%= dom_id(document)%>">
|
||||
<td class="document-link">
|
||||
<%= document.title %>
|
||||
</td>
|
||||
<td class="text-center">
|
||||
<%= link_to t('documents.buttons.download_document'),
|
||||
document.attachment.url,
|
||||
target: "_blank",
|
||||
rel: "nofollow",
|
||||
class: 'button hollow' %>
|
||||
</td>
|
||||
<td class="text-center">
|
||||
<% if can?(:destroy, document) %>
|
||||
<%= link_to t('documents.buttons.destroy_document'),
|
||||
document_path(document, from: request.url), method: :delete,
|
||||
data: { confirm: t('documents.actions.destroy.confirm') },
|
||||
class: 'button hollow alert' %>
|
||||
<% end %>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<li id="<%= dom_id(document)%>">
|
||||
<%= link_to t("documents.buttons.download_document"),
|
||||
document.attachment.url, target: "_blank",
|
||||
rel: "nofollow", class: "button hollow medium float-right" %>
|
||||
|
||||
<strong><%= document.title %></strong>
|
||||
<br>
|
||||
<small>
|
||||
<%= document.humanized_content_type %> |
|
||||
<%= number_to_human_size(document.attachment_file_size, precision: 2) %>
|
||||
</small>
|
||||
|
||||
<% if can?(:destroy, document) %>
|
||||
<br>
|
||||
<%= link_to t("documents.buttons.destroy_document"),
|
||||
document_path(document, from: request.url), method: :delete,
|
||||
data: { confirm: t("documents.actions.destroy.confirm") },
|
||||
class: "delete" %>
|
||||
<% end %>
|
||||
</li>
|
||||
|
||||
@@ -1,11 +1,9 @@
|
||||
<div class="row <% 'documents-list' if documents.any? %>">
|
||||
<div class="small-12 column">
|
||||
<% if documents.any? %>
|
||||
<div class="documents">
|
||||
<h2><%= t("documents.title") %> <span>(<%= documents.count %>)</span></h2>
|
||||
|
||||
<% if documents.any? %>
|
||||
<ul class="no-bullet document-link">
|
||||
<%= render partial: "documents/document", collection: documents %>
|
||||
<% else %>
|
||||
<div class="callout primary text-center">
|
||||
<%= t('documents.no_documents') %>
|
||||
</div>
|
||||
<% end %>
|
||||
</div>
|
||||
</ul>
|
||||
<% end %>
|
||||
</div>
|
||||
|
||||
@@ -9,14 +9,6 @@
|
||||
</h3>
|
||||
<% end %>
|
||||
</li>
|
||||
<li class="tabs-title">
|
||||
<%= link_to "#tab-documents" do %>
|
||||
<h3>
|
||||
<%= t("documents.tab") %>
|
||||
(<%= @proposal.documents.count %>)
|
||||
</h3>
|
||||
<% end %>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -80,6 +80,10 @@
|
||||
|
||||
<h4><%= @proposal.question %></h4>
|
||||
|
||||
<%= render 'documents/documents',
|
||||
documents: @proposal.documents,
|
||||
max_documents_allowed: Proposal.max_documents_allowed %>
|
||||
|
||||
<%= render 'shared/tags', taggable: @proposal %>
|
||||
|
||||
<%= render 'shared/geozone', geozonable: @proposal %>
|
||||
@@ -112,10 +116,4 @@
|
||||
<div class="tabs-panel is-active" id="tab-comments">
|
||||
<%= render "legislation/proposals/comments" %>
|
||||
</div>
|
||||
|
||||
<div class="tabs-panel" id="tab-documents">
|
||||
<%= render 'documents/documents',
|
||||
documents: @proposal.documents,
|
||||
max_documents_allowed: Proposal.max_documents_allowed %>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -17,14 +17,6 @@
|
||||
</h3>
|
||||
<% end %>
|
||||
</li>
|
||||
<li class="tabs-title">
|
||||
<%= link_to "#tab-documents" do %>
|
||||
<h3>
|
||||
<%= t("documents.tab") %>
|
||||
(<%= @proposal.documents.count %>)
|
||||
</h3>
|
||||
<% end %>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -106,6 +106,10 @@
|
||||
</div>
|
||||
<% end %>
|
||||
|
||||
<%= render 'documents/documents',
|
||||
documents: @proposal.documents,
|
||||
max_documents_allowed: Proposal.max_documents_allowed %>
|
||||
|
||||
<%= render 'shared/tags', taggable: @proposal %>
|
||||
|
||||
<%= render 'shared/geozone', geozonable: @proposal %>
|
||||
@@ -206,10 +210,4 @@
|
||||
<div class="tabs-panel is-active" id="tab-comments">
|
||||
<%= render "proposals/comments" %>
|
||||
</div>
|
||||
|
||||
<div class="tabs-panel" id="tab-documents">
|
||||
<%= render 'documents/documents',
|
||||
documents: @proposal.documents,
|
||||
max_documents_allowed: Proposal.max_documents_allowed %>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
en:
|
||||
documents:
|
||||
tab: Documents
|
||||
no_documents: Don't have uploaded documents
|
||||
title: Documents
|
||||
max_documents_allowed_reached_html: You have reached the maximum number of documents allowed! <strong>You have to delete one before you can upload another.</strong>
|
||||
form:
|
||||
title: Documents
|
||||
@@ -17,7 +16,7 @@ en:
|
||||
confirm: Are you sure you want to delete the document? This action cannot be undone!
|
||||
buttons:
|
||||
download_document: Download file
|
||||
destroy_document: Destroy
|
||||
destroy_document: Destroy document
|
||||
errors:
|
||||
messages:
|
||||
in_between: must be in between %{min} and %{max}
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
es:
|
||||
documents:
|
||||
tab: Documentos
|
||||
no_documents: No hay documentos subidos
|
||||
title: Documentos
|
||||
max_documents_allowed_reached_html: '¡Has alcanzado el número máximo de documentos permitidos! <strong>Tienes que eliminar uno antes de poder subir otro.</strong>'
|
||||
form:
|
||||
title: Documentos
|
||||
@@ -17,7 +16,7 @@ es:
|
||||
confirm: '¿Está seguro de que desea eliminar el documento? Esta acción no se puede deshacer!'
|
||||
buttons:
|
||||
download_document: Descargar archivo
|
||||
destroy_document: Eliminar
|
||||
destroy_document: Eliminar documento
|
||||
errors:
|
||||
messages:
|
||||
in_between: debe estar entre %{min} y %{max}
|
||||
|
||||
@@ -1,11 +1,13 @@
|
||||
shared_examples "documentable" do |documentable_factory_name, documentable_path, documentable_path_arguments|
|
||||
shared_examples "documentable" do |documentable_factory_name,
|
||||
documentable_path,
|
||||
documentable_path_arguments|
|
||||
include ActionView::Helpers
|
||||
|
||||
let(:administrator) { create(:user) }
|
||||
let(:user) { create(:user) }
|
||||
let(:arguments) { {} }
|
||||
let(:documentable) { create(documentable_factory_name, author: user) }
|
||||
let!(:document) { create(:document, documentable: documentable, user: documentable.author) }
|
||||
let(:administrator) { create(:user) }
|
||||
let(:user) { create(:user) }
|
||||
let(:arguments) { {} }
|
||||
let(:documentable) { create(documentable_factory_name, author: user) }
|
||||
let!(:document) { create(:document, documentable: documentable, user: documentable.author) }
|
||||
|
||||
before do
|
||||
create(:administrator, user: administrator)
|
||||
@@ -15,30 +17,24 @@ shared_examples "documentable" do |documentable_factory_name, documentable_path,
|
||||
end
|
||||
end
|
||||
|
||||
context "Show documents tab" do
|
||||
context "Show documents" do
|
||||
|
||||
scenario "Download action should be able to anyone" do
|
||||
visit send(documentable_path, arguments)
|
||||
|
||||
within "#tab-documents" do
|
||||
expect(page).to have_link("Download file")
|
||||
end
|
||||
expect(page).to have_link("Download file")
|
||||
end
|
||||
|
||||
scenario "Download file link should have blank target attribute" do
|
||||
visit send(documentable_path, arguments)
|
||||
|
||||
within "#tab-documents" do
|
||||
expect(page).to have_selector("a[target=_blank]", text: "Download file")
|
||||
end
|
||||
expect(page).to have_selector("a[target=_blank]", text: "Download file")
|
||||
end
|
||||
|
||||
scenario "Download file links should have rel attribute setted to no follow" do
|
||||
visit send(documentable_path, arguments)
|
||||
|
||||
within "#tab-documents" do
|
||||
expect(page).to have_selector("a[rel=nofollow]", text: "Download file")
|
||||
end
|
||||
expect(page).to have_selector("a[rel=nofollow]", text: "Download file")
|
||||
end
|
||||
|
||||
describe "Destroy action" do
|
||||
@@ -46,36 +42,28 @@ shared_examples "documentable" do |documentable_factory_name, documentable_path,
|
||||
scenario "Should not be able when no user logged in" do
|
||||
visit send(documentable_path, arguments)
|
||||
|
||||
within "#tab-documents" do
|
||||
expect(page).not_to have_link("Destroy")
|
||||
end
|
||||
expect(page).not_to have_link("Destroy document")
|
||||
end
|
||||
|
||||
scenario "Should be able when documentable author is logged in" do
|
||||
login_as documentable.author
|
||||
visit send(documentable_path, arguments)
|
||||
|
||||
within "#tab-documents" do
|
||||
expect(page).to have_link("Destroy")
|
||||
end
|
||||
expect(page).to have_link("Destroy document")
|
||||
end
|
||||
|
||||
scenario "Administrators cannot destroy documentables they have not authored" do
|
||||
login_as(administrator)
|
||||
visit send(documentable_path, arguments)
|
||||
|
||||
within "#tab-documents" do
|
||||
expect(page).not_to have_link("Destroy")
|
||||
end
|
||||
expect(page).not_to have_link("Destroy document")
|
||||
end
|
||||
|
||||
scenario "Users cannot destroy documentables they have not authored" do
|
||||
login_as(create(:user))
|
||||
visit send(documentable_path, arguments)
|
||||
|
||||
within "#tab-documents" do
|
||||
expect(page).not_to have_link("Destroy")
|
||||
end
|
||||
expect(page).not_to have_link("Destroy document")
|
||||
end
|
||||
|
||||
end
|
||||
@@ -88,10 +76,9 @@ shared_examples "documentable" do |documentable_factory_name, documentable_path,
|
||||
login_as documentable.author
|
||||
|
||||
visit send(documentable_path, arguments)
|
||||
within "#tab-documents" do
|
||||
within "#document_#{document.id}" do
|
||||
click_on "Destroy"
|
||||
end
|
||||
|
||||
within "#document_#{document.id}" do
|
||||
click_on "Destroy document"
|
||||
end
|
||||
|
||||
expect(page).to have_content "Document was deleted successfully."
|
||||
@@ -101,23 +88,21 @@ shared_examples "documentable" do |documentable_factory_name, documentable_path,
|
||||
login_as documentable.author
|
||||
|
||||
visit send(documentable_path, arguments)
|
||||
within "#tab-documents" do
|
||||
within "#document_#{document.id}" do
|
||||
click_on "Destroy"
|
||||
end
|
||||
|
||||
within "#document_#{document.id}" do
|
||||
click_on "Destroy document"
|
||||
end
|
||||
|
||||
expect(page).to have_link "Documents (0)"
|
||||
expect(page).to have_content "Documents (0)"
|
||||
end
|
||||
|
||||
scenario "Should redirect to documentable path after successful deletion" do
|
||||
login_as documentable.author
|
||||
|
||||
visit send(documentable_path, arguments)
|
||||
within "#tab-documents" do
|
||||
within "#document_#{document.id}" do
|
||||
click_on "Destroy"
|
||||
end
|
||||
|
||||
within "#document_#{document.id}" do
|
||||
click_on "Destroy document"
|
||||
end
|
||||
|
||||
within "##{dom_id(documentable)}" do
|
||||
|
||||
@@ -1,4 +1,7 @@
|
||||
shared_examples "nested documentable" do |login_as_name, documentable_factory_name, path, documentable_path_arguments, fill_resource_method_name, submit_button, documentable_success_notice|
|
||||
shared_examples "nested documentable" do |login_as_name, documentable_factory_name,
|
||||
path, documentable_path_arguments,
|
||||
fill_resource_method_name, submit_button,
|
||||
documentable_success_notice|
|
||||
include ActionView::Helpers
|
||||
include DocumentsHelper
|
||||
include DocumentablesHelper
|
||||
@@ -26,7 +29,8 @@ shared_examples "nested documentable" do |login_as_name, documentable_factory_na
|
||||
expect(page).to have_css "#new_document_link", visible: true
|
||||
end
|
||||
|
||||
scenario "Should not show new document link when documentable max documents allowed limit is reached", :js do
|
||||
scenario "Should not show new document link when
|
||||
documentable max documents allowed limit is reached", :js do
|
||||
login_as user_to_login
|
||||
visit send(path, arguments)
|
||||
|
||||
@@ -81,7 +85,8 @@ shared_examples "nested documentable" do |login_as_name, documentable_factory_na
|
||||
expect(page).to have_css ".file-name", text: "empty.pdf"
|
||||
end
|
||||
|
||||
scenario "Should update nested document file title with file name after choosing a file when no title defined", :js do
|
||||
scenario "Should update nested document file title with
|
||||
file name after choosing a file when no title defined", :js do
|
||||
login_as user_to_login
|
||||
visit send(path, arguments)
|
||||
|
||||
@@ -90,7 +95,8 @@ shared_examples "nested documentable" do |login_as_name, documentable_factory_na
|
||||
expect_document_has_title(0, "empty.pdf")
|
||||
end
|
||||
|
||||
scenario "Should not update nested document file title with file name after choosing a file when title already defined", :js do
|
||||
scenario "Should not update nested document file title with
|
||||
file name after choosing a file when title already defined", :js do
|
||||
login_as user_to_login
|
||||
visit send(path, arguments)
|
||||
|
||||
@@ -141,7 +147,8 @@ shared_examples "nested documentable" do |login_as_name, documentable_factory_na
|
||||
expect_document_has_cached_attachment(0, "")
|
||||
end
|
||||
|
||||
scenario "Should show document errors after documentable submit with empty document fields", :js do
|
||||
scenario "Should show document errors after documentable submit with
|
||||
empty document fields", :js do
|
||||
login_as user_to_login
|
||||
visit send(path, arguments)
|
||||
|
||||
@@ -163,7 +170,8 @@ shared_examples "nested documentable" do |login_as_name, documentable_factory_na
|
||||
expect(page).not_to have_css("#nested-documents .document")
|
||||
end
|
||||
|
||||
scenario "Should show successful notice when resource filled correctly without any nested documents", :js do
|
||||
scenario "Should show successful notice when
|
||||
resource filled correctly without any nested documents", :js do
|
||||
login_as user_to_login
|
||||
visit send(path, arguments)
|
||||
|
||||
@@ -173,7 +181,8 @@ shared_examples "nested documentable" do |login_as_name, documentable_factory_na
|
||||
expect(page).to have_content documentable_success_notice
|
||||
end
|
||||
|
||||
scenario "Should show successful notice when resource filled correctly and after valid file uploads", :js do
|
||||
scenario "Should show successful notice when
|
||||
resource filled correctly and after valid file uploads", :js do
|
||||
login_as user_to_login
|
||||
visit send(path, arguments)
|
||||
send(fill_resource_method_name) if fill_resource_method_name
|
||||
@@ -195,8 +204,6 @@ shared_examples "nested documentable" do |login_as_name, documentable_factory_na
|
||||
documentable_redirected_to_resource_show_or_navigate_to
|
||||
|
||||
expect(page).to have_content "Documents"
|
||||
|
||||
find("#tab-documents-label").click
|
||||
expect(page).to have_content "empty.pdf"
|
||||
|
||||
# Review
|
||||
@@ -204,13 +211,16 @@ shared_examples "nested documentable" do |login_as_name, documentable_factory_na
|
||||
expect(page).to have_css("a[href$='.pdf']")
|
||||
end
|
||||
|
||||
scenario "Should show resource with new document after successful creation with maximum allowed uploaded files", :js do
|
||||
scenario "Should show resource with new document after successful creation with
|
||||
maximum allowed uploaded files", :js do
|
||||
login_as user_to_login
|
||||
visit send(path, arguments)
|
||||
|
||||
send(fill_resource_method_name) if fill_resource_method_name
|
||||
|
||||
documentable.class.max_documents_allowed.times { documentable_attach_new_file(cycle(Dir.glob('spec/fixtures/files/*.pdf'))) }
|
||||
documentable.class.max_documents_allowed.times {
|
||||
documentable_attach_new_file(cycle(Dir.glob('spec/fixtures/files/*.pdf')))
|
||||
}
|
||||
|
||||
click_on submit_button
|
||||
documentable_redirected_to_resource_show_or_navigate_to
|
||||
@@ -228,7 +238,8 @@ shared_examples "nested documentable" do |login_as_name, documentable_factory_na
|
||||
expect(page).to have_css ".document", count: 1
|
||||
end
|
||||
|
||||
scenario "Should not show add document button when documentable has reached maximum of documents allowed", :js do
|
||||
scenario "Should not show add document button when
|
||||
documentable has reached maximum of documents allowed", :js do
|
||||
login_as user_to_login
|
||||
create_list(:document, documentable.class.max_documents_allowed, documentable: documentable)
|
||||
visit send(path, arguments)
|
||||
|
||||
Reference in New Issue
Block a user