Skip to content

Commit

Permalink
Fixed rubocop offenses
Browse files Browse the repository at this point in the history
  • Loading branch information
jsperezg committed Dec 1, 2018
1 parent e6f648a commit f2b5fc0
Show file tree
Hide file tree
Showing 438 changed files with 5,516 additions and 5,630 deletions.
16 changes: 15 additions & 1 deletion .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,30 @@ require: rubocop-rspec

AllCops:
TargetRubyVersion: 2.4.4
Exclude:
- 'db/migrate/*.rb'
- 'db/schema.rb'
- 'bin/*'

Metrics/LineLength:
Max: 120
Exclude:
- 'config/initializers/devise.rb'
Max: 150

Metrics/BlockLength:
Exclude:
- 'Rakefile'
- '**/*.rake'
- 'test/**/*.rb'
- 'spec/**/*.rb'
- 'config/environments/*.rb'
- 'config/routes.rb'

Documentation:
Enabled: false

RSpec/ExampleLength:
Enabled: false

RSpec/MultipleExpectations:
Enabled: false
2 changes: 2 additions & 0 deletions Capfile
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

# Load DSL and set up stages
require 'capistrano/setup'

Expand Down
4 changes: 3 additions & 1 deletion Rakefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# frozen_string_literal: true

# Add your own tasks in files placed in lib/tasks ending in .rake,
# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.

require File.expand_path('../config/application', __FILE__)
require File.expand_path('config/application', __dir__)

Rails.application.load_tasks
10 changes: 6 additions & 4 deletions app/controllers/admin_secured_controller.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

class AdminSecuredController < SecuredController
include AdminSecuredHelper

Expand All @@ -6,9 +8,9 @@ class AdminSecuredController < SecuredController
private

def check_admin_role
unless is_admin?
sign_out current_user
redirect_to new_user_session_path
end
return if admin?

sign_out current_user
redirect_to new_user_session_path
end
end
100 changes: 53 additions & 47 deletions app/controllers/api/v1/customers_controller.rb
Original file line number Diff line number Diff line change
@@ -1,50 +1,56 @@
class Api::V1::CustomersController < ApiController
include Api

before_action :set_customer, only: [:show, :update, :destroy]

def index
@customers = Customer.order(name: :asc)
end

def show
end

def create
@customer = Customer.new(customer_params)
if @customer.save
render 'show'
else
render json: ResponseFactory.get_response_for(@customer)
end
end

def update
if @customer.update(customer_params)
render 'show'
else
render json: ResponseFactory.get_response_for(@customer)
end
end

def destroy
@customer.destroy
render json: ResponseFactory.get_response_for(@customer)
end

private
# Use callbacks to share common setup or constraints between actions.
def set_customer
@customer = Customer.find(params[:id])
end

# Never trust parameters from the scary internet, only allow the white list through.
def customer_params
params
.require(:customer)
.permit(
# frozen_string_literal: true

module Api
module V1
class CustomersController < ApiController
include Api

before_action :set_customer, only: %i[show update destroy]

def index
@customers = Customer.order(name: :asc)
end

def show; end

def create
@customer = Customer.new(customer_params)
if @customer.save
render 'show'
else
render json: ResponseFactory.get_response_for(@customer)
end
end

def update
if @customer.update(customer_params)
render 'show'
else
render json: ResponseFactory.get_response_for(@customer)
end
end

def destroy
@customer.destroy
render json: ResponseFactory.get_response_for(@customer)
end

private

# Use callbacks to share common setup or constraints between actions.
def set_customer
@customer = Customer.find(params[:id])
end

# Never trust parameters from the scary internet, only allow the white list through.
def customer_params
params
.require(:customer)
.permit(
:name, :tax_id, :billing_serie, :irpf, :contact_name, :contact_phone, :contact_email,
:address, :city, :country, :state, :postal_code, :send_invoices_to
)
)
end
end
end
end
end
12 changes: 8 additions & 4 deletions app/controllers/api/v1/dashboard_controller.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
# frozen_string_literal: true

class Api::V1::DashboardController < ApiController
def index
@reports = TotalsCalculator.for(current_user)
module Api
module V1
class DashboardController < ApiController
def index
@reports = TotalsCalculator.for(current_user)
end
end
end
end
end
Loading

0 comments on commit f2b5fc0

Please sign in to comment.