Skip to content

Commit 807f0e9

Browse files
committed
fix/contact sync/async data check
The contact sync/async fields have been newly added to Contentful which means that at present if there isn't a value then `nil` is returned. However, if someone manually deletes the value in Contentful, or the value is removed from the spreadsheet and imported via the CSR upload tool then `"'` is returned. The current code is written as `return unless supplier.some_field` which is ok at present as the field is either present or `nil`, but we need to account for the fact we will get empty strings back in the future and therefore need to update the check to be `supplier.some_field.blank?` to ensure pages won't crash I've updated a couple of the test supplier factory fields to include empty strings to make sure that any future code changes that could break this behaviour will be caught
1 parent 3abf10d commit 807f0e9

2 files changed

Lines changed: 14 additions & 14 deletions

File tree

app/components/csr_table/contact_waiting_time_scores_component.rb

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ def format_sync_output(time_str)
7272
end
7373

7474
def webchat_sync
75-
return unless supplier.contact_webchat_sync
75+
return if supplier.contact_webchat_sync.blank?
7676

7777
{
7878
term: content_tag(:p, "Average Webchat response time"),
@@ -81,7 +81,7 @@ def webchat_sync
8181
end
8282

8383
def webchat_async
84-
return unless supplier.contact_webchat_async
84+
return if supplier.contact_webchat_async.blank?
8585

8686
{
8787
term: content_tag(:p, "Webchat messages responded to within 2 days"),
@@ -90,7 +90,7 @@ def webchat_async
9090
end
9191

9292
def whatsapp_sync
93-
return unless supplier.contact_whatsapp_sync
93+
return if supplier.contact_whatsapp_sync.blank?
9494

9595
{
9696
term: content_tag(:p, "Average Whatsapp response time"),
@@ -99,7 +99,7 @@ def whatsapp_sync
9999
end
100100

101101
def whatsapp_async
102-
return unless supplier.contact_whatsapp_async
102+
return if supplier.contact_whatsapp_async.blank?
103103

104104
{
105105
term: content_tag(:p, "Whatsapp messages responded to within 2 days"),
@@ -108,7 +108,7 @@ def whatsapp_async
108108
end
109109

110110
def sms_sync
111-
return unless supplier.contact_sms_sync
111+
return if supplier.contact_sms_sync.blank?
112112

113113
{
114114
term: content_tag(:p, "Average SMS response time"),
@@ -117,7 +117,7 @@ def sms_sync
117117
end
118118

119119
def sms_async
120-
return unless supplier.contact_sms_async
120+
return if supplier.contact_sms_async.blank?
121121

122122
{
123123
term: content_tag(:p, "SMS messages responded to within 2 days"),
@@ -126,7 +126,7 @@ def sms_async
126126
end
127127

128128
def in_app_sync
129-
return unless supplier.contact_in_app_sync
129+
return if supplier.contact_in_app_sync.blank?
130130

131131
{
132132
term: content_tag(:p, "Average response time using the supplier's app"),
@@ -135,7 +135,7 @@ def in_app_sync
135135
end
136136

137137
def in_app_async
138-
return unless supplier.contact_in_app_async
138+
return if supplier.contact_in_app_async.blank?
139139

140140
{
141141
term: content_tag(:p, "Messages responded to within 2 days using the supplier's app"),
@@ -144,7 +144,7 @@ def in_app_async
144144
end
145145

146146
def portal_sync
147-
return unless supplier.contact_portal_sync
147+
return if supplier.contact_portal_sync.blank?
148148

149149
{
150150
term: content_tag(:p, "Average response time using a customer account portal"),
@@ -153,7 +153,7 @@ def portal_sync
153153
end
154154

155155
def portal_async
156-
return unless supplier.contact_portal_async
156+
return if supplier.contact_portal_async.blank?
157157

158158
{
159159
term: content_tag(:p, "Messages responded to within 2 days using a customer account portal"),

spec/factories/supplier.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -64,13 +64,13 @@
6464
contact_time { "00:03:27" }
6565
contact_email { 89 }
6666
contact_webchat_sync { nil }
67-
contact_whatsapp_sync { nil }
68-
contact_sms_sync { nil }
67+
contact_whatsapp_sync { "" }
68+
contact_sms_sync { "" }
6969
contact_in_app_sync { nil }
7070
contact_portal_sync { nil }
7171
contact_webchat_async { nil }
72-
contact_whatsapp_async { nil }
73-
contact_sms_async { nil }
72+
contact_whatsapp_async { "" }
73+
contact_sms_async { "" }
7474
contact_in_app_async { nil }
7575
contact_portal_async { nil }
7676
end

0 commit comments

Comments
 (0)