mirror of
https://github.com/discourse/discourse.git
synced 2024-11-24 23:20:33 +08:00
4ea21fa2d0
This change both speeds up specs (less strings to allocate) and helps catch cases where methods in Discourse are mutating inputs. Overall we will be migrating everything to use #frozen_string_literal: true it will take a while, but this is the first and safest move in this direction
43 lines
932 B
Ruby
43 lines
932 B
Ruby
# frozen_string_literal: true
|
|
|
|
require 'rails_helper'
|
|
|
|
RSpec.describe Admin::FlaggedTopicsController do
|
|
let(:post) { Fabricate(:post) }
|
|
let(:user) { Fabricate(:user) }
|
|
|
|
before do
|
|
PostActionCreator.spam(user, post)
|
|
end
|
|
|
|
let!(:flag) { Fabricate(:flag) }
|
|
|
|
shared_examples "successfully retrieve list of flagged topics" do
|
|
it "returns a list of flagged topics" do
|
|
get "/admin/flagged_topics.json"
|
|
expect(response.status).to eq(200)
|
|
|
|
data = ::JSON.parse(response.body)
|
|
expect(data['flagged_topics']).to be_present
|
|
expect(data['users']).to be_present
|
|
end
|
|
end
|
|
|
|
context "as admin" do
|
|
before do
|
|
sign_in(Fabricate(:admin))
|
|
end
|
|
|
|
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
|