Refactoring: Prefer .update! over .update, .update_attributes and .update_attribute - see http://www.davidverhasselt.com/set-attributes-in-activerecord/ .
This commit is contained in:
parent
be682ccf1d
commit
ef38800bae
65 changed files with 143 additions and 143 deletions
|
@ -41,7 +41,7 @@ module ApplicationController::RendersModels
|
|||
generic_object.with_lock do
|
||||
|
||||
# set attributes
|
||||
generic_object.update_attributes!(clean_params)
|
||||
generic_object.update!(clean_params)
|
||||
|
||||
# set relations
|
||||
generic_object.associations_from_param(params)
|
||||
|
|
|
@ -45,7 +45,7 @@ class ApplicationsController < ApplicationController
|
|||
|
||||
def update
|
||||
application = Doorkeeper::Application.find(params[:id])
|
||||
application.update_attributes!(clean_params)
|
||||
application.update!(clean_params)
|
||||
render json: application, status: :ok
|
||||
end
|
||||
|
||||
|
|
|
@ -124,7 +124,7 @@ class ChannelsEmailController < ApplicationController
|
|||
# update account
|
||||
if channel_id
|
||||
channel = Channel.find(channel_id)
|
||||
channel.update_attributes(
|
||||
channel.update!(
|
||||
options: {
|
||||
inbound: params[:inbound],
|
||||
outbound: params[:outbound],
|
||||
|
@ -163,7 +163,7 @@ class ChannelsEmailController < ApplicationController
|
|||
end
|
||||
|
||||
if address
|
||||
address.update_attributes(
|
||||
address.update!(
|
||||
realname: params[:meta][:realname],
|
||||
email: email,
|
||||
active: true,
|
||||
|
|
|
@ -63,7 +63,7 @@ class NetworksController < ApplicationController
|
|||
@network = Network.find(params[:id])
|
||||
|
||||
respond_to do |format|
|
||||
if @network.update_attributes(params[:network])
|
||||
if @network.update!(params[:network])
|
||||
format.html { redirect_to @network, notice: 'Network was successfully updated.' }
|
||||
format.json { render json: @network, status: :ok }
|
||||
else
|
||||
|
|
|
@ -111,7 +111,7 @@ class TicketArticlesController < ApplicationController
|
|||
clean_params = Ticket::Article.association_name_to_id_convert(params)
|
||||
clean_params = Ticket::Article.param_cleanup(clean_params, true)
|
||||
|
||||
article.update_attributes!(clean_params)
|
||||
article.update!(clean_params)
|
||||
|
||||
if params[:expand]
|
||||
result = article.attributes_with_association_names
|
||||
|
|
|
@ -192,7 +192,7 @@ class TicketsController < ApplicationController
|
|||
end
|
||||
|
||||
ticket.with_lock do
|
||||
ticket.update_attributes!(clean_params)
|
||||
ticket.update!(clean_params)
|
||||
if params[:article]
|
||||
article_create(ticket, params[:article])
|
||||
end
|
||||
|
|
|
@ -253,7 +253,7 @@ class UsersController < ApplicationController
|
|||
user.with_lock do
|
||||
clean_params = User.association_name_to_id_convert(params)
|
||||
clean_params = User.param_cleanup(clean_params, true)
|
||||
user.update_attributes(clean_params)
|
||||
user.update!(clean_params)
|
||||
|
||||
# only allow Admin's
|
||||
if current_user.permissions?('admin.user') && (params[:role_ids] || params[:roles])
|
||||
|
@ -765,7 +765,7 @@ curl http://localhost/api/v1/users/password_change -v -u #{login}:#{password} -H
|
|||
return
|
||||
end
|
||||
|
||||
user.update_attributes(password: params[:password_new])
|
||||
user.update!(password: params[:password_new])
|
||||
|
||||
NotificationFactory::Mailer.notification(
|
||||
template: 'password_change',
|
||||
|
@ -980,7 +980,7 @@ curl http://localhost/api/v1/users/avatar -v -u #{login}:#{password} -H "Content
|
|||
|
||||
# update user link
|
||||
user = User.find(current_user.id)
|
||||
user.update_attributes(image: avatar.store_hash)
|
||||
user.update!(image: avatar.store_hash)
|
||||
|
||||
render json: { avatar: avatar }, status: :ok
|
||||
end
|
||||
|
@ -996,7 +996,7 @@ curl http://localhost/api/v1/users/avatar -v -u #{login}:#{password} -H "Content
|
|||
|
||||
# update user link
|
||||
user = User.find(current_user.id)
|
||||
user.update_attributes(image: avatar.store_hash)
|
||||
user.update!(image: avatar.store_hash)
|
||||
|
||||
render json: {}, status: :ok
|
||||
end
|
||||
|
@ -1013,7 +1013,7 @@ curl http://localhost/api/v1/users/avatar -v -u #{login}:#{password} -H "Content
|
|||
# update user link
|
||||
avatar = Avatar.get_default('User', current_user.id)
|
||||
user = User.find(current_user.id)
|
||||
user.update_attributes(image: avatar.store_hash)
|
||||
user.update!(image: avatar.store_hash)
|
||||
|
||||
render json: {}, status: :ok
|
||||
end
|
||||
|
|
|
@ -119,7 +119,7 @@ returns
|
|||
if data[:id]
|
||||
record = find_by(id: data[:id])
|
||||
if record
|
||||
record.update_attributes(data)
|
||||
record.update!(data)
|
||||
return record
|
||||
end
|
||||
record = new(data)
|
||||
|
@ -135,7 +135,7 @@ returns
|
|||
end
|
||||
records.each { |loop_record|
|
||||
if loop_record.name == data[:name]
|
||||
loop_record.update_attributes(data)
|
||||
loop_record.update!(data)
|
||||
return loop_record
|
||||
end
|
||||
}
|
||||
|
@ -152,7 +152,7 @@ returns
|
|||
end
|
||||
records.each { |loop_record|
|
||||
if loop_record.login.casecmp(data[:login]).zero?
|
||||
loop_record.update_attributes(data)
|
||||
loop_record.update!(data)
|
||||
return loop_record
|
||||
end
|
||||
}
|
||||
|
@ -169,7 +169,7 @@ returns
|
|||
end
|
||||
records.each { |loop_record|
|
||||
if loop_record.email.casecmp(data[:email]).zero?
|
||||
loop_record.update_attributes(data)
|
||||
loop_record.update!(data)
|
||||
return loop_record
|
||||
end
|
||||
}
|
||||
|
@ -186,7 +186,7 @@ returns
|
|||
end
|
||||
records.each { |loop_record|
|
||||
if loop_record.locale.casecmp(data[:locale]).zero?
|
||||
loop_record.update_attributes(data)
|
||||
loop_record.update!(data)
|
||||
return loop_record
|
||||
end
|
||||
}
|
||||
|
|
|
@ -14,14 +14,14 @@ class Authorization < ApplicationModel
|
|||
if auth
|
||||
|
||||
# update auth tokens
|
||||
auth.update_attributes(
|
||||
auth.update!(
|
||||
token: hash['credentials']['token'],
|
||||
secret: hash['credentials']['secret']
|
||||
)
|
||||
|
||||
# update username of auth entry if empty
|
||||
if !auth.username && hash['info']['nickname']
|
||||
auth.update_attributes(
|
||||
auth.update!(
|
||||
username: hash['info']['nickname'],
|
||||
)
|
||||
end
|
||||
|
|
|
@ -211,7 +211,7 @@ add avatar by url
|
|||
|
||||
# update existing
|
||||
if avatar_already_exists
|
||||
avatar_already_exists.update_attributes(record)
|
||||
avatar_already_exists.update!(record)
|
||||
avatar = avatar_already_exists
|
||||
|
||||
# add new one and set it as default
|
||||
|
|
|
@ -47,7 +47,7 @@ returns calendar object
|
|||
# find if auto generated calendar exists
|
||||
calendar = Calendar.find_by(default: true, updated_by_id: 1, created_by_id: 1)
|
||||
if calendar
|
||||
calendar.update_attributes(calendar_details)
|
||||
calendar.update!(calendar_details)
|
||||
return calendar
|
||||
end
|
||||
create(calendar_details)
|
||||
|
|
|
@ -141,7 +141,7 @@ module Channel::Filter::IdentifySender
|
|||
if user.firstname.blank? && user.lastname.blank?
|
||||
if data[:firstname].present?
|
||||
data[:firstname] = cleanup_name(data[:firstname])
|
||||
user.update_attributes(
|
||||
user.update!(
|
||||
firstname: data[:firstname]
|
||||
)
|
||||
end
|
||||
|
@ -166,7 +166,7 @@ module Channel::Filter::IdentifySender
|
|||
data[:created_by_id] = 1
|
||||
|
||||
user = User.create(data)
|
||||
user.update_attributes(
|
||||
user.update!(
|
||||
updated_by_id: user.id,
|
||||
created_by_id: user.id,
|
||||
)
|
||||
|
|
|
@ -34,7 +34,7 @@ class Chat::Agent < ApplicationModel
|
|||
updated_by_id: params[:updated_by_id]
|
||||
)
|
||||
if chat_agent
|
||||
chat_agent.update_attributes(params)
|
||||
chat_agent.update!(params)
|
||||
else
|
||||
Chat::Agent.create(params)
|
||||
end
|
||||
|
|
|
@ -69,7 +69,7 @@ check and if channel not exists reset configured channels for email addresses
|
|||
# delete group.email_address_id reference if email address get's deleted
|
||||
def delete_group_reference
|
||||
Group.where(email_address_id: id).each { |group|
|
||||
group.update_attributes!(email_address_id: nil)
|
||||
group.update!(email_address_id: nil)
|
||||
}
|
||||
end
|
||||
|
||||
|
|
|
@ -73,7 +73,7 @@ add a new history entry for an object
|
|||
history_record = History.find_by(id: data[:id])
|
||||
end
|
||||
if history_record
|
||||
history_record.update_attributes(record)
|
||||
history_record.update!(record)
|
||||
else
|
||||
record_new = History.create(record)
|
||||
if record[:id]
|
||||
|
|
|
@ -117,9 +117,9 @@ all:
|
|||
data.each { |locale|
|
||||
exists = Locale.find_by(locale: locale['locale'])
|
||||
if exists
|
||||
exists.update(locale.symbolize_keys!)
|
||||
exists.update!(locale.symbolize_keys!)
|
||||
else
|
||||
Locale.create(locale.symbolize_keys!)
|
||||
Locale.create!(locale.symbolize_keys!)
|
||||
end
|
||||
}
|
||||
end
|
||||
|
|
|
@ -169,7 +169,7 @@ class Scheduler < ApplicationModel
|
|||
end
|
||||
|
||||
def self._start_job(job, try_count = 0, try_run_time = Time.zone.now)
|
||||
job.update(
|
||||
job.update!(
|
||||
last_run: Time.zone.now,
|
||||
pid: Thread.current.object_id,
|
||||
status: 'ok',
|
||||
|
@ -205,7 +205,7 @@ class Scheduler < ApplicationModel
|
|||
error = "Failed to run #{job.method} after #{try_count} tries #{e.inspect}"
|
||||
logger.error error
|
||||
|
||||
job.update(
|
||||
job.update!(
|
||||
error_message: error,
|
||||
status: 'error',
|
||||
active: false,
|
||||
|
@ -285,7 +285,7 @@ class Scheduler < ApplicationModel
|
|||
# return [true]
|
||||
def self.restart_failed_jobs
|
||||
failed_jobs.each do |job|
|
||||
job.update(active: true)
|
||||
job.update!(active: true)
|
||||
end
|
||||
|
||||
true
|
||||
|
|
|
@ -38,7 +38,7 @@ load text modules from online
|
|||
exists = TextModule.find_by(foreign_id: text_module['foreign_id'])
|
||||
if exists
|
||||
next if !overwrite_existing_item
|
||||
exists.update(text_module.symbolize_keys!)
|
||||
exists.update!(text_module.symbolize_keys!)
|
||||
else
|
||||
text_module[:updated_by_id] = 1
|
||||
text_module[:created_by_id] = 1
|
||||
|
|
|
@ -371,7 +371,7 @@ Get source file at https://i18n.zammad.com/api/v1/translations_empty_translation
|
|||
end
|
||||
}
|
||||
if update_needed
|
||||
translation.update_attributes(translation_raw.symbolize_keys!)
|
||||
translation.update!(translation_raw.symbolize_keys!)
|
||||
translation.save
|
||||
end
|
||||
else
|
||||
|
|
|
@ -610,7 +610,7 @@ returns
|
|||
return if !user
|
||||
|
||||
# reset password
|
||||
user.update_attributes(password: password)
|
||||
user.update!(password: password)
|
||||
|
||||
# delete token
|
||||
Token.find_by(action: 'PasswordReset', name: token).destroy
|
||||
|
@ -689,7 +689,7 @@ returns
|
|||
return if user && local_user.id != user.id
|
||||
|
||||
# set verified
|
||||
local_user.update_attributes(verified: true)
|
||||
local_user.update!(verified: true)
|
||||
|
||||
# delete token
|
||||
Token.find_by(action: 'Signup', name: token).destroy
|
||||
|
|
|
@ -147,7 +147,7 @@ result
|
|||
next if !new_value || new_value.empty?
|
||||
user_data[target] = new_value
|
||||
}
|
||||
user.update_attributes(user_data)
|
||||
user.update!(user_data)
|
||||
else
|
||||
user_data[:login] = item_user['id']
|
||||
if item_user['first_name'] && item_user['last_name']
|
||||
|
|
|
@ -135,7 +135,7 @@ module Import
|
|||
end
|
||||
|
||||
def inform(message)
|
||||
@import_job.update_attribute(:result, {
|
||||
@import_job.update!(result: {
|
||||
info: message
|
||||
})
|
||||
end
|
||||
|
|
|
@ -29,7 +29,7 @@ module Import
|
|||
# the active state this way to send notifications
|
||||
# to the client
|
||||
::User.where(id: slice).each do |user|
|
||||
user.update_attribute(:active, false)
|
||||
user.update!(active: false)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -53,7 +53,7 @@ module Import
|
|||
@local_article = ::Ticket::Article.find_by(id: article[:id])
|
||||
return false if !@local_article
|
||||
log "update Ticket::Article.find_by(id: #{article[:id]})"
|
||||
@local_article.update_attributes(article)
|
||||
@local_article.update!(article)
|
||||
true
|
||||
end
|
||||
|
||||
|
|
|
@ -44,7 +44,7 @@ module Import
|
|||
@local_customer = Organization.find_by(name: customer[:name])
|
||||
return false if !@local_customer
|
||||
log "update Organization.find_by(name: #{customer[:name]})"
|
||||
@local_customer.update_attributes(customer)
|
||||
@local_customer.update!(customer)
|
||||
true
|
||||
end
|
||||
|
||||
|
|
|
@ -52,7 +52,7 @@ module Import
|
|||
end
|
||||
|
||||
log "update User.find_by(login: #{customer[:login]})"
|
||||
@local_customer.update_attributes(customer)
|
||||
@local_customer.update!(customer)
|
||||
true
|
||||
end
|
||||
|
||||
|
|
|
@ -33,7 +33,7 @@ module Import
|
|||
@local_priority = ::Ticket::Priority.find_by(id: priority[:id])
|
||||
return false if !@local_priority
|
||||
log "update Ticket::Priority.find_by(id: #{priority[:id]})"
|
||||
@local_priority.update_attributes(priority)
|
||||
@local_priority.update!(priority)
|
||||
true
|
||||
end
|
||||
|
||||
|
|
|
@ -33,7 +33,7 @@ module Import
|
|||
@local_queue = Group.find_by(id: queue[:id])
|
||||
return false if !@local_queue
|
||||
log "update Group.find_by(id: #{queue[:id]})"
|
||||
@local_queue.update_attributes(queue)
|
||||
@local_queue.update!(queue)
|
||||
true
|
||||
end
|
||||
|
||||
|
|
|
@ -34,7 +34,7 @@ module Import
|
|||
@local_state = ::Ticket::State.find_by(id: state[:id])
|
||||
return false if !@local_state
|
||||
log "update Ticket::State.find_by(id: #{state[:id]})"
|
||||
@local_state.update_attributes(state)
|
||||
@local_state.update!(state)
|
||||
true
|
||||
end
|
||||
|
||||
|
|
|
@ -50,7 +50,7 @@ module Import
|
|||
@local_ticket = ::Ticket.find_by(id: ticket[:id])
|
||||
return false if !@local_ticket
|
||||
log "update Ticket.find_by(id: #{ticket[:id]})"
|
||||
@local_ticket.update_attributes(ticket)
|
||||
@local_ticket.update!(ticket)
|
||||
true
|
||||
end
|
||||
|
||||
|
|
|
@ -43,7 +43,7 @@ module Import
|
|||
end
|
||||
|
||||
log "update User.find_by(id: #{user[:id]})"
|
||||
@local_user.update_attributes(user)
|
||||
@local_user.update!(user)
|
||||
true
|
||||
end
|
||||
|
||||
|
|
|
@ -25,7 +25,7 @@ module Import
|
|||
def updated?(ticket)
|
||||
@local_ticket = ::Ticket.find_by(id: ticket[:id])
|
||||
return false if !@local_ticket
|
||||
@local_ticket.update_attributes(ticket)
|
||||
@local_ticket.update!(ticket)
|
||||
true
|
||||
end
|
||||
|
||||
|
|
|
@ -19,7 +19,7 @@ module Import
|
|||
def updated?(article)
|
||||
@local_article = ::Ticket::Article.find_by(message_id: article[:message_id])
|
||||
return false if !@local_article
|
||||
@local_article.update_attributes(article)
|
||||
@local_article.update!(article)
|
||||
true
|
||||
end
|
||||
|
||||
|
|
|
@ -243,7 +243,7 @@ returns
|
|||
}
|
||||
if auth
|
||||
user = User.find(auth.user_id)
|
||||
user.update_attributes(user_data)
|
||||
user.update!(user_data)
|
||||
else
|
||||
if message_user[:username]
|
||||
user_data[:note] = "Telegram @#{message_user[:username]}"
|
||||
|
@ -261,7 +261,7 @@ returns
|
|||
provider: 'telegram'
|
||||
}
|
||||
if auth
|
||||
auth.update_attributes(auth_data)
|
||||
auth.update!(auth_data)
|
||||
else
|
||||
Authorization.create(auth_data)
|
||||
end
|
||||
|
|
|
@ -52,7 +52,7 @@ class TweetBase
|
|||
next if !new_value || new_value.empty?
|
||||
user_data[target] = new_value
|
||||
}
|
||||
user.update_attributes(user_data)
|
||||
user.update!(user_data)
|
||||
else
|
||||
user_data[:login] = tweet_user.screen_name
|
||||
user_data[:firstname] = tweet_user.name
|
||||
|
@ -91,7 +91,7 @@ class TweetBase
|
|||
provider: 'twitter'
|
||||
}
|
||||
if auth
|
||||
auth.update_attributes(auth_data)
|
||||
auth.update!(auth_data)
|
||||
else
|
||||
Authorization.create!(auth_data)
|
||||
end
|
||||
|
|
|
@ -121,8 +121,8 @@ RSpec.describe Import::BaseResource do
|
|||
old_signature = create(:signature)
|
||||
old_users = create_list(:user, 2)
|
||||
|
||||
group.update_attribute(:signature_id, old_signature.id)
|
||||
group.update_attribute(:user_ids, old_users.collect(&:id))
|
||||
group.update!(signature_id: old_signature.id)
|
||||
group.update!(user_ids: old_users.collect(&:id))
|
||||
|
||||
# simulate next import run
|
||||
travel 20.minutes
|
||||
|
|
|
@ -245,7 +245,7 @@ RSpec.describe Import::Ldap::User do
|
|||
|
||||
it "doesn't detect false changes" do
|
||||
# make sure that the nothing has changed
|
||||
User.find_by(login: uid).update_attribute(:email, 'example@example.com')
|
||||
User.find_by(login: uid).update!(email: 'example@example.com')
|
||||
|
||||
expect_any_instance_of(User).not_to receive(:save!)
|
||||
instance = described_class.new(user_entry, ldap_config, user_roles, signup_role_ids)
|
||||
|
|
|
@ -11,7 +11,7 @@ RSpec.describe Import::OTRS::Article do
|
|||
|
||||
def updates_with(zammad_structure)
|
||||
expect(import_object).to receive(:find_by).and_return(existing_object)
|
||||
expect(existing_object).to receive(:update_attributes).with(zammad_structure)
|
||||
expect(existing_object).to receive(:update!).with(zammad_structure)
|
||||
expect(import_object).not_to receive(:new)
|
||||
start_import_test
|
||||
end
|
||||
|
|
|
@ -10,7 +10,7 @@ RSpec.describe Import::OTRS::Customer do
|
|||
|
||||
def updates_with(zammad_structure)
|
||||
expect(import_object).to receive(:find_by).and_return(existing_object)
|
||||
expect(existing_object).to receive(:update_attributes).with(zammad_structure)
|
||||
expect(existing_object).to receive(:update!).with(zammad_structure)
|
||||
expect(import_object).not_to receive(:new)
|
||||
start_import_test
|
||||
end
|
||||
|
|
|
@ -15,9 +15,9 @@ RSpec.describe Import::OTRS::CustomerUser do
|
|||
expect(import_object).to receive(:find_by).and_return(existing_object)
|
||||
# we delete the :role_ids from the zammad_structure to make sure that
|
||||
# a) role_ids call returns the initial role_ids
|
||||
# b) and update_attributes gets called without them
|
||||
# b) and update! gets called without them
|
||||
expect(existing_object).to receive(:role_ids).and_return(zammad_structure.delete(:role_ids)).at_least(:once)
|
||||
expect(existing_object).to receive(:update_attributes).with(zammad_structure)
|
||||
expect(existing_object).to receive(:update!).with(zammad_structure)
|
||||
expect(import_object).not_to receive(:new)
|
||||
start_import_test
|
||||
end
|
||||
|
|
|
@ -11,7 +11,7 @@ RSpec.describe Import::OTRS::Priority do
|
|||
|
||||
def updates_with(zammad_structure)
|
||||
expect(import_object).to receive(:find_by).and_return(existing_object)
|
||||
expect(existing_object).to receive(:update_attributes).with(zammad_structure)
|
||||
expect(existing_object).to receive(:update!).with(zammad_structure)
|
||||
expect(import_object).not_to receive(:new)
|
||||
start_import_test
|
||||
end
|
||||
|
|
|
@ -11,7 +11,7 @@ RSpec.describe Import::OTRS::Queue do
|
|||
|
||||
def updates_with(zammad_structure)
|
||||
expect(import_object).to receive(:find_by).and_return(existing_object)
|
||||
expect(existing_object).to receive(:update_attributes).with(zammad_structure)
|
||||
expect(existing_object).to receive(:update!).with(zammad_structure)
|
||||
expect(import_object).not_to receive(:new)
|
||||
start_import_test
|
||||
end
|
||||
|
|
|
@ -12,7 +12,7 @@ RSpec.describe Import::OTRS::State do
|
|||
|
||||
def updates_with(zammad_structure)
|
||||
expect(import_object).to receive(:find_by).and_return(existing_object)
|
||||
expect(existing_object).to receive(:update_attributes).with(zammad_structure)
|
||||
expect(existing_object).to receive(:update!).with(zammad_structure)
|
||||
expect(import_object).not_to receive(:new)
|
||||
start_import_test
|
||||
end
|
||||
|
|
|
@ -11,7 +11,7 @@ RSpec.describe Import::OTRS::Ticket do
|
|||
|
||||
def updates_with(zammad_structure)
|
||||
expect(import_object).to receive(:find_by).and_return(existing_object)
|
||||
expect(existing_object).to receive(:update_attributes).with(zammad_structure)
|
||||
expect(existing_object).to receive(:update!).with(zammad_structure)
|
||||
expect(import_object).not_to receive(:new)
|
||||
start_import_test
|
||||
end
|
||||
|
|
|
@ -14,9 +14,9 @@ RSpec.describe Import::OTRS::User do
|
|||
expect(import_object).to receive(:find_by).and_return(existing_object)
|
||||
# we delete the :role_ids from the zammad_structure to make sure that
|
||||
# a) role_ids call returns the initial role_ids
|
||||
# b) and update_attributes gets called without them
|
||||
# b) and update! gets called without them
|
||||
expect(existing_object).to receive(:role_ids).and_return(zammad_structure.delete(:role_ids))
|
||||
expect(existing_object).to receive(:update_attributes).with(zammad_structure)
|
||||
expect(existing_object).to receive(:update!).with(zammad_structure)
|
||||
expect(import_object).not_to receive(:new)
|
||||
start_import_test
|
||||
end
|
||||
|
|
|
@ -88,7 +88,7 @@ RSpec.describe Import::Zendesk::Ticket::Comment do
|
|||
expect(Import::Zendesk::Ticket::Comment::Sender).to receive(:local_id).with(local_user_id).and_return(update_structure[:sender_id])
|
||||
|
||||
local_article = double()
|
||||
expect(local_article).to receive(:update_attributes).with(update_structure)
|
||||
expect(local_article).to receive(:update!).with(update_structure)
|
||||
|
||||
expect(::Ticket::Article).to receive(:find_by).with(message_id: comment.id).and_return(local_article)
|
||||
|
||||
|
@ -186,7 +186,7 @@ RSpec.describe Import::Zendesk::Ticket::Comment do
|
|||
expect(Import::Zendesk::Ticket::Comment::Sender).to receive(:local_id).with(local_user_id).and_return(update_structure[:sender_id])
|
||||
|
||||
local_article = double()
|
||||
expect(local_article).to receive(:update_attributes).with(update_structure)
|
||||
expect(local_article).to receive(:update!).with(update_structure)
|
||||
|
||||
expect(::Ticket::Article).to receive(:find_by).with(message_id: comment.id).and_return(local_article)
|
||||
|
||||
|
@ -282,7 +282,7 @@ RSpec.describe Import::Zendesk::Ticket::Comment do
|
|||
expect(Import::Zendesk::Ticket::Comment::Sender).to receive(:local_id).with(local_user_id).and_return(update_structure[:sender_id])
|
||||
|
||||
local_article = double()
|
||||
expect(local_article).to receive(:update_attributes).with(update_structure)
|
||||
expect(local_article).to receive(:update!).with(update_structure)
|
||||
|
||||
expect(::Ticket::Article).to receive(:find_by).with(message_id: comment.id).and_return(local_article)
|
||||
|
||||
|
@ -373,7 +373,7 @@ RSpec.describe Import::Zendesk::Ticket::Comment do
|
|||
expect(Import::Zendesk::Ticket::Comment::Sender).to receive(:local_id).with(local_user_id).and_return(update_structure[:sender_id])
|
||||
|
||||
local_article = double()
|
||||
expect(local_article).to receive(:update_attributes).with(update_structure)
|
||||
expect(local_article).to receive(:update!).with(update_structure)
|
||||
|
||||
expect(::Ticket::Article).to receive(:find_by).with(message_id: comment.id).and_return(local_article)
|
||||
|
||||
|
@ -461,7 +461,7 @@ RSpec.describe Import::Zendesk::Ticket::Comment do
|
|||
expect(Import::Zendesk::Ticket::Comment::Sender).to receive(:local_id).with(local_user_id).and_return(update_structure[:sender_id])
|
||||
|
||||
local_article = double()
|
||||
expect(local_article).to receive(:update_attributes).with(update_structure)
|
||||
expect(local_article).to receive(:update!).with(update_structure)
|
||||
|
||||
expect(::Ticket::Article).to receive(:find_by).with(message_id: comment.id).and_return(local_article)
|
||||
|
||||
|
@ -544,7 +544,7 @@ RSpec.describe Import::Zendesk::Ticket::Comment do
|
|||
expect(Import::Zendesk::Ticket::Comment::Sender).to receive(:local_id).with(local_user_id).and_return(update_structure[:sender_id])
|
||||
|
||||
local_article = double()
|
||||
expect(local_article).to receive(:update_attributes).with(update_structure)
|
||||
expect(local_article).to receive(:update!).with(update_structure)
|
||||
|
||||
expect(::Ticket::Article).to receive(:find_by).with(message_id: comment.id).and_return(local_article)
|
||||
|
||||
|
@ -626,7 +626,7 @@ RSpec.describe Import::Zendesk::Ticket::Comment do
|
|||
expect(Import::Zendesk::Ticket::Comment::Sender).to receive(:local_id).with(local_user_id).and_return(update_structure[:sender_id])
|
||||
|
||||
local_article = double()
|
||||
expect(local_article).to receive(:update_attributes).with(update_structure)
|
||||
expect(local_article).to receive(:update!).with(update_structure)
|
||||
|
||||
expect(::Ticket::Article).to receive(:find_by).with(message_id: comment.id).and_return(local_article)
|
||||
|
||||
|
|
|
@ -122,7 +122,7 @@ RSpec.describe Import::Zendesk::Ticket do
|
|||
expect(Import::Zendesk::Ticket::CommentFactory).to receive(:import).with(ticket.comments, local_ticket, ticket)
|
||||
|
||||
expect(::Ticket).to receive(:find_by).with(id: expected_structure[:id]).and_return(local_ticket)
|
||||
expect(local_ticket).to receive(:update_attributes).with(expected_structure)
|
||||
expect(local_ticket).to receive(:update!).with(expected_structure)
|
||||
|
||||
created_instance = described_class.new(ticket)
|
||||
end
|
||||
|
|
|
@ -279,7 +279,7 @@ RSpec.describe Ldap do
|
|||
expect(mocked_ldap).to receive(:search).with(include(expected)).and_yield(yield_entry).and_return(true)
|
||||
|
||||
check_entry = nil
|
||||
instancesearch(filter, additional) { |entry| check_entry = entry }
|
||||
instance.search(filter, additional) { |entry| check_entry = entry }
|
||||
expect(check_entry).to eq(yield_entry)
|
||||
end
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@ RSpec.shared_examples 'HasGroups' do
|
|||
|
||||
context 'group' do
|
||||
let(:group_access_instance_inactive) {
|
||||
group_access_instance.update_attribute(:active, false)
|
||||
group_access_instance.update!(active: false)
|
||||
group_access_instance
|
||||
}
|
||||
let(:group_full) { create(:group) }
|
||||
|
|
|
@ -5,7 +5,7 @@ RSpec.shared_examples 'HasRoles' do
|
|||
context 'role' do
|
||||
|
||||
let(:group_access_instance_inactive) {
|
||||
group_access_instance.update_attribute(:active, false)
|
||||
group_access_instance.update!(active: false)
|
||||
group_access_instance
|
||||
}
|
||||
let(:role) { create(:role) }
|
||||
|
|
|
@ -221,7 +221,7 @@ RSpec.describe ImportJob do
|
|||
instance = create(:import_job)
|
||||
delayed_job = double()
|
||||
|
||||
instance.update_attribute(:finished_at, Time.zone.now)
|
||||
instance.update!(finished_at: Time.zone.now)
|
||||
|
||||
expect(instance.reschedule?(delayed_job)).to be false
|
||||
end
|
||||
|
|
|
@ -117,7 +117,7 @@ RSpec.describe Scheduler do
|
|||
|
||||
# lock job (simluates interrupted scheduler task)
|
||||
locked_job = Delayed::Job.last
|
||||
locked_job.update_attribute(:locked_at, Time.zone.now)
|
||||
locked_job.update!(locked_at: Time.zone.now)
|
||||
|
||||
expect do
|
||||
simulate_threads_call
|
||||
|
@ -134,7 +134,7 @@ RSpec.describe Scheduler do
|
|||
|
||||
# lock job (simluates interrupted scheduler task)
|
||||
locked_job = Delayed::Job.last
|
||||
locked_job.update_attribute(:locked_at, Time.zone.now)
|
||||
locked_job.update!(locked_at: Time.zone.now)
|
||||
|
||||
expect do
|
||||
simulate_threads_call
|
||||
|
@ -151,7 +151,7 @@ RSpec.describe Scheduler do
|
|||
|
||||
# lock job (simluates interrupted scheduler task)
|
||||
locked_job = Delayed::Job.last
|
||||
locked_job.update_attribute(:locked_at, Time.zone.now)
|
||||
locked_job.update!(locked_at: Time.zone.now)
|
||||
|
||||
expect do
|
||||
simulate_threads_call
|
||||
|
|
|
@ -213,14 +213,14 @@ RSpec.describe Ticket do
|
|||
pending_time: Time.zone.now + 2.days)
|
||||
expect(ticket.pending_time).not_to be nil
|
||||
|
||||
ticket.update_attribute(:state, Ticket::State.lookup(name: 'open'))
|
||||
ticket.update!(state: Ticket::State.lookup(name: 'open'))
|
||||
expect(ticket.pending_time).to be nil
|
||||
end
|
||||
|
||||
it 'lets handle ActiveRecord nil as new value' do
|
||||
ticket = create(:ticket)
|
||||
expect do
|
||||
ticket.update_attribute(:state, nil)
|
||||
ticket.update!(state: nil)
|
||||
end.to raise_error(ActiveRecord::StatementInvalid)
|
||||
end
|
||||
|
||||
|
|
|
@ -93,7 +93,7 @@ class ClearbitTest < ActiveSupport::TestCase
|
|||
assert_equal('OTRS is an Open Source helpdesk software and an IT Service Management software free of licence costs. Improve your Customer Service Management with OTRS.', organization2_lookup.note)
|
||||
|
||||
# update with own values (do not overwrite)
|
||||
customer2.update_attributes(
|
||||
customer2.update!(
|
||||
firstname: 'Martini',
|
||||
note: 'changed by my self',
|
||||
)
|
||||
|
@ -122,7 +122,7 @@ class ClearbitTest < ActiveSupport::TestCase
|
|||
assert_equal('Norsk-Data-Straße 1, 61352 Bad Homburg vor der Höhe, Germany', customer2_lookup.address)
|
||||
|
||||
# update with own values (do not overwrite)
|
||||
customer2.update_attributes(
|
||||
customer2.update!(
|
||||
firstname: '',
|
||||
note: 'changed by my self',
|
||||
)
|
||||
|
@ -139,7 +139,7 @@ class ClearbitTest < ActiveSupport::TestCase
|
|||
assert_equal('Norsk-Data-Straße 1, 61352 Bad Homburg vor der Höhe, Germany', customer2_lookup.address)
|
||||
|
||||
# update with changed values at clearbit site (do overwrite)
|
||||
customer2.update_attributes(
|
||||
customer2.update!(
|
||||
email: 'me2@example.com',
|
||||
)
|
||||
|
||||
|
|
|
@ -91,7 +91,7 @@ class EmailDeliverTest < ActiveSupport::TestCase
|
|||
assert_nil(article1_lookup.preferences['delivery_status_message'])
|
||||
|
||||
# send with invalid smtp settings
|
||||
channel.update_attributes(
|
||||
channel.update!(
|
||||
options: {
|
||||
inbound: {
|
||||
adapter: 'imap',
|
||||
|
@ -125,7 +125,7 @@ class EmailDeliverTest < ActiveSupport::TestCase
|
|||
assert(article1_lookup.preferences['delivery_status_message'])
|
||||
|
||||
# send with correct smtp settings
|
||||
channel.update_attributes(
|
||||
channel.update!(
|
||||
options: {
|
||||
inbound: {
|
||||
adapter: 'imap',
|
||||
|
@ -162,7 +162,7 @@ class EmailDeliverTest < ActiveSupport::TestCase
|
|||
Delayed::Job.destroy_all
|
||||
|
||||
# send with invalid smtp settings
|
||||
channel.update_attributes(
|
||||
channel.update!(
|
||||
options: {
|
||||
inbound: {
|
||||
adapter: 'imap',
|
||||
|
|
|
@ -66,7 +66,7 @@ class ReportTest < ActiveSupport::TestCase
|
|||
updated_by_id: 1,
|
||||
created_by_id: 1,
|
||||
)
|
||||
@ticket1.update_attributes(
|
||||
@ticket1.update!(
|
||||
group: Group.lookup(name: 'Users'),
|
||||
updated_at: '2015-10-28 14:30:00 UTC',
|
||||
)
|
||||
|
@ -97,7 +97,7 @@ class ReportTest < ActiveSupport::TestCase
|
|||
updated_by_id: 1,
|
||||
created_by_id: 1,
|
||||
)
|
||||
@ticket2.update_attributes(
|
||||
@ticket2.update!(
|
||||
group_id: group2.id,
|
||||
updated_at: '2015-10-28 14:30:00 UTC',
|
||||
)
|
||||
|
@ -184,7 +184,7 @@ class ReportTest < ActiveSupport::TestCase
|
|||
updated_by_id: 1,
|
||||
created_by_id: 1,
|
||||
)
|
||||
@ticket5.update_attributes(
|
||||
@ticket5.update!(
|
||||
state: Ticket::State.lookup(name: 'open'),
|
||||
updated_at: '2015-10-28 14:30:00 UTC',
|
||||
)
|
||||
|
|
|
@ -47,7 +47,7 @@ class ActivityStreamTest < ActiveSupport::TestCase
|
|||
)
|
||||
|
||||
travel 100.seconds
|
||||
ticket.update_attributes(
|
||||
ticket.update!(
|
||||
title: 'Unit Test 1 (äöüß) - update!',
|
||||
state_id: Ticket::State.lookup(name: 'open').id,
|
||||
priority_id: Ticket::Priority.lookup(name: '1 low').id,
|
||||
|
@ -55,7 +55,7 @@ class ActivityStreamTest < ActiveSupport::TestCase
|
|||
updated_at = ticket.updated_at
|
||||
|
||||
travel 1.second
|
||||
ticket.update_attributes(
|
||||
ticket.update!(
|
||||
title: 'Unit Test 2 (äöüß) - update!',
|
||||
priority_id: Ticket::Priority.lookup(name: '2 normal').id,
|
||||
)
|
||||
|
@ -99,11 +99,11 @@ class ActivityStreamTest < ActiveSupport::TestCase
|
|||
travel 100.seconds
|
||||
assert_equal(organization.class, Organization)
|
||||
|
||||
organization.update_attributes(name: 'some name (äöüß)')
|
||||
organization.update!(name: 'some name (äöüß)')
|
||||
updated_at = organization.updated_at
|
||||
|
||||
travel 10.seconds
|
||||
organization.update_attributes(name: 'some name 2 (äöüß)')
|
||||
organization.update!(name: 'some name 2 (äöüß)')
|
||||
|
||||
# check activity_stream
|
||||
stream = @admin_user.activity_stream(3)
|
||||
|
@ -138,7 +138,7 @@ class ActivityStreamTest < ActiveSupport::TestCase
|
|||
created_by_id: @current_user.id,
|
||||
)
|
||||
assert_equal(user.class, User)
|
||||
user.update_attributes(
|
||||
user.update!(
|
||||
firstname: 'Bob U',
|
||||
lastname: 'Smith U',
|
||||
)
|
||||
|
@ -172,14 +172,14 @@ class ActivityStreamTest < ActiveSupport::TestCase
|
|||
travel 100.seconds
|
||||
assert_equal(user.class, User)
|
||||
|
||||
user.update_attributes(
|
||||
user.update!(
|
||||
firstname: 'Bob U',
|
||||
lastname: 'Smith U',
|
||||
)
|
||||
updated_at = user.updated_at
|
||||
|
||||
travel 10.seconds
|
||||
user.update_attributes(
|
||||
user.update!(
|
||||
firstname: 'Bob',
|
||||
lastname: 'Smith',
|
||||
)
|
||||
|
|
|
@ -5,7 +5,7 @@ class AuthTest < ActiveSupport::TestCase
|
|||
test 'auth' do
|
||||
|
||||
user = User.find_by(email: 'nicole.braun@zammad.org')
|
||||
user.update_attributes(
|
||||
user.update!(
|
||||
login: 'nicole.braun',
|
||||
firstname: 'Nicole',
|
||||
lastname: 'Braun',
|
||||
|
|
|
@ -36,7 +36,7 @@ Subject: #{ticket.subject_build('some new subject')}
|
|||
|
||||
Some Text"
|
||||
|
||||
users_group.update_attribute('follow_up_possible', 'new_ticket')
|
||||
users_group.update!('follow_up_possible' => 'new_ticket')
|
||||
|
||||
travel 1.second
|
||||
ticket_p, article_p, user_p = Channel::EmailParser.new.process({}, follow_up_raw)
|
||||
|
@ -60,7 +60,7 @@ Some Text"
|
|||
assert_equal('some new subject2', ticket_p.title)
|
||||
assert_equal('some new subject2', article_p.subject)
|
||||
|
||||
users_group.update_attribute('follow_up_possible', 'yes')
|
||||
users_group.update!('follow_up_possible' => 'yes')
|
||||
|
||||
travel 1.second
|
||||
ticket_p, article_p, user_p = Channel::EmailParser.new.process({}, follow_up_raw)
|
||||
|
|
|
@ -164,10 +164,10 @@ class HistoryTest < ActiveSupport::TestCase
|
|||
|
||||
# update ticket
|
||||
if test[:ticket_update][:ticket]
|
||||
ticket.update_attributes(test[:ticket_update][:ticket])
|
||||
ticket.update!(test[:ticket_update][:ticket])
|
||||
end
|
||||
if test[:ticket_update][:article]
|
||||
article.update_attributes(test[:ticket_update][:article])
|
||||
article.update!(test[:ticket_update][:article])
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -260,7 +260,7 @@ class HistoryTest < ActiveSupport::TestCase
|
|||
# update user
|
||||
if test[:user_update][:user]
|
||||
test[:user_update][:user][:active] = false
|
||||
user.update_attributes(test[:user_update][:user])
|
||||
user.update!(test[:user_update][:user])
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -323,7 +323,7 @@ class HistoryTest < ActiveSupport::TestCase
|
|||
|
||||
# update organization
|
||||
if test[:organization_update][:organization]
|
||||
organization.update_attributes(test[:organization_update][:organization])
|
||||
organization.update!(test[:organization_update][:organization])
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -78,7 +78,7 @@ class OnlineNotificationTest < ActiveSupport::TestCase
|
|||
assert(!OnlineNotification.exists?(@agent_user2, 'Ticket', ticket1.id, 'create', @agent_user1, false))
|
||||
assert(OnlineNotification.exists?(@agent_user2, 'Ticket', ticket1.id, 'create', @agent_user1, true))
|
||||
|
||||
ticket1.update_attributes(
|
||||
ticket1.update!(
|
||||
title: 'Unit Test 1 (äöüß) - update!',
|
||||
state_id: Ticket::State.lookup(name: 'open').id,
|
||||
priority_id: Ticket::Priority.lookup(name: '1 low').id,
|
||||
|
@ -133,7 +133,7 @@ class OnlineNotificationTest < ActiveSupport::TestCase
|
|||
assert(!OnlineNotification.exists?(@agent_user2, 'Ticket', ticket2.id, 'create', @customer_user, false))
|
||||
assert(!OnlineNotification.exists?(@agent_user2, 'Ticket', ticket2.id, 'create', @customer_user, true))
|
||||
|
||||
ticket2.update_attributes(
|
||||
ticket2.update!(
|
||||
title: 'Unit Test 1 (äöüß) - update!',
|
||||
state_id: Ticket::State.lookup(name: 'open').id,
|
||||
priority_id: Ticket::Priority.lookup(name: '1 low').id,
|
||||
|
@ -187,7 +187,7 @@ class OnlineNotificationTest < ActiveSupport::TestCase
|
|||
assert(OnlineNotification.exists?(@agent_user2, 'Ticket', ticket3.id, 'create', @agent_user1, false))
|
||||
assert(!OnlineNotification.exists?(@agent_user2, 'Ticket', ticket3.id, 'create', @agent_user1, true))
|
||||
|
||||
ticket3.update_attributes(
|
||||
ticket3.update!(
|
||||
title: 'Unit Test 2 (äöüß) - update!',
|
||||
state_id: Ticket::State.lookup(name: 'closed').id,
|
||||
priority_id: Ticket::Priority.lookup(name: '1 low').id,
|
||||
|
@ -267,7 +267,7 @@ class OnlineNotificationTest < ActiveSupport::TestCase
|
|||
assert(!OnlineNotification.exists?(@agent_user2, 'Ticket', ticket4.id, 'create', @customer_user, false))
|
||||
assert(!OnlineNotification.exists?(@agent_user2, 'Ticket', ticket4.id, 'create', @customer_user, true))
|
||||
|
||||
ticket4.update_attributes(
|
||||
ticket4.update!(
|
||||
title: 'Unit Test 3 (äöüß) - update!',
|
||||
state_id: Ticket::State.lookup(name: 'open').id,
|
||||
priority_id: Ticket::Priority.lookup(name: '1 low').id,
|
||||
|
@ -321,7 +321,7 @@ class OnlineNotificationTest < ActiveSupport::TestCase
|
|||
assert(OnlineNotification.exists?(@agent_user2, 'Ticket', ticket5.id, 'create', @agent_user1, false))
|
||||
assert(!OnlineNotification.exists?(@agent_user2, 'Ticket', ticket5.id, 'create', @agent_user1, true))
|
||||
|
||||
ticket5.update_attributes(
|
||||
ticket5.update!(
|
||||
title: 'Unit Test 4 (äöüß) - update!',
|
||||
state_id: Ticket::State.lookup(name: 'open').id,
|
||||
priority_id: Ticket::Priority.lookup(name: '1 low').id,
|
||||
|
@ -398,7 +398,7 @@ class OnlineNotificationTest < ActiveSupport::TestCase
|
|||
assert_equal(ticket1.online_notification_seen_state(@agent_user2), false)
|
||||
|
||||
# pending reminder, just let new owner to unseed
|
||||
ticket1.update_attributes(
|
||||
ticket1.update!(
|
||||
owner_id: @agent_user1.id,
|
||||
state: Ticket::State.lookup(name: 'pending reminder'),
|
||||
updated_by_id: @agent_user2.id,
|
||||
|
@ -409,7 +409,7 @@ class OnlineNotificationTest < ActiveSupport::TestCase
|
|||
assert_equal(ticket1.online_notification_seen_state(@agent_user2.id), true)
|
||||
|
||||
# pending reminder, just let new owner to unseed
|
||||
ticket1.update_attributes(
|
||||
ticket1.update!(
|
||||
owner_id: 1,
|
||||
state: Ticket::State.lookup(name: 'pending reminder'),
|
||||
updated_by_id: @agent_user2.id,
|
||||
|
@ -420,7 +420,7 @@ class OnlineNotificationTest < ActiveSupport::TestCase
|
|||
assert_equal(ticket1.online_notification_seen_state(@agent_user2.id), false)
|
||||
|
||||
# pending reminder, self done, all to unseed
|
||||
ticket1.update_attributes(
|
||||
ticket1.update!(
|
||||
owner_id: @agent_user1.id,
|
||||
state: Ticket::State.lookup(name: 'pending reminder'),
|
||||
updated_by_id: @agent_user1.id,
|
||||
|
@ -431,7 +431,7 @@ class OnlineNotificationTest < ActiveSupport::TestCase
|
|||
assert_equal(ticket1.online_notification_seen_state(@agent_user2.id), true)
|
||||
|
||||
# pending close, all to unseen
|
||||
ticket1.update_attributes(
|
||||
ticket1.update!(
|
||||
owner_id: @agent_user1.id,
|
||||
state: Ticket::State.lookup(name: 'pending close'),
|
||||
updated_by_id: @agent_user2.id,
|
||||
|
@ -442,7 +442,7 @@ class OnlineNotificationTest < ActiveSupport::TestCase
|
|||
assert_equal(ticket1.online_notification_seen_state(@agent_user2.id), true)
|
||||
|
||||
# to open, all to seen
|
||||
ticket1.update_attributes(
|
||||
ticket1.update!(
|
||||
owner_id: @agent_user1.id,
|
||||
state: Ticket::State.lookup(name: 'open'),
|
||||
updated_by_id: @agent_user2.id,
|
||||
|
@ -453,7 +453,7 @@ class OnlineNotificationTest < ActiveSupport::TestCase
|
|||
assert_equal(ticket1.online_notification_seen_state(@agent_user2.id), false)
|
||||
|
||||
# to closed, all only others to seen
|
||||
ticket1.update_attributes(
|
||||
ticket1.update!(
|
||||
owner_id: @agent_user1.id,
|
||||
state: Ticket::State.lookup(name: 'closed'),
|
||||
updated_by_id: @agent_user2.id,
|
||||
|
@ -464,7 +464,7 @@ class OnlineNotificationTest < ActiveSupport::TestCase
|
|||
assert_equal(ticket1.online_notification_seen_state(@agent_user2.id), true)
|
||||
|
||||
# to closed by owner self, all to seen
|
||||
ticket1.update_attributes(
|
||||
ticket1.update!(
|
||||
owner_id: @agent_user1.id,
|
||||
state: Ticket::State.lookup(name: 'closed'),
|
||||
updated_by_id: @agent_user1.id,
|
||||
|
@ -475,7 +475,7 @@ class OnlineNotificationTest < ActiveSupport::TestCase
|
|||
assert_equal(ticket1.online_notification_seen_state(@agent_user2.id), true)
|
||||
|
||||
# to closed by owner self, all to seen
|
||||
ticket1.update_attributes(
|
||||
ticket1.update!(
|
||||
owner_id: @agent_user1.id,
|
||||
state: Ticket::State.lookup(name: 'merged'),
|
||||
updated_by_id: @agent_user2.id,
|
||||
|
|
|
@ -243,7 +243,7 @@ class SessionBasicTest < ActiveSupport::TestCase
|
|||
result1 = as_client1.push
|
||||
assert(!result1, 'check as agent1 - recall 2')
|
||||
|
||||
agent1.update_attribute(:email, 'activity-stream-agent11@example.com')
|
||||
agent1.update!(email: 'activity-stream-agent11@example.com')
|
||||
ticket = Ticket.create!(
|
||||
title: '12323',
|
||||
group_id: 1,
|
||||
|
|
|
@ -168,7 +168,7 @@ class TicketSlaTest < ActiveSupport::TestCase
|
|||
assert_nil(ticket.close_diff_in_min, 'ticket.close_diff_in_min verify 2')
|
||||
|
||||
# set first response in time
|
||||
ticket.update_attributes(
|
||||
ticket.update!(
|
||||
first_response_at: '2013-03-21 10:00:00 UTC',
|
||||
)
|
||||
|
||||
|
@ -187,7 +187,7 @@ class TicketSlaTest < ActiveSupport::TestCase
|
|||
assert_nil(ticket.close_diff_in_min, 'ticket.close_diff_in_min verify 3')
|
||||
|
||||
# set first reponse over time
|
||||
ticket.update_attributes(
|
||||
ticket.update!(
|
||||
first_response_at: '2013-03-21 14:00:00 UTC',
|
||||
)
|
||||
|
||||
|
@ -206,7 +206,7 @@ class TicketSlaTest < ActiveSupport::TestCase
|
|||
assert_nil(ticket.close_diff_in_min, 'ticket.close_diff_in_min verify 4')
|
||||
|
||||
# set update time in time
|
||||
ticket.update_attributes(
|
||||
ticket.update!(
|
||||
last_contact_agent_at: '2013-03-21 11:00:00 UTC',
|
||||
)
|
||||
assert_equal(ticket.escalation_at.gmtime.to_s, '2013-03-21 12:30:00 UTC', 'ticket.escalation_at verify 5')
|
||||
|
@ -225,7 +225,7 @@ class TicketSlaTest < ActiveSupport::TestCase
|
|||
assert_nil(ticket.close_diff_in_min, 'ticket.close_diff_in_min verify 5')
|
||||
|
||||
# set update time over time
|
||||
ticket.update_attributes(
|
||||
ticket.update!(
|
||||
last_contact_agent_at: '2013-03-21 12:00:00 UTC',
|
||||
)
|
||||
assert_equal(ticket.escalation_at.gmtime.to_s, '2013-03-21 12:30:00 UTC', 'ticket.escalation_at verify 6')
|
||||
|
@ -244,7 +244,7 @@ class TicketSlaTest < ActiveSupport::TestCase
|
|||
assert_nil(ticket.close_diff_in_min, 'ticket.close_diff_in_min verify 6')
|
||||
|
||||
# set update time over time
|
||||
ticket.update_attributes(
|
||||
ticket.update!(
|
||||
last_contact_customer_at: '2013-03-21 12:05:00 UTC',
|
||||
)
|
||||
assert_equal(ticket.escalation_at.gmtime.to_s, '2013-03-21 12:30:00 UTC', 'ticket.escalation_at verify 6')
|
||||
|
@ -263,7 +263,7 @@ class TicketSlaTest < ActiveSupport::TestCase
|
|||
assert_nil(ticket.close_diff_in_min, 'ticket.close_diff_in_min verify 6')
|
||||
|
||||
# set update time over time
|
||||
ticket.update_attributes(
|
||||
ticket.update!(
|
||||
last_contact_agent_at: '2013-03-21 12:10:00 UTC',
|
||||
)
|
||||
assert_equal(ticket.escalation_at.gmtime.to_s, '2013-03-21 12:30:00 UTC', 'ticket.escalation_at verify 6')
|
||||
|
@ -282,7 +282,7 @@ class TicketSlaTest < ActiveSupport::TestCase
|
|||
assert_nil(ticket.close_diff_in_min, 'ticket.close_diff_in_min verify 6')
|
||||
|
||||
# set close time in time
|
||||
ticket.update_attributes(
|
||||
ticket.update!(
|
||||
close_at: '2013-03-21 11:30:00 UTC',
|
||||
)
|
||||
assert_equal(ticket.escalation_at.gmtime.to_s, '2013-03-21 14:10:00 UTC', 'ticket.escalation_at verify 7')
|
||||
|
@ -301,7 +301,7 @@ class TicketSlaTest < ActiveSupport::TestCase
|
|||
assert_equal(ticket.close_diff_in_min, 60, 'ticket.close_diff_in_min verify 7')
|
||||
|
||||
# set close time over time
|
||||
ticket.update_attributes(
|
||||
ticket.update!(
|
||||
close_at: '2013-03-21 13:00:00 UTC',
|
||||
)
|
||||
assert_equal(ticket.escalation_at.gmtime.to_s, '2013-03-21 14:10:00 UTC', 'ticket.escalation_at verify 8')
|
||||
|
@ -320,7 +320,7 @@ class TicketSlaTest < ActiveSupport::TestCase
|
|||
assert_equal(ticket.close_diff_in_min, -30, 'ticket.close_diff_in_min verify 8')
|
||||
|
||||
# set close time over time
|
||||
ticket.update_attributes(
|
||||
ticket.update!(
|
||||
state: Ticket::State.lookup(name: 'closed')
|
||||
)
|
||||
assert_nil(ticket.escalation_at, 'ticket.escalation_at verify 9')
|
||||
|
@ -1097,12 +1097,12 @@ class TicketSlaTest < ActiveSupport::TestCase
|
|||
)
|
||||
|
||||
# set update time
|
||||
ticket.update_attributes(
|
||||
ticket.update!(
|
||||
last_contact_agent_at: '2013-06-04 10:15:00 UTC',
|
||||
)
|
||||
|
||||
# set first response time
|
||||
ticket.update_attributes(
|
||||
ticket.update!(
|
||||
first_response_at: '2013-06-04 10:45:00 UTC',
|
||||
)
|
||||
|
||||
|
@ -1121,7 +1121,7 @@ class TicketSlaTest < ActiveSupport::TestCase
|
|||
updated_at: '2013-06-04 12:00:00 UTC'
|
||||
)
|
||||
|
||||
ticket.update_attributes(
|
||||
ticket.update!(
|
||||
close_at: '2013-06-04 12:00:00 UTC',
|
||||
)
|
||||
|
||||
|
@ -1218,7 +1218,7 @@ class TicketSlaTest < ActiveSupport::TestCase
|
|||
created_at: '2013-06-04 12:00:00 UTC',
|
||||
updated_at: '2013-06-04 12:00:00 UTC',
|
||||
)
|
||||
ticket.update_attributes(
|
||||
ticket.update!(
|
||||
close_at: '2013-06-04 12:00:00 UTC',
|
||||
)
|
||||
ticket.escalation_calculation(true)
|
||||
|
@ -1346,7 +1346,7 @@ class TicketSlaTest < ActiveSupport::TestCase
|
|||
created_at: '2013-06-04 12:00:00 UTC',
|
||||
updated_at: '2013-06-04 12:00:00 UTC',
|
||||
)
|
||||
ticket.update_attributes(
|
||||
ticket.update!(
|
||||
close_at: '2013-06-04 12:00:00 UTC',
|
||||
)
|
||||
|
||||
|
@ -1489,7 +1489,7 @@ class TicketSlaTest < ActiveSupport::TestCase
|
|||
created_at: '2013-06-04 12:00:00 UTC',
|
||||
updated_at: '2013-06-04 12:00:00 UTC',
|
||||
)
|
||||
ticket.update_attributes(
|
||||
ticket.update!(
|
||||
close_at: '2013-06-04 12:00:00 UTC',
|
||||
)
|
||||
|
||||
|
@ -2074,7 +2074,7 @@ class TicketSlaTest < ActiveSupport::TestCase
|
|||
assert_nil(ticket.close_escalation_at, 'ticket.close_escalation_at verify 1')
|
||||
|
||||
# set sla's for timezone "Europe/Berlin" wintertime (+1), so UTC times are 3:00-18:00
|
||||
calendar.update_attributes(
|
||||
calendar.update!(
|
||||
business_hours: {
|
||||
mon: {
|
||||
active: true,
|
||||
|
|
|
@ -1497,7 +1497,7 @@ class TicketTriggerTest < ActiveSupport::TestCase
|
|||
assert_equal(1, ticket1.articles.count, 'ticket1.articles verify')
|
||||
assert_equal([], ticket1.tag_list)
|
||||
|
||||
ticket1.update_attribute(:customer, User.lookup(email: 'nicole.braun@zammad.org') )
|
||||
ticket1.update!(customer: User.lookup(email: 'nicole.braun@zammad.org') )
|
||||
|
||||
UserInfo.current_user_id = agent.id
|
||||
Ticket::Article.create(
|
||||
|
@ -1608,7 +1608,7 @@ class TicketTriggerTest < ActiveSupport::TestCase
|
|||
assert_equal(1, ticket1.articles.count, 'ticket1.articles verify')
|
||||
assert_equal([], ticket1.tag_list)
|
||||
|
||||
ticket1.update_attribute(:customer, customer )
|
||||
ticket1.update!(customer: customer )
|
||||
|
||||
UserInfo.current_user_id = agent.id
|
||||
Ticket::Article.create(
|
||||
|
|
|
@ -271,7 +271,7 @@ class UserTest < ActiveSupport::TestCase
|
|||
assert_equal(test[:create_verify][:image_md5], file_md5, "create avatar md5 check in (#{test[:name]})")
|
||||
end
|
||||
if test[:update]
|
||||
user.update_attributes( test[:update] )
|
||||
user.update!( test[:update] )
|
||||
|
||||
test[:update_verify].each { |key, value|
|
||||
next if key == :image_md5
|
||||
|
@ -848,18 +848,18 @@ class UserTest < ActiveSupport::TestCase
|
|||
admin_count_inital = User.with_permissions('admin').count
|
||||
assert_equal(3, admin_count_inital)
|
||||
|
||||
admin1.update_attribute(:roles, Role.where(name: %w(Agent)))
|
||||
admin1.update!(roles: Role.where(name: %w(Agent)))
|
||||
|
||||
admin_count_inital = User.with_permissions('admin').count
|
||||
assert_equal(2, admin_count_inital)
|
||||
|
||||
admin2.update_attribute(:roles, Role.where(name: %w(Agent)))
|
||||
admin2.update!(roles: Role.where(name: %w(Agent)))
|
||||
|
||||
admin_count_inital = User.with_permissions('admin').count
|
||||
assert_equal(1, admin_count_inital)
|
||||
|
||||
assert_raises(Exceptions::UnprocessableEntity) {
|
||||
admin3.update_attribute(:roles, Role.where(name: %w(Agent)))
|
||||
admin3.update!(roles: Role.where(name: %w(Agent)))
|
||||
}
|
||||
|
||||
admin_count_inital = User.with_permissions('admin').count
|
||||
|
|
Loading…
Reference in a new issue