Unverified Commit 01ae0045 authored by Steffen van Bergerem's avatar Steffen van Bergerem Committed by Benjamin Neff

Make public stream accessible for logged out users

Fixes #6564.

closes #7775
parent 7d6623d0
......@@ -9,6 +9,7 @@
* Show error message when creating posts with invalid aspects [#7742](https://github.com/diaspora/diaspora/pull/7742)
## Features
* Make public stream accessible for logged out users [#7775](https://github.com/diaspora/diaspora/pull/7775)
# 0.7.4.1
......
......@@ -25,7 +25,7 @@ app.views.Stream = app.views.InfScroll.extend({
markNavSelected : function() {
var activeStream = Backbone.history.fragment;
var streamSelection = $("#stream_selection");
var streamSelection = $("#stream-selection");
streamSelection.find("[data-stream]").removeClass("selected");
streamSelection.find("[data-stream='" + activeStream + "']").addClass("selected");
......
......@@ -4,6 +4,10 @@
}
}
.public-stream {
float: none;
}
.main-stream-publisher {
margin-top: 20px;
padding: 0;
......
......@@ -5,7 +5,7 @@
# the COPYRIGHT file.
class StreamsController < ApplicationController
before_action :authenticate_user!
before_action :authenticate_user!, except: :public
before_action :save_selected_aspects, :only => :aspects
layout proc { request.format == :mobile ? "application" : "with_header" }
......
......@@ -46,6 +46,10 @@ module ApplicationHelper
current_user.services.size == AppConfig.configured_services.size
end
def service_unconnected?(service)
AppConfig.show_service?(service, current_user) && current_user.services.none? {|x| x.provider == service }
end
def popover_with_close_html(without_close_html)
without_close_html + link_to('&times;'.html_safe, "#", :class => 'close')
end
......
......@@ -2,12 +2,13 @@
-# licensed under the Affero General Public License version 3 or later. See
-# the COPYRIGHT file.
.container-fluid.main-stream-publisher
.pull-left.hidden-xs
= owner_image_link
= render "publisher/publisher", publisher_aspects_for(stream)
- if user_signed_in?
.container-fluid.main-stream-publisher
.pull-left.hidden-xs
= owner_image_link
= render "publisher/publisher", publisher_aspects_for(stream)
- if current_user.getting_started?
- if current_user&.getting_started?
.stream#main-stream{:title => popover_with_close_html("3. #{t('.stay_updated')}"),
"data-content" => t(".stay_updated_explanation")}
- else
......@@ -17,5 +18,5 @@
.loader.hidden
.spinner
- if current_user.contacts.size < 2
- if current_user && current_user.contacts.size < 2
= render 'aspects/no_contacts_message'
This diff is collapsed.
......@@ -2,6 +2,9 @@
-# licensed under the Affero General Public License version 3 or later. See
-# the COPYRIGHT file.
- unless user_signed_in?
%h1= @stream.title
#main-stream.stream
= render 'shared/stream', posts: @stream.stream_posts
= render 'shared/stream_more_button'
......@@ -25,7 +25,7 @@ Feature: Keyboard navigation
Scenario: navigate downwards after changing the stream
When I go to the activity stream page
And I click on selector "[data-stream='stream'] a"
Then I should see "Stream" within "#stream_selection .selected"
Then I should see "Stream" within "#stream-selection .selected"
When I press the "J" key somewhere
Then post 1 should be highlighted
......
......@@ -12,3 +12,7 @@ Feature: The public stream
When I sign in as "alice@alice.alice"
And I am on the public stream page
Then I should see "Bob’s public post"
Scenario: seeing public posts as a logged out user
When I am on the public stream page
Then I should see "Bob’s public post"
......@@ -7,54 +7,80 @@
describe StreamsController, :type => :controller do
include_context :gon
before do
sign_in alice
end
describe "#public" do
it "succeeds" do
get :public
expect(response).to be_success
context "with a logged in user" do
before do
sign_in alice
end
end
describe '#multi' do
it 'succeeds' do
get :multi
expect(response).to be_success
describe "#public" do
it "succeeds" do
get :public
expect(response).to be_success
end
end
it 'succeeds on mobile' do
get :multi, :format => :mobile
expect(response).to be_success
end
describe "#multi" do
it "succeeds" do
get :multi
expect(response).to be_success
end
context "getting started" do
it "add the inviter to gon" do
user = FactoryGirl.create(:user, getting_started: true, invited_by: alice)
sign_in user
it "succeeds on mobile" do
get :multi, format: :mobile
expect(response).to be_success
end
get :multi
context "getting started" do
it "add the inviter to gon" do
user = FactoryGirl.create(:user, getting_started: true, invited_by: alice)
sign_in user
expect(gon["preloads"][:mentioned_person][:name]).to eq(alice.person.name)
expect(gon["preloads"][:mentioned_person][:handle]).to eq(alice.person.diaspora_handle)
get :multi
expect(gon["preloads"][:mentioned_person][:name]).to eq(alice.person.name)
expect(gon["preloads"][:mentioned_person][:handle]).to eq(alice.person.diaspora_handle)
end
end
end
streams = {
liked: Stream::Likes,
mentioned: Stream::Mention,
followed_tags: Stream::FollowedTag,
activity: Stream::Activity
}
streams.each do |stream_path, stream_class|
describe "a GET to #{stream_path}" do
it "assigns a stream of the proper class" do
get stream_path
expect(response).to be_success
expect(assigns[:stream]).to be_a stream_class
end
end
end
end
streams = {
:liked => Stream::Likes,
:mentioned => Stream::Mention,
:followed_tags => Stream::FollowedTag,
:activity => Stream::Activity
}
streams.each do |stream_path, stream_class|
describe "a GET to #{stream_path}" do
it 'assigns a stream of the proper class' do
get stream_path
context "with no user signed in" do
describe "#public" do
it "succeeds" do
get :public
expect(response).to be_success
expect(assigns[:stream]).to be_a stream_class
end
it "succeeds on mobile" do
get :public, format: :mobile
expect(response).to be_success
end
end
describe "other streams" do
it "redirects to the login page" do
%i[activity followed_tags liked mentioned multi].each do |stream_path|
get stream_path
expect(response).to be_redirect
expect(response).to redirect_to new_user_session_path
end
end
end
end
......
......@@ -35,6 +35,30 @@ describe ApplicationHelper, :type => :helper do
end
end
describe "#service_unconnected?" do
attr_reader :current_user
before do
@current_user = alice
end
it "returns true if the service is unconnected" do
expect(AppConfig).to receive(:show_service?).with("service", alice).and_return(true)
expect(service_unconnected?("service")).to be true
end
it "returns false if the service is already connected" do
@current_user.services << FactoryGirl.build(:service, provider: "service")
expect(AppConfig).to receive(:show_service?).with("service", alice).and_return(true)
expect(service_unconnected?("service")).to be false
end
it "returns false if the the service shouldn't be shown" do
expect(AppConfig).to receive(:show_service?).with("service", alice).and_return(false)
expect(service_unconnected?("service")).to be false
end
end
describe "#jquery_include_tag" do
describe "with jquery cdn" do
before do
......
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