DG MS; fix case where pod does not have any communty spotlight
This commit is contained in:
parent
794247d07b
commit
64f7450d6c
3 changed files with 52 additions and 2 deletions
|
|
@ -1,3 +1,7 @@
|
||||||
|
# Copyright (c) 2010-2011, Diaspora Inc. This file is
|
||||||
|
# licensed under the Affero General Public License version 3 or later. See
|
||||||
|
# the COPYRIGHT file.
|
||||||
|
|
||||||
require File.join(Rails.root, 'lib', 'stream', 'multi')
|
require File.join(Rails.root, 'lib', 'stream', 'multi')
|
||||||
|
|
||||||
class MultisController < ApplicationController
|
class MultisController < ApplicationController
|
||||||
|
|
|
||||||
|
|
@ -1,12 +1,16 @@
|
||||||
class Stream::Multi < Stream::Base
|
class Stream::Multi < Stream::Base
|
||||||
|
|
||||||
|
# @return [String] URL
|
||||||
def link(opts)
|
def link(opts)
|
||||||
Rails.application.routes.url_helpers.multi_path
|
Rails.application.routes.url_helpers.multi_path
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# @return [String]
|
||||||
def title
|
def title
|
||||||
I18n.t('streams.multi.title')
|
I18n.t('streams.multi.title')
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# @return [String]
|
||||||
def contacts_title
|
def contacts_title
|
||||||
I18n.t('streams.multi.contacts_title')
|
I18n.t('streams.multi.contacts_title')
|
||||||
end
|
end
|
||||||
|
|
@ -19,6 +23,7 @@ class Stream::Multi < Stream::Base
|
||||||
end.call
|
end.call
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# @return [Boolean]
|
||||||
def ajax_stream?
|
def ajax_stream?
|
||||||
false
|
false
|
||||||
end
|
end
|
||||||
|
|
@ -26,21 +31,32 @@ class Stream::Multi < Stream::Base
|
||||||
#emits an enum of the groups which the post appeared
|
#emits an enum of the groups which the post appeared
|
||||||
# :spotlight, :aspects, :tags, :mentioned
|
# :spotlight, :aspects, :tags, :mentioned
|
||||||
def post_from_group(post)
|
def post_from_group(post)
|
||||||
[:mentioned, :aspects, :followed_tags, :community_spotlight].collect do |source|
|
streams_included.collect do |source|
|
||||||
is_in?(source, post)
|
is_in?(source, post)
|
||||||
end.compact
|
end.compact
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
|
# @return [Array<Symbol>]
|
||||||
|
def streams_included
|
||||||
|
@streams_included ||= lambda do
|
||||||
|
array = [:mentioned, :aspects, :followed_tags]
|
||||||
|
array << :community_spotlight if include_community_spotlight?
|
||||||
|
array
|
||||||
|
end.call
|
||||||
|
end
|
||||||
|
|
||||||
|
# @return [Symbol]
|
||||||
def is_in?(sym, post)
|
def is_in?(sym, post)
|
||||||
if self.send("#{sym.to_s}_post_ids").find{|x| x == post.id}
|
if self.send("#{sym.to_s}_post_ids").find{|x| x == post.id}
|
||||||
"#{sym.to_s}_stream".to_sym
|
"#{sym.to_s}_stream".to_sym
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# @return [Boolean]
|
||||||
def include_community_spotlight?
|
def include_community_spotlight?
|
||||||
user.show_community_spotlight_in_stream?
|
AppConfig[:community_spotlight].present? && user.show_community_spotlight_in_stream?
|
||||||
end
|
end
|
||||||
|
|
||||||
def aspects_post_ids
|
def aspects_post_ids
|
||||||
|
|
|
||||||
30
spec/controllers/multis_controller_spec.rb
Normal file
30
spec/controllers/multis_controller_spec.rb
Normal file
|
|
@ -0,0 +1,30 @@
|
||||||
|
# Copyright (c) 2010-2011, Diaspora Inc. This file is
|
||||||
|
# licensed under the Affero General Public License version 3 or later. See
|
||||||
|
# the COPYRIGHT file.
|
||||||
|
|
||||||
|
require 'spec_helper'
|
||||||
|
|
||||||
|
describe MultisController do
|
||||||
|
describe '#index' do
|
||||||
|
before do
|
||||||
|
@old_spotlight_value = AppConfig[:community_spotlight]
|
||||||
|
sign_in :user, alice
|
||||||
|
end
|
||||||
|
|
||||||
|
after do
|
||||||
|
AppConfig[:community_spotlight] = @old_spotlight_value
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'succeeds' do
|
||||||
|
AppConfig[:community_spotlight] = [bob.person.diaspora_handle]
|
||||||
|
get :index
|
||||||
|
response.should be_success
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'succeeds without AppConfig[:community_spotlight]' do
|
||||||
|
AppConfig[:community_spotlight] = nil
|
||||||
|
get :index
|
||||||
|
response.should be_success
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
Loading…
Reference in a new issue