2017-09-13 01:04:53 +08:00
|
|
|
require 'rails_helper'
|
|
|
|
|
|
|
|
RSpec.describe Admin::FlaggedTopicsController do
|
|
|
|
let!(:flag) { Fabricate(:flag) }
|
|
|
|
|
2017-10-06 02:12:07 +08:00
|
|
|
shared_examples "successfully retrieve list of flagged topics" do
|
|
|
|
it "returns a list of flagged topics" do
|
|
|
|
get "/admin/flagged_topics.json"
|
2018-06-05 15:29:17 +08:00
|
|
|
expect(response).to be_successful
|
2017-10-06 02:12:07 +08:00
|
|
|
|
|
|
|
data = ::JSON.parse(response.body)
|
|
|
|
expect(data['flagged_topics']).to be_present
|
|
|
|
expect(data['users']).to be_present
|
|
|
|
end
|
2017-09-13 01:04:53 +08:00
|
|
|
end
|
|
|
|
|
2017-10-06 02:12:07 +08:00
|
|
|
context "as admin" do
|
|
|
|
before do
|
|
|
|
sign_in(Fabricate(:admin))
|
|
|
|
end
|
2017-09-13 01:04:53 +08:00
|
|
|
|
2017-10-06 02:12:07 +08:00
|
|
|
include_examples "successfully retrieve list of flagged topics"
|
2017-09-13 01:04:53 +08:00
|
|
|
end
|
2017-10-06 02:12:07 +08:00
|
|
|
|
|
|
|
context "as moderator" do
|
|
|
|
before do
|
|
|
|
sign_in(Fabricate(:moderator))
|
|
|
|
end
|
|
|
|
|
|
|
|
include_examples "successfully retrieve list of flagged topics"
|
|
|
|
end
|
|
|
|
|
2017-09-13 01:04:53 +08:00
|
|
|
end
|