Skip to content

Commit

Permalink
Rename method to be a little clearer about what it is
Browse files Browse the repository at this point in the history
  • Loading branch information
mlandauer committed Oct 10, 2023
1 parent fa42957 commit 9a287e2
Show file tree
Hide file tree
Showing 10 changed files with 15 additions and 15 deletions.
2 changes: 1 addition & 1 deletion app/models/application.rb
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ def comment_email_with_fallback
end

sig { returns(String) }
def comment_authority_with_fallback
def comment_recipient_full_name
comment_authority.presence || T.must(authority).full_name
end

Expand Down
2 changes: 1 addition & 1 deletion app/models/comment.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class Comment < ApplicationRecord
scope(:in_past_week, -> { where("confirmed_at > ?", 7.days.ago) })

delegate :email, to: :user
delegate :comment_authority_with_fallback, to: :application
delegate :comment_recipient_full_name, to: :application

counter_culture :application,
column_name: proc { |comment| comment.visible? ? "visible_comments_count" : nil },
Expand Down
2 changes: 1 addition & 1 deletion app/views/_tailwind/applications/show.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@

<%# TODO: Handle situation with 0 comments differently %>
<p class="text-2xl text-navy">
Comments made here were sent to <strong><%= @application.comment_authority_with_fallback %></strong>.
Comments made here were sent to <strong><%= @application.comment_recipient_full_name %></strong>.
<%= pa_link_to "Add your own comment", "#add-comment" %>.
</p>
<% @comments.each do |comment| %>
Expand Down
4 changes: 2 additions & 2 deletions app/views/_tailwind/comments/_delivery_status.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@
<% component.with_summary { "Delivered to the planning authority" } %>
<%# TODO: Use more sensible time zone %>
This comment was successfully delivered to the email server of
<%= comment.comment_authority_with_fallback %>
<%= comment.comment_recipient_full_name %>
on
<%= comment.last_delivered_at.utc.to_fs(:long) %> UTC
<% end %>
<% else %>
<%= render Tailwind::DisclosureComponent.new(size: "xl") do |component| %>
<% component.with_summary { "There was a problem delivering this to the planning authority" } %>
The comment was hard bounced by the email server of
<%= comment.comment_authority_with_fallback %>
<%= comment.comment_recipient_full_name %>
on
<%= comment.last_delivered_at.utc.to_fs(:long) %> UTC
Please follow up by
Expand Down
2 changes: 1 addition & 1 deletion app/views/_tailwind/comments/_form.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
<div class="flex flex-col items-center gap-8 p-12 mt-12 md:flex-row bg-light-grey">
<p class="text-2xl text-navy">
Your comment will be published here and also sent automatically to
<strong><%= application.comment_authority_with_fallback %></strong>.
<strong><%= application.comment_recipient_full_name %></strong>.
They may consider these submissions when they decide whether to approve this application.
</p>
<%= image_tag "tailwind/illustration/send-comment.svg" %>
Expand Down
4 changes: 2 additions & 2 deletions app/views/_tailwind/comments/preview.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@

<div class="mt-4">
<%= render Tailwind::ButtonComponent.new(tag: :button, size: "2xl", type: :primary) do %>
Publish (and send to <%= @comment.comment_authority_with_fallback %>)
Publish (and send to <%= @comment.comment_recipient_full_name %>)
<% end %>
</div>
</div>
Expand All @@ -37,7 +37,7 @@
<h2 class="text-3xl font-bold text-navy">Email preview</h2>

<p class="mt-8 text-2xl text-navy">
Your comment and details will also automatically be sent to <strong><%= @comment.comment_authority_with_fallback %></strong>.
Your comment and details will also automatically be sent to <strong><%= @comment.comment_recipient_full_name %></strong>.
They may consider your submission when they decide whether to approve this application.
</p>
<p class="mt-4 text-2xl text-navy">
Expand Down
4 changes: 2 additions & 2 deletions app/views/comments/_comment.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,12 @@
- elsif comment.last_delivered_successfully
This comment was successfully delivered to the
email server of
= comment.comment_authority_with_fallback
= comment.comment_recipient_full_name
at
= comment.last_delivered_at
- else
The comment was hard bounced by the email server of
= comment.comment_authority_with_fallback
= comment.comment_recipient_full_name
at
= comment.last_delivered_at
Please follow up by
Expand Down
2 changes: 1 addition & 1 deletion app/views/comments/_confirmed.html.haml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
.notice-comment-confirmed
%h1.page-title Thanks, your comment has been sent!
%p
Your comment has been sent to #{comment.comment_authority_with_fallback}
Your comment has been sent to #{comment.comment_recipient_full_name}
and #{link_to "posted below", comment_path(comment)}.
= link_to "Share your comment on Facebook",
"https://www.facebook.com/sharer/sharer.php?u=#{comment_url(comment)}&t=",
Expand Down
2 changes: 1 addition & 1 deletion app/views/comments/_form_introduction.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
%p= on_notice_text(application)
%p
Your comment and details will be sent to
%strong #{application.comment_authority_with_fallback}.
%strong #{application.comment_recipient_full_name}.
- unless application.official_submission_period_expired?
They may consider your submission when they decide whether to approve this application.
Your&nbsp;name and comment will be posted publicly above.
6 changes: 3 additions & 3 deletions spec/models/application_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -104,22 +104,22 @@
end
end

describe "#comment_authority_with_fallback" do
describe "#comment_recipient_full_name" do
let(:authority) { create(:authority, full_name: "Foo Council") }

context "when application has comment_authority set to nil" do
let(:application) { create(:geocoded_application, authority:) }

it "returns the the full name of the authority" do
expect(application.comment_authority_with_fallback).to eq "Foo Council"
expect(application.comment_recipient_full_name).to eq "Foo Council"
end
end

context "when application has comment_authority set to Special Council" do
let(:application) { create(:geocoded_application, authority:, comment_authority: "Special Council") }

it "returns the overridden name connected to the application" do
expect(application.comment_authority_with_fallback).to eq "Special Council"
expect(application.comment_recipient_full_name).to eq "Special Council"
end
end
end
Expand Down

0 comments on commit 9a287e2

Please sign in to comment.