chore: apply rubocop

This commit is contained in:
gabrieljablonski 2025-09-19 19:44:02 -03:00
parent 18c672c204
commit 24620a0baf
9 changed files with 20 additions and 20 deletions

View File

@ -37,7 +37,7 @@ class Twilio::SendOnTwilioService < Base::SendOnChannelService
# Add messaging service or from number
send_params = send_params.merge(channel.send(:send_message_from))
channel.send(:client).messages.create(**send_params)
channel.send(:client).messages.create!(**send_params)
end
def template_params

View File

@ -42,7 +42,7 @@ class SamlUserBuilder
full_name = [auth_attribute('first_name'), auth_attribute('last_name')].compact.join(' ')
fallback_name = auth_attribute('name') || auth_attribute('email').split('@').first
User.create(
User.create!(
email: auth_attribute('email'),
name: (full_name.presence || fallback_name),
display_name: auth_attribute('first_name'),
@ -58,13 +58,13 @@ class SamlUserBuilder
return unless account
# Create account_user if not exists
account_user = AccountUser.find_or_create_by(
account_user = AccountUser.find_or_create_by!(
user: @user,
account: account
)
# Set default role as agent if not set
account_user.update(role: 'agent') if account_user.role.blank?
account_user.update!(role: 'agent') if account_user.role.blank?
# Handle role mappings if configured
apply_role_mappings(account_user, account)
@ -75,9 +75,9 @@ class SamlUserBuilder
return unless matching_mapping
if matching_mapping['role']
account_user.update(role: matching_mapping['role'])
account_user.update!(role: matching_mapping['role'])
elsif matching_mapping['custom_role_id']
account_user.update(custom_role_id: matching_mapping['custom_role_id'])
account_user.update!(custom_role_id: matching_mapping['custom_role_id'])
end
end

View File

@ -26,7 +26,7 @@ class Twilio::VoiceWebhookSetupService
def create_twiml_app!
friendly_name = "Chatwoot Voice #{channel.phone_number}"
app = api_key_client.applications.create(
app = api_key_client.applications.create!(
friendly_name: friendly_name,
voice_url: channel.voice_call_webhook_url,
voice_method: HTTP_METHOD
@ -46,7 +46,7 @@ class Twilio::VoiceWebhookSetupService
api_key_client
.incoming_phone_numbers(numbers.first.sid)
.update(
.update!(
voice_url: channel.voice_call_webhook_url,
voice_method: HTTP_METHOD,
status_callback: channel.voice_status_webhook_url,

View File

@ -127,7 +127,7 @@ RSpec.describe AccountSamlSettings, type: :model do
it 'queues job to reset account users provider' do
settings = create(:account_saml_settings, account: account)
expect(Saml::UpdateAccountUsersProviderJob).to receive(:perform_later).with(account.id, 'email')
settings.destroy
settings.destroy!
end
end
end

View File

@ -22,7 +22,7 @@ RSpec.describe AgentCapacityPolicy, type: :model do
account_user = user.account_users.first
account_user.update!(agent_capacity_policy: policy)
policy.destroy
policy.destroy!
expect(account_user.reload.agent_capacity_policy).to be_nil
end
end

View File

@ -24,7 +24,7 @@ RSpec.describe Avatar::AvatarFromUrlJob do
it 'returns early when rate limited' do
ts = 30.seconds.ago.iso8601
avatarable.update(additional_attributes: { 'last_avatar_sync_at' => ts })
avatarable.update!(additional_attributes: { 'last_avatar_sync_at' => ts })
expect(Down).not_to receive(:download)
described_class.perform_now(avatarable, valid_url)
avatarable.reload
@ -36,7 +36,7 @@ RSpec.describe Avatar::AvatarFromUrlJob do
end
it 'returns early when hash unchanged' do
avatarable.update(additional_attributes: { 'avatar_url_hash' => Digest::SHA256.hexdigest(valid_url) })
avatarable.update!(additional_attributes: { 'avatar_url_hash' => Digest::SHA256.hexdigest(valid_url) })
expect(Down).not_to receive(:download)
described_class.perform_now(avatarable, valid_url)
expect(avatarable.avatar).not_to be_attached

View File

@ -47,7 +47,7 @@ RSpec.describe Inboxes::BulkAutoAssignmentJob do
context 'when account is on default plan in chatwoot cloud' do
before do
account.update!(custom_attributes: {})
InstallationConfig.create(name: 'CHATWOOT_CLOUD_PLANS', value: [{ 'name' => 'default' }])
InstallationConfig.create!(name: 'CHATWOOT_CLOUD_PLANS', value: [{ 'name' => 'default' }])
allow(ChatwootApp).to receive(:chatwoot_cloud?).and_return(true)
end

View File

@ -121,7 +121,7 @@ RSpec.describe AutomationRules::ActionService do
describe '#perform with add_label action' do
before do
rule.actions << { action_name: 'add_label', action_params: %w[bug feature] }
rule.save
rule.save!
end
it 'will add labels to conversation' do
@ -141,7 +141,7 @@ RSpec.describe AutomationRules::ActionService do
before do
conversation.add_labels(%w[bug feature support])
rule.actions << { action_name: 'remove_label', action_params: %w[bug feature] }
rule.save
rule.save!
end
it 'will remove specified labels from conversation' do

View File

@ -145,7 +145,7 @@ RSpec.describe AutomationRules::ConditionsFilterService do
rule.conditions = [
{ 'values': ['bug'], 'attribute_key': 'labels', 'query_operator': nil, 'filter_operator': 'equal_to' }
]
rule.save
rule.save!
end
it 'will return true when conversation has the label' do
@ -156,7 +156,7 @@ RSpec.describe AutomationRules::ConditionsFilterService do
rule.conditions = [
{ 'values': ['feature'], 'attribute_key': 'labels', 'query_operator': nil, 'filter_operator': 'equal_to' }
]
rule.save
rule.save!
expect(described_class.new(rule, conversation, { changed_attributes: {} }).perform).to be(false)
end
end
@ -166,7 +166,7 @@ RSpec.describe AutomationRules::ConditionsFilterService do
rule.conditions = [
{ 'values': ['feature'], 'attribute_key': 'labels', 'query_operator': nil, 'filter_operator': 'not_equal_to' }
]
rule.save
rule.save!
end
it 'will return true when conversation does not have the label' do
@ -184,7 +184,7 @@ RSpec.describe AutomationRules::ConditionsFilterService do
rule.conditions = [
{ 'values': [], 'attribute_key': 'labels', 'query_operator': nil, 'filter_operator': 'is_present' }
]
rule.save
rule.save!
end
it 'will return true when conversation has any labels' do
@ -202,7 +202,7 @@ RSpec.describe AutomationRules::ConditionsFilterService do
rule.conditions = [
{ 'values': [], 'attribute_key': 'labels', 'query_operator': nil, 'filter_operator': 'is_not_present' }
]
rule.save
rule.save!
end
it 'will return false when conversation has any labels' do