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
|
||||
|
||||
def local_public
|
||||
return stream_responder(Stream::LocalPublic) if AppConfig.settings.enable_show_local_post_link == "always"
|
||||
|
||||
if AppConfig.settings.enable_show_local_post_link == "admin" && Role.is_admin?(current_user)
|
||||
return stream_responder(Stream::LocalPublic)
|
||||
if AppConfig.local_posts_stream?(current_user)
|
||||
stream_responder(Stream::LocalPublic)
|
||||
else
|
||||
head :not_found
|
||||
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
|
||||
|
||||
def activity
|
||||
|
|
|
|||
|
|
@ -42,17 +42,6 @@ module ApplicationHelper
|
|||
"bookmarklet('#{bookmarklet_url}', #{width}, #{height});"
|
||||
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?
|
||||
current_user.services.size == AppConfig.configured_services.size
|
||||
end
|
||||
|
|
|
|||
|
|
@ -37,7 +37,7 @@
|
|||
= render "aspects/aspect_listings", stream: @stream
|
||||
%li.nested-list
|
||||
= render "tags/followed_tags_listings"
|
||||
- if show_local_posts_link?(current_user)
|
||||
- if AppConfig.local_posts_stream?(current_user)
|
||||
%li{data: {stream: "local_public"}}
|
||||
= link_to t("streams.local_public.title"), local_public_stream_path, rel: "backbone", class: "hoverable"
|
||||
%li{data: {stream: "public"}}
|
||||
|
|
|
|||
|
|
@ -287,11 +287,13 @@
|
|||
## (or commented out) to enable the first registration (you).
|
||||
#enable_registrations = true
|
||||
|
||||
## Show local posts (default="disabled")
|
||||
## Show local posts stream (default="disabled")
|
||||
## If any other setting than disabled local public posts
|
||||
## created on this pod can be showed.
|
||||
## Choose one setting
|
||||
# enable_show_local_post_link= "disabled"|"admin"|"moderator"|"always"
|
||||
## created on this pod can be shown.
|
||||
## Setting this to admins shows the local posts stream only to users with the admin role.
|
||||
## 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)
|
||||
## Users will automatically follow a specified account on creation.
|
||||
|
|
|
|||
|
|
@ -1245,8 +1245,6 @@ de:
|
|||
title: "Stream"
|
||||
public:
|
||||
title: "Öffentliche Aktivität"
|
||||
local_public:
|
||||
title: "Lokale Posts"
|
||||
tags:
|
||||
title: "Getaggte Beiträge: %{tags}"
|
||||
tag_followings:
|
||||
|
|
|
|||
|
|
@ -50,6 +50,15 @@ module Configuration
|
|||
self["services.#{service}.authorized"] == true
|
||||
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
|
||||
if heroku?
|
||||
return ENV["SECRET_TOKEN"] if ENV["SECRET_TOKEN"]
|
||||
|
|
|
|||
|
|
@ -1,9 +1,5 @@
|
|||
# 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
|
||||
class Stream::LocalPublic < Stream::Base
|
||||
def link(opts={})
|
||||
|
|
|
|||
|
|
@ -122,43 +122,6 @@ describe ApplicationHelper, :type => :helper do
|
|||
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
|
||||
let(:changelog_url_setting) {
|
||||
double.tap {|double| allow(AppConfig).to receive(:settings).and_return(double(changelog_url: double)) }
|
||||
|
|
|
|||
|
|
@ -128,6 +128,43 @@ describe Configuration::Methods do
|
|||
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
|
||||
before do
|
||||
@version = double
|
||||
|
|
|
|||
|
|
@ -75,8 +75,8 @@ describe Post, type: :model do
|
|||
end
|
||||
end
|
||||
|
||||
describe '.for_a_stream' do
|
||||
it 'calls #for_visible_shareable_sql' do
|
||||
describe ".for_a_stream" do
|
||||
it "calls #for_visible_shareable_sql" do
|
||||
time = double
|
||||
order = double
|
||||
expect(Post).to receive(:for_visible_shareable_sql).with(time, order).and_return(Post)
|
||||
|
|
|
|||
Loading…
Reference in a new issue