2022-01-01 13:38:12 +00:00
|
|
|
# Copyright (C) 2012-2022 Zammad Foundation, https://zammad-foundation.org/
|
2021-06-01 12:20:20 +00:00
|
|
|
|
2019-06-04 03:40:48 +00:00
|
|
|
RSpec.shared_examples 'ChecksKbClientNotification' do
|
|
|
|
context 'sends client notifications', performs_jobs: true do
|
|
|
|
before { subject }
|
|
|
|
|
|
|
|
it 'on creation' do
|
2022-04-01 09:41:19 +00:00
|
|
|
expect(ChecksKbClientNotificationJob).to have_been_enqueued.with(subject.class.name, subject.id)
|
2019-06-04 03:40:48 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
context 'after initial notifications are cleared' do
|
|
|
|
before { clear_jobs }
|
|
|
|
|
|
|
|
it 'on update' do
|
|
|
|
subject.update(updated_at: Time.zone.now)
|
2022-04-01 09:41:19 +00:00
|
|
|
expect(ChecksKbClientNotificationJob).to have_been_enqueued.with(subject.class.name, subject.id)
|
2019-06-04 03:40:48 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
it 'on touch' do
|
|
|
|
subject.touch
|
2022-04-01 09:41:19 +00:00
|
|
|
expect(ChecksKbClientNotificationJob).to have_been_enqueued.with(subject.class.name, subject.id)
|
2019-06-04 03:40:48 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
it 'on destroy' do
|
|
|
|
subject.destroy
|
2022-04-01 09:41:19 +00:00
|
|
|
expect(ChecksKbClientNotificationJob).not_to have_been_enqueued.with(subject.class.name, subject.id)
|
2019-06-04 03:40:48 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
it 'notifications be disabled' do
|
|
|
|
ChecksKbClientNotification.disable_in_all_classes!
|
|
|
|
subject.update(updated_at: Time.zone.now)
|
|
|
|
expect(ChecksKbClientNotificationJob).not_to have_been_enqueued.at_least(:once) # some object have associations that triggers touch job after creation
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'notifications be re-enabled' do
|
|
|
|
ChecksKbClientNotification.disable_in_all_classes!
|
|
|
|
ChecksKbClientNotification.enable_in_all_classes!
|
|
|
|
subject.update(updated_at: Time.zone.now)
|
|
|
|
expect(ChecksKbClientNotificationJob).to have_been_enqueued.at_least(:once) # some object have associations that triggers touch job after creation
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|