Chore: clean up Reporting Events (#4044)
Tech debt clean up Fixes #4057 Co-authored-by: Aswin Dev P S <aswin@chatwoot.com>
This commit is contained in:
@@ -227,7 +227,7 @@ describe ::V2::ReportBuilder do
|
||||
end
|
||||
|
||||
it 'returns average first response time' do
|
||||
label_2.events.update(value: 1.5)
|
||||
label_2.reporting_events.update(value: 1.5)
|
||||
|
||||
params = {
|
||||
metric: 'avg_first_response_time',
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
FactoryBot.define do
|
||||
factory :event do
|
||||
factory :reporting_event do
|
||||
name { 'MyString' }
|
||||
value { 1.5 }
|
||||
account_id { 1 }
|
||||
@@ -1,5 +1,5 @@
|
||||
require 'rails_helper'
|
||||
describe EventListener do
|
||||
describe ReportingEventListener do
|
||||
let(:listener) { described_class.instance }
|
||||
let!(:account) { create(:account) }
|
||||
let!(:user) { create(:user, account: account) }
|
||||
@@ -12,19 +12,19 @@ describe EventListener do
|
||||
|
||||
describe '#conversation_resolved' do
|
||||
it 'creates conversation_resolved event' do
|
||||
expect(account.events.where(name: 'conversation_resolved').count).to be 0
|
||||
expect(account.reporting_events.where(name: 'conversation_resolved').count).to be 0
|
||||
event = Events::Base.new('conversation.resolved', Time.zone.now, conversation: conversation)
|
||||
listener.conversation_resolved(event)
|
||||
expect(account.events.where(name: 'conversation_resolved').count).to be 1
|
||||
expect(account.reporting_events.where(name: 'conversation_resolved').count).to be 1
|
||||
end
|
||||
end
|
||||
|
||||
describe '#first_reply_created' do
|
||||
it 'creates first_response event' do
|
||||
previous_count = account.events.where(name: 'first_response').count
|
||||
previous_count = account.reporting_events.where(name: 'first_response').count
|
||||
event = Events::Base.new('first.reply.created', Time.zone.now, message: message)
|
||||
listener.first_reply_created(event)
|
||||
expect(account.events.where(name: 'first_response').count).to eql previous_count + 1
|
||||
expect(account.reporting_events.where(name: 'first_response').count).to eql previous_count + 1
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -18,7 +18,7 @@ RSpec.describe Account do
|
||||
it { is_expected.to have_many(:web_widgets).class_name('::Channel::WebWidget').dependent(:destroy_async) }
|
||||
it { is_expected.to have_many(:webhooks).dependent(:destroy_async) }
|
||||
it { is_expected.to have_many(:notification_settings).dependent(:destroy_async) }
|
||||
it { is_expected.to have_many(:events) }
|
||||
it { is_expected.to have_many(:reporting_events) }
|
||||
it { is_expected.to have_many(:kbase_portals).dependent(:destroy_async) }
|
||||
it { is_expected.to have_many(:kbase_categories).dependent(:destroy_async) }
|
||||
it { is_expected.to have_many(:teams).dependent(:destroy_async) }
|
||||
|
||||
@@ -29,7 +29,7 @@ RSpec.describe Inbox do
|
||||
|
||||
it { is_expected.to have_many(:webhooks).dependent(:destroy_async) }
|
||||
|
||||
it { is_expected.to have_many(:events) }
|
||||
it { is_expected.to have_many(:reporting_events) }
|
||||
|
||||
it { is_expected.to have_many(:hooks) }
|
||||
end
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe Event, type: :model do
|
||||
RSpec.describe ReportingEvent, type: :model do
|
||||
describe 'validations' do
|
||||
it { is_expected.to validate_presence_of(:account_id) }
|
||||
it { is_expected.to validate_presence_of(:name) }
|
||||
@@ -19,7 +19,7 @@ RSpec.describe User do
|
||||
it { is_expected.to have_many(:inbox_members).dependent(:destroy_async) }
|
||||
it { is_expected.to have_many(:notification_settings).dependent(:destroy_async) }
|
||||
it { is_expected.to have_many(:messages) }
|
||||
it { is_expected.to have_many(:events) }
|
||||
it { is_expected.to have_many(:reporting_events) }
|
||||
it { is_expected.to have_many(:teams) }
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user