Commit efe55f39 authored by danielgrippi's avatar danielgrippi

remove ajax_stream? logic from streams now that we're using backbone & never...

remove ajax_stream? logic from streams now that we're using backbone & never ajaxing on mobile; remove unreferenced community_spotlight stream & controller
parent 9a9cc8d8
require File.join(Rails.root, 'lib', 'stream', 'community_spotlight')
class CommunitySpotlightController < ApplicationController
def index
default_stream_action(Stream::CommunitySpotlight)
end
end
......@@ -5,34 +5,32 @@
module StreamHelper
def next_page_path(opts ={})
if controller.instance_of?(TagsController)
tag_path(:name => @stream.tag_name, :max_time => time_for_scroll(opts[:ajax_stream], @stream))
tag_path(:name => @stream.tag_name, :max_time => time_for_scroll(@stream))
elsif controller.instance_of?(AppsController)
"/apps/1?#{{:max_time => @posts.last.created_at.to_i}.to_param}"
elsif controller.instance_of?(PeopleController)
local_or_remote_person_path(@person, :max_time => time_for_scroll(opts[:ajax_stream], @stream))
local_or_remote_person_path(@person, :max_time => time_for_scroll(@stream))
elsif controller.instance_of?(TagFollowingsController)
tag_followings_path(:max_time => time_for_scroll(opts[:ajax_stream], @stream))
elsif controller.instance_of?(CommunitySpotlightController)
spotlight_path(:max_time => time_for_scroll(opts[:ajax_stream], @stream))
tag_followings_path(:max_time => time_for_scroll(@stream))
elsif controller.instance_of?(MentionsController)
mentions_path(:max_time => time_for_scroll(opts[:ajax_stream], @stream))
mentions_path(:max_time => time_for_scroll(@stream))
elsif controller.instance_of?(MultisController)
multi_path(:max_time => time_for_scroll(opts[:ajax_stream], @stream))
multi_path(:max_time => time_for_scroll(@stream))
elsif controller.instance_of?(PostsController)
public_stream_path(:max_time => time_for_scroll(opts[:ajax_stream], @stream))
public_stream_path(:max_time => time_for_scroll(@stream))
elsif controller.instance_of?(AspectsController)
aspects_path(:max_time => time_for_scroll(opts[:ajax_stream], @stream), :a_ids => @stream.aspect_ids)
aspects_path(:max_time => time_for_scroll(@stream), :a_ids => @stream.aspect_ids)
elsif controller.instance_of?(LikeStreamController)
like_stream_path(:max_time => time_for_scroll(opts[:ajax_stream], @stream))
like_stream_path(:max_time => time_for_scroll(@stream))
elsif controller.instance_of?(CommentStreamController)
comment_stream_path(:max_time => time_for_scroll(opts[:ajax_stream], @stream))
comment_stream_path(:max_time => time_for_scroll(@stream))
else
raise 'in order to use pagination for this new controller, update next_page_path in stream helper'
end
end
def time_for_scroll(ajax_stream, stream)
if ajax_stream || stream.stream_posts.empty?
def time_for_scroll(stream)
if stream.stream_posts.empty?
(Time.now() + 1).to_i
else
stream.stream_posts.last.send(stream.order.to_sym).to_i
......
......@@ -118,8 +118,6 @@ Diaspora::Application.routes.draw do
resources :share_visibilities, :only => [:update]
resources :blocks, :only => [:create, :destroy]
get 'spotlight' => 'community_spotlight#index', :as => 'spotlight'
get 'community_spotlight' => "contacts#spotlight", :as => 'community_spotlight'
get 'stream' => "multis#index", :as => 'multi'
......
......@@ -65,16 +65,6 @@ class Stream::Aspect < Stream::Base
end
end
# Only ajax in the stream if all aspects are present.
# In this case, we know we're on the first page of the stream,
# as the default view for aspects/index is showing posts from
# all a user's aspects.
#
# @return [Boolean] see #for_all_aspects?
def ajax_stream?
!AppConfig[:redis_cache] && for_all_aspects?
end
# The title that will display at the top of the stream's
# publisher box.
#
......
......@@ -75,12 +75,6 @@ class Stream::Base
Rails.application.routes.url_helpers.contacts_path
end
#helpers
# @return [Boolean]
def ajax_stream?
false
end
# @return [Boolean]
def for_all_aspects?
true
......
class Stream::CommunitySpotlight < Stream::Base
def title
"Community Spotlight doing cool stuff!"
end
def link(opts={})
Rails.application.routes.url_helpers.spotlight_path(opts)
end
def contacts_title
"This week's community spotlight"
end
def contacts_link
Rails.application.routes.url_helpers.community_spotlight_path
end
def contacts_link_title
I18n.translate('aspects.selected_contacts.view_all_community_spotlight')
end
def posts
Post.all_public.where(:author_id => people.map{|x| x.id})
end
def people
Person.community_spotlight
end
end
......@@ -23,11 +23,6 @@ class Stream::Multi < Stream::Base
end.call
end
# @return [Boolean]
def ajax_stream?
false
end
#emits an enum of the groups which the post appeared
# :spotlight, :aspects, :tags, :mentioned
def post_from_group(post)
......
......@@ -16,7 +16,6 @@ class Stream::Public < Stream::Base
@posts ||= Post.all_public
end
def contacts_title
I18n.translate("streams.public.contacts_title")
end
......
require 'spec_helper'
describe CommunitySpotlightController do
describe "GET 'index'" do
it "should be successful" do
sign_in alice
get 'index'
response.should be_success
end
end
end
......@@ -5,15 +5,4 @@
require 'spec_helper'
describe StreamHelper do
before do
@post = Factory(:status_message)
end
describe '#next_page_path' do
it 'works for apps page' do
stub!(:controller).and_return(AppsController.new)
@posts = [Factory(:activity_streams_photo)]
next_page_path.should include '/apps/1'
end
end
end
......@@ -62,7 +62,7 @@ describe Stream::Aspect do
stream.posts
end
it 'respects ordering' do
it 'respects ordering' do
stream = Stream::Aspect.new(@alice, [1,2], :order => 'created_at')
@alice.should_receive(:visible_shareables).with(Post, hash_including(:order => 'created_at DESC')).and_return(stub.as_null_object)
stream.posts
......@@ -132,40 +132,6 @@ describe Stream::Aspect do
end
end
describe '.ajax_stream?' do
before do
@original_value = AppConfig[:redis_cache]
@stream = Stream::Aspect.new(stub, stub)
end
after do
AppConfig[:redis_cache] = @original_value
end
context 'if we are not caching with redis' do
before do
AppConfig[:redis_cache] = false
end
it 'is true if stream is for all aspects?' do
@stream.stub(:for_all_aspects?).and_return(true)
@stream.ajax_stream?.should be_true
end
it 'is false if it is not for all aspects' do
@stream.stub(:for_all_aspects?).and_return(false)
@stream.ajax_stream?.should be_false
end
end
context 'if we are caching with redis' do
it 'returns false' do
AppConfig[:redis_cache] = true
@stream.ajax_stream?.should be_false
end
end
end
describe 'shared behaviors' do
before do
@stream = Stream::Aspect.new(alice, alice.aspects.map(&:id))
......
require 'spec_helper'
require File.join(Rails.root, 'spec', 'shared_behaviors', 'stream')
describe Stream::CommunitySpotlight do
before do
@stream = Stream::CommunitySpotlight.new(Factory(:user), :max_time => Time.now, :order => 'updated_at')
end
describe 'shared behaviors' do
it_should_behave_like 'it is a stream'
end
end
......@@ -27,14 +27,6 @@ describe 'Streams' do
@stream.contacts_link.should_not be_nil
end
it 'responds to ajax_stream' do
@stream.ajax_stream?.should_not be_nil
end
it 'responds to ajax_stream' do
@stream.ajax_stream?.should_not be_nil
end
it 'should make the stream a time object' do
@stream.max_time = 123
@stream.max_time.should be_a(Time)
......
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