Fixing PR Rewview issues
This commit is contained in:
parent
4147249d2d
commit
2db1d5d641
10 changed files with 59 additions and 72 deletions
|
|
@ -26,18 +26,11 @@ class StreamsController < ApplicationController
|
||||||
end
|
end
|
||||||
|
|
||||||
def local_public
|
def local_public
|
||||||
return stream_responder(Stream::LocalPublic) if AppConfig.settings.enable_show_local_post_link == "always"
|
if AppConfig.local_posts_stream?(current_user)
|
||||||
|
stream_responder(Stream::LocalPublic)
|
||||||
if AppConfig.settings.enable_show_local_post_link == "admin" && Role.is_admin?(current_user)
|
else
|
||||||
return stream_responder(Stream::LocalPublic)
|
head :not_found
|
||||||
end
|
end
|
||||||
|
|
||||||
if AppConfig.settings.enable_show_local_post_link == "moderator" &&
|
|
||||||
(Role.moderator?(current_user) || Role.is_admin?(current_user))
|
|
||||||
return stream_responder(Stream::LocalPublic)
|
|
||||||
end
|
|
||||||
|
|
||||||
stream_responder(Stream::Public)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def activity
|
def activity
|
||||||
|
|
|
||||||
|
|
@ -42,17 +42,6 @@ module ApplicationHelper
|
||||||
"bookmarklet('#{bookmarklet_url}', #{width}, #{height});"
|
"bookmarklet('#{bookmarklet_url}', #{width}, #{height});"
|
||||||
end
|
end
|
||||||
|
|
||||||
def show_local_posts_link?(current_user)
|
|
||||||
return true if AppConfig.settings.enable_show_local_post_link == "always"
|
|
||||||
return true if AppConfig.settings.enable_show_local_post_link == "admin" &&
|
|
||||||
Role.is_admin?(current_user)
|
|
||||||
|
|
||||||
return true if AppConfig.settings.enable_show_local_post_link == "moderator" &&
|
|
||||||
(Role.moderator?(current_user) || Role.is_admin?(current_user))
|
|
||||||
|
|
||||||
false
|
|
||||||
end
|
|
||||||
|
|
||||||
def all_services_connected?
|
def all_services_connected?
|
||||||
current_user.services.size == AppConfig.configured_services.size
|
current_user.services.size == AppConfig.configured_services.size
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -37,7 +37,7 @@
|
||||||
= render "aspects/aspect_listings", stream: @stream
|
= render "aspects/aspect_listings", stream: @stream
|
||||||
%li.nested-list
|
%li.nested-list
|
||||||
= render "tags/followed_tags_listings"
|
= render "tags/followed_tags_listings"
|
||||||
- if show_local_posts_link?(current_user)
|
- if AppConfig.local_posts_stream?(current_user)
|
||||||
%li{data: {stream: "local_public"}}
|
%li{data: {stream: "local_public"}}
|
||||||
= link_to t("streams.local_public.title"), local_public_stream_path, rel: "backbone", class: "hoverable"
|
= link_to t("streams.local_public.title"), local_public_stream_path, rel: "backbone", class: "hoverable"
|
||||||
%li{data: {stream: "public"}}
|
%li{data: {stream: "public"}}
|
||||||
|
|
|
||||||
|
|
@ -287,11 +287,13 @@
|
||||||
## (or commented out) to enable the first registration (you).
|
## (or commented out) to enable the first registration (you).
|
||||||
#enable_registrations = true
|
#enable_registrations = true
|
||||||
|
|
||||||
## Show local posts (default="disabled")
|
## Show local posts stream (default="disabled")
|
||||||
## If any other setting than disabled local public posts
|
## If any other setting than disabled local public posts
|
||||||
## created on this pod can be showed.
|
## created on this pod can be shown.
|
||||||
## Choose one setting
|
## Setting this to admins shows the local posts stream only to users with the admin role.
|
||||||
# enable_show_local_post_link= "disabled"|"admin"|"moderator"|"always"
|
## Setting this to moderators shows the local posts stream only to users with the moderator or admin role.
|
||||||
|
## Setting this to everyone shows the local posts stream to all users.
|
||||||
|
# enable_local_posts_stream= "disabled"|"admins"|"moderators"|"everyone"
|
||||||
|
|
||||||
## Auto-follow on sign-up (default=true)
|
## Auto-follow on sign-up (default=true)
|
||||||
## Users will automatically follow a specified account on creation.
|
## Users will automatically follow a specified account on creation.
|
||||||
|
|
|
||||||
|
|
@ -1245,8 +1245,6 @@ de:
|
||||||
title: "Stream"
|
title: "Stream"
|
||||||
public:
|
public:
|
||||||
title: "Öffentliche Aktivität"
|
title: "Öffentliche Aktivität"
|
||||||
local_public:
|
|
||||||
title: "Lokale Posts"
|
|
||||||
tags:
|
tags:
|
||||||
title: "Getaggte Beiträge: %{tags}"
|
title: "Getaggte Beiträge: %{tags}"
|
||||||
tag_followings:
|
tag_followings:
|
||||||
|
|
|
||||||
|
|
@ -50,6 +50,15 @@ module Configuration
|
||||||
self["services.#{service}.authorized"] == true
|
self["services.#{service}.authorized"] == true
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def local_posts_stream?(user)
|
||||||
|
return true if settings.enable_local_posts_stream == "admins" &&
|
||||||
|
Role.is_admin?(user)
|
||||||
|
return true if settings.enable_local_posts_stream == "moderators" &&
|
||||||
|
(Role.moderator?(user) || Role.is_admin?(user))
|
||||||
|
|
||||||
|
settings.enable_local_posts_stream == "everyone"
|
||||||
|
end
|
||||||
|
|
||||||
def secret_token
|
def secret_token
|
||||||
if heroku?
|
if heroku?
|
||||||
return ENV["SECRET_TOKEN"] if ENV["SECRET_TOKEN"]
|
return ENV["SECRET_TOKEN"] if ENV["SECRET_TOKEN"]
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,5 @@
|
||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
# Copyright (c) 2010-2011, Diaspora Inc. This file is
|
|
||||||
# licensed under the Affero General Public License version 3 or later. See
|
|
||||||
# the COPYRIGHT file.
|
|
||||||
|
|
||||||
# rubocop:disable Style/ClassAndModuleChildren
|
# rubocop:disable Style/ClassAndModuleChildren
|
||||||
class Stream::LocalPublic < Stream::Base
|
class Stream::LocalPublic < Stream::Base
|
||||||
def link(opts={})
|
def link(opts={})
|
||||||
|
|
|
||||||
|
|
@ -122,43 +122,6 @@ describe ApplicationHelper, :type => :helper do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe "#enable_show_local_post_link" do
|
|
||||||
let!(:moderator) { create(:person) }
|
|
||||||
let!(:admin) { create(:person) }
|
|
||||||
before do
|
|
||||||
moderator.roles.create(name: "moderator")
|
|
||||||
admin.roles.create(name: "admin")
|
|
||||||
end
|
|
||||||
|
|
||||||
it "return false if show_local_posts_link is 'disabled'" do
|
|
||||||
AppConfig.settings.enable_show_local_post_link = "disabled"
|
|
||||||
expect(helper.show_local_posts_link?(admin)).to be false
|
|
||||||
expect(helper.show_local_posts_link?(moderator)).to be false
|
|
||||||
expect(helper.show_local_posts_link?(alice)).to be false
|
|
||||||
end
|
|
||||||
|
|
||||||
it "return true for admins if show_local_posts_link is 'admin'" do
|
|
||||||
AppConfig.settings.enable_show_local_post_link = "admin"
|
|
||||||
expect(helper.show_local_posts_link?(admin)).to be true
|
|
||||||
expect(helper.show_local_posts_link?(moderator)).to be false
|
|
||||||
expect(helper.show_local_posts_link?(alice)).to be false
|
|
||||||
end
|
|
||||||
|
|
||||||
it "return true for admins and moderators if show_local_posts_link is 'moderator'" do
|
|
||||||
AppConfig.settings.enable_show_local_post_link = "moderator"
|
|
||||||
expect(helper.show_local_posts_link?(admin)).to be true
|
|
||||||
expect(helper.show_local_posts_link?(moderator)).to be true
|
|
||||||
expect(helper.show_local_posts_link?(alice)).to be false
|
|
||||||
end
|
|
||||||
|
|
||||||
it "return true for everybody if show_local_posts_link is 'always'" do
|
|
||||||
AppConfig.settings.enable_show_local_post_link = "always"
|
|
||||||
expect(helper.show_local_posts_link?(admin)).to be true
|
|
||||||
expect(helper.show_local_posts_link?(moderator)).to be true
|
|
||||||
expect(helper.show_local_posts_link?(alice)).to be true
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
describe "#changelog_url" do
|
describe "#changelog_url" do
|
||||||
let(:changelog_url_setting) {
|
let(:changelog_url_setting) {
|
||||||
double.tap {|double| allow(AppConfig).to receive(:settings).and_return(double(changelog_url: double)) }
|
double.tap {|double| allow(AppConfig).to receive(:settings).and_return(double(changelog_url: double)) }
|
||||||
|
|
|
||||||
|
|
@ -128,6 +128,43 @@ describe Configuration::Methods do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
describe "#has_local_posts_stream" do
|
||||||
|
let!(:moderator) { create(:person) }
|
||||||
|
let!(:admin) { create(:person) }
|
||||||
|
before do
|
||||||
|
moderator.roles.create(name: "moderator")
|
||||||
|
admin.roles.create(name: "admin")
|
||||||
|
end
|
||||||
|
|
||||||
|
it "return false if show_local_posts_link is 'disabled'" do
|
||||||
|
AppConfig.settings.enable_local_posts_stream = "disabled"
|
||||||
|
expect(AppConfig.local_posts_stream?(admin)).to be false
|
||||||
|
expect(AppConfig.local_posts_stream?(moderator)).to be false
|
||||||
|
expect(AppConfig.local_posts_stream?(alice)).to be false
|
||||||
|
end
|
||||||
|
|
||||||
|
it "return true for admins if show_local_posts_link is 'admins'" do
|
||||||
|
AppConfig.settings.enable_local_posts_stream = "admins"
|
||||||
|
expect(AppConfig.local_posts_stream?(admin)).to be true
|
||||||
|
expect(AppConfig.local_posts_stream?(moderator)).to be false
|
||||||
|
expect(AppConfig.local_posts_stream?(alice)).to be false
|
||||||
|
end
|
||||||
|
|
||||||
|
it "return true for admins and moderators if show_local_posts_link is 'moderators'" do
|
||||||
|
AppConfig.settings.enable_local_posts_stream = "moderators"
|
||||||
|
expect(AppConfig.local_posts_stream?(admin)).to be true
|
||||||
|
expect(AppConfig.local_posts_stream?(moderator)).to be true
|
||||||
|
expect(AppConfig.local_posts_stream?(alice)).to be false
|
||||||
|
end
|
||||||
|
|
||||||
|
it "return true for everybody if show_local_posts_link is 'everyone'" do
|
||||||
|
AppConfig.settings.enable_local_posts_stream = "everyone"
|
||||||
|
expect(AppConfig.local_posts_stream?(admin)).to be true
|
||||||
|
expect(AppConfig.local_posts_stream?(moderator)).to be true
|
||||||
|
expect(AppConfig.local_posts_stream?(alice)).to be true
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
describe "#version_string" do
|
describe "#version_string" do
|
||||||
before do
|
before do
|
||||||
@version = double
|
@version = double
|
||||||
|
|
|
||||||
|
|
@ -75,8 +75,8 @@ describe Post, type: :model do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe '.for_a_stream' do
|
describe ".for_a_stream" do
|
||||||
it 'calls #for_visible_shareable_sql' do
|
it "calls #for_visible_shareable_sql" do
|
||||||
time = double
|
time = double
|
||||||
order = double
|
order = double
|
||||||
expect(Post).to receive(:for_visible_shareable_sql).with(time, order).and_return(Post)
|
expect(Post).to receive(:for_visible_shareable_sql).with(time, order).and_return(Post)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue