Fix links of more-button on mobile streams

Fixes #6999

closes #7036
This commit is contained in:
Benjamin Neff 2016-08-26 21:04:57 +02:00 committed by Dennis Schubert
parent 4fea926057
commit 8c58206e63
No known key found for this signature in database
GPG key ID: 5A0304BEA7966D7E
3 changed files with 45 additions and 18 deletions

View file

@ -11,6 +11,7 @@
* Post comments no longer get collapsed when interacting with a post [#7040](https://github.com/diaspora/diaspora/pull/7040) * Post comments no longer get collapsed when interacting with a post [#7040](https://github.com/diaspora/diaspora/pull/7040)
* Closed accounts will no longer show up in the account search [#7042](https://github.com/diaspora/diaspora/pull/7042) * Closed accounts will no longer show up in the account search [#7042](https://github.com/diaspora/diaspora/pull/7042)
* Code blocks in conversations no longer overflow the content [#7055](https://github.com/diaspora/diaspora/pull/7055) * Code blocks in conversations no longer overflow the content [#7055](https://github.com/diaspora/diaspora/pull/7055)
* More buttons in mobile streams are fixed [#7036](https://github.com/diaspora/diaspora/pull/7036)
## Features ## Features
* Deleted comments will be removed when loading more comments [#7045](https://github.com/diaspora/diaspora/pull/7045) * Deleted comments will be removed when loading more comments [#7045](https://github.com/diaspora/diaspora/pull/7045)

View file

@ -8,16 +8,8 @@ module StreamHelper
tag_path(:name => @stream.tag_name, :max_time => time_for_scroll(@stream)) tag_path(:name => @stream.tag_name, :max_time => time_for_scroll(@stream))
elsif controller.instance_of?(PeopleController) elsif controller.instance_of?(PeopleController)
local_or_remote_person_path(@person, :max_time => time_for_scroll(@stream)) 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) next_stream_path
stream_path(:max_time => time_for_scroll(@stream))
elsif current_page?(:aspects_stream)
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
else else
raise 'in order to use pagination for this new controller, update next_page_path in stream helper' raise 'in order to use pagination for this new controller, update next_page_path in stream helper'
end end
@ -29,6 +21,24 @@ module StreamHelper
private private
def next_stream_path
if current_page?(:stream)
stream_path(max_time: time_for_scroll(@stream))
elsif current_page?(:activity_stream)
activity_stream_path(max_time: time_for_scroll(@stream))
elsif current_page?(:aspects_stream)
aspects_stream_path(max_time: time_for_scroll(@stream), a_ids: session[:a_ids])
elsif current_page?(:public_stream)
public_stream_path(max_time: time_for_scroll(@stream))
elsif current_page?(:mentioned_stream)
mentioned_stream_path(max_time: time_for_scroll(@stream))
elsif current_page?(:followed_tags_stream)
followed_tags_stream_path(max_time: time_for_scroll(@stream))
else
raise "in order to use pagination for this new stream, update next_stream_path in stream helper"
end
end
def time_for_scroll(stream) def time_for_scroll(stream)
if stream.stream_posts.empty? if stream.stream_posts.empty?
(Time.now() + 1).to_i (Time.now() + 1).to_i

View file

@ -2,9 +2,9 @@
# licensed under the Affero General Public License version 3 or later. See # licensed under the Affero General Public License version 3 or later. See
# the COPYRIGHT file. # the COPYRIGHT file.
require 'spec_helper' require "spec_helper"
describe StreamHelper, :type => :helper do describe StreamHelper, type: :helper do
describe "next_page_path" do describe "next_page_path" do
def build_controller controller_class def build_controller controller_class
controller_class.new.tap {|c| c.request = controller.request } controller_class.new.tap {|c| c.request = controller.request }
@ -13,30 +13,46 @@ describe StreamHelper, :type => :helper do
@stream = Stream::Base.new(alice, :max_time => Time.now) @stream = Stream::Base.new(alice, :max_time => Time.now)
end end
it 'works for public page' do it "works for public page when current page is public stream" do
allow(helper).to receive(:controller).and_return(build_controller(PostsController)) allow(helper).to receive(:current_page?).and_return(false)
expect(helper.next_page_path).to include '/public' expect(helper).to receive(:current_page?).with(:public_stream).and_return(true)
allow(helper).to receive(:controller).and_return(build_controller(StreamsController))
expect(helper.next_page_path).to include "/public"
end end
it 'works for stream page when current page is stream' do it "works for stream page when current page is stream" do
allow(helper).to receive(:current_page?).and_return(false) allow(helper).to receive(:current_page?).and_return(false)
expect(helper).to receive(:current_page?).with(:stream).and_return(true) expect(helper).to receive(:current_page?).with(:stream).and_return(true)
allow(helper).to receive(:controller).and_return(build_controller(StreamsController)) allow(helper).to receive(:controller).and_return(build_controller(StreamsController))
expect(helper.next_page_path).to include stream_path expect(helper.next_page_path).to include stream_path
end end
it 'works for aspects page when current page is aspects' do it "works for aspects page when current page is aspects" do
allow(helper).to receive(:current_page?).and_return(false) allow(helper).to receive(:current_page?).and_return(false)
expect(helper).to receive(:current_page?).with(:aspects_stream).and_return(true) expect(helper).to receive(:current_page?).with(:aspects_stream).and_return(true)
allow(helper).to receive(:controller).and_return(build_controller(StreamsController)) allow(helper).to receive(:controller).and_return(build_controller(StreamsController))
expect(helper.next_page_path).to include aspects_stream_path expect(helper.next_page_path).to include aspects_stream_path
end end
it 'works for activity page when current page is not stream or aspects' do it "works for activity page when current page is activity stream" do
allow(helper).to receive(:current_page?).and_return(false) allow(helper).to receive(:current_page?).and_return(false)
expect(helper).to receive(:current_page?).with(:activity_stream).and_return(true)
allow(helper).to receive(:controller).and_return(build_controller(StreamsController)) allow(helper).to receive(:controller).and_return(build_controller(StreamsController))
# binding.pry
expect(helper.next_page_path).to include activity_stream_path expect(helper.next_page_path).to include activity_stream_path
end end
it "works for mentioned page when current page is mentioned stream" do
allow(helper).to receive(:current_page?).and_return(false)
expect(helper).to receive(:current_page?).with(:mentioned_stream).and_return(true)
allow(helper).to receive(:controller).and_return(build_controller(StreamsController))
expect(helper.next_page_path).to include mentioned_stream_path
end
it "works for followed tags page when current page is followed tags stream" do
allow(helper).to receive(:current_page?).and_return(false)
expect(helper).to receive(:current_page?).with(:followed_tags_stream).and_return(true)
allow(helper).to receive(:controller).and_return(build_controller(StreamsController))
expect(helper.next_page_path).to include followed_tags_stream_path
end
end end
end end