particpate stream, yo!

This commit is contained in:
danielgrippi 2012-02-01 16:05:16 -08:00
parent c7d422c338
commit 310a0679f1
10 changed files with 53 additions and 35 deletions

View file

@ -8,6 +8,8 @@ require File.join(Rails.root, "lib", "stream", "comments")
require File.join(Rails.root, "lib", "stream", "likes")
require File.join(Rails.root, "lib", "stream", "mention")
require File.join(Rails.root, "lib", "stream", "followed_tag")
require File.join(Rails.root, "lib", "stream", "participate")
class StreamsController < ApplicationController
before_filter :authenticate_user!
@ -29,6 +31,10 @@ class StreamsController < ApplicationController
stream_responder(Stream::Public)
end
def participate
stream_responder(Stream::Participate)
end
def multi
stream_responder(Stream::Multi)
end

View file

@ -37,9 +37,12 @@
#followed_tags_listing
= render 'tags/followed_tags_listings'
/participation stream
%br
%ul.left_nav
%li
= link_to t("streams.participate.title"), participate_stream_path, :class => 'home_selector', :rel => 'backbone'
%ul.left_nav.sub
%li
= link_to t('streams.like_stream.title'), liked_stream_path, :class => 'home_selector', :rel => 'backbone'

View file

@ -929,6 +929,8 @@ en:
aspects:
title: "Your Aspects"
participate:
title: "Participate"
users:
logged_out:
signed_out: "You've signed out of Diaspora*"

View file

@ -21,6 +21,7 @@ Diaspora::Application.routes.draw do
end
# Streams
get "participate" => "streams#participate", :as => "participate_stream"
get "public" => "streams#public", :as => "public_stream"
get "stream" => "streams#multi", :as => "multi_stream"
get "followed_tags" => "streams#followed_tags", :as => "followed_tags_stream"

View file

@ -11,16 +11,6 @@ class Stream::Base
self.publisher = Publisher.new(self.user, publisher_opts)
end
# @return [Person]
def random_community_spotlight_member
@random_community_spotlight_member ||= Person.find_by_diaspora_handle(spotlight_diaspora_id)
end
# @return [Boolean]
def has_community_spotlight?
random_community_spotlight_member.present?
end
#requied to implement said stream
def link(opts={})
'change me in lib/base_stream.rb!'

15
lib/stream/participate.rb Normal file
View file

@ -0,0 +1,15 @@
class Stream::Participate < Stream::Base
def link(opts={})
Rails.application.routes.url_helpers.participate_stream_path(opts)
end
def title
I18n.translate("streams.participate.title")
end
# @return [ActiveRecord::Association<Post>] AR association of posts
def posts
@posts ||= EvilQuery::Participation.new(user).posts
end
end

View file

@ -1,5 +1,6 @@
app.Router = Backbone.Router.extend({
routes: {
"participate": "stream",
"stream": "stream",
"aspects:query": "stream",
"commented": "stream",

View file

@ -50,22 +50,19 @@ describe StreamsController do
end
end
streams = [
{:path => :liked, :type => Stream::Likes},
{:path => :mentioned, :type => Stream::Mention},
{:path => :followed_tags, :type => Stream::FollowedTag}
]
streams = {
:liked => Stream::Likes,
:mentioned => Stream::Mention,
:followed_tags => Stream::FollowedTag,
:participate => Stream::Participate
}
streams.each do |s|
describe "##{s[:path]}" do
it 'succeeds' do
get s[:path]
streams.each do |stream_path, stream_class|
describe "a GET to #{stream_path}" do
it 'assigns a stream of the proper class' do
get stream_path
response.should be_success
end
it 'assigns a stream' do
get s[:path]
assigns[:stream].should be_a s[:type]
assigns[:stream].should be_a stream_class
end
end
end

View file

@ -0,0 +1,12 @@
require 'spec_helper'
require File.join(Rails.root, 'spec', 'shared_behaviors', 'stream')
describe Stream::Participate do
before do
@stream = Stream::Participate.new(alice, :max_time => Time.now, :order => 'updated_at')
end
describe 'shared behaviors' do
it_should_behave_like 'it is a stream'
end
end

View file

@ -1,9 +0,0 @@
#class Object
# def id
# if self.class.ancestors.include?(ActiveRecord::Base)
# super
# else
# raise "You are calling id on a non-ActiveRecord object. STOP IT."
# end
# end
#end