discourse/spec/controllers/admin/flags_controller_spec.rb

38 lines
856 B
Ruby
Raw Normal View History

2013-02-05 14:16:51 -05:00
require 'spec_helper'
describe Admin::FlagsController do
it "is a subclass of AdminController" do
(Admin::FlagsController < Admin::AdminController).should == true
2013-02-05 14:16:51 -05:00
end
context 'while logged in as an admin' do
before do
@user = log_in(:admin)
end
context 'index' do
it 'returns empty json when nothing is flagged' do
xhr :get, :index
data = ::JSON.parse(response.body)
data["users"].should == []
data["posts"].should == []
end
it 'returns a valid json payload when some thing is flagged' do
p = Fabricate(:post)
u = Fabricate(:user)
2013-02-25 11:42:20 -05:00
2013-03-01 07:07:44 -05:00
PostAction.act(u, p, PostActionType.types[:spam])
2013-02-05 14:16:51 -05:00
xhr :get, :index
2013-02-25 11:42:20 -05:00
2013-02-05 14:16:51 -05:00
data = ::JSON.parse(response.body)
data["users"].length == 2
data["posts"].length == 1
end
end
end
end
2013-02-25 11:42:20 -05:00