SPEC: Do not raise error if topic not exist

This commit is contained in:
Vinoth Kannan 2018-10-05 09:37:28 +05:30
parent bb44fd469c
commit 004cf718b9
1 changed files with 24 additions and 0 deletions

View File

@ -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