2019-04-30 08:27:42 +08:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2017-09-13 01:04:53 +08:00
|
|
|
require 'rails_helper'
|
|
|
|
|
|
|
|
RSpec.describe Admin::FlaggedTopicsController do
|
2019-05-07 11:12:20 +08:00
|
|
|
fab!(:post) { Fabricate(:post) }
|
|
|
|
fab!(:user) { Fabricate(:user) }
|
2019-01-04 01:03:01 +08:00
|
|
|
|
|
|
|
before do
|
|
|
|
PostActionCreator.spam(user, post)
|
|
|
|
end
|
|
|
|
|
2019-05-07 11:12:20 +08:00
|
|
|
fab!(:flag) { Fabricate(:flag) }
|
2017-09-13 01:04:53 +08:00
|
|
|
|
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-07 16:11:09 +08:00
|
|
|
expect(response.status).to eq(200)
|
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
|