DG IZ; moved post() into User from Person.
This commit is contained in:
parent
fc7f59bdfc
commit
dea6551374
4 changed files with 13 additions and 17 deletions
|
|
@ -5,13 +5,9 @@ module SocketsHelper
|
||||||
(object.is_a? Post) ? object.id : object.post_id
|
(object.is_a? Post) ? object.id : object.post_id
|
||||||
end
|
end
|
||||||
|
|
||||||
#def url_options
|
|
||||||
# {:host => ""}
|
|
||||||
#end
|
|
||||||
|
|
||||||
def action_hash(uid, object)
|
def action_hash(uid, object)
|
||||||
begin
|
begin
|
||||||
user = User.first(:id => uid)
|
user = User.find_by_id(uid)
|
||||||
v = render_to_string(:partial => type_partial(object), :locals => {:post => object, :current_user => user}) unless object.is_a? Retraction
|
v = render_to_string(:partial => type_partial(object), :locals => {:post => object, :current_user => user}) unless object.is_a? Retraction
|
||||||
rescue Exception => e
|
rescue Exception => e
|
||||||
Rails.logger.error("web socket view rendering failed for object #{object.inspect}.")
|
Rails.logger.error("web socket view rendering failed for object #{object.inspect}.")
|
||||||
|
|
|
||||||
|
|
@ -57,16 +57,7 @@ class Person
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
######## Posting ########
|
|
||||||
def post(class_name, options = {})
|
|
||||||
options[:person] = self
|
|
||||||
model_class = class_name.to_s.camelize.constantize
|
|
||||||
post = model_class.instantiate(options)
|
|
||||||
post.creator_signature = post.sign_with_key(encryption_key)
|
|
||||||
post.notify_people
|
|
||||||
post.socket_to_uid owner.id if (owner_id && post.respond_to?( :socket_to_uid))
|
|
||||||
post
|
|
||||||
end
|
|
||||||
|
|
||||||
######## Commenting ########
|
######## Commenting ########
|
||||||
def comment(text, options = {})
|
def comment(text, options = {})
|
||||||
|
|
|
||||||
|
|
@ -37,7 +37,17 @@ class User
|
||||||
Group.create(opts)
|
Group.create(opts)
|
||||||
end
|
end
|
||||||
|
|
||||||
######### Posts and Such ###############
|
######## Posting ########
|
||||||
|
def post(class_name, options = {})
|
||||||
|
options[:person] = self.person
|
||||||
|
model_class = class_name.to_s.camelize.constantize
|
||||||
|
post = model_class.instantiate(options)
|
||||||
|
post.creator_signature = post.sign_with_key(encryption_key)
|
||||||
|
post.notify_people
|
||||||
|
post.socket_to_uid owner.id if (owner_id && post.respond_to?( :socket_to_uid))
|
||||||
|
post
|
||||||
|
end ######### Posts and Such ###############
|
||||||
|
|
||||||
def retract( post )
|
def retract( post )
|
||||||
retraction = Retraction.for(post)
|
retraction = Retraction.for(post)
|
||||||
retraction.creator_signature = retraction.sign_with_key( encryption_key )
|
retraction.creator_signature = retraction.sign_with_key( encryption_key )
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,6 @@ describe 'SocketsController' do
|
||||||
before do
|
before do
|
||||||
@user = Factory.create(:user)
|
@user = Factory.create(:user)
|
||||||
SocketsController.unstub!(:new)
|
SocketsController.unstub!(:new)
|
||||||
#EventMachine::WebSocket.stub!(:start)
|
|
||||||
@controller = SocketsController.new
|
@controller = SocketsController.new
|
||||||
@controller.request = mock_model(Request, :env =>
|
@controller.request = mock_model(Request, :env =>
|
||||||
{'warden' => mock_model(Warden, :authenticate? => @user, :authenticate! => @user, :authenticate => @user)})
|
{'warden' => mock_model(Warden, :authenticate? => @user, :authenticate! => @user, :authenticate => @user)})
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue