From f959ca0c1200b6d81bc68ed60038cc978790123f Mon Sep 17 00:00:00 2001
From: Maxwell Salzberg <maxwell@joindiaspora.com>
Date: Thu, 13 Oct 2011 22:23:35 -0700
Subject: [PATCH] refactor streams to be in a Stream module, hopefully they
 will auto-reload now

---
 app/controllers/aspects_controller.rb        |   4 +-
 app/controllers/featured_users_controller.rb |   4 +-
 app/controllers/mentions_controller.rb       |   4 +-
 app/controllers/posts_controller.rb          |   4 +-
 app/controllers/publics_controller.rb        |   2 +-
 app/controllers/soups_controller.rb          |   2 +-
 app/controllers/tag_followings_controller.rb |   4 +-
 app/models/post.rb                           |   2 +-
 lib/base_stream.rb                           |  92 -----------
 lib/diaspora/redis_cache.rb                  |   2 +-
 lib/diaspora/user/querying.rb                |   2 +-
 lib/stream/aspect_stream.rb                  | 120 --------------
 lib/stream/featured_users_stream.rb          |  29 ----
 lib/stream/mention_stream.rb                 |  23 ---
 lib/stream/public_stream.rb                  |  27 ----
 lib/stream/soup_stream.rb                    |  50 ------
 lib/stream/tag_stream.rb                     |  49 ------
 spec/controllers/aspects_controller_spec.rb  |  13 +-
 spec/lib/base_stream_spec.rb                 |  11 --
 spec/lib/diaspora/redis_cache_spec.rb        |   2 +-
 spec/lib/stream/aspect_stream_spec.rb        | 155 -------------------
 spec/lib/stream/featured_users_spec.rb       |  12 --
 spec/lib/stream/mention_stream_spec.rb       |  12 --
 spec/lib/stream/public_stream_spec.rb        |  11 --
 spec/lib/stream/soups_stream_spec.rb         |  12 --
 spec/lib/stream/tag_stream_spec.rb           |  35 -----
 spec/models/user/querying_spec.rb            |   2 +-
 27 files changed, 24 insertions(+), 661 deletions(-)
 delete mode 100644 lib/base_stream.rb
 delete mode 100644 lib/stream/aspect_stream.rb
 delete mode 100644 lib/stream/featured_users_stream.rb
 delete mode 100644 lib/stream/mention_stream.rb
 delete mode 100644 lib/stream/public_stream.rb
 delete mode 100644 lib/stream/soup_stream.rb
 delete mode 100644 lib/stream/tag_stream.rb
 delete mode 100644 spec/lib/base_stream_spec.rb
 delete mode 100644 spec/lib/stream/aspect_stream_spec.rb
 delete mode 100644 spec/lib/stream/featured_users_spec.rb
 delete mode 100644 spec/lib/stream/mention_stream_spec.rb
 delete mode 100644 spec/lib/stream/public_stream_spec.rb
 delete mode 100644 spec/lib/stream/soups_stream_spec.rb
 delete mode 100644 spec/lib/stream/tag_stream_spec.rb

diff --git a/app/controllers/aspects_controller.rb b/app/controllers/aspects_controller.rb
index 57dcabc92d..5ca11fa677 100644
--- a/app/controllers/aspects_controller.rb
+++ b/app/controllers/aspects_controller.rb
@@ -2,7 +2,7 @@
 #   licensed under the Affero General Public License version 3 or later.  See
 #   the COPYRIGHT file.
 
-require File.join(Rails.root, "lib", 'stream', "aspect_stream")
+require File.join(Rails.root, "lib", 'stream', "aspect")
 
 class AspectsController < ApplicationController
   before_filter :authenticate_user!
@@ -15,7 +15,7 @@ class AspectsController < ApplicationController
 
   def index
     aspect_ids = (session[:a_ids] ? session[:a_ids] : [])
