From cb2e0825c413dad8480c1a5352424299790bcc9f Mon Sep 17 00:00:00 2001 From: Matthew Landauer Date: Fri, 28 Jun 2024 05:52:07 +0000 Subject: [PATCH] Inline method --- app/mailers/alert_mailer.rb | 14 ++++++-------- app/mailers/devise_mailer.rb | 12 ++++++------ app/mailers/users/activation_mailer.rb | 8 ++++---- app/models/user.rb | 6 ------ spec/features/sign_up_for_alerts_spec.rb | 9 --------- 5 files changed, 16 insertions(+), 33 deletions(-) diff --git a/app/mailers/alert_mailer.rb b/app/mailers/alert_mailer.rb index 7b50abd44..ab668f18e 100644 --- a/app/mailers/alert_mailer.rb +++ b/app/mailers/alert_mailer.rb @@ -26,17 +26,15 @@ def alert(alert:, applications: [], comments: []) # It's not sent on in the outgoing email "X-Cuttlefish-Metadata-alert-id" => alert.id.to_s, "X-Cuttlefish-Metadata-user-id" => T.must(alert.user).id.to_s, - # If we're on the tailwind theme then disable css inlining because we're already + # Disable css inlining because we're already # doing it with maizzle and the inlining on cuttlefish strips out media queries for # responsive designs and some more modern css features - "X-Cuttlefish-Disable-Css-Inlining" => T.must(alert.user).tailwind_theme.to_s + "X-Cuttlefish-Disable-Css-Inlining" => "true" ) - if T.must(alert.user).tailwind_theme - attachments.inline["pencil.png"] = Rails.root.join("app/assets/images/tailwind/pencil.png").read - attachments.inline["trash.png"] = Rails.root.join("app/assets/images/tailwind/trash.png").read - attachments.inline["footer-illustration.png"] = Rails.root.join("app/assets/images/tailwind/illustration/woman-looking-off2.png").read - end + attachments.inline["pencil.png"] = Rails.root.join("app/assets/images/tailwind/pencil.png").read + attachments.inline["trash.png"] = Rails.root.join("app/assets/images/tailwind/trash.png").read + attachments.inline["footer-illustration.png"] = Rails.root.join("app/assets/images/tailwind/illustration/woman-looking-off2.png").read mail( from: "PlanningAlerts ", @@ -45,7 +43,7 @@ def alert(alert:, applications: [], comments: []) partial: "subject", locals: { applications:, comments:, alert: } ).strip, - template_path: ("_tailwind/alert_mailer" if T.must(alert.user).tailwind_theme) + template_path: "_tailwind/alert_mailer" ) end end diff --git a/app/mailers/devise_mailer.rb b/app/mailers/devise_mailer.rb index 09721c751..c5e7bf7d1 100644 --- a/app/mailers/devise_mailer.rb +++ b/app/mailers/devise_mailer.rb @@ -10,26 +10,26 @@ class DeviseMailer < Devise::Mailer # which doesn't work. See https://github.com/heartcombo/devise/issues/4842 sig { params(action: T.untyped, opts: T.untyped).returns(T.untyped) } def headers_for(action, opts) - super.merge!(template_path: (resource.tailwind_theme ? "_tailwind/devise/mailer" : "devise/mailer")) + super.merge!(template_path: "_tailwind/devise/mailer") end sig { params(record: User, token: String, opts: T.untyped).returns(T.untyped) } def confirmation_instructions(record, token, opts = {}) - headers["X-Cuttlefish-Disable-Css-Inlining"] = record.tailwind_theme.to_s - attachments.inline["illustration.png"] = Rails.root.join("app/assets/images/tailwind/illustration/confirmation.png").read if record.tailwind_theme + headers["X-Cuttlefish-Disable-Css-Inlining"] = "true" + attachments.inline["illustration.png"] = Rails.root.join("app/assets/images/tailwind/illustration/confirmation.png").read super end sig { params(record: User, token: String, opts: T.untyped).returns(T.untyped) } def reset_password_instructions(record, token, opts = {}) - headers["X-Cuttlefish-Disable-Css-Inlining"] = record.tailwind_theme.to_s - attachments.inline["illustration.png"] = Rails.root.join("app/assets/images/tailwind/illustration/reset-password.png").read if record.tailwind_theme + headers["X-Cuttlefish-Disable-Css-Inlining"] = "true" + attachments.inline["illustration.png"] = Rails.root.join("app/assets/images/tailwind/illustration/reset-password.png").read super end sig { params(record: User, token: String, opts: T.untyped).returns(T.untyped) } def unlock_instructions(record, token, opts = {}) - headers["X-Cuttlefish-Disable-Css-Inlining"] = record.tailwind_theme.to_s + headers["X-Cuttlefish-Disable-Css-Inlining"] = "true" super end end diff --git a/app/mailers/users/activation_mailer.rb b/app/mailers/users/activation_mailer.rb index 0f5d4c978..c1c12e321 100644 --- a/app/mailers/users/activation_mailer.rb +++ b/app/mailers/users/activation_mailer.rb @@ -11,17 +11,17 @@ def notify(user, token) @token = T.let(token, T.nilable(String)) headers( - # If we're on the tailwind theme then disable css inlining because we're already + # Disable css inlining because we're already # doing it with maizzle and the inlining on cuttlefish strips out media queries for # responsive designs and some more modern css features - "X-Cuttlefish-Disable-Css-Inlining" => user.tailwind_theme.to_s + "X-Cuttlefish-Disable-Css-Inlining" => "true" ) - attachments.inline["illustration.png"] = Rails.root.join("app/assets/images/tailwind/illustration/confirmation.png").read if user.tailwind_theme + attachments.inline["illustration.png"] = Rails.root.join("app/assets/images/tailwind/illustration/confirmation.png").read mail( to: user.email, - template_path: ("_tailwind/users/activation_mailer" if user.tailwind_theme) + template_path: "_tailwind/users/activation_mailer" ) end end diff --git a/app/models/user.rb b/app/models/user.rb index 38fe5dd65..8b97c1ce2 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -26,12 +26,6 @@ class User < ApplicationRecord has_many :reports, dependent: :nullify has_many :contact_messages, dependent: :nullify - # Force the tailwind_theme on everyone. - sig { returns(T::Boolean) } - def tailwind_theme - true - end - sig { params(notification: T.untyped, args: T.untyped).void } def send_devise_notification(notification, *args) devise_mailer.send(notification, self, *args).deliver_later diff --git a/spec/features/sign_up_for_alerts_spec.rb b/spec/features/sign_up_for_alerts_spec.rb index 1065b8cec..43178c7af 100644 --- a/spec/features/sign_up_for_alerts_spec.rb +++ b/spec/features/sign_up_for_alerts_spec.rb @@ -116,17 +116,8 @@ end it "when via the homepage but not yet have an account" do - # rubocop:disable RSpec/AnyInstance - allow_any_instance_of(User).to receive(:tailwind_theme).and_return(true) - # rubocop:enable RSpec/AnyInstance - create(:geocoded_application, address: "26 Bruce Rd, Glenbrook NSW 2773", lat: -33.772812, lng: 150.624252, lonlat: RGeo::Geographic.spherical_factory(srid: 4326).point(150.624252, -33.772812)) - user = create(:confirmed_user) - sign_in user - visit root_path - sign_out user - visit root_path fill_in("Street address", with: "24 Bruce Rd, Glenbrook") click_button("Search")