Maintenance: Bump rubocop-rails from 2.12.4 to 2.13.0
Bumps [rubocop-rails](https://github.com/rubocop/rubocop-rails) from 2.12.4 to 2.13.0. - [Release notes](https://github.com/rubocop/rubocop-rails/releases) - [Changelog](https://github.com/rubocop/rubocop-rails/blob/master/CHANGELOG.md) - [Commits](https://github.com/rubocop/rubocop-rails/compare/v2.12.4...v2.13.0)
This commit is contained in:
parent
2c4ca0adfa
commit
6714b5f1a4
40 changed files with 94 additions and 97 deletions
|
@ -189,6 +189,10 @@ Rails/SkipsModelValidations:
|
|||
- "**/*_spec.rb"
|
||||
- "**/*_examples.rb"
|
||||
|
||||
Rails/ReversibleMigration:
|
||||
Description: This cop checks whether the change method of the migration file is reversible.
|
||||
Enabled: false
|
||||
|
||||
Style/ClassAndModuleChildren:
|
||||
Description: 'Checks style of children classes and modules.'
|
||||
Enabled: false
|
||||
|
|
|
@ -523,7 +523,7 @@ GEM
|
|||
rubocop-performance (1.13.1)
|
||||
rubocop (>= 1.7.0, < 2.0)
|
||||
rubocop-ast (>= 0.4.0)
|
||||
rubocop-rails (2.12.4)
|
||||
rubocop-rails (2.13.0)
|
||||
activesupport (>= 4.2.0)
|
||||
rack (>= 1.1)
|
||||
rubocop (>= 1.7.0, < 2.0)
|
||||
|
@ -644,7 +644,7 @@ GEM
|
|||
writeexcel (1.0.5)
|
||||
xpath (3.2.0)
|
||||
nokogiri (~> 1.8)
|
||||
zeitwerk (2.5.1)
|
||||
zeitwerk (2.5.2)
|
||||
zendesk_api (1.33.0)
|
||||
faraday (>= 0.9.0, < 2.0.0)
|
||||
hashie (>= 3.5.2, < 5.0.0)
|
||||
|
|
|
@ -24,9 +24,9 @@ module ApplicationController::HandlesDevices
|
|||
|
||||
if user_device_updated_at
|
||||
# check if entry exists / only if write action
|
||||
diff = Time.zone.now - 10.minutes
|
||||
diff = 10.minutes.ago
|
||||
if %w[GET OPTIONS HEAD].include?(request.method)
|
||||
diff = Time.zone.now - 30.minutes
|
||||
diff = 30.minutes.ago
|
||||
end
|
||||
|
||||
# only update if needed
|
||||
|
|
|
@ -34,7 +34,7 @@ curl http://localhost/api/v1/monitoring/health_check?token=XXX
|
|||
actions = Set.new
|
||||
|
||||
# channel check
|
||||
last_run_tolerance = Time.zone.now - 1.hour
|
||||
last_run_tolerance = 1.hour.ago
|
||||
options_keys = %w[host user uid]
|
||||
Channel.where(active: true).each do |channel|
|
||||
|
||||
|
@ -124,7 +124,7 @@ curl http://localhost/api/v1/monitoring/health_check?token=XXX
|
|||
end
|
||||
|
||||
# job count check
|
||||
total_jobs = Delayed::Job.where('created_at < ?', Time.zone.now - 15.minutes).count
|
||||
total_jobs = Delayed::Job.where('created_at < ?', 15.minutes.ago).count
|
||||
if total_jobs > 8000
|
||||
issues.push "#{total_jobs} background jobs in queue"
|
||||
end
|
||||
|
|
|
@ -151,7 +151,7 @@ class ReportsController < ApplicationController
|
|||
|
||||
case params[:timeRange]
|
||||
when 'realtime'
|
||||
start_at = (Time.zone.now - 60.minutes)
|
||||
start_at = 60.minutes.ago
|
||||
stop_at = Time.zone.now
|
||||
range = 'minute'
|
||||
when 'day'
|
||||
|
|
|
@ -17,7 +17,7 @@ class UserDevicesController < ApplicationController
|
|||
attributes.delete('fingerprint')
|
||||
|
||||
# mark current device to prevent killing own session via user preferences device management
|
||||
if session[:user_device_fingerprint] == device.fingerprint && device.updated_at > Time.zone.now - 30.minutes
|
||||
if session[:user_device_fingerprint] == device.fingerprint && device.updated_at > 30.minutes.ago
|
||||
attributes['current'] = true
|
||||
end
|
||||
devices_full.push attributes
|
||||
|
|
|
@ -56,7 +56,7 @@ class Channel::Driver::Facebook
|
|||
# only fetch once in 5 minutes
|
||||
return true if !channel.preferences
|
||||
return true if !channel.preferences[:last_fetch]
|
||||
return false if channel.preferences[:last_fetch] > Time.zone.now - 5.minutes
|
||||
return false if channel.preferences[:last_fetch] > 5.minutes.ago
|
||||
|
||||
true
|
||||
end
|
||||
|
|
|
@ -437,7 +437,7 @@ returns
|
|||
Rails.logger.error e
|
||||
return true
|
||||
end
|
||||
return true if verify_time < Time.zone.now - 30.minutes
|
||||
return true if verify_time < 30.minutes.ago
|
||||
|
||||
Rails.logger.info " - ignore message #{count}/#{count_all} - because message has a verify message"
|
||||
|
||||
|
|
|
@ -152,7 +152,7 @@ returns
|
|||
if mail.match?(%r{(X-Zammad-Ignore: true|X-Zammad-Verify: true)}) && mail =~ %r{X-Zammad-Verify-Time:\s(.+?)\s}
|
||||
begin
|
||||
verify_time = Time.zone.parse($1)
|
||||
if verify_time > Time.zone.now - 30.minutes
|
||||
if verify_time > 30.minutes.ago
|
||||
info = " - ignore message #{count}/#{count_all} - because it's a verify message"
|
||||
Rails.logger.info info
|
||||
next
|
||||
|
|
|
@ -80,7 +80,7 @@ returns
|
|||
# only fetch once in 30 minutes
|
||||
return true if !channel.preferences
|
||||
return true if !channel.preferences[:last_fetch]
|
||||
return false if channel.preferences[:last_fetch] > Time.zone.now - 20.minutes
|
||||
return false if channel.preferences[:last_fetch] > 20.minutes.ago
|
||||
|
||||
true
|
||||
end
|
||||
|
|
|
@ -507,7 +507,7 @@ optional you can ignore it for dedicated user
|
|||
def self.broadcast_agent_state_update(chat_ids, ignore_user_id = nil)
|
||||
|
||||
# send broadcast to agents
|
||||
Chat::Agent.where('active = ? OR updated_at > ?', true, Time.zone.now - 8.hours).each do |item|
|
||||
Chat::Agent.where('active = ? OR updated_at > ?', true, 8.hours.ago).each do |item|
|
||||
next if item.updated_by_id == ignore_user_id
|
||||
|
||||
user = User.lookup(id: item.updated_by_id)
|
||||
|
|
|
@ -68,10 +68,10 @@ job.run(true)
|
|||
return false if !active
|
||||
|
||||
# only execute jobs older than 1 min to give admin time to make last-minute changes
|
||||
return false if updated_at > Time.zone.now - 1.minute
|
||||
return false if updated_at > 1.minute.ago
|
||||
|
||||
# check if job got stuck
|
||||
return false if running == true && last_run_at && Time.zone.now - 1.day < last_run_at
|
||||
return false if running == true && last_run_at && 1.day.ago < last_run_at
|
||||
|
||||
# check if jobs need to be executed
|
||||
# ignore if job was running within last 10 min.
|
||||
|
|
|
@ -18,8 +18,6 @@ class KnowledgeBase::Answer < ApplicationModel
|
|||
|
||||
acts_as_list scope: :category, top_of_list: 0
|
||||
|
||||
validates :category, presence: true
|
||||
|
||||
# provide consistent naming with KB category
|
||||
alias_attribute :parent, :category
|
||||
|
||||
|
|
|
@ -19,7 +19,6 @@ class KnowledgeBase::Answer::Translation < ApplicationModel
|
|||
accepts_nested_attributes_for :content, update_only: true
|
||||
|
||||
validates :title, presence: true, length: { maximum: 250 }
|
||||
validates :content, presence: true
|
||||
validates :kb_locale_id, uniqueness: { case_sensitive: true, scope: :answer_id }
|
||||
|
||||
scope :neighbours_of, ->(translation) { joins(:answer).where(knowledge_base_answers: { category_id: translation.answer&.category_id }) }
|
||||
|
|
|
@ -9,10 +9,8 @@ class KnowledgeBase::Category::Translation < ApplicationModel
|
|||
AGENT_ALLOWED_ATTRIBUTES = %i[title kb_locale_id].freeze
|
||||
|
||||
belongs_to :kb_locale, class_name: 'KnowledgeBase::Locale', inverse_of: :category_translations
|
||||
validates :kb_locale, presence: true
|
||||
|
||||
belongs_to :category, class_name: 'KnowledgeBase::Category', inverse_of: :translations, touch: true
|
||||
validates :category, presence: true
|
||||
|
||||
validates :title, presence: true
|
||||
validates :kb_locale_id, uniqueness: { case_sensitive: true, scope: :category_id }
|
||||
|
|
|
@ -225,7 +225,7 @@ with dedicated times
|
|||
|
||||
=end
|
||||
|
||||
def self.cleanup(max_age = Time.zone.now - 9.months, max_own_seen = Time.zone.now - 10.minutes, max_auto_seen = Time.zone.now - 8.hours)
|
||||
def self.cleanup(max_age = Time.zone.now - 9.months, max_own_seen = 10.minutes.ago, max_auto_seen = 8.hours.ago)
|
||||
OnlineNotification.where('created_at < ?', max_age).delete_all
|
||||
OnlineNotification.where('seen = ? AND updated_at < ?', true, max_own_seen).each do |notification|
|
||||
|
||||
|
|
|
@ -186,7 +186,7 @@ returns
|
|||
result = []
|
||||
|
||||
# fetch all escalated and soon to be escalating tickets
|
||||
where('escalation_at <= ?', Time.zone.now + 15.minutes).find_each(batch_size: 500) do |ticket|
|
||||
where('escalation_at <= ?', 15.minutes.from_now).find_each(batch_size: 500) do |ticket|
|
||||
|
||||
article_id = nil
|
||||
article = Ticket::Article.last_customer_agent_article(ticket.id)
|
||||
|
|
|
@ -93,7 +93,7 @@ cleanup old token
|
|||
=end
|
||||
|
||||
def self.cleanup
|
||||
Token.where('persistent IS ? AND created_at < ?', nil, Time.zone.now - 30.days).delete_all
|
||||
Token.where('persistent IS ? AND created_at < ?', nil, 30.days.ago).delete_all
|
||||
true
|
||||
end
|
||||
|
||||
|
|
|
@ -54,7 +54,7 @@ class Transaction::Karma
|
|||
|
||||
if @item[:type] == 'reminder_reached'
|
||||
return if ticket.owner_id == 1
|
||||
return if ticket.pending_time && ticket.pending_time > Time.zone.now - 2.days
|
||||
return if ticket.pending_time && ticket.pending_time > 2.days.ago
|
||||
|
||||
Karma::ActivityLog.add('ticket reminder overdue (+2 days)', ticket.owner, 'Ticket', ticket.id)
|
||||
return
|
||||
|
|
|
@ -27,7 +27,7 @@ class User
|
|||
email_address_validation = EmailAddressValidation.new(email)
|
||||
return if !email_address_validation.valid_format?
|
||||
|
||||
return if !saved_change_to_attribute?('email') && updated_at > Time.zone.now - 10.days
|
||||
return if !saved_change_to_attribute?('email') && updated_at > 10.days.ago
|
||||
|
||||
avatar_auto_detection
|
||||
end
|
||||
|
|
|
@ -6,7 +6,6 @@ class RemoveNetwork < ActiveRecord::Migration[5.0]
|
|||
def change
|
||||
return if !ActiveRecord::Base.connection.table_exists? 'networks'
|
||||
|
||||
# rubocop:disable Rails/ReversibleMigration
|
||||
drop_table :networks
|
||||
drop_table :network_category_types
|
||||
drop_table :network_privacies
|
||||
|
@ -17,6 +16,5 @@ class RemoveNetwork < ActiveRecord::Migration[5.0]
|
|||
drop_table :network_item_plus
|
||||
drop_table :network_category_subscriptions
|
||||
drop_table :network_item_subscriptions
|
||||
# rubocop:enable Rails/ReversibleMigration
|
||||
end
|
||||
end
|
||||
|
|
|
@ -222,7 +222,7 @@ class ExternalCredential::Microsoft365
|
|||
end
|
||||
|
||||
def self.refresh_token(token)
|
||||
return token if token[:created_at] >= Time.zone.now - 50.minutes
|
||||
return token if token[:created_at] >= 50.minutes.ago
|
||||
|
||||
params = refresh_token_params(token)
|
||||
uri = refresh_token_uri(token)
|
||||
|
|
|
@ -41,10 +41,10 @@ module SessionHelper
|
|||
def self.cleanup_expired
|
||||
|
||||
# delete temp. sessions
|
||||
ActiveRecord::SessionStore::Session.where('persistent IS NULL AND updated_at < ?', Time.zone.now - 2.hours).delete_all
|
||||
ActiveRecord::SessionStore::Session.where('persistent IS NULL AND updated_at < ?', 2.hours.ago).delete_all
|
||||
|
||||
# web sessions not updated the last x days
|
||||
ActiveRecord::SessionStore::Session.where('updated_at < ?', Time.zone.now - 60.days).delete_all
|
||||
ActiveRecord::SessionStore::Session.where('updated_at < ?', 60.days.ago).delete_all
|
||||
|
||||
end
|
||||
|
||||
|
|
|
@ -16,14 +16,14 @@ class Stats::TicketInProcess
|
|||
closed_state_ids = Ticket::State.by_category(:closed).pluck(:id)
|
||||
closed_ticket_ids = Ticket.select('id').where(
|
||||
'owner_id = ? AND state_id IN (?) AND close_at > ?',
|
||||
user.id, closed_state_ids, Time.zone.now - 1.day
|
||||
user.id, closed_state_ids, 1.day.ago
|
||||
).limit(100).pluck(:id)
|
||||
|
||||
# get all tickets which I changed to pending action
|
||||
pending_action_state_ids = Ticket::State.by_category(:pending_action).pluck(:id)
|
||||
pending_action_ticket_ids = Ticket.select('id').where(
|
||||
'owner_id = ? AND state_id IN (?) AND updated_at > ?',
|
||||
user.id, pending_action_state_ids, Time.zone.now - 1.day
|
||||
user.id, pending_action_state_ids, 1.day.ago
|
||||
).limit(100).pluck(:id)
|
||||
|
||||
all_ticket_ids = own_ticket_ids.concat(closed_ticket_ids).concat(pending_action_ticket_ids).uniq
|
||||
|
@ -31,7 +31,7 @@ class Stats::TicketInProcess
|
|||
# get count where user worked on
|
||||
history_object = History::Object.lookup(name: 'Ticket')
|
||||
count = History.select('DISTINCT(o_id)').where(
|
||||
'histories.created_at >= ? AND histories.history_object_id = ? AND histories.created_by_id = ? AND histories.o_id IN (?)', Time.zone.now - 1.day, history_object.id, user.id, all_ticket_ids
|
||||
'histories.created_at >= ? AND histories.history_object_id = ? AND histories.created_by_id = ? AND histories.o_id IN (?)', 1.day.ago, history_object.id, user.id, all_ticket_ids
|
||||
).count
|
||||
|
||||
total = all_ticket_ids.count
|
||||
|
|
|
@ -7,7 +7,7 @@ class Stats::TicketReopen
|
|||
# get my closed tickets
|
||||
total = Ticket.select('id').where(
|
||||
'owner_id = ? AND close_at > ?',
|
||||
user.id, Time.zone.now - 7.days
|
||||
user.id, 7.days.ago
|
||||
).count
|
||||
|
||||
# get count of reopens
|
||||
|
|
|
@ -22,7 +22,7 @@ class Stats::TicketResponseTime
|
|||
end
|
||||
|
||||
def self.generate(user)
|
||||
items = StatsStore.where('created_at > ? AND created_at < ?', Time.zone.now - 7.days, Time.zone.now).where(key: 'ticket:response_time')
|
||||
items = StatsStore.where('created_at > ? AND created_at < ?', 7.days.ago, Time.zone.now).where(key: 'ticket:response_time')
|
||||
total = 0
|
||||
count_own = 0
|
||||
own = 0
|
||||
|
|
|
@ -551,7 +551,7 @@ create a tweet or direct message from an article
|
|||
max_count = 120
|
||||
max_count *= factor
|
||||
type_id = Ticket::Article::Type.lookup(name: 'twitter status').id
|
||||
created_at = Time.zone.now - 15.minutes
|
||||
created_at = 15.minutes.ago
|
||||
created_count = Ticket::Article.where('created_at > ? AND type_id = ?', created_at, type_id).count
|
||||
if created_count > max_count
|
||||
Rails.logger.info "Tweet limit of #{created_count}/#{max_count} reached, ignored tweed id (#{tweet.id})"
|
||||
|
|
|
@ -132,7 +132,7 @@ RSpec.describe Escalation::TicketBizBreak, time_zone: 'Europe/Berlin' do
|
|||
let(:second_value) { result.values.second }
|
||||
|
||||
it { expect(result.keys.count).to be(6) }
|
||||
it { expect(result.keys).to eq ((Time.current - 5.days).to_date..Time.current).to_a }
|
||||
it { expect(result.keys).to eq (5.days.ago.to_date..Time.current).to_a }
|
||||
it { expect(result.values[0].keys).to eq %w[12:00] }
|
||||
it { expect(result.values[0]['12:00']).to eq '24:00' }
|
||||
it { expect(result.values[1].keys).to eq %w[00:00] }
|
||||
|
@ -257,7 +257,7 @@ RSpec.describe Escalation::TicketBizBreak, time_zone: 'Europe/Berlin' do
|
|||
let(:history_to) { mock_state_hash(ticket.created_at + 2.days, 'pending close', 'closed') }
|
||||
|
||||
it { expect(result).to be_a Hash }
|
||||
it { expect(result.keys).to eq [Time.current.to_date, Time.current.tomorrow.to_date, (Time.current + 2.days).to_date] }
|
||||
it { expect(result.keys).to eq [Time.current.to_date, Time.current.tomorrow.to_date, 2.days.from_now.to_date] }
|
||||
it { expect(result.values.first).to eq({ '13:30' => '24:00' }) }
|
||||
it { expect(result.values.second).to eq({ '00:00' => '24:00' }) }
|
||||
it { expect(result.values.third).to eq({ '00:00' => '12:00' }) }
|
||||
|
|
|
@ -28,8 +28,8 @@ RSpec.describe Stats::TicketWaitingTime do
|
|||
let(:ticket) { create(:ticket, group: group) }
|
||||
|
||||
before do
|
||||
create(:ticket_article, sender_name: 'Customer', ticket: ticket, created_at: Time.current + 1.hour)
|
||||
create(:ticket_article, sender_name: 'Agent', ticket: ticket, created_at: Time.current + 2.hours)
|
||||
create(:ticket_article, sender_name: 'Customer', ticket: ticket, created_at: 1.hour.from_now)
|
||||
create(:ticket_article, sender_name: 'Agent', ticket: ticket, created_at: 2.hours.from_now)
|
||||
end
|
||||
|
||||
it 'returns a hash with 1-day average ticket wait time across user’s groups (in minutes)' do
|
||||
|
@ -42,8 +42,8 @@ RSpec.describe Stats::TicketWaitingTime do
|
|||
let(:ticket) { create(:ticket, group: group, owner_id: user.id) }
|
||||
|
||||
before do
|
||||
create(:ticket_article, sender_name: 'Customer', ticket: ticket, created_at: Time.current + 1.hour)
|
||||
create(:ticket_article, sender_name: 'Agent', ticket: ticket, created_at: Time.current + 2.hours)
|
||||
create(:ticket_article, sender_name: 'Customer', ticket: ticket, created_at: 1.hour.from_now)
|
||||
create(:ticket_article, sender_name: 'Agent', ticket: ticket, created_at: 2.hours.from_now)
|
||||
end
|
||||
|
||||
it 'returns a hash with 1-day average ticket wait time for user (in minutes)' do
|
||||
|
@ -66,8 +66,8 @@ RSpec.describe Stats::TicketWaitingTime do
|
|||
let(:other_ticket) { create(:ticket, group: group) }
|
||||
|
||||
before do
|
||||
create(:ticket_article, sender_name: 'Customer', ticket: other_ticket, created_at: Time.current + 1.hour)
|
||||
create(:ticket_article, sender_name: 'Agent', ticket: other_ticket, created_at: Time.current + 3.hours)
|
||||
create(:ticket_article, sender_name: 'Customer', ticket: other_ticket, created_at: 1.hour.from_now)
|
||||
create(:ticket_article, sender_name: 'Agent', ticket: other_ticket, created_at: 3.hours.from_now)
|
||||
end
|
||||
|
||||
it 'returns a hash with 1-day average ticket wait time across user’s groups (in minutes)' do
|
||||
|
|
|
@ -124,7 +124,7 @@ RSpec.describe Channel::Filter::ImportArchive do
|
|||
|
||||
context 'when initial ticket (import till outdated)' do
|
||||
let(:channel_as_model) do
|
||||
Channel.new(options: { inbound: { options: { archive: true, archive_till: (Time.zone.now - 1.day).to_s } } })
|
||||
Channel.new(options: { inbound: { options: { archive: true, archive_till: 1.day.ago.to_s } } })
|
||||
end
|
||||
|
||||
include_examples 'notification sent checks', 1
|
||||
|
@ -132,7 +132,7 @@ RSpec.describe Channel::Filter::ImportArchive do
|
|||
|
||||
context 'when initial ticket (import till matched)' do
|
||||
let(:channel_as_model) do
|
||||
Channel.new(options: { inbound: { options: { archive: true, archive_till: (Time.zone.now + 1.day).to_s } } })
|
||||
Channel.new(options: { inbound: { options: { archive: true, archive_till: 1.day.from_now.to_s } } })
|
||||
end
|
||||
|
||||
include_examples 'notification sent checks', 0
|
||||
|
@ -156,7 +156,7 @@ RSpec.describe Channel::Filter::ImportArchive do
|
|||
|
||||
context 'when initial ticket (import till outdated) with channel hash' do
|
||||
let(:channel_as_hash) do
|
||||
{ options: { inbound: { options: { archive: true, archive_till: (Time.zone.now - 1.day).to_s } } } }
|
||||
{ options: { inbound: { options: { archive: true, archive_till: 1.day.ago.to_s } } } }
|
||||
end
|
||||
|
||||
include_examples 'notification sent checks', 1, true
|
||||
|
@ -164,7 +164,7 @@ RSpec.describe Channel::Filter::ImportArchive do
|
|||
|
||||
context 'when initial ticket (import till matched) with channel hash' do
|
||||
let(:channel_as_hash) do
|
||||
{ options: { inbound: { options: { archive: true, archive_till: (Time.zone.now + 1.day).to_s } } } }
|
||||
{ options: { inbound: { options: { archive: true, archive_till: 1.day.from_now.to_s } } } }
|
||||
end
|
||||
|
||||
include_examples 'notification sent checks', 0, true
|
||||
|
|
|
@ -10,7 +10,7 @@ RSpec.shared_examples 'ChecksCoreWorkflow' do
|
|||
end
|
||||
|
||||
context 'when creation of closed tickets are only allowed by type set' do
|
||||
subject(:ticket) { create(:ticket, group: agent_group, screen: 'create_middle', state: Ticket::State.find_by(name: 'open'), pending_time: Time.zone.now + 5.days) }
|
||||
subject(:ticket) { create(:ticket, group: agent_group, screen: 'create_middle', state: Ticket::State.find_by(name: 'open'), pending_time: 5.days.from_now) }
|
||||
|
||||
before do
|
||||
create(:core_workflow,
|
||||
|
@ -29,7 +29,7 @@ RSpec.shared_examples 'ChecksCoreWorkflow' do
|
|||
end
|
||||
|
||||
context 'when creation of closed tickets are only allowed by type remove' do
|
||||
subject(:ticket) { create(:ticket, group: agent_group, screen: 'create_middle', state: Ticket::State.find_by(name: 'open'), pending_time: Time.zone.now + 5.days) }
|
||||
subject(:ticket) { create(:ticket, group: agent_group, screen: 'create_middle', state: Ticket::State.find_by(name: 'open'), pending_time: 5.days.from_now) }
|
||||
|
||||
before do
|
||||
create(:core_workflow,
|
||||
|
@ -48,7 +48,7 @@ RSpec.shared_examples 'ChecksCoreWorkflow' do
|
|||
end
|
||||
|
||||
context 'when creation of closed tickets are only allowed by type add' do
|
||||
subject(:ticket) { create(:ticket, group: agent_group, screen: 'create_middle', state: Ticket::State.find_by(name: 'open'), pending_time: Time.zone.now + 5.days) }
|
||||
subject(:ticket) { create(:ticket, group: agent_group, screen: 'create_middle', state: Ticket::State.find_by(name: 'open'), pending_time: 5.days.from_now) }
|
||||
|
||||
before do
|
||||
create(:core_workflow,
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
require 'rails_helper'
|
||||
|
||||
RSpec.describe CoreWorkflow::Attributes, type: :model do
|
||||
let!(:ticket) { create(:ticket, state: Ticket::State.find_by(name: 'pending reminder'), pending_time: Time.zone.now + 5.days) }
|
||||
let!(:ticket) { create(:ticket, state: Ticket::State.find_by(name: 'pending reminder'), pending_time: 5.days.from_now) }
|
||||
let!(:base_payload) do
|
||||
{
|
||||
'event' => 'core_workflow',
|
||||
|
|
|
@ -4,7 +4,7 @@ require 'rails_helper'
|
|||
|
||||
RSpec.describe CoreWorkflow, type: :model do
|
||||
let(:group) { create(:group) }
|
||||
let!(:ticket) { create(:ticket, state: Ticket::State.find_by(name: 'pending reminder'), pending_time: Time.zone.now + 5.days, group: group) }
|
||||
let!(:ticket) { create(:ticket, state: Ticket::State.find_by(name: 'pending reminder'), pending_time: 5.days.from_now, group: group) }
|
||||
let!(:base_payload) do
|
||||
{
|
||||
'event' => 'core_workflow',
|
||||
|
|
|
@ -393,7 +393,7 @@ RSpec.describe 'Monitoring', type: :request do
|
|||
|
||||
# health_check - scheduler may not run
|
||||
scheduler = Scheduler.where(active: true).last
|
||||
scheduler.last_run = Time.zone.now - 20.minutes
|
||||
scheduler.last_run = 20.minutes.ago
|
||||
scheduler.period = 600
|
||||
scheduler.save!
|
||||
|
||||
|
@ -408,7 +408,7 @@ RSpec.describe 'Monitoring', type: :request do
|
|||
|
||||
# health_check - scheduler may not run
|
||||
scheduler = Scheduler.where(active: true).last
|
||||
scheduler.last_run = Time.zone.now - 1.day
|
||||
scheduler.last_run = 1.day.ago
|
||||
scheduler.period = 600
|
||||
scheduler.save!
|
||||
|
||||
|
|
|
@ -138,7 +138,7 @@ RSpec.describe 'User Device', type: :request, sends_notification_emails: true do
|
|||
user_device_last = UserDevice.last
|
||||
expect(user_device_first.updated_at.to_s).to eq(user_device_last.updated_at.to_s)
|
||||
|
||||
ENV['USER_DEVICE_UPDATED_AT'] = (Time.zone.now - 4.hours).to_s
|
||||
ENV['USER_DEVICE_UPDATED_AT'] = 4.hours.ago.to_s
|
||||
params = {}
|
||||
get '/api/v1/users', params: params, as: :json
|
||||
expect(response).to have_http_status(:ok)
|
||||
|
@ -393,7 +393,7 @@ RSpec.describe 'User Device', type: :request, sends_notification_emails: true do
|
|||
expect(user_device_first.id).to eq(user_device_last.id)
|
||||
expect(user_device_first.updated_at.to_s).to eq(user_device_last.updated_at.to_s)
|
||||
|
||||
user_device_last.updated_at = Time.zone.now - 4.hours
|
||||
user_device_last.updated_at = 4.hours.ago
|
||||
user_device_last.save!
|
||||
|
||||
params = {}
|
||||
|
@ -567,7 +567,7 @@ RSpec.describe 'User Device', type: :request, sends_notification_emails: true do
|
|||
|
||||
expect(UserDevice.where(user_id: agent.id).count).to eq(0)
|
||||
|
||||
ENV['USER_DEVICE_UPDATED_AT'] = (Time.zone.now - 4.hours).to_s
|
||||
ENV['USER_DEVICE_UPDATED_AT'] = 4.hours.ago.to_s
|
||||
params = {}
|
||||
get '/api/v1/users', params: params, as: :json
|
||||
expect(response).to have_http_status(:ok)
|
||||
|
|
|
@ -126,7 +126,7 @@ class SlackTest < ActiveSupport::TestCase
|
|||
assert_equal(1, slack_check(channel, hash))
|
||||
|
||||
ticket2.state = Ticket::State.find_by(name: 'pending reminder')
|
||||
ticket2.pending_time = Time.zone.now - 2.days
|
||||
ticket2.pending_time = 2.days.ago
|
||||
ticket2.save
|
||||
|
||||
TransactionDispatcher.commit
|
||||
|
|
|
@ -52,8 +52,8 @@ class KarmaTest < ActiveSupport::TestCase
|
|||
priority: Ticket::Priority.lookup(name: '2 normal'),
|
||||
updated_by_id: agent1.id,
|
||||
created_by_id: agent1.id,
|
||||
updated_at: Time.zone.now - 10.hours,
|
||||
created_at: Time.zone.now - 10.hours,
|
||||
updated_at: 10.hours.ago,
|
||||
created_at: 10.hours.ago,
|
||||
)
|
||||
Ticket::Article.create!(
|
||||
ticket_id: ticket1.id,
|
||||
|
@ -67,8 +67,8 @@ class KarmaTest < ActiveSupport::TestCase
|
|||
type: Ticket::Article::Type.lookup(name: 'phone'),
|
||||
updated_by_id: agent1.id,
|
||||
created_by_id: agent1.id,
|
||||
updated_at: Time.zone.now - 10.hours,
|
||||
created_at: Time.zone.now - 10.hours,
|
||||
updated_at: 10.hours.ago,
|
||||
created_at: 10.hours.ago,
|
||||
)
|
||||
assert(ticket1)
|
||||
|
||||
|
@ -90,8 +90,8 @@ class KarmaTest < ActiveSupport::TestCase
|
|||
|
||||
ticket1.state = Ticket::State.lookup(name: 'pending reminder')
|
||||
ticket1.updated_by_id = agent1.id
|
||||
ticket1.updated_at = Time.zone.now - 9.hours
|
||||
ticket1.created_at = Time.zone.now - 9.hours
|
||||
ticket1.updated_at = 9.hours.ago
|
||||
ticket1.created_at = 9.hours.ago
|
||||
ticket1.save!
|
||||
|
||||
# execute object transaction
|
||||
|
@ -112,8 +112,8 @@ class KarmaTest < ActiveSupport::TestCase
|
|||
|
||||
ticket1.state = Ticket::State.lookup(name: 'pending close')
|
||||
ticket1.updated_by_id = agent1.id
|
||||
ticket1.updated_at = Time.zone.now - 9.hours
|
||||
ticket1.created_at = Time.zone.now - 9.hours
|
||||
ticket1.updated_at = 9.hours.ago
|
||||
ticket1.created_at = 9.hours.ago
|
||||
ticket1.save!
|
||||
|
||||
# execute object transaction
|
||||
|
@ -126,8 +126,8 @@ class KarmaTest < ActiveSupport::TestCase
|
|||
|
||||
ticket1.state = Ticket::State.lookup(name: 'closed')
|
||||
ticket1.updated_by_id = agent2.id
|
||||
ticket1.updated_at = Time.zone.now - 9.hours
|
||||
ticket1.created_at = Time.zone.now - 9.hours
|
||||
ticket1.updated_at = 9.hours.ago
|
||||
ticket1.created_at = 9.hours.ago
|
||||
ticket1.save!
|
||||
|
||||
# execute object transaction
|
||||
|
@ -192,8 +192,8 @@ class KarmaTest < ActiveSupport::TestCase
|
|||
type: Ticket::Article::Type.lookup(name: 'phone'),
|
||||
updated_by_id: customer1.id,
|
||||
created_by_id: customer1.id,
|
||||
updated_at: Time.zone.now - 8.hours,
|
||||
created_at: Time.zone.now - 8.hours,
|
||||
updated_at: 8.hours.ago,
|
||||
created_at: 8.hours.ago,
|
||||
)
|
||||
|
||||
# execute object transaction
|
||||
|
@ -264,8 +264,8 @@ class KarmaTest < ActiveSupport::TestCase
|
|||
type: Ticket::Article::Type.lookup(name: 'phone'),
|
||||
updated_by_id: customer1.id,
|
||||
created_by_id: customer1.id,
|
||||
updated_at: Time.zone.now - 7.hours,
|
||||
created_at: Time.zone.now - 7.hours,
|
||||
updated_at: 7.hours.ago,
|
||||
created_at: 7.hours.ago,
|
||||
)
|
||||
|
||||
# execute object transaction
|
||||
|
@ -356,8 +356,8 @@ class KarmaTest < ActiveSupport::TestCase
|
|||
priority: Ticket::Priority.lookup(name: '2 normal'),
|
||||
updated_by_id: agent1.id,
|
||||
created_by_id: agent1.id,
|
||||
updated_at: Time.zone.now - 10.hours,
|
||||
created_at: Time.zone.now - 10.hours,
|
||||
updated_at: 10.hours.ago,
|
||||
created_at: 10.hours.ago,
|
||||
)
|
||||
Ticket::Article.create!(
|
||||
ticket_id: ticket2.id,
|
||||
|
@ -371,8 +371,8 @@ class KarmaTest < ActiveSupport::TestCase
|
|||
type: Ticket::Article::Type.lookup(name: 'phone'),
|
||||
updated_by_id: agent1.id,
|
||||
created_by_id: agent1.id,
|
||||
updated_at: Time.zone.now - 2.hours,
|
||||
created_at: Time.zone.now - 2.hours,
|
||||
updated_at: 2.hours.ago,
|
||||
created_at: 2.hours.ago,
|
||||
)
|
||||
assert(ticket2)
|
||||
|
||||
|
@ -385,7 +385,7 @@ class KarmaTest < ActiveSupport::TestCase
|
|||
assert_equal(0, Karma.score_by_user(customer1))
|
||||
|
||||
ticket2.state = Ticket::State.lookup(name: 'pending reminder')
|
||||
ticket2.pending_time = Time.zone.now - 1.day
|
||||
ticket2.pending_time = 1.day.ago
|
||||
ticket2.save!
|
||||
|
||||
Ticket.process_pending
|
||||
|
@ -395,7 +395,7 @@ class KarmaTest < ActiveSupport::TestCase
|
|||
assert_equal(0, Karma.score_by_user(customer1))
|
||||
|
||||
ticket2.state = Ticket::State.lookup(name: 'pending reminder')
|
||||
ticket2.pending_time = Time.zone.now - 3.days
|
||||
ticket2.pending_time = 3.days.ago
|
||||
ticket2.save!
|
||||
|
||||
Ticket.process_pending
|
||||
|
|
|
@ -582,8 +582,8 @@ class OnlineNotificationTest < ActiveSupport::TestCase
|
|||
user_id: @agent_user1.id,
|
||||
created_by_id: 1,
|
||||
updated_by_id: 1,
|
||||
created_at: Time.zone.now - 2.days,
|
||||
updated_at: Time.zone.now - 2.days,
|
||||
created_at: 2.days.ago,
|
||||
updated_at: 2.days.ago,
|
||||
)
|
||||
online_notification4 = OnlineNotification.add(
|
||||
type: 'create',
|
||||
|
@ -593,8 +593,8 @@ class OnlineNotificationTest < ActiveSupport::TestCase
|
|||
user_id: @agent_user1.id,
|
||||
created_by_id: @agent_user1.id,
|
||||
updated_by_id: @agent_user1.id,
|
||||
created_at: Time.zone.now - 2.days,
|
||||
updated_at: Time.zone.now - 2.days,
|
||||
created_at: 2.days.ago,
|
||||
updated_at: 2.days.ago,
|
||||
)
|
||||
online_notification5 = OnlineNotification.add(
|
||||
type: 'create',
|
||||
|
@ -604,8 +604,8 @@ class OnlineNotificationTest < ActiveSupport::TestCase
|
|||
user_id: @agent_user1.id,
|
||||
created_by_id: @agent_user2.id,
|
||||
updated_by_id: @agent_user2.id,
|
||||
created_at: Time.zone.now - 2.days,
|
||||
updated_at: Time.zone.now - 2.days,
|
||||
created_at: 2.days.ago,
|
||||
updated_at: 2.days.ago,
|
||||
)
|
||||
online_notification6 = OnlineNotification.add(
|
||||
type: 'create',
|
||||
|
@ -615,8 +615,8 @@ class OnlineNotificationTest < ActiveSupport::TestCase
|
|||
user_id: @agent_user1.id,
|
||||
created_by_id: @agent_user1.id,
|
||||
updated_by_id: @agent_user1.id,
|
||||
created_at: Time.zone.now - 5.minutes,
|
||||
updated_at: Time.zone.now - 5.minutes,
|
||||
created_at: 5.minutes.ago,
|
||||
updated_at: 5.minutes.ago,
|
||||
)
|
||||
online_notification7 = OnlineNotification.add(
|
||||
type: 'create',
|
||||
|
@ -626,8 +626,8 @@ class OnlineNotificationTest < ActiveSupport::TestCase
|
|||
user_id: @agent_user1.id,
|
||||
created_by_id: @agent_user2.id,
|
||||
updated_by_id: @agent_user2.id,
|
||||
created_at: Time.zone.now - 5.minutes,
|
||||
updated_at: Time.zone.now - 5.minutes,
|
||||
created_at: 5.minutes.ago,
|
||||
updated_at: 5.minutes.ago,
|
||||
)
|
||||
|
||||
OnlineNotification.cleanup
|
||||
|
|
|
@ -169,8 +169,8 @@ class TicketOverviewOutOfOfficeTest < ActiveSupport::TestCase
|
|||
assert_equal(1, result.count)
|
||||
assert_equal('My Tickets', result[0].name)
|
||||
@agent1.out_of_office = true
|
||||
@agent1.out_of_office_start_at = Time.zone.now - 2.days
|
||||
@agent1.out_of_office_end_at = Time.zone.now + 2.days
|
||||
@agent1.out_of_office_start_at = 2.days.ago
|
||||
@agent1.out_of_office_end_at = 2.days.from_now
|
||||
@agent1.out_of_office_replacement_id = @agent2.id
|
||||
@agent1.save!
|
||||
|
||||
|
@ -220,8 +220,8 @@ class TicketOverviewOutOfOfficeTest < ActiveSupport::TestCase
|
|||
assert(result[0][:tickets].blank?)
|
||||
|
||||
@agent1.out_of_office = true
|
||||
@agent1.out_of_office_start_at = Time.zone.now - 2.days
|
||||
@agent1.out_of_office_end_at = Time.zone.now + 2.days
|
||||
@agent1.out_of_office_start_at = 2.days.ago
|
||||
@agent1.out_of_office_end_at = 2.days.from_now
|
||||
@agent1.out_of_office_replacement_id = @agent2.id
|
||||
@agent1.save!
|
||||
|
||||
|
|
|
@ -465,7 +465,7 @@ class TicketSelectorTest < ActiveSupport::TestCase
|
|||
},
|
||||
'ticket.updated_at' => {
|
||||
operator: 'before (absolute)',
|
||||
value: (Time.zone.now + 1.day).iso8601,
|
||||
value: 1.day.from_now.iso8601,
|
||||
},
|
||||
}
|
||||
ticket_count, tickets = Ticket.selectors(condition, limit: 10, current_user: @agent1)
|
||||
|
@ -487,7 +487,7 @@ class TicketSelectorTest < ActiveSupport::TestCase
|
|||
},
|
||||
'ticket.updated_at' => {
|
||||
operator: 'before (absolute)',
|
||||
value: (Time.zone.now - 1.day).iso8601,
|
||||
value: 1.day.ago.iso8601,
|
||||
},
|
||||
}
|
||||
ticket_count, tickets = Ticket.selectors(condition, limit: 10, current_user: @agent1)
|
||||
|
@ -509,7 +509,7 @@ class TicketSelectorTest < ActiveSupport::TestCase
|
|||
},
|
||||
'ticket.updated_at' => {
|
||||
operator: 'after (absolute)',
|
||||
value: (Time.zone.now + 1.day).iso8601,
|
||||
value: 1.day.from_now.iso8601,
|
||||
},
|
||||
}
|
||||
ticket_count, tickets = Ticket.selectors(condition, limit: 10, current_user: @agent1)
|
||||
|
@ -531,7 +531,7 @@ class TicketSelectorTest < ActiveSupport::TestCase
|
|||
},
|
||||
'ticket.updated_at' => {
|
||||
operator: 'after (absolute)',
|
||||
value: (Time.zone.now - 1.day).iso8601,
|
||||
value: 1.day.ago.iso8601,
|
||||
},
|
||||
}
|
||||
ticket_count, tickets = Ticket.selectors(condition, limit: 10, current_user: @agent1)
|
||||
|
|
Loading…
Reference in a new issue