Unverified Commit 8c58206e authored by Benjamin Neff's avatar Benjamin Neff Committed by Dennis Schubert

Fix links of more-button on mobile streams

Fixes #6999

closes #7036
parent 4fea9260
......@@ -11,6 +11,7 @@
* 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)
* 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
* Deleted comments will be removed when loading more comments [#7045](https://github.com/diaspora/diaspora/pull/7045)
......
......@@ -8,16 +8,8 @@ module StreamHelper
tag_path(:name => @stream.tag_name, :max_time => time_for_scroll(@stream))
elsif controller.instance_of?(PeopleController)
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)
if current_page?(:stream)
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
next_stream_path
else
raise 'in order to use pagination for this new controller, update next_page_path in stream helper'
end
......@@ -29,6 +21,24 @@ module StreamHelper
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)
if stream.stream_posts.empty?
(Time.now() + 1).to_i
......
......@@ -2,9 +2,9 @@
# licensed under the Affero General Public License version 3 or later. See
# the COPYRIGHT file.
require 'spec_helper'
require "spec_helper"
describe StreamHelper, :type => :helper do
describe StreamHelper, type: :helper do
describe "next_page_path" do
def build_controller controller_class
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)
end
it 'works for public page' do
allow(helper).to receive(:controller).and_return(build_controller(PostsController))
expect(helper.next_page_path).to include '/public'
it "works for public page when current page is public stream" do
allow(helper).to receive(:current_page?).and_return(false)
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
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)
expect(helper).to receive(:current_page?).with(:stream).and_return(true)
allow(helper).to receive(:controller).and_return(build_controller(StreamsController))
expect(helper.next_page_path).to include stream_path
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)
expect(helper).to receive(:current_page?).with(:aspects_stream).and_return(true)
allow(helper).to receive(:controller).and_return(build_controller(StreamsController))
expect(helper.next_page_path).to include aspects_stream_path
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)
expect(helper).to receive(:current_page?).with(:activity_stream).and_return(true)
allow(helper).to receive(:controller).and_return(build_controller(StreamsController))
# binding.pry
expect(helper.next_page_path).to include activity_stream_path
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
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment