Skip to content

Commit

Permalink
KBP-179 #time 90m - Edit rubocop warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
hamdibayhan committed Dec 15, 2017
1 parent 346a510 commit 2e2fdb8
Show file tree
Hide file tree
Showing 18 changed files with 74 additions and 48 deletions.
2 changes: 1 addition & 1 deletion lib/cybele/helpers/error_pages.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ def configure_error_pages
after: 'protect_from_forgery with: :exception'

inject_into_file 'config/routes.rb',
template_content('error_pages/error_route.erb'),
template_content('error_pages/error_route.erb.rb'),
before: /^end/

create_error_pages_files
Expand Down
2 changes: 1 addition & 1 deletion lib/cybele/helpers/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ def configure_routes
''

inject_into_file 'config/routes.rb', template_content('config/routes.rb.erb'),
before: 'if Rails.env.production? || Rails.env.staging?'
before: "match '*unmatched_route'"
end
end
end
Expand Down
5 changes: 3 additions & 2 deletions templates/Gemfile.erb
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ gem 'rollbar', '~> 2.15', '>= 2.15.4'
# Ransack is the successor to the MetaSearch gem.
gem 'ransack', '~> 1.8', '>= 1.8.4'

# will_paginate
gem 'will_paginate', '~> 3.1', '>= 3.1.6'
gem 'will_paginate-bootstrap', '~> 1.0', '>= 1.0.1'

Expand All @@ -28,14 +29,14 @@ gem 'roo-xls', '~> 1.1'
gem 'roo', '~> 2.7', '>= 2.7.1'

group :development, :test do
gem 'colorize', '~> 0.8.1'
gem 'better_errors', '~> 2.4'
gem 'bullet', '~> 5.6', '>= 5.6.1'
gem 'colorize', '~> 0.8.1'
gem 'guard', '~> 2.14', '>= 2.14.1'
gem 'mailtrap', '~> 0.2.1'
gem 'pronto', '~> 0.9.5'
gem 'pronto-flay', '~> 0.9.0', require: false
gem 'pronto-rubocop', '~> 0.9.0', require: false
gem 'guard', '~> 2.14', '>= 2.14.1'
end

# A set of common locale data and translations to internationalize and/or localize your Rails applications.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# frozen_string_literal: true

class Hq::ApplicationController < ApplicationController
before_action :authenticate_admin!
before_action :set_audit_user
layout 'hq/application'

Expand Down
18 changes: 11 additions & 7 deletions templates/app_files/app/helpers/application_helper.rb.erb
Original file line number Diff line number Diff line change
@@ -1,19 +1,23 @@
# frozen_string_literal: true

module ApplicationHelper
def get_active_users
User.active.map{|c| ["#{c.email} - #{c.full_name}", c.id] }
def devise_model_map(model_name)
model_name.map { |c| ["#{c.email} - #{c.full_name}", c.id] }
end

def get_users
User.all.map{|c| ["#{c.email} - #{c.full_name}", c.id] }
def active_users
devise_model_map(User.active)
end

def get_admins
Admin.all.map{|c| ["#{c.email} - #{c.full_name}", c.id] }
def users
devise_model_map(User.all)
end

def get_audit_users
def admins
devise_model_map(Admin.all)
end

def audit_users
[[t('activerecord.models.admin'), 'Admin'], [t('activerecord.models.user'), 'User']]
end
end
6 changes: 3 additions & 3 deletions templates/app_files/app/views/hq/audits/_filters.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -11,20 +11,20 @@
= f.label :user_type, label: t('activerecord.attributes.audits.user_type')
= f.input_field :user_type_eq, label: false, class: 'form-control chosen-select',
placeholder: t('activerecord.attributes.audits.user'),
collection: get_audit_users, include_blank: t('view.select')
collection: audit_users, include_blank: t('view.select')

- if params[:q].present? and params[:q][:user_type_eq].present?
- type = params[:q][:user_type_eq]
- if type == 'Admin'
= f.label :user, label: t('activerecord.attributes.audits.user')
= f.input_field :user_id_eq, label: false, class: 'form-control chosen-select',
placeholder: t('activerecord.attributes.audits.user'),
collection: get_admins, include_blank: t('view.select')
collection: admins, include_blank: t('view.select')
- elsif type == 'User'
= f.label :user, label: t('activerecord.attributes.audits.user')
= f.input_field :user_id_eq, label: false, class: 'form-control chosen-select',
placeholder: t('activerecord.attributes.audits.user'),
collection: get_users, include_blank: t('view.select')
collection: users, include_blank: t('view.select')

= f.label :auditable_type, label: t('activerecord.attributes.audits.auditable_type')
= f.input_field :auditable_type_eq, label: false, class: 'form-control chosen-select',
Expand Down
1 change: 1 addition & 0 deletions templates/app_files/jquery_Gemfile.erb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@

# jquery gems
gem 'jquery-rails', '~> 4.3', '>= 4.3.1'
gem 'jquery-ui-rails', '~> 6.0', '>= 6.0.1'
25 changes: 21 additions & 4 deletions templates/config/routes.rb.erb
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,22 @@
post :toggle_is_active, on: :member
end

devise_path_names = {
sign_in: 'login',
sign_out: 'logout',
password: 'secret',
confirmation: 'verification'
}

# Admins
devise_for :admins, controllers: { sessions: 'hq/sessions', registrations: 'hq/registrations', passwords: 'hq/passwords' },
devise_for :admins,
controllers: {
sessions: 'hq/sessions',
registrations: 'hq/registrations',
passwords: 'hq/passwords'
},
path: 'hq',
path_names: { sign_in: 'login', sign_out: 'logout', password: 'secret', confirmation: 'verification' }
path_names: devise_path_names

as :admin do
get 'hq/edit' => 'hq/registrations#edit', as: 'edit_admin_registration'
Expand All @@ -22,9 +34,14 @@
end

# Users
devise_for :users, controllers: { sessions: 'user/sessions', registrations: 'user/registrations', passwords: 'user/passwords' },
devise_for :users,
controllers: {
sessions: 'user/sessions',
registrations: 'user/registrations',
passwords: 'user/passwords'
},
path: 'user',
path_names: { sign_in: 'login', sign_out: 'logout', password: 'secret', confirmation: 'verification' }
path_names: devise_path_names

as :user do
get 'user/edit' => 'user/registrations#edit', as: 'edit_user_profile_registration'
Expand Down
2 changes: 1 addition & 1 deletion templates/devise/devise_authenticate_admin.rb.erb
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@

before_action :authenticate_admin!
before_action :authenticate_admin!
10 changes: 6 additions & 4 deletions templates/devise/devise_strong_parameter.rb.erb
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@


def configure_devise_permitted_parameters
sign_up_attributes = %i[email password password_confirmation name surname]
sign_in_attributes = %i[email password password_confirmation current_password]
if resource_class == User
devise_parameter_sanitizer.permit(:sign_up, keys: [:email, :password, :password_confirmation, :name, :surname])
devise_parameter_sanitizer.permit(:sign_in, keys: [:email, :password, :password_confirmation, :current_password])
devise_parameter_sanitizer.permit(:sign_up, keys: sign_up_attributes)
devise_parameter_sanitizer.permit(:sign_in, keys: sign_in_attributes)
elsif resource_class == Admin
devise_parameter_sanitizer.permit(:sign_up, keys: [:email, :password, :password_confirmation, :name, :surname])
devise_parameter_sanitizer.permit(:sign_in, keys: [:email, :password, :password_confirmation, :current_password])
devise_parameter_sanitizer.permit(:sign_up, keys: sign_up_attributes)
devise_parameter_sanitizer.permit(:sign_in, keys: sign_in_attributes)
end
end
2 changes: 1 addition & 1 deletion templates/error_pages/error_method.erb
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@

def page_not_found
render template: 'errors/not_found', status: 404
end
end
4 changes: 0 additions & 4 deletions templates/error_pages/error_route.erb

This file was deleted.

2 changes: 2 additions & 0 deletions templates/error_pages/error_route.erb.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@

match '*unmatched_route', to: 'application#page_not_found', via: :all unless Rails.env.development?
12 changes: 6 additions & 6 deletions templates/mailer/smtp.rb.erb
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
config.action_mailer.delivery_method = :smtp
config.action_mailer.raise_delivery_errors = false
config.action_mailer.smtp_settings = {
address: Settings.smtp.address,
port: Settings.smtp.port,
enable_starttls_auto: Settings.smtp.enable_starttls_auto,
user_name: Settings.smtp.user_name,
password: Settings.smtp.password,
authentication: Settings.smtp.authentication
address: Settings.smtp.address,
port: Settings.smtp.port,
enable_starttls_auto: Settings.smtp.enable_starttls_auto,
user_name: Settings.smtp.user_name,
password: Settings.smtp.password,
authentication: Settings.smtp.authentication
}
4 changes: 2 additions & 2 deletions templates/paperclip/paperclip_Gemfile.erb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@

# Easy file attachment management for ActiveRecord. Amazon's S3 storage adapter.
gem "paperclip", "~> 5.0.0"
gem 'aws-sdk', '~> 2.3.0'
gem 'aws-sdk', '~> 2.3.0'
gem 'paperclip', '~> 5.0.0'
15 changes: 9 additions & 6 deletions templates/pronto/.rubocop.yml.erb
Original file line number Diff line number Diff line change
@@ -1,21 +1,19 @@
AllCops:
Includes:
Include:
- 'Rakefile'
- 'config.ru'
- 'Gemfile'
Excludes:
Exclude:
- Guardfile
- bin/**
- bin/**/**
- db/**/**
- spec/**/**/**/**
- test/**/**/**/**
- tmp/**/**/**/**

Documentation:
Enabled: false

Metrics/LineLength:
Max: 100
Max: 110
Exclude:
- 'Gemfile'

Expand All @@ -30,6 +28,11 @@ Metrics/BlockLength:
- 'Rakefile'
- '**/*.rake'
- 'spec/**/*.rb'
- 'config/routes.rb'

Style/FrozenStringLiteralComment:
EnforcedStyle: when_needed

Style/ClassAndModuleChildren:
Exclude:
- 'app/controllers/**/*.rb'
1 change: 1 addition & 0 deletions templates/show_for/show_for_Gemfile.erb
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@

#Wrap your objects with a helper to easily show them
gem 'show_for', '~> 0.6.0'
10 changes: 5 additions & 5 deletions templates/sidekiq/sidekiq_routes_mount.erb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@


# ========== Sidekiq ==========
Sidekiq::Web.use Rack::Auth::Basic do |username, password|
username == 'sidekiq' && password == 'sidekiq'
end if Rails.env.production?
mount Sidekiq::Web, at: '/sidekiq'
if Rails.env.production?
Sidekiq::Web.use Rack::Auth::Basic do |username, password|
username == 'sidekiq' && password == 'sidekiq'
end
end

0 comments on commit 2e2fdb8

Please sign in to comment.