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/disagree/:id" => "flags#disagree"
post "flags/defer/:id" => "flags#defer" post "flags/defer/:id" => "flags#defer"
resources :flagged_topics, constraints: AdminConstraint.new resources :flagged_topics, constraints: StaffConstraint.new
resources :themes, constraints: AdminConstraint.new resources :themes, constraints: AdminConstraint.new
post "themes/import" => "themes#import" post "themes/import" => "themes#import"

View File

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