diff options
Diffstat (limited to 'spec/helpers/link_to_helper_spec.rb')
-rw-r--r-- | spec/helpers/link_to_helper_spec.rb | 39 |
1 files changed, 39 insertions, 0 deletions
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 == '<a href="/help/privacy#anonymous">Anonymous user</a>' + end + + it 'should return a link with an alternative text if requested' do + request_user_link(@info_request, 'other text').should == '<a href="/help/privacy#anonymous">other text</a>' + end + + it 'should display an absolute link if requested' do + request_user_link_absolute(@info_request).should == '<a href="http://test.host/help/privacy#anonymous">Anonymous user</a>' + 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 == '<a href="/user/example_user">Example User</a>' + end + + it 'should display an absolute link if requested' do + request_user_link_absolute(@info_request).should == '<a href="http://test.host/user/example_user">Example User</a>' + 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 |