diff --git a/app/controllers/streams_controller.rb b/app/controllers/streams_controller.rb index 50a240f37..f7f00f772 100644 --- a/app/controllers/streams_controller.rb +++ b/app/controllers/streams_controller.rb @@ -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 diff --git a/app/views/layouts/main_stream.html.haml b/app/views/layouts/main_stream.html.haml index 81474102b..4a73f346e 100644 --- a/app/views/layouts/main_stream.html.haml +++ b/app/views/layouts/main_stream.html.haml @@ -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' diff --git a/config/locales/diaspora/en.yml b/config/locales/diaspora/en.yml index ff6a6fcf5..ed793e74f 100644 --- a/config/locales/diaspora/en.yml +++ b/config/locales/diaspora/en.yml @@ -929,6 +929,8 @@ en: aspects: title: "Your Aspects" + participate: + title: "Participate" users: logged_out: signed_out: "You've signed out of Diaspora*" diff --git a/config/routes.rb b/config/routes.rb index 260610739..153e5ce37 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -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" diff --git a/lib/stream/base.rb b/lib/stream/base.rb index 826954183..b3af708ca 100644 --- a/lib/stream/base.rb +++ b/lib/stream/base.rb @@ -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!' diff --git a/lib/stream/participate.rb b/lib/stream/participate.rb new file mode 100644 index 000000000..f942858ea --- /dev/null +++ b/lib/stream/participate.rb @@ -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] AR association of posts + def posts + @posts ||= EvilQuery::Participation.new(user).posts + end + +end \ No newline at end of file diff --git a/public/javascripts/app/router.js b/public/javascripts/app/router.js index ca3c05775..4b29da6a6 100644 --- a/public/javascripts/app/router.js +++ b/public/javascripts/app/router.js @@ -1,5 +1,6 @@ app.Router = Backbone.Router.extend({ routes: { + "participate": "stream", "stream": "stream", "aspects:query": "stream", "commented": "stream", diff --git a/spec/controllers/streams_controller_spec.rb b/spec/controllers/streams_controller_spec.rb index 6b713e06d..87a278bf0 100644 --- a/spec/controllers/streams_controller_spec.rb +++ b/spec/controllers/streams_controller_spec.rb @@ -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 diff --git a/spec/lib/stream/participate_spec.rb b/spec/lib/stream/participate_spec.rb new file mode 100644 index 000000000..ff9349d72 --- /dev/null +++ b/spec/lib/stream/participate_spec.rb @@ -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 diff --git a/spec/support/no_id_on_object.rb b/spec/support/no_id_on_object.rb deleted file mode 100644 index 00914edfa..000000000 --- a/spec/support/no_id_on_object.rb +++ /dev/null @@ -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