fix: rubocop

This commit is contained in:
Sojan 2022-12-08 18:31:51 +03:00
parent f8dc22602e
commit ba3b70ea30
13 changed files with 39 additions and 26 deletions

View file

@ -86,6 +86,10 @@ Style/ClassAndModuleChildren:
- 'config/application.rb'
Style/MapToHash:
Enabled: false
Style/HashSyntax:
Enabled: true
EnforcedStyle: no_mixed_keys
EnforcedShorthandSyntax: never
RSpec/NestedGroups:
Enabled: true
Max: 4

View file

@ -135,6 +135,11 @@ gem 'stripe'
## to populate db with sample data
gem 'faker'
# Can remove this in rails 7
gem 'net-imap', require: false
gem 'net-pop', require: false
gem 'net-smtp', require: false
group :production, :staging do
# we dont want request timing out in development while using byebug
gem 'rack-timeout'
@ -186,5 +191,3 @@ group :development, :test do
gem 'spring'
gem 'spring-watcher-listen'
end
gem "net-smtp", "~> 0.3.2"

View file

@ -424,6 +424,10 @@ GEM
multipart-post (2.2.3)
net-http-persistent (4.0.1)
connection_pool (~> 2.2)
net-imap (0.3.1)
net-protocol
net-pop (0.1.2)
net-protocol
net-protocol (0.2.1)
timeout
net-smtp (0.3.3)
@ -760,7 +764,9 @@ DEPENDENCIES
listen
maxminddb
mock_redis
net-smtp (~> 0.3.2)
net-imap
net-pop
net-smtp
newrelic_rpm
pg
pg_search

View file

@ -8,20 +8,20 @@ module SwitchLocale
locale ||= locale_from_params
# if locale is not set in account, let's use DEFAULT_LOCALE env variable
locale ||= locale_from_env_variable
set_locale(locale, &action)
set_locale(locale, &)
end
def switch_locale_using_account_locale(&action)
def switch_locale_using_account_locale(&)
locale = locale_from_account(@current_account)
set_locale(locale, &action)
set_locale(locale, &)
end
def set_locale(locale, &action)
def set_locale(locale, &)
# if locale is empty, use default_locale
locale ||= I18n.default_locale
# Ensure locale won't bleed into other requests
# https://guides.rubyonrails.org/i18n.html#managing-the-locale-across-requests
I18n.with_locale(locale, &action)
I18n.with_locale(locale, &)
end
def locale_from_params

View file

@ -69,11 +69,11 @@ class ApplicationMailer < ActionMailer::Base
Current.account = account if account.present?
end
def switch_locale(&action)
def switch_locale(&)
locale ||= locale_from_account(Current.account)
locale ||= I18n.default_locale
# ensure locale won't bleed into other requests
# https://guides.rubyonrails.org/i18n.html#managing-the-locale-across-requests
I18n.with_locale(locale, &action)
I18n.with_locale(locale, &)
end
end

View file

@ -33,7 +33,7 @@ class DashboardApp < ApplicationRecord
'required' => %w[url type],
'properties' => {
'type' => { 'enum': ['frame'] },
'url' => { 'type': 'string', 'format' => 'uri' }
'url' => { :type => 'string', 'format' => 'uri' }
}
},
'additionalProperties' => false,

View file

@ -78,7 +78,7 @@ class Whatsapp::Providers::WhatsappCloudService < Whatsapp::Providers::BaseServi
"#{phone_id_path}/messages",
headers: api_headers,
body: {
messaging_product: 'whatsapp',
:messaging_product => 'whatsapp',
'to' => phone_number,
'type' => type,
type.to_s => type_content

View file

@ -278,7 +278,7 @@ RSpec.describe 'Api::V1::Accounts::MacrosController', type: :request do
{ 'action_name' => 'snooze_conversation' },
{ 'action_name' => 'assign_agent', 'action_params' => [user_1.id] },
{ 'action_name' => 'send_message', 'action_params' => ['Send this message.'] },
{ 'action_name' => 'add_private_note', 'action_params': ['We are sending greeting message to customer.'] }
{ 'action_name' => 'add_private_note', :action_params => ['We are sending greeting message to customer.'] }
])
end

