Skip to content

Commit 0459aea

Browse files
authored
Merge pull request #2114 from codebar/rollbar-569-undefined-method-name-for-nil
Fix Rollbar error #569 undefined method name for nil:NilClass in admin sponsor page
2 parents 8dec17e + b1e5f73 commit 0459aea

File tree

3 files changed

+32
-2
lines changed

3 files changed

+32
-2
lines changed
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1-
%li #{link_to(activity.owner.full_name, admin_member_path(activity.owner))} subscribed #{activity.recipient.name} #{activity.recipient.surname} with email #{activity.parameters[:note]} to the Sponsor newsletter
1+
- if activity.recipient.present?
2+
%li #{link_to(activity.owner.full_name, admin_member_path(activity.owner))} subscribed #{activity&.recipient.name} #{activity&.recipient.surname} with email #{activity.parameters[:note]} to the Sponsor newsletter
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1-
%li #{link_to(activity.owner.full_name, admin_member_path(activity.owner))} unsubscribed #{activity.recipient.name} #{activity.recipient.surname} with email #{activity.parameters[:note]} from the Sponsor newsletter
1+
- if activity.recipient.present?
2+
%li #{link_to(activity.owner.full_name, admin_member_path(activity.owner))} unsubscribed #{activity.recipient.name} #{activity.recipient.surname} with email #{activity.parameters[:note]} from the Sponsor newsletter

spec/features/admin/sponsor_spec.rb

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,34 @@
155155
end
156156
end
157157
end
158+
159+
context 'activities' do
160+
scenario 'when there are activities' do
161+
contact = sponsor.contacts.first
162+
audit = Auditor::Audit.new(sponsor, 'sponsor.admin_contact_subscribe', manager, contact)
163+
audit.log_with_note(contact.email)
164+
165+
visit admin_sponsor_path(sponsor)
166+
167+
within '#activities' do
168+
expect(page).to have_content("#{manager.full_name} subscribed #{contact.name} #{contact.surname} with email #{contact.email} to the Sponsor newsletter")
169+
end
170+
end
171+
172+
scenario 'when an activity is associated with a deleted contact' do
173+
contact = sponsor.contacts.first
174+
audit = Auditor::Audit.new(sponsor, 'sponsor.admin_contact_subscribe', manager, contact)
175+
audit.log_with_note(contact.email)
176+
177+
contact.delete
178+
179+
visit admin_sponsor_path(sponsor)
180+
181+
within '#activities' do
182+
expect(page).to_not have_content("#{manager.full_name} subscribed #{contact.name} #{contact.surname} with email #{contact.email} to the Sponsor newsletter")
183+
end
184+
end
185+
end
158186
end
159187

160188
context 'Editing a sponsor' do

0 commit comments

Comments
 (0)