diff --git a/app/listeners/reporting_event_listener.rb b/app/listeners/reporting_event_listener.rb index 7c625c12d..b31d899bb 100644 --- a/app/listeners/reporting_event_listener.rb +++ b/app/listeners/reporting_event_listener.rb @@ -34,7 +34,7 @@ class ReportingEventListener < BaseListener message.created_at), account_id: conversation.account_id, inbox_id: conversation.inbox_id, - user_id: conversation.assignee_id, + user_id: message.sender_id, conversation_id: conversation.id, event_start_time: last_non_human_activity(conversation), event_end_time: message.created_at diff --git a/spec/listeners/reporting_event_listener_spec.rb b/spec/listeners/reporting_event_listener_spec.rb index 86647eb87..9a6b8d123 100644 --- a/spec/listeners/reporting_event_listener_spec.rb +++ b/spec/listeners/reporting_event_listener_spec.rb @@ -99,7 +99,9 @@ describe ReportingEventListener do it 'creates first_response event with business hour value' do event = Events::Base.new('first.reply.created', Time.zone.now, message: new_message) listener.first_reply_created(event) - expect(account.reporting_events.where(name: 'first_response')[0]['value_in_business_hours']).to be 144_000.0 + reporting_event = account.reporting_events.where(name: 'first_response').first + expect(reporting_event.value_in_business_hours).to be 144_000.0 + expect(reporting_event.user_id).to be new_message.sender_id end end