From 1015257cc4b3c6c74aa8a4716e7e76c149beaa3d Mon Sep 17 00:00:00 2001 From: Skud Date: Thu, 28 Mar 2013 12:18:33 +1100 Subject: [PATCH] use fully qualified links in notification email --- app/views/notifier/notify.html.haml | 6 +++--- spec/views/notifier/notify.html.haml_spec.rb | 9 ++++++++- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/app/views/notifier/notify.html.haml b/app/views/notifier/notify.html.haml index 1c4c044d2..7623d2be8 100644 --- a/app/views/notifier/notify.html.haml +++ b/app/views/notifier/notify.html.haml @@ -3,18 +3,18 @@ %p You have received a message from - = link_to @notification.sender.login_name, url_for(@notification.sender) + = link_to @notification.sender.login_name, url_for(:controller => 'members', :action => 'show', :id => @notification.sender.id, :only_path => false ) on #{site_name} at #{@notification.created_at.to_s(:date)} - if @notification.post in response to - = link_to @notification.post.subject, url_for(@notification.post) + = link_to @notification.post.subject, url_for(:controller => 'posts', :action => 'show', :id => @notification.post.id, :only_path => false) \. %blockquote :markdown #{strip_tags @notification.body} %p - = link_to "View this message in your inbox", url_for(@notification) + = link_to "View this message in your inbox", url_for(:controller => 'notifications', :action => 'show', :id => @notification.id, :only_path => false) %br/ = link_to "Turn off these notifications", edit_member_registration_url diff --git a/spec/views/notifier/notify.html.haml_spec.rb b/spec/views/notifier/notify.html.haml_spec.rb index 40d12b06d..3f70895c1 100644 --- a/spec/views/notifier/notify.html.haml_spec.rb +++ b/spec/views/notifier/notify.html.haml_spec.rb @@ -17,6 +17,13 @@ describe 'notifier/notify.html.haml', :type => "view" do end it 'should contain a link to your inbox' do - assert_select "a[href=#{url_for(@notification)}]" + assert_select "a[href*=notifications]" + end + + it 'should have fully qualified URLs' do + # lots of lovely fully qualified URLs + assert_select "a[href^=http]", { :minimum => 4 } + # no relative URLs starting with / + assert_select "a[href^=/]", { :count => 0 } end end