1
0
Fork 0

Fix code style

This commit is contained in:
Alex Kotov 2019-04-28 18:34:46 +05:00
parent d875995e11
commit b19734d18b
Signed by: kotovalexarian
GPG key ID: 553C0EBBEB5D5F08
36 changed files with 104 additions and 107 deletions

View file

@ -15,9 +15,6 @@ AllCops:
Layout/AccessModifierIndentation:
EnforcedStyle: outdent
Layout/AlignHash:
EnforcedColonStyle: table
Layout/EmptyLinesAroundArguments:
Enabled: false

View file

@ -28,7 +28,7 @@ private
def set_raven_context
Raven.user_context(
account_id: current_account&.id,
user_id: current_user&.id,
user_id: current_user&.id,
)
Raven.extra_context params: params.to_unsafe_h, url: request.url
@ -63,7 +63,7 @@ private
def render_method_not_allowed
respond_to do |format|
format.html do
render status: :method_not_allowed,
render status: :method_not_allowed,
template: 'errors/method_not_allowed'
end
format.json { render status: :method_not_allowed, json: {} }

View file

@ -17,7 +17,7 @@ class Staffs::Passports::PassportConfirmationsController < ApplicationController
def create
ActiveRecord::Base.transaction do
ConfirmPassport.call(passport: @passport,
account: current_account).tap do |context|
account: current_account).tap do |context|
authorize_if_present context.passport_confirmation
end
end

View file

@ -17,9 +17,9 @@ class Users::OmniauthCallbacksController < Devise::OmniauthCallbacksController
# GET|POST /users/auth/github/callback
def github
context = AuthenticateUserWithOmniauth.call(
provider: auth_hash.provider,
provider: auth_hash.provider,
remote_id: auth_hash.uid,
email: auth_hash.info.email,
email: auth_hash.info.email,
)
sign_in_and_redirect context.user

View file

@ -2,7 +2,7 @@
module ApplicationHelper
NAV_TABS_LIST_HTML_CLASS = {
tabs: 'nav nav-tabs d-none d-sm-flex',
tabs: 'nav nav-tabs d-none d-sm-flex',
pills: 'nav nav-pills d-flex d-sm-none flex-column',
}.freeze

View file

@ -33,7 +33,7 @@ private
def build_user_omniauth
context.user_omniauth = UserOmniauth.where(
provider: context.provider,
provider: context.provider,
remote_id: context.remote_id,
).lock(true).first_or_initialize do |new_user_omniauth|
new_user_omniauth.user = context.user

View file

@ -5,7 +5,7 @@ class MembershipAppMailer < ApplicationMailer
def tracking
mail(
to: @membership_app.email,
to: @membership_app.email,
subject: translate('membership_app_mailer.tracking.subject'),
)
end

View file

@ -27,7 +27,7 @@ class Account < ApplicationRecord
has_many :account_roles,
-> { active },
inverse_of: :account,
dependent: :restrict_with_exception
dependent: :restrict_with_exception
has_many :roles, through: :account_roles
@ -37,7 +37,7 @@ class Account < ApplicationRecord
has_one :own_membership_app,
class_name: 'MembershipApp',
dependent: :restrict_with_exception
dependent: :restrict_with_exception
has_many :passport_confirmations, dependent: :restrict_with_exception
@ -59,9 +59,9 @@ class Account < ApplicationRecord
validates :person, allow_nil: true, uniqueness: true
validates :nickname,
presence: true,
length: { in: 3..36 },
format: NICKNAME_RE,
presence: true,
length: { in: 3..36 },
format: NICKNAME_RE,
uniqueness: { case_sensitive: false }
validates :public_name, allow_nil: true, length: { in: 3..255 }

View file

@ -20,8 +20,8 @@ class Person < ApplicationRecord
has_one :own_membership_app,
class_name: 'MembershipApp',
inverse_of: :person,
through: :account,
source: :own_membership_app
through: :account,
source: :own_membership_app
###############
# Validations #

View file

@ -13,10 +13,10 @@ class Relationship < ApplicationRecord
###############
validates :number,
presence: true,
uniqueness: { scope: :person_id },
presence: true,
uniqueness: { scope: :person_id },
numericality: {
only_integer: true,
only_integer: true,
greater_than_or_equal_to: 0,
}

View file

