diff --git a/app/models/application.rb b/app/models/application.rb index 65b8da161..4d3a812a9 100644 --- a/app/models/application.rb +++ b/app/models/application.rb @@ -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 diff --git a/app/models/comment.rb b/app/models/comment.rb index 6cd3f0796..557ddb9f9 100644 --- a/app/models/comment.rb +++ b/app/models/comment.rb @@ -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 }, diff --git a/app/views/_tailwind/applications/show.html.erb b/app/views/_tailwind/applications/show.html.erb index 59a339d37..e50ecaf31 100644 --- a/app/views/_tailwind/applications/show.html.erb +++ b/app/views/_tailwind/applications/show.html.erb @@ -151,7 +151,7 @@ <%# TODO: Handle situation with 0 comments differently %>
- Comments made here were sent to <%= @application.comment_authority_with_fallback %>. + Comments made here were sent to <%= @application.comment_recipient_full_name %>. <%= pa_link_to "Add your own comment", "#add-comment" %>.
<% @comments.each do |comment| %> diff --git a/app/views/_tailwind/comments/_delivery_status.html.erb b/app/views/_tailwind/comments/_delivery_status.html.erb index 5354e4dfb..72628085e 100644 --- a/app/views/_tailwind/comments/_delivery_status.html.erb +++ b/app/views/_tailwind/comments/_delivery_status.html.erb @@ -9,7 +9,7 @@ <% 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 %> @@ -17,7 +17,7 @@ <%= 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 diff --git a/app/views/_tailwind/comments/_form.html.erb b/app/views/_tailwind/comments/_form.html.erb index 91c9e1c96..d74bfb170 100644 --- a/app/views/_tailwind/comments/_form.html.erb +++ b/app/views/_tailwind/comments/_form.html.erb @@ -41,7 +41,7 @@Your comment will be published here and also sent automatically to - <%= application.comment_authority_with_fallback %>. + <%= application.comment_recipient_full_name %>. They may consider these submissions when they decide whether to approve this application.
<%= image_tag "tailwind/illustration/send-comment.svg" %> diff --git a/app/views/_tailwind/comments/preview.html.erb b/app/views/_tailwind/comments/preview.html.erb index da1a3ec7f..fbd0ffdc3 100644 --- a/app/views/_tailwind/comments/preview.html.erb +++ b/app/views/_tailwind/comments/preview.html.erb @@ -27,7 +27,7 @@- Your comment and details will also automatically be sent to <%= @comment.comment_authority_with_fallback %>. + Your comment and details will also automatically be sent to <%= @comment.comment_recipient_full_name %>. They may consider your submission when they decide whether to approve this application.
diff --git a/app/views/comments/_comment.html.haml b/app/views/comments/_comment.html.haml index ed6a8620a..20bfbe51c 100644 --- a/app/views/comments/_comment.html.haml +++ b/app/views/comments/_comment.html.haml @@ -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 diff --git a/app/views/comments/_confirmed.html.haml b/app/views/comments/_confirmed.html.haml index 5afab3017..0ef347730 100755 --- a/app/views/comments/_confirmed.html.haml +++ b/app/views/comments/_confirmed.html.haml @@ -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=", diff --git a/app/views/comments/_form_introduction.html.haml b/app/views/comments/_form_introduction.html.haml index 06a62bb39..08784e78c 100644 --- a/app/views/comments/_form_introduction.html.haml +++ b/app/views/comments/_form_introduction.html.haml @@ -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 name and comment will be posted publicly above. diff --git a/spec/models/application_spec.rb b/spec/models/application_spec.rb index 555beb0bb..817c63156 100644 --- a/spec/models/application_spec.rb +++ b/spec/models/application_spec.rb @@ -104,14 +104,14 @@ 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 @@ -119,7 +119,7 @@ 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