2017-09-12 13:04:53 -04:00
|
|
|
require 'rails_helper'
|
|
|
|
|
|
|
|
RSpec.describe Admin::FlaggedTopicsController do
|
|
|
|
let!(:flag) { Fabricate(:flag) }
|
|
|
|
|
2017-10-05 14:12:07 -04:00
|
|
|
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
|
2017-09-12 13:04:53 -04:00
|
|
|
end
|
|
|
|
|
2017-10-05 14:12:07 -04:00
|
|
|
context "as admin" do
|
|
|
|
before do
|
|
|
|
sign_in(Fabricate(:admin))
|
|
|
|
end
|
2017-09-12 13:04:53 -04:00
|
|
|
|
2017-10-05 14:12:07 -04:00
|
|
|
include_examples "successfully retrieve list of flagged topics"
|
2017-09-12 13:04:53 -04:00
|
|
|
end
|
2017-10-05 14:12:07 -04:00
|
|
|
|
|
|
|
context "as moderator" do
|
|
|
|
before do
|
|
|
|
sign_in(Fabricate(:moderator))
|
|
|
|
end
|
|
|
|
|
|
|
|
include_examples "successfully retrieve list of flagged topics"
|
|
|
|
end
|
|
|
|
|
2017-09-12 13:04:53 -04:00
|
|
|
end
|