@ -14,7 +14,7 @@ class Role < ApplicationRecord
has_many :account_roles,
-> { active },
inverse_of: :role,
dependent: :restrict_with_exception
dependent: :restrict_with_exception
has_many :accounts, through: :account_roles
@ -25,7 +25,7 @@ class Role < ApplicationRecord
###############
validates :name,
presence: true,
presence: true,
inclusion: { in: NAMES }
validates :resource_type,
@ -43,9 +43,9 @@ class Role < ApplicationRecord
resource_id = resource&.id unless resource.is_a? Class
find_or_create_by!(
name: role_name,
name: role_name,
resource_type: resource_type,
resource_id: resource_id,
resource_id: resource_id,
)
end

View file

@ -14,11 +14,11 @@ development_mode = ['', nil, 'development'].include?(env)
test_mode = env == 'test'
Bootsnap.setup(
cache_dir: cache_dir,
development_mode: development_mode,
load_path_cache: true,
cache_dir: cache_dir,
development_mode: development_mode,
load_path_cache: true,
autoload_paths_cache: true,
disable_trace: false,
compile_cache_iseq: test_mode,
compile_cache_yaml: true,
disable_trace: false,
compile_cache_iseq: test_mode,
compile_cache_yaml: true,
)

View file

@ -67,9 +67,9 @@ Rails.application.configure do
# Use a different cache store in production.
cache_conf = Rails.application.settings :cache_store
config.cache_store = :redis_cache_store, {
host: cache_conf[:host],
port: cache_conf[:port],
db: cache_conf[:db],
host: cache_conf[:host],
port: cache_conf[:port],
db: cache_conf[:db],
password: cache_conf[:password],
}

View file

@ -5,12 +5,12 @@
conf = Rails.application.settings :smtp
ActionMailer::Base.smtp_settings = {
address: conf[:address],
port: conf[:port]&.to_i,
domain: conf[:domain],
user_name: conf[:user_name],
password: conf[:password],
authentication: conf[:authentication]&.to_sym,
address: conf[:address],
port: conf[:port]&.to_i,
domain: conf[:domain],
user_name: conf[:user_name],
password: conf[:password],
authentication: conf[:authentication]&.to_sym,
enable_starttls_auto: conf[:enable_starttls_auto],
openssl_verify_mode: conf[:openssl_verify_mode],
openssl_verify_mode: conf[:openssl_verify_mode],
}.compact.presence

View file

@ -7,18 +7,18 @@ server_conf = Rails.application.settings :sidekiq_server
Sidekiq.configure_client do |config|
config.redis = {
host: client_conf[:redis_host],
port: client_conf[:redis_port],
db: client_conf[:redis_db],
host: client_conf[:redis_host],
port: client_conf[:redis_port],
db: client_conf[:redis_db],
password: client_conf[:redis_password],
}
end
Sidekiq.configure_server do |config|
config.redis = {
host: server_conf[:redis_host],
port: server_conf[:redis_port],
db: server_conf[:redis_db],
host: server_conf[:redis_host],
port: server_conf[:redis_port],
db: server_conf[:redis_db],
password: server_conf[:redis_password],
}
end

View file

@ -408,14 +408,14 @@ SimpleForm.setup do |config|
# Custom wrappers for input types. This should be a hash containing an input
# type as key and the wrapper that will be used for all inputs with specified type.
config.wrapper_mappings = {
boolean: :vertical_boolean,
check_boxes: :vertical_collection,
date: :vertical_multi_select,
datetime: :vertical_multi_select,
file: :vertical_file,
boolean: :vertical_boolean,
check_boxes: :vertical_collection,
date: :vertical_multi_select,
datetime: :vertical_multi_select,
file: :vertical_file,
radio_buttons: :vertical_collection,
range: :vertical_range,
time: :vertical_multi_select,
range: :vertical_range,
time: :vertical_multi_select,
}
# enable custom form wrappers

View file

@ -22,11 +22,11 @@ Rails.application.routes.draw do
###############
devise_for :users, controllers: {
sessions: 'users/sessions',
registrations: 'users/registrations',
confirmations: 'users/confirmations',
passwords: 'users/passwords',
unlocks: 'users/unlocks',
sessions: 'users/sessions',
registrations: 'users/registrations',
confirmations: 'users/confirmations',
passwords: 'users/passwords',
unlocks: 'users/unlocks',
omniauth_callbacks: 'users/omniauth_callbacks',
}
@ -56,17 +56,17 @@ Rails.application.routes.draw do
resources :people, only: %i[index show] do
resources :passports,
controller: 'people/passports',
only: :index
only: :index
resources :resident_registrations,
controller: 'people/resident_registrations',
only: :index
only: :index
end
resources :passports, only: %i[index show new create] do
resources :passport_confirmations,
controller: 'passports/passport_confirmations',
only: %i[index create]
only: %i[index create]
end
resources :membership_apps, only: %i[index show]

