A platform for community discussion. Free, open, simple.
FIX: Allow category group reviewers to edit queued posts
Robin Ward885f1e7e5f89
diff --git a/app/models/reviewable_queued_post.rb b/app/models/reviewable_queued_post.rbindex 30c854df507..2933dff09d2 100644--- a/app/models/reviewable_queued_post.rb+++ b/app/models/reviewable_queued_post.rb@@ -36,11 +36,14 @@ class ReviewableQueuedPost < Reviewableenddef build_editable_fields(fields, guardian, args)- return unless guardian.is_staff?# We can edit category / title if it's a new topicif topic_id.blank?- fields.add('category_id', :category)++ # Only staff can edit category for now, since in theory a category group reviewer could+ # post in a category they don't have access to.+ fields.add('category_id', :category) if guardian.is_staff?+fields.add('payload.title', :text)fields.add('payload.tags', :tags)enddiff --git a/spec/models/reviewable_queued_post_spec.rb b/spec/models/reviewable_queued_post_spec.rbindex 55076154f09..08478c6d57e 100644--- a/spec/models/reviewable_queued_post_spec.rb+++ b/spec/models/reviewable_queued_post_spec.rb@@ -137,15 +137,22 @@ RSpec.describe ReviewableQueuedPost, type: :model dolet(:reviewable) { Fabricate(:reviewable_queued_post_topic, category: category) }context "editing" do- let(:guardian) { Guardian.new(moderator) }it "is editable and returns the fields" do- fields = reviewable.editable_for(guardian)+ fields = reviewable.editable_for(Guardian.new(moderator))expect(fields.has?('category_id')).to eq(true)expect(fields.has?('payload.raw')).to eq(true)expect(fields.has?('payload.title')).to eq(true)expect(fields.has?('payload.tags')).to eq(true)end++ it "is editable by a category group reviewer" do+ fields = reviewable.editable_for(Guardian.new(Fabricate(:user)))+ expect(fields.has?('category_id')).to eq(false)+ expect(fields.has?('payload.raw')).to eq(true)+ expect(fields.has?('payload.title')).to eq(true)+ expect(fields.has?('payload.tags')).to eq(true)+ endendit "returns the appropriate create options for a topic" do