diff options
Diffstat (limited to 'spec/integration')
-rw-r--r-- | spec/integration/view_request_spec.rb | 97 |
1 files changed, 93 insertions, 4 deletions
diff --git a/spec/integration/view_request_spec.rb b/spec/integration/view_request_spec.rb index 79453e4c2..6f02cff7c 100644 --- a/spec/integration/view_request_spec.rb +++ b/spec/integration/view_request_spec.rb @@ -20,7 +20,41 @@ describe "When viewing requests" do unregistered.browses_request('why_do_you_have_such_a_fancy_dog?action=add') end - context 'when a response is hidden' do + 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) @@ -28,12 +62,67 @@ describe "When viewing requests" do useless_message.save! end - it 'should show a hidden notice to an unregistered user' do + 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 - response = unregistered.browses_request('why_do_you_have_such_a_fancy_dog') - response.body.should include("This message has been hidden.") + 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 |