Skip to content

Commit c112684

Browse files
committed
test: add cross-status retry tests for PR #2558
Verify that when logging success/failure for a member+invitation that already has an entry with a different status, the existing entry is returned (not a new one created, which would cause uniqueness violation)
1 parent 4bd3c78 commit c112684

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

spec/services/invitation_logger_spec.rb

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,4 +129,32 @@
129129
expect(log.completed_at).to be_present
130130
end
131131
end
132+
133+
describe 'cross-status retry (PR #2558 fix)' do
134+
let(:logger) { described_class.new(workshop, initiator, 'students', :invite) }
135+
let!(:log) { logger.start_batch }
136+
137+
it 'returns existing failure entry when logging success for same member+invitation' do
138+
error = StandardError.new('SMTP error')
139+
failure_entry = logger.log_failure(member, invitation, error)
140+
141+
success_entry = logger.log_success(member, invitation)
142+
143+
expect(success_entry).to eq failure_entry
144+
expect(success_entry.status).to eq 'failed'
145+
expect(log.reload.success_count).to eq 0
146+
expect(log.reload.failure_count).to eq 1
147+
end
148+
149+
it 'returns existing success entry when logging failure for same member+invitation' do
150+
logger.log_success(member, invitation)
151+
152+
error = StandardError.new('SMTP error')
153+
failure_entry = logger.log_failure(member, invitation, error)
154+
155+
expect(failure_entry.status).to eq 'success'
156+
expect(log.reload.success_count).to eq 1
157+
expect(log.reload.failure_count).to eq 0
158+
end
159+
end
132160
end

0 commit comments

Comments
 (0)