FEATURE - Category group moderators can (un)accept solutions, if enabled (#89)

This commit is contained in:
jbrw 2020-07-27 17:42:42 -04:00 committed by GitHub
parent 36579b774f
commit 6f1cf5a779
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 21 additions and 0 deletions

View File

@ -472,6 +472,10 @@ SQL
return true if is_staff?
return true if current_user.trust_level >= SiteSetting.accept_all_solutions_trust_level
if respond_to? :can_perform_action_available_to_group_moderators?
return true if can_perform_action_available_to_group_moderators?(topic)
end
topic.user_id == current_user.id && !topic.closed
end

View File

@ -148,4 +148,21 @@ RSpec.describe "Managing Posts solved status" do
expect(payload["id"]).to eq(p1.id)
end
end
context 'group moderators' do
fab!(:group_user) { Fabricate(:group_user) }
let(:user_gm) { group_user.user }
let(:group) { group_user.group }
before do
SiteSetting.enable_category_group_moderation = true
p1.topic.category.update!(reviewable_by_group_id: group.id)
sign_in(user_gm)
end
it 'can accept a solution' do
post "/solution/accept.json", params: { id: p1.id }
expect(response.status).to eq(200)
end
end
end