2015-10-11 17:41:23 +08:00
|
|
|
require 'rails_helper'
|
2013-02-06 03:16:51 +08:00
|
|
|
|
|
|
|
describe Admin::FlagsController do
|
|
|
|
|
|
|
|
it "is a subclass of AdminController" do
|
2015-01-10 01:04:02 +08:00
|
|
|
expect(Admin::FlagsController < Admin::AdminController).to eq(true)
|
2013-02-06 03:16:51 +08: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)
|
2015-01-10 01:04:02 +08:00
|
|
|
expect(data["users"]).to eq([])
|
|
|
|
expect(data["posts"]).to eq([])
|
2013-02-06 03:16:51 +08:00
|
|
|
end
|
|
|
|
|
|
|
|
it 'returns a valid json payload when some thing is flagged' do
|
|
|
|
p = Fabricate(:post)
|
|
|
|
u = Fabricate(:user)
|
2013-02-26 00:42:20 +08:00
|
|
|
|
2013-03-01 20:07:44 +08:00
|
|
|
PostAction.act(u, p, PostActionType.types[:spam])
|
2013-02-06 03:16:51 +08:00
|
|
|
xhr :get, :index
|
2013-02-26 00:42:20 +08:00
|
|
|
|
2013-02-06 03:16:51 +08:00
|
|
|
data = ::JSON.parse(response.body)
|
|
|
|
data["users"].length == 2
|
|
|
|
data["posts"].length == 1
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2013-02-26 00:42:20 +08:00
|
|
|
|