From fee5d9384862af086613c4f09e0fd96f7bd347b8 Mon Sep 17 00:00:00 2001 From: Gareth Rees Date: Tue, 3 Jun 2014 11:19:21 +0100 Subject: Add cache-busting to request response notification Users get a new response email, click the link, but get a cached page. This is a quick fix to ensure they always see the response when clicking the link. --- spec/helpers/link_to_helper_spec.rb | 68 +++++++++++++++++++++++++++++++++++++ 1 file changed, 68 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 4a01ec683..08362da6e 100644 --- a/spec/helpers/link_to_helper_spec.rb +++ b/spec/helpers/link_to_helper_spec.rb @@ -20,6 +20,74 @@ describe LinkToHelper do end + describe 'when linking to new incoming messages' do + + before do + @info_request = mock_model(InfoRequest, :id => 123, :url_title => 'test_title') + @incoming_message = mock_model(IncomingMessage, :id => 32, :info_request => @info_request) + end + + context 'for external links' do + + it 'generates the url to the info request of the message' do + incoming_message_url(@incoming_message).should include('http://test.host/request/test_title') + end + + it 'includes an anchor to the new message' do + incoming_message_url(@incoming_message).should include('#incoming-32') + end + + it 'includes a cache busting parameter' do + incoming_message_url(@incoming_message).should include('nocache=incoming-32') + end + + end + + context 'for internal links' do + + it 'generates the incoming_message_url with the path only' do + expected = '/request/test_title?nocache=incoming-32#incoming-32' + incoming_message_path(@incoming_message).should == expected + end + + end + + end + + describe 'when linking to new outgoing messages' do + + before do + @info_request = mock_model(InfoRequest, :id => 123, :url_title => 'test_title') + @outgoing_message = mock_model(OutgoingMessage, :id => 32, :info_request => @info_request) + end + + context 'for external links' do + + it 'generates the url to the info request of the message' do + outgoing_message_url(@outgoing_message).should include('http://test.host/request/test_title') + end + + it 'includes an anchor to the new message' do + outgoing_message_url(@outgoing_message).should include('#outgoing-32') + end + + it 'includes a cache busting parameter' do + outgoing_message_url(@outgoing_message).should include('nocache=outgoing-32') + end + + end + + context 'for internal links' do + + it 'generates the outgoing_message_url with the path only' do + expected = '/request/test_title?nocache=outgoing-32#outgoing-32' + outgoing_message_path(@outgoing_message).should == expected + end + + end + + end + describe 'when displaying a user link for a request' do context "for external requests" do -- cgit v1.2.3 From 6bd0bfe7599aee4e55bdd63196d1e2c5cc80129c Mon Sep 17 00:00:00 2001 From: Gareth Rees Date: Tue, 3 Jun 2014 12:34:00 +0100 Subject: Remove duplication from new correspondence urls --- spec/helpers/link_to_helper_spec.rb | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) (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 08362da6e..f7be9eab0 100644 --- a/spec/helpers/link_to_helper_spec.rb +++ b/spec/helpers/link_to_helper_spec.rb @@ -37,8 +37,12 @@ describe LinkToHelper do incoming_message_url(@incoming_message).should include('#incoming-32') end - it 'includes a cache busting parameter' do - incoming_message_url(@incoming_message).should include('nocache=incoming-32') + it 'includes does not cache by default' do + incoming_message_url(@incoming_message).should_not include('nocache=incoming-32') + end + + it 'includes a cache busting parameter if set' do + incoming_message_url(@incoming_message, :cachebust => true).should include('nocache=incoming-32') end end @@ -46,7 +50,7 @@ describe LinkToHelper do context 'for internal links' do it 'generates the incoming_message_url with the path only' do - expected = '/request/test_title?nocache=incoming-32#incoming-32' + expected = '/request/test_title#incoming-32' incoming_message_path(@incoming_message).should == expected end @@ -71,8 +75,12 @@ describe LinkToHelper do outgoing_message_url(@outgoing_message).should include('#outgoing-32') end - it 'includes a cache busting parameter' do - outgoing_message_url(@outgoing_message).should include('nocache=outgoing-32') + it 'includes does not cache by default' do + outgoing_message_url(@outgoing_message).should_not include('nocache=outgoing-32') + end + + it 'includes a cache busting parameter if set' do + outgoing_message_url(@outgoing_message, :cachebust => true).should include('nocache=outgoing-32') end end @@ -80,7 +88,7 @@ describe LinkToHelper do context 'for internal links' do it 'generates the outgoing_message_url with the path only' do - expected = '/request/test_title?nocache=outgoing-32#outgoing-32' + expected = '/request/test_title#outgoing-32' outgoing_message_path(@outgoing_message).should == expected end -- cgit v1.2.3 From 77ce9b795c62d8241b22878cf60ca688fa4b44a1 Mon Sep 17 00:00:00 2001 From: Gareth Rees Date: Tue, 3 Jun 2014 11:35:55 +0100 Subject: Move date helpers to DateTimeHelper --- spec/helpers/link_to_helper_spec.rb | 47 ------------------------------------- 1 file changed, 47 deletions(-) (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 f7be9eab0..b11c35056 100644 --- a/spec/helpers/link_to_helper_spec.rb +++ b/spec/helpers/link_to_helper_spec.rb @@ -145,51 +145,4 @@ describe LinkToHelper do end - describe 'simple_date' do - - it 'formats a date in html by default' do - time = Time.utc(2012, 11, 07, 21, 30, 26) - self.should_receive(:simple_date_html).with(time) - simple_date(time) - end - - it 'formats a date in the specified format' do - time = Time.utc(2012, 11, 07, 21, 30, 26) - self.should_receive(:simple_date_text).with(time) - simple_date(time, :format => :text) - end - - it 'raises an argument error if given an unrecognized format' do - time = Time.utc(2012, 11, 07, 21, 30, 26) - expect { simple_date(time, :format => :unknown) }.to raise_error(ArgumentError) - end - - end - - describe 'simple_date_html' do - - it 'formats a date in a time tag' do - Time.use_zone('London') do - time = Time.utc(2012, 11, 07, 21, 30, 26) - expected = "" - simple_date_html(time).should == expected - end - end - - end - - describe 'simple_date_text' do - - it 'should respect time zones' do - Time.use_zone('Australia/Sydney') do - simple_date_text(Time.utc(2012, 11, 07, 21, 30, 26)).should == 'November 08, 2012' - end - end - - it 'should handle Date objects' do - simple_date_text(Date.new(2012, 11, 21)).should == 'November 21, 2012' - end - - end - end -- cgit v1.2.3 From 7bf6cbe307d3fd99680c084025240ed504e37297 Mon Sep 17 00:00:00 2001 From: Gareth Rees Date: Mon, 16 Jun 2014 10:36:36 +0100 Subject: Fix typo Fixes typo in 6bd0bfe --- spec/helpers/link_to_helper_spec.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (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 b11c35056..261e1ef3e 100644 --- a/spec/helpers/link_to_helper_spec.rb +++ b/spec/helpers/link_to_helper_spec.rb @@ -37,7 +37,7 @@ describe LinkToHelper do incoming_message_url(@incoming_message).should include('#incoming-32') end - it 'includes does not cache by default' do + it 'does not cache by default' do incoming_message_url(@incoming_message).should_not include('nocache=incoming-32') end @@ -75,7 +75,7 @@ describe LinkToHelper do outgoing_message_url(@outgoing_message).should include('#outgoing-32') end - it 'includes does not cache by default' do + it 'does not cache by default' do outgoing_message_url(@outgoing_message).should_not include('nocache=outgoing-32') end -- cgit v1.2.3