From 499eb6a9bbd8da733b6073a2754e1891fe33067f Mon Sep 17 00:00:00 2001 From: Erwan Guyader Date: Mon, 16 Jun 2014 18:13:05 +0200 Subject: [PATCH 1/3] Load right stream with Show More on mobile - Load aspects stream if user is on this stream instead of loading the activity stream --- app/helpers/stream_helper.rb | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/app/helpers/stream_helper.rb b/app/helpers/stream_helper.rb index d0721b388..4753e783c 100644 --- a/app/helpers/stream_helper.rb +++ b/app/helpers/stream_helper.rb @@ -10,9 +10,12 @@ module StreamHelper local_or_remote_person_path(@person, :max_time => time_for_scroll(@stream)) elsif controller.instance_of?(PostsController) public_stream_path(:max_time => time_for_scroll(@stream)) - elsif controller.instance_of?(StreamsController) + elsif controller.instance_of?(StreamsController) if current_page?(:stream) stream_path(:max_time => time_for_scroll(@stream)) + elsif current_page?(:aspects_stream) + aspect_ids = (session[:a_ids] || []) + aspects_stream_path(:max_time => time_for_scroll(@stream), a_ids: aspect_ids) else activity_stream_path(:max_time => time_for_scroll(@stream)) end From e804f308235ca9c808bab4a279a0f9d71254bc13 Mon Sep 17 00:00:00 2001 From: Erwan Guyader Date: Tue, 17 Jun 2014 21:19:17 +0200 Subject: [PATCH 2/3] Code style + allow aspects to be nil - Only use old hash style - Don't replace the aspect ids list with an empty array if it's nil --- app/helpers/stream_helper.rb | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/app/helpers/stream_helper.rb b/app/helpers/stream_helper.rb index 4753e783c..f3eb25415 100644 --- a/app/helpers/stream_helper.rb +++ b/app/helpers/stream_helper.rb @@ -14,8 +14,7 @@ module StreamHelper if current_page?(:stream) stream_path(:max_time => time_for_scroll(@stream)) elsif current_page?(:aspects_stream) - aspect_ids = (session[:a_ids] || []) - aspects_stream_path(:max_time => time_for_scroll(@stream), a_ids: aspect_ids) + aspects_stream_path(:max_time => time_for_scroll(@stream), :a_ids => session[:a_ids]) else activity_stream_path(:max_time => time_for_scroll(@stream)) end From 3ebc0f0387eb66102dc7171881d774630eedc7aa Mon Sep 17 00:00:00 2001 From: Erwan Guyader Date: Tue, 17 Jun 2014 21:36:38 +0200 Subject: [PATCH 3/3] Test returned path for Show More on mobile - Added test when the currant page is Aspects Stream - Modified test for the Stream page to account for the new possibility (i.e current page is Aspects Stream) --- spec/helpers/stream_helper_spec.rb | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/spec/helpers/stream_helper_spec.rb b/spec/helpers/stream_helper_spec.rb index df4520222..b44b54d1c 100644 --- a/spec/helpers/stream_helper_spec.rb +++ b/spec/helpers/stream_helper_spec.rb @@ -19,13 +19,21 @@ describe StreamHelper do end it 'works for stream page when current page is stream' do - helper.stub(:current_page?).and_return(true) + helper.stub(:current_page?).and_return(false) + helper.should_receive(:current_page?).with(:stream).and_return(true) helper.stub(:controller).and_return(build_controller(StreamsController)) helper.next_page_path.should include stream_path end - it 'works for activity page when current page is not stream' do - helper.stub("current_page?").and_return(false) + it 'works for aspects page when current page is aspects' do + helper.stub(:current_page?).and_return(false) + helper.should_receive(:current_page?).with(:aspects_stream).and_return(true) + helper.stub(:controller).and_return(build_controller(StreamsController)) + helper.next_page_path.should include aspects_stream_path + end + + it 'works for activity page when current page is not stream or aspects' do + helper.stub(:current_page?).and_return(false) helper.stub(:controller).and_return(build_controller(StreamsController)) # binding.pry helper.next_page_path.should include activity_stream_path