From cb326c18d586220c6196b66c2af22dce250dbc06 Mon Sep 17 00:00:00 2001 From: Louise Crow Date: Tue, 14 Jan 2014 17:03:45 +0000 Subject: Link 'anonymous' users to help section with explanation. Requests submitted using the write API may have an anonymous user. Add a section to the FAQ explaining this, and link to it from those requests. Note this commit removes some 'h' calls that are no longer needed in Rails 3. Contributes to https://github.com/mysociety/alaveteli/issues/1286 --- spec/helpers/link_to_helper_spec.rb | 39 +++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) (limited to 'spec/helpers/link_to_helper_spec.rb') diff --git a/spec/helpers/link_to_helper_spec.rb b/spec/helpers/link_to_helper_spec.rb index b29419ef3..2259db6c2 100644 --- a/spec/helpers/link_to_helper_spec.rb +++ b/spec/helpers/link_to_helper_spec.rb @@ -20,6 +20,45 @@ describe LinkToHelper do end + describe 'when displaying a user link for a request' do + + context "for external requests" do + before do + @info_request = mock_model(InfoRequest, :external_user_name => nil, + :is_external? => true) + end + + it 'should return the text "Anonymous user" with a link to the privacy help pages when there is no external username' do + request_user_link(@info_request).should == 'Anonymous user' + end + + it 'should return a link with an alternative text if requested' do + request_user_link(@info_request, 'other text').should == 'other text' + end + + it 'should display an absolute link if requested' do + request_user_link_absolute(@info_request).should == 'Anonymous user' + end + end + + context "for normal requests" do + + before do + @info_request = FactoryGirl.build(:info_request) + end + + it 'should display a relative link by default' do + request_user_link(@info_request).should == 'Example User' + end + + it 'should display an absolute link if requested' do + request_user_link_absolute(@info_request).should == 'Example User' + end + + end + + end + describe 'when displaying a user admin link for a request' do it 'should return the text "An anonymous user (external)" in the case where there is no external username' do -- cgit v1.2.3