View file

@ -22,7 +22,7 @@ class CreateActiveStorageTables < ActiveRecord::Migration[5.2]
t.datetime :created_at, null: false
t.index %i[record_type record_id name blob_id],
name: 'index_active_storage_attachments_uniqueness',
name: 'index_active_storage_attachments_uniqueness',
unique: true
end
end

View file

@ -4,8 +4,8 @@ class AddAccountToUsers < ActiveRecord::Migration[5.2]
def change
add_reference :users,
:account,
null: false, # rubocop:disable Rails/NotNullColumn
index: { unique: true },
null: false, # rubocop:disable Rails/NotNullColumn
index: { unique: true },
foreign_key: true
end
end

View file

@ -3,7 +3,7 @@
class AddAccountToMembershipApplications < ActiveRecord::Migration[5.2]
def change
add_reference :membership_applications, :account,
null: false, # rubocop:disable Rails/NotNullColumn
null: false, # rubocop:disable Rails/NotNullColumn
foreign_key: true
end
end

View file

@ -6,7 +6,7 @@ class CreatePassportMaps < ActiveRecord::Migration[5.2]
t.timestamps null: false
t.references :passport, null: false,
index: { unique: true }, foreign_key: true
index: { unique: true }, foreign_key: true
t.string :surname, null: false
t.string :given_name, null: false

View file

@ -3,12 +3,12 @@
class NonUniquePassportForPassportMaps < ActiveRecord::Migration[5.2]
def change
remove_reference :passport_maps, :passport,
null: false,
index: { unique: true },
null: false,
index: { unique: true },
foreign_key: true
add_reference :passport_maps, :passport,
null: false, # rubocop:disable Rails/NotNullColumn
null: false, # rubocop:disable Rails/NotNullColumn
foreign_key: true
end
end

View file

@ -9,7 +9,7 @@ class CreateMembershipPoolApps < ActiveRecord::Migration[5.2]
t.references :membership_app, null: false, foreign_key: true
t.index %i[membership_app_id membership_pool_id],
name: 'index_membership_pool_apps_on_app_and_pool',
name: 'index_membership_pool_apps_on_app_and_pool',
unique: true
end
end

View file

@ -9,7 +9,7 @@ class CreateMembershipPoolAccounts < ActiveRecord::Migration[5.2]
t.references :account, null: false, foreign_key: true
t.index %i[membership_pool_id account_id],
name: 'index_membership_pool_accounts_on_pool_and_account',
name: 'index_membership_pool_accounts_on_pool_and_account',
unique: true
end
end

View file

@ -6,8 +6,8 @@ class CreateRegionalOffices < ActiveRecord::Migration[5.2]
t.timestamps null: false
t.references :country_state,
null: false,
index: { unique: true },
null: false,
index: { unique: true },
foreign_key: true
end
end

View file

@ -3,7 +3,7 @@
class AddGuestTokenToAccounts < ActiveRecord::Migration[5.2]
def change
add_column :accounts, :guest_token, :string,
null: false, # rubocop:disable Rails/NotNullColumn
null: false, # rubocop:disable Rails/NotNullColumn
index: { unique: true }
end
end

View file

@ -6,12 +6,12 @@ class CreateAccountTelegramContacts < ActiveRecord::Migration[5.2]
t.timestamps null: false
t.references :account,
null: false,
null: false,
foreign_key: true
t.references :telegram_chat,
null: false,
index: { unique: true },
null: false,
index: { unique: true },
foreign_key: true
end
end

View file

@ -2,7 +2,7 @@
class UniqueUsernameOfAccounts < ActiveRecord::Migration[6.0]
def change
change_column :accounts, :username, :string, null: false,
change_column :accounts, :username, :string, null: false,
index: { unique: true }
end
end

View file

@ -20,9 +20,9 @@ Rails.application.settings(:superuser).tap do |config|
new_user.password = config[:password]
new_user.confirmed_at = Time.zone.now
new_user.account = Account.create!(
nickname: config[:nickname],
nickname: config[:nickname],
public_name: config[:public_name],
biography: config[:biography],
biography: config[:biography],
)
end.account.add_role :superuser
end

