Skip to content

Commit 27bd784

Browse files
committed
Add tests around when set_read fails
1 parent 74e82eb commit 27bd784

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

spec/concepts/feedback/set_read_at_spec.rb

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,5 +27,32 @@
2727
expect(response[:feedback].read_at).to be_a(ActiveSupport::TimeWithZone)
2828
end
2929
end
30+
31+
context 'when set_read fails' do
32+
before do
33+
allow(feedback).to receive(:save!).and_raise(StandardError, 'Transition failed')
34+
end
35+
36+
it 'returns a failed operation response' do
37+
response = described_class.call(feedback: feedback)
38+
expect(response.success?).to be(false)
39+
end
40+
41+
it 'returns the original feedback' do
42+
response = described_class.call(feedback: feedback)
43+
expect(response[:feedback]).to eq(feedback)
44+
end
45+
46+
it 'does not persist read_at' do
47+
described_class.call(feedback: feedback)
48+
feedback.reload
49+
expect(feedback.read_at).to be_nil
50+
end
51+
52+
it 'includes an error object in the response' do
53+
response = described_class.call(feedback: feedback)
54+
expect(response[:error]).to be_a(ActiveModel::Errors)
55+
end
56+
end
3057
end
3158
end

0 commit comments

Comments
 (0)