Skip to content
Extraits de code Groupes Projets
Valider dea65513 rédigé par ilya's avatar ilya
Parcourir les fichiers

DG IZ; moved post() into User from Person.

parent fc7f59bd
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
......@@ -4,14 +4,10 @@ module SocketsHelper
def obj_id(object)
(object.is_a? Post) ? object.id : object.post_id
end
#def url_options
# {:host => ""}
#end
def action_hash(uid, object)
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
rescue Exception => e
Rails.logger.error("web socket view rendering failed for object #{object.inspect}.")
......
......@@ -57,16 +57,7 @@ class Person
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 ########
def comment(text, options = {})
......
......@@ -37,7 +37,17 @@ class User
Group.create(opts)
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 )
retraction = Retraction.for(post)
retraction.creator_signature = retraction.sign_with_key( encryption_key )
......
......@@ -5,7 +5,6 @@ describe 'SocketsController' do
before do
@user = Factory.create(:user)
SocketsController.unstub!(:new)
#EventMachine::WebSocket.stub!(:start)
@controller = SocketsController.new
@controller.request = mock_model(Request, :env =>
{'warden' => mock_model(Warden, :authenticate? => @user, :authenticate! => @user, :authenticate => @user)})
......
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Veuillez vous inscrire ou vous pour commenter