FIX: moderators couldn't see flagged topics list

This commit is contained in:
Neil Lalonde 2017-10-05 14:12:07 -04:00
parent b2127600fb
commit beca02c046
2 changed files with 24 additions and 10 deletions

View File

@ -193,7 +193,7 @@ Discourse::Application.routes.draw do
post "flags/disagree/:id" => "flags#disagree"
post "flags/defer/:id" => "flags#defer"
resources :flagged_topics, constraints: AdminConstraint.new
resources :flagged_topics, constraints: StaffConstraint.new
resources :themes, constraints: AdminConstraint.new
post "themes/import" => "themes#import"

View File

@ -1,19 +1,33 @@
require 'rails_helper'
RSpec.describe Admin::FlaggedTopicsController do
let(:admin) { Fabricate(:admin) }
let!(:flag) { Fabricate(:flag) }
before do
sign_in(admin)
shared_examples "successfully retrieve list of flagged topics" do
it "returns a list of flagged topics" do
get "/admin/flagged_topics.json"
expect(response).to be_success
data = ::JSON.parse(response.body)
expect(data['flagged_topics']).to be_present
expect(data['users']).to be_present
end
end
it "returns a list of flagged topics" do
get "/admin/flagged_topics.json"
expect(response).to be_success
context "as admin" do
before do
sign_in(Fabricate(:admin))
end
data = ::JSON.parse(response.body)
expect(data['flagged_topics']).to be_present
expect(data['users']).to be_present
include_examples "successfully retrieve list of flagged topics"
end
context "as moderator" do
before do
sign_in(Fabricate(:moderator))
end
include_examples "successfully retrieve list of flagged topics"
end
end