Commit ee749488 authored by Ilya Zhitomirskiy's avatar Ilya Zhitomirskiy Committed by danielgrippi

wip welcome post, publisher object

parent c6a17cc0
......@@ -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
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
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
......
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
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