diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index fd52f5913..9cbbca94a 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -33,10 +33,10 @@ class ApplicationController < ActionController::Base end def which_action_and_user - str = "controller=#{self.class} action=#{self.action_name} " + str = "event=request_with_user controller=#{self.class} action=#{self.action_name} " if current_user - str << "uid=#{current_user.id}" - str << "created_at=#{current_user.created_at.to_date.to_s}" if current_user.created_at + str << "uid=#{current_user.id} " + str << "user_created_at=#{current_user.created_at.to_date.to_s} " if current_user.created_at else str << 'uid=nil' end diff --git a/app/models/user.rb b/app/models/user.rb index 50fa80917..6a1762d6c 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -218,19 +218,26 @@ class User < ActiveRecord::Base end def accept_invitation!(opts = {}) - if self.invited? - log_string = "event=invitation_accepted username=#{opts[:username]} " - log_string << "inviter=#{invitations_to_me.first.sender.diaspora_handle}" if invitations_to_me.first - Rails.logger.info log_string - self.setup(opts) - self.invitation_token = nil - self.password = opts[:password] - self.password_confirmation = opts[:password_confirmation] - self.save! - invitations_to_me.each{|invitation| invitation.to_request!} + log_string = "event=invitation_accepted username=#{opts[:username]} uid=#{self.id} " + log_string << "inviter=#{invitations_to_me.first.sender.diaspora_handle} " if invitations_to_me.first + begin + if self.invited? + self.setup(opts) + self.invitation_token = nil + self.password = opts[:password] + self.password_confirmation = opts[:password_confirmation] + self.save! + invitations_to_me.each{|invitation| invitation.to_request!} + log_string << "success" + Rails.logger.info log_string - self.reload # Because to_request adds a request and saves elsewhere - self + self.reload # Because to_request adds a request and saves elsewhere + self + end + rescue Exception => e + log_string << "failure" + Rails.logger.info log_string + raise e end end diff --git a/spec/helpers/stream_helper_spec.rb b/spec/helpers/stream_helper_spec.rb index 812845457..f9672bca2 100644 --- a/spec/helpers/stream_helper_spec.rb +++ b/spec/helpers/stream_helper_spec.rb @@ -7,13 +7,14 @@ describe StreamHelper do @post = @user.post(:status_message, :message => "hi", :to => @aspect.id) end it 'renders a new comment form' do - new_comment_form(@post.id).should == - @controller.render_to_string(:partial => 'comments/new_comment', :locals => {:post_id => @post.id}) + new_comment_form(@post.id, @user).should == + @controller.render_to_string(:partial => 'comments/new_comment', + :locals => {:post_id => @post.id, :current_user => @user}) end it 'renders it fast the second time' do - new_comment_form(@post.id) + new_comment_form(@post.id, @user) time = Benchmark.realtime{ - new_comment_form(@post.id) + new_comment_form(@post.id, @user) } (time*1000).should < 1 end