diff --git a/spec/integration/assign_spec.rb b/spec/integration/assign_spec.rb index dc5c900..bc1c3ec 100644 --- a/spec/integration/assign_spec.rb +++ b/spec/integration/assign_spec.rb @@ -57,4 +57,28 @@ describe 'integration tests' do end end end + + describe "on before_staff_flag_action event" do + let(:post) { Fabricate(:post) } + let(:user) { Fabricate(:user) } + let(:args) {{ post: post, user: user }} + + before do + SiteSetting.assign_locks_flags = true + TopicCustomField.create( + topic_id: post.topic_id, + name: TopicAssigner::ASSIGNED_TO_ID, + value: Discourse.system_user.id + ) + end + + it "do not raise error if topic is deleted" do + expect { DiscourseEvent.trigger(:before_staff_flag_action, args) }.to raise_error(Discourse::InvalidAccess) + + post.topic.destroy! + post.reload + + expect { DiscourseEvent.trigger(:before_staff_flag_action, args) }.not_to raise_error + end + end end