diff options
author | Starfall <us@starfall.systems> | 2023-04-22 20:32:00 -0500 |
---|---|---|
committer | Starfall <us@starfall.systems> | 2023-04-22 20:32:00 -0500 |
commit | 609ee7b2979252464e63acbfd2eff3e0e3786f3e (patch) | |
tree | 6ade160c4354b803ed36ae5dae28a0ae38bcf032 /spec/services | |
parent | 4fe1689de43f4404eb9530fcfbcbfb26d6c1c13a (diff) | |
parent | 5b58ebb04fe197cc7aa0cfc05a4d1b2df8da0050 (diff) |
Merge remote-tracking branch 'glitch/main'
Diffstat (limited to 'spec/services')
-rw-r--r-- | spec/services/reblog_service_spec.rb | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/spec/services/reblog_service_spec.rb b/spec/services/reblog_service_spec.rb index c00472229..2ad6d30f6 100644 --- a/spec/services/reblog_service_spec.rb +++ b/spec/services/reblog_service_spec.rb @@ -35,10 +35,25 @@ RSpec.describe ReblogService, type: :service do end context 'when the reblogged status is discarded in the meantime' do - let(:status) { Fabricate(:status, account: alice, visibility: :public) } + let(:status) { Fabricate(:status, account: alice, visibility: :public, text: 'discard-status-text') } + # Add a callback to discard the status being reblogged after the + # validations pass but before the database commit is executed. before do - status.discard + Status.class_eval do + before_save :discard_status + def discard_status + Status + .where(id: reblog_of_id) + .where(text: 'discard-status-text') + .update_all(deleted_at: Time.now.utc) # rubocop:disable Rails/SkipsModelValidations + end + end + end + + # Remove race condition simulating `discard_status` callback. + after do + Status._save_callbacks.delete(:discard_status) end it 'raises an exception' do |