From b0db7b9c78cca0795a459428b3ba9322564f4da0 Mon Sep 17 00:00:00 2001 From: "Daniel (dB.) Doubrovkine" Date: Sun, 27 Oct 2024 16:10:16 -0400 Subject: [PATCH] Replace calendar confirmation with a button. --- slack-sup/models/sup.rb | 17 ++++++++++++++++- spec/api/endpoints/sups_endpoint_spec.rb | 17 ++++++++++++++++- 2 files changed, 32 insertions(+), 2 deletions(-) diff --git a/slack-sup/models/sup.rb b/slack-sup/models/sup.rb index d42f057..cddec9f 100644 --- a/slack-sup/models/sup.rb +++ b/slack-sup/models/sup.rb @@ -159,7 +159,22 @@ def captain_user_name def notify_gcal_html_link_changed! return unless gcal_html_link && (gcal_html_link_changed? || saved_change_to_gcal_html_link?) - dm!(text: "I've added this S'Up to your Google Calendar: #{gcal_html_link}") + dm!( + { + text: "I've added this S'Up to your Google Calendar.", + attachments: [ + { + text: '', + attachment_type: 'default', + actions: [{ + type: 'button', + text: 'Google Calendar', + url: gcal_html_link + }] + } + ] + } + ) end def select_best_captain diff --git a/spec/api/endpoints/sups_endpoint_spec.rb b/spec/api/endpoints/sups_endpoint_spec.rb index 47aacc7..08b7912 100644 --- a/spec/api/endpoints/sups_endpoint_spec.rb +++ b/spec/api/endpoints/sups_endpoint_spec.rb @@ -43,7 +43,22 @@ end it 'updates a sup html link and DMs sup' do - expect_any_instance_of(Sup).to receive(:dm!).with(text: "I've added this S'Up to your Google Calendar: updated") + expect_any_instance_of(Sup).to receive(:dm!).with( + { + text: "I've added this S'Up to your Google Calendar.", + attachments: [ + { + text: '', + attachment_type: 'default', + actions: [{ + type: 'button', + text: 'Google Calendar', + url: 'updated' + }] + } + ] + } + ) client.headers.update('X-Access-Token' => team.short_lived_token) client.sup(id: existing_sup.id)._put(gcal_html_link: 'updated') expect(existing_sup.reload.gcal_html_link).to eq 'updated'