Skip to content

Commit

Permalink
revert rubocop
Browse files Browse the repository at this point in the history
  • Loading branch information
microstudi committed Feb 5, 2024
1 parent d385786 commit b35ced5
Show file tree
Hide file tree
Showing 71 changed files with 821 additions and 861 deletions.
2 changes: 1 addition & 1 deletion Rakefile
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
# 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", __dir__)
require File.expand_path('../config/application', __FILE__)

Rails.application.load_tasks
2 changes: 1 addition & 1 deletion config.ru
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# This file is used by Rack-based servers to start the application.

require_relative "config/environment"
require_relative 'config/environment'

run Rails.application
18 changes: 9 additions & 9 deletions config/application.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
require File.expand_path("boot", __dir__)
require File.expand_path('../boot', __FILE__)

require "rails/all"
require 'rails/all'

# Require the gems listed in Gemfile, including any gems
# you've limited to :test, :development, or :production.
Expand All @@ -13,11 +13,11 @@ class Application < Rails::Application

# I18n configuration
config.i18n.default_locale = :es
config.i18n.available_locales = %i[es ca eu gl en pt-BR fr]
config.i18n.available_locales = [:es, :ca, :eu, :gl, :en, :'pt-BR', :fr]
config.i18n.fallbacks = true

# This tells Rails to serve error pages from the app itself, rather than using static error pages in public/
config.exceptions_app = routes
config.exceptions_app = self.routes

# Activate the Skylight agent in staging. You need to provision the
# SKYLIGHT_AUTHENTICATION env var for this to work.
Expand All @@ -31,10 +31,10 @@ class Application < Rails::Application
config.active_record.schema_format = :sql

# Guard against DNS rebinding attacks by permitting hosts
config.hosts << "localhost"
config.hosts << "timeoverflow.local"
config.hosts << "staging.timeoverflow.org"
config.hosts << "www.timeoverflow.org"
config.hosts << "timeoverflow.org"
config.hosts << 'localhost'
config.hosts << 'timeoverflow.local'
config.hosts << 'staging.timeoverflow.org'
config.hosts << 'www.timeoverflow.org'
config.hosts << 'timeoverflow.org'
end
end
6 changes: 3 additions & 3 deletions config/boot.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../Gemfile", __dir__)
ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../Gemfile', __dir__)

require "bundler/setup" # Set up gems listed in the Gemfile.
require "bootsnap/setup" # Speed up boot time by caching expensive operations.
require 'bundler/setup' # Set up gems listed in the Gemfile.
require 'bootsnap/setup' # Speed up boot time by caching expensive operations.
2 changes: 1 addition & 1 deletion config/environment.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Load the Rails application.
require_relative "application"
require_relative 'application'

# Initialize the Rails application.
Rails.application.initialize!
6 changes: 3 additions & 3 deletions config/environments/development.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@

# Enable/disable caching. By default caching is disabled.
# Run rails dev:cache to toggle caching.
if Rails.root.join("tmp/caching-dev.txt").exist?
if Rails.root.join('tmp', 'caching-dev.txt').exist?
config.action_controller.perform_caching = true
config.action_controller.enable_fragment_cache_logging = true

config.cache_store = :memory_store
config.public_file_server.headers = {
"Cache-Control" => "public, max-age=#{2.days.to_i}"
'Cache-Control' => "public, max-age=#{2.days.to_i}"
}
else
config.action_controller.perform_caching = false
Expand All @@ -38,7 +38,7 @@

config.action_mailer.delivery_method = :letter_opener
config.action_mailer.default_url_options = {
host: ENV["MAIL_LINK_HOST"] || "localhost:3000"
host: (ENV["MAIL_LINK_HOST"] || "localhost:3000")
}

# Print deprecation notices to the Rails logger.
Expand Down
2 changes: 1 addition & 1 deletion config/environments/staging.rb
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
#  Use same settings we use for production
# Use same settings we use for production
require_relative "production"
2 changes: 1 addition & 1 deletion config/environments/test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
# Configure public file server for tests with Cache-Control for performance.
config.public_file_server.enabled = true
config.public_file_server.headers = {
"Cache-Control" => "public, max-age=#{1.hour.to_i}"
'Cache-Control' => "public, max-age=#{1.hour.to_i}"
}

# Show full error reports and disable caching.
Expand Down
35 changes: 17 additions & 18 deletions config/routes.rb
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
require "sidekiq/web"
require "sidekiq/cron/web"
require 'sidekiq/web'
require 'sidekiq/cron/web'

Rails.application.routes.draw do
root to: "home#index"

authenticate :user, lambda { |u| Rails.env.development? || u.superadmin? } do
mount Sidekiq::Web => "/sidekiq"
mount Sidekiq::Web => '/sidekiq'
end

devise_for :users, controllers: { sessions: "sessions" }
Expand All @@ -16,7 +16,7 @@

ActiveAdmin.routes(self)

get :switch_lang, to: "application#switch_lang"
get :switch_lang, to: 'application#switch_lang'

get "/pages/:page" => "pages#show", as: :page

Expand All @@ -28,35 +28,34 @@
get :give_time, on: :member
end

resources :organizations, except: %i[new create destroy], concerns: :accountable do
resources :organizations, except: [:new, :create, :destroy], concerns: :accountable do
member do
post :set_current
end
end
get :select_organization, to: "organizations#select_organization"
get :select_organization, to: 'organizations#select_organization'

resources :users, concerns: :accountable, except: :destroy, path: "members" do
resources :users, concerns: :accountable, except: :destroy, :path => "members" do
collection do
get "signup"
get "manage"
get "please_confirm"
get 'signup'
get 'manage'
get 'please_confirm'
end
end
put :update_avatar, to: "users#update_avatar"
put :update_avatar, to: 'users#update_avatar'

resources :petitions, only: %i[create update] do
resources :petitions, only: [:create, :update] do
collection do
get "manage"
get 'manage'
end
end

resources :transfers, only: %i[new create] do
resources :transfers, only: [:new, :create] do
member do
put :delete_reason
end
end
match "multi/step/:step", to: "multi_transfers#step", via: %i[get post],
as: :multi_transfers_step
match "multi/step/:step", to: "multi_transfers#step", via: [:get, :post], as: :multi_transfers_step
post "multi/create", to: "multi_transfers#create", as: :multi_transfers_create

resources :documents
Expand Down Expand Up @@ -100,6 +99,6 @@
end
end

match "/404", to: "errors#not_found", via: :all
match "/500", to: "errors#internal_server_error", via: :all
match '/404', to: 'errors#not_found', via: :all
match '/500', to: 'errors#internal_server_error', via: :all
end
8 changes: 3 additions & 5 deletions spec/admin/organizations_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,10 @@
it "sign out if current user is logged to organization deleted" do
session[:current_organization_id] = organization.id

expect do
expect {
delete :destroy, params: { id: organization.id }
end.to change { controller.current_user }.to(nil).
and change {
session[:current_organization_id]
}.to(nil)
}.to change { controller.current_user }.to(nil)
.and change { session[:current_organization_id] }.to(nil)
end
end
end
4 changes: 2 additions & 2 deletions spec/controllers/application_controller_spec.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
RSpec.describe ApplicationController do
describe "#switch_lang" do
describe '#switch_lang' do
let(:original_locale) { I18n.locale }

before do
Expand All @@ -10,7 +10,7 @@
I18n.locale = original_locale
end

it "switches locale to passed language via params" do
it 'switches locale to passed language via params' do
new_locale = (I18n.available_locales - [original_locale]).sample

expect do
Expand Down
16 changes: 8 additions & 8 deletions spec/controllers/device_tokens_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,27 +2,27 @@
let (:organization) { Fabricate(:organization) }
let (:member) { Fabricate(:member, organization: organization) }

describe "POST #create" do
context "without login" do
it "responds with error" do
describe 'POST #create' do
context 'without login' do
it 'responds with error' do
expect do
post :create
end.to change(DeviceToken, :count).by(0)
end
end

context "with valid params" do
it "creates a new device_token" do
context 'with valid params' do
it 'creates a new device_token' do
login(member.user)

expect do
post :create, params: { token: "xxx" }
post :create, params: { token: 'xxx' }
end.to change(DeviceToken, :count).by(1)
end
end

context "with invalid params" do
it "responds with error" do
context 'with invalid params' do
it 'responds with error' do
login(member.user)
post :create
expect(response.status).to eq(422)
Expand Down
4 changes: 2 additions & 2 deletions spec/controllers/inquiries_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@

expect do
post "create", params: { inquiry: { user: another_member.user,
category_id: test_category.id,
title: "New title" } }
category_id: test_category.id,
title: "New title" }}
end.to change(Inquiry, :count).by(1)
end
end
Expand Down
23 changes: 12 additions & 11 deletions spec/controllers/multi_transfers_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
category: test_category)
end

it "creates one to many transfers" do
it 'creates one to many transfers' do
expect do
login(admin.user)

Expand All @@ -37,14 +37,14 @@

post :step, params: params.merge!(
step: 5,
transfer: { amount: 3600, reason: "because of reasons" }
transfer: {amount: 3600, reason: 'because of reasons'}
)

post :create, params: params
end.to change { Transfer.count }.by(2)
end

it "creates many to one transfers" do
it 'creates many to one transfers' do
expect do
login(admin.user)

Expand All @@ -69,15 +69,15 @@

post :step, params: params.merge!(
step: 5,
transfer: { amount: 3600, reason: "because of reasons" }
transfer: {amount: 3600, reason: 'because of reasons'}
)

post :create, params: params
end.to change { Transfer.count }.by(2)
end

context "when only one source and one target is selected" do
it "creates one to one transfers" do
context 'when only one source and one target is selected' do
it 'creates one to one transfers' do
expect do
login(admin.user)

Expand All @@ -102,29 +102,30 @@

post :step, params: params.merge!(
step: 5,
transfer: { amount: 3600, reason: "because of reasons" }
transfer: {amount: 3600, reason: 'because of reasons'}
)

post :create, params: params
end.to change { Transfer.count }.by(1)
end
end

context "non admins" do
it "cannot access step route" do
context 'non admins' do
it 'cannot access step route' do
login(member.user)

get :step, params: { step: 1 }

expect(response).not_to have_http_status(:success)
end

it "cannot access create route" do
it 'cannot access create route' do
login(member.user)

post :create

expect(response).to redirect_to("/")
expect(response).to redirect_to('/')
end
end
end

Loading

0 comments on commit b35ced5

Please sign in to comment.