Newer
Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
require 'spec_helper'
describe ReportController do
before do
sign_in alice
@message = alice.post(:status_message, :text => "hey", :to => alice.aspects.first.id)
@comment = alice.comment!(@message, "flying pigs, everywhere")
end
describe '#index' do
context 'admin not signed in' do
it 'is behind redirect_unless_admin' do
get :index
response.should redirect_to stream_path
end
end
context 'admin signed in' do
before do
Role.add_admin(alice.person)
end
it 'succeeds and renders index' do
get :index
response.should render_template('index')
end
end
end
describe '#create' do
let(:comment_hash) {
{:text =>"facebook, is that you?",
:post_id =>"#{@post.id}"}
}
context 'report offensive post' do
it 'succeeds' do
put :create, :id => @message.id, :type => 'post', :text => 'offensive content'
response.status.should == 200
Report.exists?(:post_id => @message.id, :post_type => 'post').should be_true
end
end
context 'report offensive comment' do
it 'succeeds' do
put :create, :id => @comment.id, :type => 'comment', :text => 'offensive content'
response.status.should == 200
Report.exists?(:post_id => @comment.id, :post_type => 'comment').should be_true
end
end
end
describe '#update' do
context 'mark post report as user' do
it 'is behind redirect_unless_admin' do
put :update, :id => @message.id, :type => 'post'
response.should redirect_to stream_path
Report.where(:reviewed => false, :post_id => @message.id, :post_type => 'post').should be_true
end
end
context 'mark comment report as user' do
it 'is behind redirect_unless_admin' do
put :update, :id => @comment.id, :type => 'comment'
response.should redirect_to stream_path
Report.where(:reviewed => false, :post_id => @comment.id, :post_type => 'comment').should be_true
end
end
context 'mark post report as admin' do
before do
Role.add_admin(alice.person)
end
it 'succeeds' do
put :update, :id => @message.id, :type => 'post'
response.status.should == 302
Report.where(:reviewed => true, :post_id => @message.id, :post_type => 'post').should be_true
end
end
context 'mark comment report as admin' do
before do
Role.add_admin(alice.person)
end
it 'succeeds' do
put :update, :id => @comment.id, :type => 'comment'
response.status.should == 302
Report.where(:reviewed => true, :post_id => @comment.id, :post_type => 'comment').should be_true
end
end
end
describe '#destroy' do
context 'destroy post as user' do
it 'is behind redirect_unless_admin' do
delete :destroy, :id => @message.id, :type => 'post'
response.should redirect_to stream_path
Report.where(:reviewed => false, :post_id => @message.id, :post_type => 'post').should be_true
end
end
context 'destroy comment as user' do
it 'is behind redirect_unless_admin' do
delete :destroy, :id => @comment.id, :type => 'comment'
response.should redirect_to stream_path
Report.where(:reviewed => false, :post_id => @comment.id, :post_type => 'comment').should be_true
end
end
context 'destroy post as admin' do
before do
Role.add_admin(alice.person)
end
it 'succeeds' do
delete :destroy, :id => @message.id, :type => 'post'
response.status.should == 302
Report.where(:reviewed => true, :post_id => @message.id, :post_type => 'post').should be_true
end
end
context 'destroy comment as admin' do
before do
Role.add_admin(alice.person)
end
it 'succeeds' do
delete :destroy, :id => @comment.id, :type => 'comment'
response.status.should == 302
Report.where(:reviewed => true, :post_id => @comment.id, :post_type => 'comment').should be_true
end
end
end
end