-    @stream = AspectStream.new(current_user, aspect_ids,
+    @stream = Stream::Aspect.new(current_user, aspect_ids,
                                :order => sort_order,
                                :max_time => params[:max_time].to_i)
 
diff --git a/app/controllers/featured_users_controller.rb b/app/controllers/featured_users_controller.rb
index 66c030b78b..e5cc606d6b 100644
--- a/app/controllers/featured_users_controller.rb
+++ b/app/controllers/featured_users_controller.rb
@@ -1,7 +1,7 @@
-require File.join(Rails.root, 'lib', 'stream', 'featured_users_stream')
+require File.join(Rails.root, 'lib', 'stream', 'featured_users')
 
 class FeaturedUsersController < ApplicationController
   def index
-    default_stream_action(FeaturedUsersStream)
+    default_stream_action(Stream::FeaturedUsers)
   end
 end
diff --git a/app/controllers/mentions_controller.rb b/app/controllers/mentions_controller.rb
index d546c9684f..2efbebe3a4 100644
--- a/app/controllers/mentions_controller.rb
+++ b/app/controllers/mentions_controller.rb
@@ -2,10 +2,10 @@
 #   licensed under the Affero General Public License version 3 or later.  See
 #   the COPYRIGHT file.
 
-require File.join(Rails.root, 'lib','stream', 'mention_stream')
+require File.join(Rails.root, 'lib','stream', 'mention')
 
 class MentionsController < ApplicationController
   def index
-    default_stream_action(MentionStream)
+    default_stream_action(Stream::Mention)
   end
 end
diff --git a/app/controllers/posts_controller.rb b/app/controllers/posts_controller.rb
index cb36b646c2..a2905dee5b 100644
--- a/app/controllers/posts_controller.rb
+++ b/app/controllers/posts_controller.rb
@@ -2,7 +2,7 @@
 #   licensed under the Affero General Public License version 3 or later.  See
 #   the COPYRIGHT file.
 
-require File.join(Rails.root, 'lib', 'stream', 'public_stream')
+require File.join(Rails.root, 'lib', 'stream', 'public')
 
 class PostsController < ApplicationController
   before_filter :authenticate_user!, :except => :show
@@ -63,7 +63,7 @@ class PostsController < ApplicationController
   end
 
   def index
-    default_stream_action(PublicStream)
+    default_stream_action(Stream::Public)
   end
 
   def set_format_if_malformed_from_status_net
diff --git a/app/controllers/publics_controller.rb b/app/controllers/publics_controller.rb
index 923868f269..12e3e8ab5e 100644
--- a/app/controllers/publics_controller.rb
+++ b/app/controllers/publics_controller.rb
@@ -1,7 +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', 'public_stream')
+require File.join(Rails.root, 'lib', 'stream', 'public')
 
 class PublicsController < ApplicationController
   require File.join(Rails.root, '/lib/diaspora/parser')
diff --git a/app/controllers/soups_controller.rb b/app/controllers/soups_controller.rb
index 7de56d8500..91769bac1e 100644
--- a/app/controllers/soups_controller.rb
+++ b/app/controllers/soups_controller.rb
@@ -1,4 +1,4 @@
-require File.join(Rails.root, 'lib', 'stream', 'soup_stream')
+require File.join(Rails.root, 'lib', 'stream', 'soup')
 
 class SoupsController < ApplicationController
   before_filter :redirect_unless_admin
diff --git a/app/controllers/tag_followings_controller.rb b/app/controllers/tag_followings_controller.rb
index 55945abbaf..9262c9c87b 100644
--- a/app/controllers/tag_followings_controller.rb
+++ b/app/controllers/tag_followings_controller.rb
@@ -2,13 +2,13 @@
 #   licensed under the Affero General Public License version 3 or later.  See
 #   the COPYRIGHT file.
 #
-require File.join(Rails.root, 'lib', 'stream', 'tag_stream')
+require File.join(Rails.root, 'lib', 'stream', 'followed_tag')
 
 class TagFollowingsController < ApplicationController
   before_filter :authenticate_user!
 
   def index
-    default_stream_action(TagStream)
+    default_stream_action(Stream::FollowedTag)
   end
 
   # POST /tag_followings
diff --git a/app/models/post.rb b/app/models/post.rb
index 9d821a9ddf..048990f7c4 100644
--- a/app/models/post.rb
+++ b/app/models/post.rb
@@ -43,7 +43,7 @@ class Post < ActiveRecord::Base
   def self.for_a_stream(max_time, order)
     by_max_time(max_time, order).
     includes_for_a_stream.
-    where(:type => BaseStream::TYPES_OF_POST_IN_STREAM).
+    where(:type => Stream::Base::TYPES_OF_POST_IN_STREAM).
     limit(15)
   end
 
diff --git a/lib/base_stream.rb b/lib/base_stream.rb
deleted file mode 100644
index 038e14698c..0000000000
--- a/lib/base_stream.rb
+++ /dev/null
@@ -1,92 +0,0 @@
-class BaseStream
-  TYPES_OF_POST_IN_STREAM = ['StatusMessage', 'Reshare', 'ActivityStreams::Photo']
-  attr_accessor :max_time, :order, :user
-
-  def initialize(user, opts={})
-    self.user = user
-    self.max_time = opts[:max_time]
-    self.order = opts[:order] 
-  end
-
-  def random_featured_user
-    @random_featured_user ||= Person.find_by_diaspora_handle(featured_diaspora_id)
-  end
-
-  def has_featured_users?
-    random_featured_user.present?
-  end
-  
-  #requied to implement said stream
-  def link(opts={})
-    'change me in lib/base_stream.rb!'
-  end
-
-  def can_comment?(post)
-    true
-  end
-
-  def title
-    'a title'
-  end
-
-  def posts
-    []
-  end
-
-  # @return [ActiveRecord::Association<Person>] AR association of people within stream's given aspects
-  def people
-    people_ids = posts.map{|x| x.author_id}
-    Person.where(:id => people_ids).includes(:profile)
-  end
-
-  def contacts_link_title
-    I18n.translate('aspects.selected_contacts.view_all_contacts')
-  end
-
-  def contacts_title
-    'change me in lib/base_stream.rb!'
-  end
-
-  def contacts_link
-    '#'
-  end
-
-  #helpers
-  def ajax_stream?
-    false
-  end
-  
-  def for_all_aspects?
-    true
-  end
-
-
-  #NOTE: MBS bad bad methods the fact we need these means our views are foobared. please kill them and make them 
-  #private methods on the streams that need them
-  def aspects
-    @user.aspects
-  end
-
-  def aspect
-    aspects.first
-  end
-  
-  def aspect_ids
-    aspects.map{|x| x.id} 
-  end
-
-  def max_time=(time_string)
-    @max_time = Time.at(time_string.to_i) unless time_string.blank?
-    @max_time ||= (Time.now + 1)
-  end
-
-  def order=(order_string)
-    @order = order_string
-    @order ||= 'created_at'
-  end
-
-  private
-  def featured_diaspora_id
-    @featured_diaspora_id ||= AppConfig[:featured_users].try(:sample, 1)
-  end
-end
diff --git a/lib/diaspora/redis_cache.rb b/lib/diaspora/redis_cache.rb
index b41f184b69..68ab20cebc 100644
--- a/lib/diaspora/redis_cache.rb
+++ b/lib/diaspora/redis_cache.rb
@@ -89,7 +89,7 @@ class RedisCache
   # exposing the need to tie cache to a stream
   # @return [Array<String>] Acceptable Post types for the given cache
   def self.acceptable_types
-    BaseStream::TYPES_OF_POST_IN_STREAM
+    Stream::Base::TYPES_OF_POST_IN_STREAM
   end
 
   # Instantiate a redis connection
diff --git a/lib/diaspora/user/querying.rb b/lib/diaspora/user/querying.rb
index 796a13603e..cc838d9fb7 100644
--- a/lib/diaspora/user/querying.rb
+++ b/lib/diaspora/user/querying.rb
@@ -126,7 +126,7 @@ module Diaspora
       # @return [Hash]
       def prep_opts(opts)
         defaults = {
-          :type => BaseStream::TYPES_OF_POST_IN_STREAM, 
+          :type => Stream::Base::TYPES_OF_POST_IN_STREAM, 
           :order => 'created_at DESC',
           :limit => 15,
           :hidden => false
diff --git a/lib/stream/aspect_stream.rb b/lib/stream/aspect_stream.rb
deleted file mode 100644
index d7338174ff..0000000000
--- a/lib/stream/aspect_stream.rb
+++ /dev/null
@@ -1,120 +0,0 @@
-#   Copyright (c) 2010-2011, Diaspora Inc.  This file is
-#   licensed under the Affero General Public License version 3 or later.  See
-#   the COPYRIGHT file.
-
-class AspectStream < BaseStream
-
-  # @param user [User]
-  # @param inputted_aspect_ids [Array<Integer>] Ids of aspects for given stream
-  # @param aspect_ids [Array<Integer>] Aspects this stream is responsible for
-  # @opt max_time [Integer] Unix timestamp of stream's post ceiling
-  # @opt order [String] Order of posts (i.e. 'created_at', 'updated_at')
-  # @return [void]
-  def initialize(user, inputted_aspect_ids, opts={})
-    super(user, opts)
-    @inputted_aspect_ids = inputted_aspect_ids
-  end
-
-  # Filters aspects given the stream's aspect ids on initialization and the user.
-  # Will disclude aspects from inputted aspect ids if user is not associated with their
-  # target aspects.
-  #
-  # @return [ActiveRecord::Association<Aspect>] Filtered aspects given the stream's user
-  def aspects
-    @aspects ||= lambda do
-      a = user.aspects
-      a = a.where(:id => @inputted_aspect_ids) if @inputted_aspect_ids.any?
-      a
-    end.call
-  end
-
-  # Maps ids into an array from #aspects
-  #
-  # @return [Array<Integer>] Aspect ids
-  def aspect_ids
-    @aspect_ids ||= aspects.map { |a| a.id }
-  end
-
-  # @return [ActiveRecord::Association<Post>] AR association of posts
-  def posts
-    # NOTE(this should be something like Post.all_for_stream(@user, aspect_ids, {}) that calls visible_posts
-    @posts ||= user.visible_posts(:all_aspects? => for_all_aspects?,
-                                   :by_members_of => aspect_ids,
-                                   :type => TYPES_OF_POST_IN_STREAM,
-                                   :order => "#{order} DESC",
-                                   :max_time => max_time
-                   ).for_a_stream(max_time, order)
-  end
-
-  # @return [ActiveRecord::Association<Person>] AR association of people within stream's given aspects
-  def people
-    @people ||= Person.all_from_aspects(aspect_ids, user).includes(:profile)
-  end
-
-  # @return [String] URL
-  def link(opts={})
-    Rails.application.routes.url_helpers.aspects_path(opts)
-  end
-
-  # The first aspect in #aspects, given the stream is not for all aspects, or #aspects size is 1
-  # @note aspects.first is used for mobile. NOTE(this is a hack and should be fixed)
-  # @return [Aspect,Symbol]
-  def aspect
-    if !for_all_aspects? || aspects.size == 1
-      aspects.first
-    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?
-    for_all_aspects?
-  end
-
-  # The title that will display at the top of the stream's
-  # publisher box.
-  #
-  # @return [String]
-  def title
-    if self.for_all_aspects?
-      I18n.t('aspects.aspect_stream.stream')
-    else
-      self.aspects.to_sentence
-    end
-  end
-
-  # Determine whether or not the stream is displaying across
-  # all of the user's aspects.
-  #
-  # @return [Boolean]
-  def for_all_aspects?
-    @all_aspects ||= aspect_ids.length == user.aspects.size
-  end
-
-  # Provides a translated title for contacts box on the right pane.
-  #
-  # @return [String]
-  def contacts_title
-    if self.for_all_aspects? || self.aspect_ids.size > 1
-      I18n.t('_contacts')
-    else
-     "#{self.aspect.name} (#{self.people.size})"
-    end
-  end
-
-  # Provides a link to the user to the contacts page that corresponds with
-  # the stream's active aspects.
-  #
-  # @return [String] Link to contacts
-  def contacts_link
-    if for_all_aspects? || aspect_ids.size > 1
-      Rails.application.routes.url_helpers.contacts_path
-    else
-      Rails.application.routes.url_helpers.contacts_path(:a_id => aspect.id)
-    end
-  end
-end
diff --git a/lib/stream/featured_users_stream.rb b/lib/stream/featured_users_stream.rb
deleted file mode 100644
index b58ad08164..0000000000
--- a/lib/stream/featured_users_stream.rb
+++ /dev/null
@@ -1,29 +0,0 @@
-class FeaturedUsersStream < BaseStream
-  def title
-    "Featured users doing cool stuff!"
-  end
-
-  def link(opts={})
-    Rails.application.routes.url_helpers.featured_path(opts)
-  end
-
-  def contacts_title
-    "This week's featured users"
-  end
-
-  def contacts_link
-    Rails.application.routes.url_helpers.featured_users_path
-  end
-
-  def contacts_link_title
-    I18n.translate('aspects.selected_contacts.view_all_featured_users')
-  end
-
-  def posts
-    Post.all_public.where(:author_id => people.map{|x| x.id}).for_a_stream(max_time, order)
-  end
-
-  def people
-   Person.featured_users 
-  end
-end
diff --git a/lib/stream/mention_stream.rb b/lib/stream/mention_stream.rb
deleted file mode 100644
index 069bad02da..0000000000
--- a/lib/stream/mention_stream.rb
+++ /dev/null
@@ -1,23 +0,0 @@
-#   Copyright (c) 2010-2011, Diaspora Inc.  This file is
-#   licensed under the Affero General Public License version 3 or later.  See
-#   the COPYRIGHT file.
-
-class MentionStream< BaseStream
-  def link(opts={})
-    Rails.application.routes.url_helpers.mentions_path(opts)
-  end
-
-  def title
-    I18n.translate("streams.mentions.title")
-  end
-
-
-  # @return [ActiveRecord::Association<Post>] AR association of posts
-  def posts
-    @posts ||= StatusMessage.where_person_is_mentioned(self.user.person).for_a_stream(max_time, order)
-  end
-
-  def contacts_title
-    I18n.translate('streams.mentions.contacts_title')
-  end
-end
diff --git a/lib/stream/public_stream.rb b/lib/stream/public_stream.rb
deleted file mode 100644
index dbb813aa25..0000000000
--- a/lib/stream/public_stream.rb
+++ /dev/null
@@ -1,27 +0,0 @@
-#   Copyright (c) 2010-2011, Diaspora Inc.  This file is
-#   licensed under the Affero General Public License version 3 or later.  See
-#   the COPYRIGHT file.
-
-class PublicStream < BaseStream
-  def link(opts={})
-    Rails.application.routes.url_helpers.public_stream_path(opts)
-  end
-
-  def title
-    I18n.translate("streams.public.title")
-  end
-
-  # @return [ActiveRecord::Association<Post>] AR association of posts
-  def posts
-    @posts ||= Post.all_public.for_a_stream(max_time, order) 
-  end
-
-
-  def contacts_title
-    I18n.translate("streams.public.contacts_title")
-  end
-
-  def can_comment?(post)
-    post.author.local?
-  end
-end
diff --git a/lib/stream/soup_stream.rb b/lib/stream/soup_stream.rb
deleted file mode 100644
index 5098b57269..0000000000
--- a/lib/stream/soup_stream.rb
+++ /dev/null
@@ -1,50 +0,0 @@
-class SoupStream < BaseStream
-  def link(opts)
-    Rails.application.routes.url_helpers.soup_path
-  end
-
-  def title
-    I18n.t('streams.soup.title')
-  end
-
-  def contacts_title
-    I18n.t('streams.soup.contacts_title')
-  end
-
-  def posts
-    post_ids = aspect_posts_ids + followed_tag_ids + mentioned_post_ids
-    post_ids += featured_user_post_ids
-    Post.where(:id => post_ids).for_a_stream(max_time, order)
-  end
-
-  private
-
-  def aspect_posts_ids
-    user.visible_post_ids(:limit => 15, :order => order, :max_time => max_time)
-  end
-
-  def followed_tag_ids
-    StatusMessage.tag_stream(user, tag_array, max_time, order).map{|x| x.id}
-  end
-
-  def mentioned_post_ids
-    ids(StatusMessage.where_person_is_mentioned(user.person).for_a_stream(max_time, order))
-  end
-
-  def featured_user_post_ids
-    ids(Post.all_public.where(:author_id => featured_user_ids).for_a_stream(max_time, order))
-  end
-
-  #worthless helpers
-  def featured_user_ids
-    ids(Person.featured_users)
-  end
-
-  def tag_array
-    user.followed_tags.map{|x| x.name}
-  end
-  
-  def ids(enumerable)
-    enumerable.map{|x| x.id}
-  end
-end
diff --git a/lib/stream/tag_stream.rb b/lib/stream/tag_stream.rb
deleted file mode 100644
index 2a2e73f767..0000000000
--- a/lib/stream/tag_stream.rb
+++ /dev/null
@@ -1,49 +0,0 @@
-#   Copyright (c) 2010-2011, Diaspora Inc.  This file is
-#   licensed under the Affero General Public License version 3 or later.  See
-#   the COPYRIGHT file.
-
-class TagStream < BaseStream
-
-  def link(opts={})
-    Rails.application.routes.url_helpers.tag_followings_path(opts)
-  end
-
-  def title
-    I18n.t('aspects.index.tags_following')
-  end
-
-  # @return [ActiveRecord::Association<Post>] AR association of posts
-  def posts
-    return [] if tag_string.empty?
-    @posts ||= StatusMessage.tag_stream(user, tag_array, max_time, order)
-  end
-
-  def contacts_title
-    I18n.translate('streams.tags.contacts_title')
-  end
-
-  def can_comment?(post)
-    @can_comment_cache ||= {}
-    @can_comment_cache[post.id] ||= contacts_in_stream.find{|contact| contact.person_id == post.author.id}.present?
-    @can_comment_cache[post.id] ||= user.person.id == post.author.id
-    @can_comment_cache[post.id]
-  end
-
-  def contacts_in_stream
-    @contacts_in_stream ||= Contact.where(:user_id => user.id, :person_id => people.map{|x| x.id}).all
-  end
-
-  private
-
-  def tag_string
-    @tag_string ||= tags.join(', '){|tag| tag.name}.to_s
-  end
-
-  def tag_array
-    tags.map{|x| x.name}
-  end
-
-  def tags
-    @tags = user.followed_tags
-  end
-end
diff --git a/spec/controllers/aspects_controller_spec.rb b/spec/controllers/aspects_controller_spec.rb
index d42153eae8..b8b9a9d0b3 100644
--- a/spec/controllers/aspects_controller_spec.rb
+++ b/spec/controllers/aspects_controller_spec.rb
@@ -68,8 +68,9 @@ describe AspectsController do
   describe "#index" do
     context 'jasmine fixtures' do
       before do
-        AspectStream.any_instance.stub(:ajax_stream?).and_return(false)
+        Stream::Aspect.any_instance.stub(:ajax_stream?).and_return(false)
       end
+
       it "generates a jasmine fixture", :fixture => true do
         get :index
         save_fixture(html_for("body"), "aspects_index")
@@ -152,26 +153,26 @@ describe AspectsController do
       response.should render_template('shared/_stream')
     end
 
-    it 'assigns an AspectStream' do
+    it 'assigns an Stream::Aspect' do
       get :index
-      assigns(:stream).class.should == AspectStream
+      assigns(:stream).class.should == Stream::Aspect
     end
 
     describe 'filtering by aspect' do
       before do
         @aspect1 = alice.aspects.create(:name => "test aspect")
-        @stream = AspectStream.new(alice, [])
+        @stream = Stream::Aspect.new(alice, [])
         @stream.stub(:posts).and_return([])
       end
 
       it 'respects a single aspect' do
-        AspectStream.should_receive(:new).with(alice, [@aspect1.id], anything).and_return(@stream)
+        Stream::Aspect.should_receive(:new).with(alice, [@aspect1.id], anything).and_return(@stream)
         get :index, :a_ids => [@aspect1.id]
       end
 
       it 'respects multiple aspects' do
         aspect2 = alice.aspects.create(:name => "test aspect two")
-        AspectStream.should_receive(:new).with(alice, [@aspect1.id, aspect2.id], anything).and_return(@stream)
+        Stream::Aspect.should_receive(:new).with(alice, [@aspect1.id, aspect2.id], anything).and_return(@stream)
         get :index, :a_ids => [@aspect1.id, aspect2.id]
       end
     end
diff --git a/spec/lib/base_stream_spec.rb b/spec/lib/base_stream_spec.rb
deleted file mode 100644
index 1083821a3e..0000000000
--- a/spec/lib/base_stream_spec.rb
+++ /dev/null
@@ -1,11 +0,0 @@
-require 'spec_helper'
-require File.join(Rails.root, 'spec', 'shared_behaviors', 'stream')
-describe BaseStream do
-  before do
-    @stream = BaseStream.new(stub)
-  end
-
-  describe 'shared behaviors' do
-    it_should_behave_like 'it is a stream'
-  end
-end
diff --git a/spec/lib/diaspora/redis_cache_spec.rb b/spec/lib/diaspora/redis_cache_spec.rb
index 56500fc421..f6a74f7e36 100644
--- a/spec/lib/diaspora/redis_cache_spec.rb
+++ b/spec/lib/diaspora/redis_cache_spec.rb
@@ -207,7 +207,7 @@ describe RedisCache do
   describe '.acceptable_types' do
     #exposing the need to tie cache to a stream
     it 'returns the types from the aspect stream' do
-      RedisCache.acceptable_types.should =~ AspectStream::TYPES_OF_POST_IN_STREAM
+      RedisCache.acceptable_types.should =~ Stream::Base::TYPES_OF_POST_IN_STREAM
     end
   end
 end
diff --git a/spec/lib/stream/aspect_stream_spec.rb b/spec/lib/stream/aspect_stream_spec.rb
deleted file mode 100644
index 6d9c486ade..0000000000
--- a/spec/lib/stream/aspect_stream_spec.rb
+++ /dev/null
@@ -1,155 +0,0 @@
-#   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 AspectStream do
-  describe '#aspects' do
-    it 'queries the user given initialized aspect ids' do
-      alice = stub.as_null_object
-      stream = AspectStream.new(alice, [1,2,3])
-
-      alice.aspects.should_receive(:where)
-      stream.aspects
-    end
-
-    it "returns all the user's aspects if no aspect ids are specified" do
-      alice = stub.as_null_object
-      stream = AspectStream.new(alice, [])
-
-      alice.aspects.should_not_receive(:where)
-      stream.aspects
-    end
-
-    it 'filters aspects given a user' do
-      alice = stub(:aspects => [stub(:id => 1)])
-      alice.aspects.stub(:where).and_return(alice.aspects)
-      stream = AspectStream.new(alice, [1,2,3])
-
-      stream.aspects.should == alice.aspects
-    end
-  end
-
-  describe '#aspect_ids' do
-    it 'maps ids from aspects' do
-      alice = stub.as_null_object
-      aspects = stub.as_null_object
-
-      stream = AspectStream.new(alice, [1,2])
-
-      stream.should_receive(:aspects).and_return(aspects)
-      aspects.should_receive(:map)
-      stream.aspect_ids
-    end
-  end
-
-  describe '#posts' do
-    before do
-      @alice = stub.as_null_object
-    end
-
-    it 'calls visible posts for the given user' do
-      stream = AspectStream.new(@alice, [1,2])
-
-      @alice.should_receive(:visible_posts).and_return(stub.as_null_object)
-      stream.posts
-    end
-
-    it 'is called with 3 types' do
-      stream = AspectStream.new(@alice, [1,2], :order => 'created_at')
-      @alice.should_receive(:visible_posts).with(hash_including(:type=> ['StatusMessage', 'Reshare', 'ActivityStreams::Photo'])).and_return(stub.as_null_object)
-      stream.posts
-    end
-
-    it 'respects ordering' do 
-      stream = AspectStream.new(@alice, [1,2], :order => 'created_at')
-      @alice.should_receive(:visible_posts).with(hash_including(:order => 'created_at DESC')).and_return(stub.as_null_object)
-      stream.posts
-    end
-
-    it 'respects max_time' do
-      stream = AspectStream.new(@alice, [1,2], :max_time => 123)
-      @alice.should_receive(:visible_posts).with(hash_including(:max_time => instance_of(Time))).and_return(stub.as_null_object)
-      stream.posts
-    end
-
-    it 'passes for_all_aspects to visible posts' do
-      stream = AspectStream.new(@alice, [1,2], :max_time => 123)
-      all_aspects = mock
-      stream.stub(:for_all_aspects?).and_return(all_aspects)
-      @alice.should_receive(:visible_posts).with(hash_including(:all_aspects? => all_aspects)).and_return(stub.as_null_object)
-      stream.posts
-    end
-  end
-
-  describe '#people' do
-    it 'should call Person.all_from_aspects' do
-      class Person ; end
-
-      alice = stub.as_null_object
-      aspect_ids = [1,2,3]
-      stream = AspectStream.new(alice, [])
-
-      stream.stub(:aspect_ids).and_return(aspect_ids)
-      Person.should_receive(:all_from_aspects).with(stream.aspect_ids, alice).and_return(stub(:includes => :profile))
-      stream.people
-    end
-  end
-
-  describe '#aspect' do
-    before do
-      alice = stub.as_null_object
-      @stream = AspectStream.new(alice, [1,2])
-    end
-
-    it "returns an aspect if the stream is not for all the user's aspects" do
-      @stream.stub(:for_all_aspects?).and_return(false)
-      @stream.aspect.should_not be_nil
-    end
-
-    it "returns nothing if the stream is not for all the user's aspects" do
-      @stream.stub(:for_all_aspects?).and_return(true)
-      @stream.aspect.should be_nil
-    end
-  end
-
-  describe 'for_all_aspects?' do
-    before do
-      alice = stub.as_null_object
-      alice.aspects.stub(:size).and_return(2)
-      @stream = AspectStream.new(alice, [1,2])
-    end
-
-    it "is true if the count of aspect_ids is equal to the size of the user's aspect count" do
-      @stream.aspect_ids.stub(:length).and_return(2)
-      @stream.should be_for_all_aspects
-    end
-
-    it "is false if the count of aspect_ids is not equal to the size of the user's aspect count" do
-      @stream.aspect_ids.stub(:length).and_return(1)
-      @stream.should_not be_for_all_aspects
-    end
-  end
-
-  describe '.ajax_stream?' do
-    before do
-      @stream = AspectStream.new(stub, stub)
-    end
-    it 'is true 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
-  describe 'shared behaviors' do
-    before do
-      @stream = AspectStream.new(alice, alice.aspects.map(&:id))
-    end
-    it_should_behave_like 'it is a stream'
-  end
-end
diff --git a/spec/lib/stream/featured_users_spec.rb b/spec/lib/stream/featured_users_spec.rb
deleted file mode 100644
index e592dcc1b5..0000000000
--- a/spec/lib/stream/featured_users_spec.rb
+++ /dev/null
@@ -1,12 +0,0 @@
-require 'spec_helper'
-require File.join(Rails.root, 'spec', 'shared_behaviors', 'stream')
-
-describe FeaturedUsersStream do
-  before do
-    @stream = FeaturedUsersStream.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
diff --git a/spec/lib/stream/mention_stream_spec.rb b/spec/lib/stream/mention_stream_spec.rb
deleted file mode 100644
index d92b3f8c3f..0000000000
--- a/spec/lib/stream/mention_stream_spec.rb
+++ /dev/null
@@ -1,12 +0,0 @@
-require 'spec_helper'
-require File.join(Rails.root, 'spec', 'shared_behaviors', 'stream')
-
-describe MentionStream do
-  before do
-    @stream = MentionStream.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
diff --git a/spec/lib/stream/public_stream_spec.rb b/spec/lib/stream/public_stream_spec.rb
deleted file mode 100644
index 3d272ed09e..0000000000
--- a/spec/lib/stream/public_stream_spec.rb
+++ /dev/null
@@ -1,11 +0,0 @@
-require 'spec_helper'
-require File.join(Rails.root, 'spec', 'shared_behaviors', 'stream')
-describe PublicStream do
-  before do
-    @stream = PublicStream.new(stub)
-  end
-
-  describe 'shared behaviors' do
-    it_should_behave_like 'it is a stream'
-  end
-end
diff --git a/spec/lib/stream/soups_stream_spec.rb b/spec/lib/stream/soups_stream_spec.rb
deleted file mode 100644
index 4f71533320..0000000000
--- a/spec/lib/stream/soups_stream_spec.rb
+++ /dev/null
@@ -1,12 +0,0 @@
-require 'spec_helper'
-require File.join(Rails.root, 'spec', 'shared_behaviors', 'stream')
-
-describe SoupStream do
-  before do
-    @stream = SoupStream.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
diff --git a/spec/lib/stream/tag_stream_spec.rb b/spec/lib/stream/tag_stream_spec.rb
deleted file mode 100644
index deff898213..0000000000
--- a/spec/lib/stream/tag_stream_spec.rb
+++ /dev/null
@@ -1,35 +0,0 @@
-require 'spec_helper'
-require File.join(Rails.root, 'spec', 'shared_behaviors', 'stream')
-
-describe TagStream do
-  before do
-    @stream = TagStream.new(Factory(:user), :max_time => Time.now, :order => 'updated_at')
-    @stream.stub(:tag_string).and_return("foo")
-  end
-
-  describe 'shared behaviors' do
-    it_should_behave_like 'it is a stream'
-  end
-
-  describe '.can_comment?' do
-    before do
-      @stream = TagStream.new(alice)
-      @stream.stub(:people).and_return([bob.person])
-    end
-
-    it 'returns true if user is a contact of the post author' do
-      post = Factory(:status_message, :author => bob.person)
-      @stream.can_comment?(post).should be_true
-    end 
-
-    it 'returns true if a user is the author of the post' do 
-      post = Factory(:status_message, :author => alice.person)
-      @stream.can_comment?(post).should be_true
-    end
-
-    it 'returns false otherwise' do
-      post = Factory(:status_message, :author => eve.person)
-      @stream.can_comment?(post).should be_false
-    end
-  end
-end
diff --git a/spec/models/user/querying_spec.rb b/spec/models/user/querying_spec.rb
index 58e7556731..befff05390 100644
--- a/spec/models/user/querying_spec.rb
+++ b/spec/models/user/querying_spec.rb
@@ -145,7 +145,7 @@ describe User do
       time = Time.now
       Time.stub(:now).and_return(time)
       alice.send(:prep_opts, {}).should == {
-        :type => BaseStream::TYPES_OF_POST_IN_STREAM, 
+        :type => Stream::Base::TYPES_OF_POST_IN_STREAM, 
         :order => 'created_at DESC',
         :limit => 15,
         :hidden => false,
-- 
GitLab