wip welcome post, publisher object
This commit is contained in:
parent
c6a17cc00b
commit
ee74948863
6 changed files with 71 additions and 2 deletions
|
|
@ -22,7 +22,8 @@ class ApplicationController < ActionController::Base
|
|||
:my_contacts_count,
|
||||
:only_sharing_count,
|
||||
:tag_followings,
|
||||
:tags
|
||||
:tags,
|
||||
:open_publisher
|
||||
|
||||
def ensure_http_referer_is_set
|
||||
request.env['HTTP_REFERER'] ||= '/aspects'
|
||||
|
|
|
|||
|
|
@ -61,6 +61,6 @@ class TagFollowingsController < ApplicationController
|
|||
@tag_following = current_user.tag_followings.create(:tag_id => @tag.id)
|
||||
end
|
||||
|
||||
redirect_to aspects_path
|
||||
redirect_to aspects_path(:welcome => true)
|
||||
end
|
||||
end
|
||||
|
|
|
|||
18
lib/publisher.rb
Normal file
18
lib/publisher.rb
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
class Publisher
|
||||
attr_accessor :user, :open, :prefill_text, :public
|
||||
|
||||
def initialize(user, opts={})
|
||||
self.user = user
|
||||
self.open = (opts[:open] == true)? true : false
|
||||
self.prefill_text = opts[:prefill_text]
|
||||
self.public = (opts[:public] == true)? true : false
|
||||
end
|
||||
|
||||
def open?
|
||||
self.open
|
||||
end
|
||||
|
||||
def public?
|
||||
self.public
|
||||
end
|
||||
end
|
||||
|
|
@ -1,3 +1,4 @@
|
|||
require File.join(Rails.root, "lib", "publisher")
|
||||
class Stream::Base
|
||||
TYPES_OF_POST_IN_STREAM = ['StatusMessage', 'Reshare', 'ActivityStreams::Photo']
|
||||
attr_accessor :max_time, :order, :user
|
||||
|
|
@ -106,6 +107,10 @@ class Stream::Base
|
|||
@order ||= 'created_at'
|
||||
end
|
||||
|
||||
def publisher
|
||||
@publisher ||= Publisher.new(self.user)
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
# Memoizes all Contacts present in the Stream
|
||||
|
|
|
|||
41
spec/lib/publisher_spec.rb
Normal file
41
spec/lib/publisher_spec.rb
Normal file
|
|
@ -0,0 +1,41 @@
|
|||
|
||||
require 'spec_helper'
|
||||
|
||||
#NOTE;why is it not auto loadeded?
|
||||
require File.join(Rails.root, 'lib', 'publisher')
|
||||
|
||||
describe Publisher do
|
||||
before do
|
||||
@publisher = Publisher.new(alice)
|
||||
end
|
||||
|
||||
describe '#open?' do
|
||||
it 'defaults to closed' do
|
||||
@publisher.open?.should be_false
|
||||
end
|
||||
|
||||
it 'listens to the opts' do
|
||||
Publisher.new(alice, :open => true).open?.should be_true
|
||||
end
|
||||
end
|
||||
|
||||
describe "#prefill" do
|
||||
it 'defaults to nothing' do
|
||||
@publisher.prefill_text.should be_blank
|
||||
end
|
||||
|
||||
it 'is settable' do
|
||||
Publisher.new(alice, :prefill_text => "party!").prefill_text.should == "party!"
|
||||
end
|
||||
end
|
||||
|
||||
describe "#public?" do
|
||||
it 'defaults to false' do
|
||||
@publisher.public?.should be_false
|
||||
end
|
||||
|
||||
it 'listens to the opts' do
|
||||
Publisher.new(alice, :public => true).public?.should be_true
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
@ -40,6 +40,10 @@ describe 'Streams' do
|
|||
@stream.order=nil
|
||||
@stream.order.should == 'created_at'
|
||||
end
|
||||
|
||||
it 'initializes a publisher' do
|
||||
@stream.publisher.should be_a(Publisher)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
Loading…
Reference in a new issue