View file

@ -8,7 +8,7 @@ FactoryBot.define do
'type' => 'message_create',
'id' => '123',
'message_create' => {
target: { 'recipient_id' => '1' },
:target => { 'recipient_id' => '1' },
'sender_id' => '2',
'source_app_id' => '268278',
'message_data' => {

View file

@ -4,7 +4,7 @@ RSpec.describe Webhooks::LineEventsJob, type: :job do
subject(:job) { described_class.perform_later(params: params) }
let!(:line_channel) { create(:channel_line) }
let!(:params) { { line_channel_id: line_channel.line_channel_id, 'line' => { test: 'test' } } }
let!(:params) { { :line_channel_id => line_channel.line_channel_id, 'line' => { test: 'test' } } }
let(:post_body) { params.to_json }
let(:signature) { Base64.strict_encode64(OpenSSL::HMAC.digest(OpenSSL::Digest.new('SHA256'), line_channel.line_channel_secret, post_body)) }

View file

@ -4,7 +4,7 @@ RSpec.describe Webhooks::TelegramEventsJob, type: :job do
subject(:job) { described_class.perform_later(params) }
let!(:telegram_channel) { create(:channel_telegram) }
let!(:params) { { bot_token: telegram_channel.bot_token, 'telegram' => { test: 'test' } } }
let!(:params) { { :bot_token => telegram_channel.bot_token, 'telegram' => { test: 'test' } } }
it 'enqueues the job' do
expect { job }.to have_enqueued_job(described_class)

View file

@ -58,8 +58,8 @@ describe Whatsapp::IncomingMessageService do
'contacts' => [{ 'profile' => { 'name' => 'Sojan Jose' }, 'wa_id' => '2423423243' }],
'messages' => [{
'errors' => [{ 'code': 131_051, 'title': 'Message type is currently not supported.' }],
'from': '2423423243', 'id': 'wamid.SDFADSf23sfasdafasdfa',
'timestamp': '1667047370', 'type': 'unsupported'
:from => '2423423243', :id => 'wamid.SDFADSf23sfasdafasdfa',
:timestamp => '1667047370', :type => 'unsupported'
}]
}.with_indifferent_access
@ -115,7 +115,7 @@ describe Whatsapp::IncomingMessageService do
params = {
'contacts' => [{ 'profile' => { 'name' => 'Sojan Jose' }, 'wa_id' => '2423423243' }],
'messages' => [{ 'from' => '2423423243', 'id' => 'SDFADSf23sfasdafasdfa',
'interactive': {
:interactive => {
'button_reply': {
'id': '1',
'title': 'First Button'
@ -179,11 +179,11 @@ describe Whatsapp::IncomingMessageService do
'contacts' => [{ 'profile' => { 'name' => 'Sojan Jose' }, 'wa_id' => '2423423243' }],
'messages' => [{ 'from' => '2423423243', 'id' => 'SDFADSf23sfasdafasdfa',
'location' => { 'id' => 'b1c68f38-8734-4ad3-b4a1-ef0c10d683',
'address': 'San Francisco, CA, USA',
'latitude': 37.7893768,
'longitude': -122.3895553,
'name': 'Bay Bridge',
'url': 'http://location_url.test' },
:address => 'San Francisco, CA, USA',
:latitude => 37.7893768,
:longitude => -122.3895553,
:name => 'Bay Bridge',
:url => 'http://location_url.test' },
'timestamp' => '1633034394', 'type' => 'location' }]
}.with_indifferent_access
described_class.new(inbox: whatsapp_channel.inbox, params: params).perform

View file

@ -15,7 +15,7 @@ RSpec.configure do |config|
config.shared_context_metadata_behavior = :apply_to_host_groups
def with_modified_env(options, &block)
ClimateControl.modify(options, &block)
def with_modified_env(options, &)
ClimateControl.modify(options, &)
end
end