View file

@ -23,7 +23,7 @@ FactoryBot.define do
after :build do |passport, evaluator|
passport.images.attach(
filename: evaluator.image_filename,
io: File.open(evaluator.image_path),
io: File.open(evaluator.image_path),
)
end
end

View file

@ -4,9 +4,9 @@ When 'there is a usual account with the following data:' do |table|
options = table.raw.map { |(k, v)| [k.to_sym, v] }.to_h
create :usual_account,
nickname: options[:nickname],
nickname: options[:nickname],
public_name: options[:public_name],
biography: options[:biography]
biography: options[:biography]
end
When 'there is a supporter account with the following data:' do |table|
@ -17,10 +17,10 @@ When 'there is a supporter account with the following data:' do |table|
person = create :supporter_person, regional_office: regional_office
create :personal_account,
nickname: options[:nickname],
nickname: options[:nickname],
public_name: options[:public_name],
biography: options[:biography],
person: person
biography: options[:biography],
person: person
end
When 'there is a member account with the following data:' do |table|
@ -31,10 +31,10 @@ When 'there is a member account with the following data:' do |table|
person = create :member_person, regional_office: regional_office
create :personal_account,
nickname: options[:nickname],
nickname: options[:nickname],
public_name: options[:public_name],
biography: options[:biography],
person: person
biography: options[:biography],
person: person
end
When 'there is an excluded member account with the following data:' do |table|
@ -45,8 +45,8 @@ When 'there is an excluded member account with the following data:' do |table|
person = create :excluded_person, regional_office: regional_office
create :personal_account,
nickname: options[:nickname],
nickname: options[:nickname],
public_name: options[:public_name],
biography: options[:biography],
person: person
biography: options[:biography],
person: person
end

View file

@ -43,8 +43,8 @@ RSpec.describe ConfirmPassport do
specify do
expect(subject).to have_attributes(
passport: passport,
account: account,
passport: passport,
account: account,
passport_confirmation: nil,
)
end
@ -59,8 +59,8 @@ RSpec.describe ConfirmPassport do
specify do
expect(subject).to have_attributes(
passport: passport,
account: account,
passport: passport,
account: account,
passport_confirmation: nil,
)
end
@ -75,8 +75,8 @@ RSpec.describe ConfirmPassport do
specify do
expect(subject).to have_attributes(
passport: passport,
account: account,
passport: passport,
account: account,
passport_confirmation: nil,
)
end

View file

@ -114,8 +114,8 @@ RSpec.describe 'POST /join' do
specify do
expect(ActionMailer::Base.deliveries.last).to have_attributes(
from: [Rails.application.config.noreply_email_address],
to: [MembershipApp.last.email],
from: [Rails.application.config.noreply_email_address],
to: [MembershipApp.last.email],
subject: I18n.t('membership_app_mailer.tracking.subject'),
)
end

View file

@ -7,9 +7,9 @@ RSpec.describe 'PATCH/PUT /settings/profile' do
let :account_attributes do
{
nickname: Faker::Internet.username(3..36, %w[_]),
nickname: Faker::Internet.username(3..36, %w[_]),
public_name: Faker::Name.name,
biography: Faker::Lorem.paragraph,
biography: Faker::Lorem.paragraph,
}
end

View file

@ -47,7 +47,7 @@ RSpec.describe 'POST /staff/passports/:passport_id/passport_confirmations' do
specify do
expect(PassportConfirmation.last).to have_attributes(
passport: passport,
account: current_account,
account: current_account,
)
end
end
@ -228,7 +228,7 @@ RSpec.describe 'POST /staff/passports/:passport_id/passport_confirmations' do
specify do
expect(PassportConfirmation.last).to have_attributes(
passport: passport,
account: current_account,
account: current_account,
)
end
end
@ -264,7 +264,7 @@ RSpec.describe 'POST /staff/passports/:passport_id/passport_confirmations' do
specify do
expect(PassportConfirmation.last).to have_attributes(
passport: passport,
account: current_account,
account: current_account,
)
end
end

View file

@ -22,7 +22,7 @@ RSpec.describe 'POST /users' do
specify do
expect(User.last).to have_attributes user_attributes.merge(
password: nil,
password: nil,
password_confirmation: nil,
)
end