Skip to content

Commit

Permalink
Use existing delegation to avoid demeter violations
Browse files Browse the repository at this point in the history
  • Loading branch information
pixeltrix committed Oct 9, 2024
1 parent 79260db commit 8c5f4e9
Show file tree
Hide file tree
Showing 7 changed files with 12 additions and 12 deletions.
2 changes: 1 addition & 1 deletion app/controllers/documents_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def create
@document = @planning_application.documents.build(document_params)

if @document.save
flash[:notice] = "#{@document.file.filename} has been uploaded."
flash[:notice] = "#{@document.name} has been uploaded."
redirect_to planning_application_documents_path
else
render :new
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ json.extract!(
)

json.documents additional_document_validation_request.additional_documents do |document|
json.name document.file.filename
json.name document.name
json.url document.file.representation(resize_to_limit: [1000, 1000]).processed.url
json.extract! document
end
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@ json.extract! replacement_document_validation_request,
:cancelled_at

json.old_document do
json.name replacement_document_validation_request.old_document.file.filename
json.name replacement_document_validation_request.old_document.name
json.invalid_document_reason replacement_document_validation_request.invalidated_document_reason
json.url replacement_document_validation_request.old_document.image_url
end

json.new_document do
if replacement_document_validation_request.new_document
json.name replacement_document_validation_request.new_document.file.filename
json.name replacement_document_validation_request.new_document.name
json.url replacement_document_validation_request.new_document.image_url
end
end
6 changes: 3 additions & 3 deletions app/views/api/v1/validation_requests/index.json.jbuilder
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,13 @@ json.data do
:cancel_reason,
:cancelled_at
json.old_document do
json.name replacement_document_validation_request.old_document.file.filename
json.name replacement_document_validation_request.old_document.name
json.invalid_document_reason replacement_document_validation_request.invalidated_document_reason
end

json.new_document do
if replacement_document_validation_request.new_document
json.name replacement_document_validation_request.new_document.file.filename
json.name replacement_document_validation_request.new_document.name
json.url replacement_document_validation_request
.new_document.file.representation(resize_to_limit: [1000, 1000]).processed.url
end
Expand All @@ -70,7 +70,7 @@ json.data do
:cancelled_at

json.documents additional_document_validation_request.additional_documents do |document|
json.name document.file.filename
json.name document.name
json.url document.file.representation(resize_to_limit: [1000, 1000]).processed.url
json.extract! document
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
<tbody class="govuk-table__body">
<% @documents.each do |document| %>
<%= content_tag(:tr, id: dom_id(document)) do %>
<td class="govuk-table__cell"><%= document.numbers.presence || document.file.filename %></td>
<td class="govuk-table__cell"><%= document.numbers.presence || document.name %></td>
<td class="govuk-table__cell">
<% if document.tags.present? %>
<% document.tags.each do |tag| %>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,18 +84,18 @@

within("#document_#{document_with_reference.id}") do
expect(page).to have_content(document_with_reference.numbers)
expect(page).not_to have_content(document_with_reference.file.filename)
expect(page).not_to have_content(document_with_reference.name)
expect(page).to have_content("No tags added")
end

within("#document_#{document_with_reference_and_tags.id}") do
expect(page).to have_content(document_with_reference_and_tags.numbers)
expect(page).not_to have_content(document_with_reference_and_tags.file.filename)
expect(page).not_to have_content(document_with_reference_and_tags.name)
expect(page).to have_content("Elevations - proposed Photographs - proposed")
end

within("#document_#{document_without_reference.id}") do
expect(page).to have_content(document_without_reference.file.filename)
expect(page).to have_content(document_without_reference.name)
end
end

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@
)

document = planning_application.documents.last
expect(document.file.filename.to_s).to eq("proposed-roofplan.png")
expect(document.name).to eq("proposed-roofplan.png")
expect(document.redacted).to be(true)
end
end
Expand Down

0 comments on commit 8c5f4e9

Please sign in to comment.