aboutsummaryrefslogtreecommitdiffstats
path: root/spec/helpers/link_to_helper_spec.rb
diff options
context:
space:
mode:
authorLouise Crow <louise.crow@gmail.com>2014-01-14 17:03:45 +0000
committerLouise Crow <louise.crow@gmail.com>2014-01-14 17:37:05 +0000
commitcb326c18d586220c6196b66c2af22dce250dbc06 (patch)
treeb3e8021c455444f62ea907b91438467862f0148d /spec/helpers/link_to_helper_spec.rb
parent1555a395957f6d1208980509efb9bc989443a063 (diff)
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
Diffstat (limited to 'spec/helpers/link_to_helper_spec.rb')
-rw-r--r--spec/helpers/link_to_helper_spec.rb39
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