Disable flagging behaviour in favor of the new reviewable API (#34)

This commit is contained in:
Roman Rizzi 2019-05-14 16:29:50 -03:00 committed by GitHub
parent b4148a8858
commit 4b7a99f017
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 18 additions and 1 deletions

View File

@ -30,9 +30,24 @@ after_initialize do
require 'topic_assigner'
require 'pending_assigns_reminder'
=begin
TODO: Remove this once 2.3 becomes the new stable.
Also remove:
- flagged-* connectors
- flagged queue code inside the JS initializer
=end
reviewable_api_enabled = begin
'Reviewable'.constantize
true
rescue NameError
false
end
# Raise an invalid access error if a user tries to act on something
# not assigned to them
DiscourseEvent.on(:before_staff_flag_action) do |args|
return if reviewable_api_enabled
if SiteSetting.assign_locks_flags?
if custom_fields = args[:post].topic&.custom_fields
@ -247,6 +262,8 @@ after_initialize do
# Unassign if there are no more flags in the topic
on(:flag_reviewed) do |post|
return if reviewable_api_enabled
if SiteSetting.assign_locks_flags? &&
post.topic &&
FlagQuery.flagged_post_actions(topic_id: post.topic_id, filter: "old").count > 0 &&

View File

@ -75,7 +75,7 @@ describe 'integration tests' do
)
end
it "do not raise error if topic is deleted" do
it "do not raise error if topic is deleted", unless: defined?(Reviewable) do
expect { DiscourseEvent.trigger(:before_staff_flag_action, args) }
.to raise_error(Discourse::InvalidAccess)