blob: 6f02cff7cfda99b1e1ed74b6f88f4b2aa490b5cf (
plain)
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
127
128
|
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
require File.expand_path(File.dirname(__FILE__) + '/alaveteli_dsl')
describe "When viewing requests" do
before(:each) do
load_raw_emails_data
end
it "should not make endlessly recursive JSON <link>s" do
unregistered = without_login
unregistered.browses_request('why_do_you_have_such_a_fancy_dog?unfold=1')
unregistered.response.body.should_not include("dog?unfold=1.json")
unregistered.response.body.should include("dog.json?unfold=1")
end
it 'should not raise a routing error when making a json link for a request with an
"action" querystring param' do
unregistered = without_login
unregistered.browses_request('why_do_you_have_such_a_fancy_dog?action=add')
end
context 'when a response has prominence "normal"' do
before do
useless_message = incoming_messages(:useless_incoming_message)
useless_message.prominence = 'normal'
useless_message.save!
end
it 'should show the message itself to any user' do
# unregistered
unregistered = without_login
unregistered.browses_request('why_do_you_have_such_a_fancy_dog')
unregistered.response.body.should include("No way!")
unregistered.response.body.should_not include("This message has been hidden.")
unregistered.response.body.should_not include("sign in</a> to view the message.")
# requester
bob = login(:bob_smith_user)
bob.browses_request('why_do_you_have_such_a_fancy_dog')
bob.response.body.should include("No way!")
bob.response.body.should_not include("This message has been hidden.")
# admin
confirm(:admin_user)
admin_user = login(:admin_user)
admin_user.browses_request('why_do_you_have_such_a_fancy_dog')
admin_user.response.body.should include('No way!')
admin_user.response.body.should_not include("This message has prominence \'hidden\'.")
end
end
context 'when a response has prominence "hidden"' do
before do
useless_message = incoming_messages(:useless_incoming_message)
useless_message.prominence = 'hidden'
useless_message.save!
end
it 'should show a hidden notice, not the message, to an unregistered user or the requester and
the message itself to an admin ' do
# unregistered
unregistered = without_login
unregistered.browses_request('why_do_you_have_such_a_fancy_dog')
unregistered.response.body.should include("This message has been hidden.")
unregistered.response.body.should_not include("sign in</a> to view the message.")
unregistered.response.body.should_not include("No way!")
# requester
bob = login(:bob_smith_user)
bob.browses_request('why_do_you_have_such_a_fancy_dog')
bob.response.body.should include("This message has been hidden.")
bob.response.body.should_not include("No way!")
# admin
confirm(:admin_user)
admin_user = login(:admin_user)
admin_user.browses_request('why_do_you_have_such_a_fancy_dog')
admin_user.response.body.should include('No way!')
admin_user.response.body.should include("This message has prominence \'hidden\'. You can only see it because you are logged in as a super user.")
end
end
context 'when as response has prominence "requester_only"' do
before do
useless_message = incoming_messages(:useless_incoming_message)
useless_message.prominence = 'requester_only'
useless_message.save!
end
it 'should show a hidden notice with login link to an unregistered user, and the message itself
with a hidden note to the requester or an admin' do
# unregistered
unregistered = without_login
unregistered.browses_request('why_do_you_have_such_a_fancy_dog')
unregistered.response.body.should include("This message has been hidden.")
unregistered.response.body.should include("sign in</a> to view the message.")
unregistered.response.body.should_not include("No way!")
# requester
bob = login(:bob_smith_user)
bob.browses_request('why_do_you_have_such_a_fancy_dog')
bob.response.body.should include("No way!")
bob.response.body.should include("This message is hidden, so that only you, the requester, can see it.")
# admin
confirm(:admin_user)
admin_user = login(:admin_user)
admin_user.browses_request('why_do_you_have_such_a_fancy_dog')
admin_user.response.body.should include('No way!')
admin_user.response.body.should_not include("This message has been hidden.")
admin_user.response.body.should include("This message is hidden, so that only you, the requester, can see it.")
end
end
end
|