mirror of
https://github.com/LaCasemate/fab-manager.git
synced 2024-11-28 09:24:24 +01:00
(quality) linted code
This commit is contained in:
parent
1d15c3bfac
commit
db5796816a
@ -7380,6 +7380,14 @@ CREATE INDEX proof_of_identity_type_id_and_proof_of_identity_refusal_id ON publi
|
||||
CREATE UNIQUE INDEX unique_not_null_external_id ON public.invoicing_profiles USING btree (external_id) WHERE (external_id IS NOT NULL);
|
||||
|
||||
|
||||
--
|
||||
-- Name: accounting_periods accounting_periods_del_protect; Type: RULE; Schema: public; Owner: -
|
||||
--
|
||||
|
||||
CREATE RULE accounting_periods_del_protect AS
|
||||
ON DELETE TO public.accounting_periods DO INSTEAD NOTHING;
|
||||
|
||||
|
||||
--
|
||||
-- Name: accounting_periods accounting_periods_upd_protect; Type: RULE; Schema: public; Owner: -
|
||||
--
|
||||
|
@ -22,7 +22,6 @@ module OmniAuth::Strategies
|
||||
# Strategy name.
|
||||
option :name, active_provider.strategy_name
|
||||
|
||||
|
||||
option :client_options,
|
||||
site: active_provider.providable.base_url,
|
||||
authorize_url: active_provider.providable.authorization_endpoint,
|
||||
@ -39,7 +38,7 @@ module OmniAuth::Strategies
|
||||
"#{url[:protocol]}://#{url[:host]}#{script_name}#{callback_path}"
|
||||
end
|
||||
|
||||
uid { parsed_info['user.uid'.to_sym] }
|
||||
uid { parsed_info[:'user.uid'] }
|
||||
|
||||
info do
|
||||
{
|
||||
|
@ -32,6 +32,4 @@ class PayZen::PCI::Charge < PayZen::Client
|
||||
device: device,
|
||||
paymentForms: payment_forms)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
|
@ -1,12 +1,14 @@
|
||||
module FabManager
|
||||
module Middleware
|
||||
class ServerLocale
|
||||
def call(worker_class, job, queue)
|
||||
locale = job['locale'] || Rails.application.secrets.rails_locale
|
||||
I18n.with_locale(locale) do
|
||||
yield
|
||||
end
|
||||
end
|
||||
# frozen_string_literal: true
|
||||
|
||||
# module definition
|
||||
module FabManager::Middleware; end
|
||||
|
||||
# Provides localization in workers
|
||||
class FabManager::Middleware::ServerLocale
|
||||
def call(_worker_class, job, _queue)
|
||||
locale = job['locale'] || Rails.application.secrets.rails_locale
|
||||
I18n.with_locale(locale) do
|
||||
yield
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -2,9 +2,9 @@
|
||||
|
||||
# This class provides logging functionalities for SSO authentication
|
||||
class SsoLogger
|
||||
def initialize()
|
||||
@logger = ActiveSupport::TaggedLogging.new(Logger.new(STDOUT))
|
||||
@log_status = ENV.fetch('SSO_DEBUG') { false }
|
||||
def initialize
|
||||
@logger = ActiveSupport::TaggedLogging.new(Logger.new($stdout))
|
||||
@log_status = ENV.fetch('SSO_DEBUG', false)
|
||||
end
|
||||
|
||||
def debug(message)
|
||||
|
@ -3,20 +3,20 @@
|
||||
namespace :db do
|
||||
desc 'Convert development DB to Rails test fixtures'
|
||||
task :to_fixtures, [:table] => :environment do |_task, args|
|
||||
TABLES_TO_SKIP = %w[ar_internal_metadata delayed_jobs schema_info schema_migrations].freeze
|
||||
tables_to_skip = %w[ar_internal_metadata delayed_jobs schema_info schema_migrations].freeze
|
||||
|
||||
begin
|
||||
ActiveRecord::Base.establish_connection
|
||||
ActiveRecord::Base.connection.tables.each do |table_name|
|
||||
next if TABLES_TO_SKIP.include?(table_name)
|
||||
next if tables_to_skip.include?(table_name)
|
||||
next if args.table && args.table != table_name
|
||||
|
||||
conter = '000'
|
||||
file_path = "#{Rails.root}/test/fixtures/test/#{table_name}.yml"
|
||||
file_path = Rails.root.join("test/fixtures/test/#{table_name}.yml")
|
||||
File.open(file_path, 'w') do |file|
|
||||
rows = ActiveRecord::Base.connection.select_all("SELECT * FROM #{table_name}")
|
||||
data = rows.each_with_object({}) do |record, hash|
|
||||
suffix = record['id'].blank? ? conter.succ! : record['id']
|
||||
suffix = record['id'].presence || conter.succ!
|
||||
hash["#{table_name.singularize}_#{suffix}"] = record
|
||||
end
|
||||
puts "Writing table '#{table_name}' to '#{file_path}'"
|
||||
|
@ -3,7 +3,6 @@
|
||||
# SSO and authentication relative tasks
|
||||
namespace :fablab do
|
||||
namespace :auth do
|
||||
|
||||
desc 'switch the active authentication provider'
|
||||
task :switch_provider, [:provider] => :environment do |_task, args|
|
||||
providers = AuthProvider.all.inject('') { |str, item| "#{str}#{item[:name]}, " }
|
||||
@ -24,18 +23,18 @@ namespace :fablab do
|
||||
|
||||
# disable previous provider
|
||||
prev_prev = AuthProvider.previous
|
||||
prev_prev&.update_attribute(:status, 'pending')
|
||||
prev_prev&.update(status: 'pending')
|
||||
|
||||
AuthProvider.active.update_attribute(:status, 'previous') unless AuthProvider.active.name == 'DatabaseProvider::SimpleAuthProvider'
|
||||
AuthProvider.active.update(status: 'previous') unless AuthProvider.active.name == 'DatabaseProvider::SimpleAuthProvider'
|
||||
|
||||
# enable given provider
|
||||
AuthProvider.find_by(name: args.provider).update_attribute(:status, 'active')
|
||||
AuthProvider.find_by(name: args.provider).update(status: 'active')
|
||||
|
||||
# migrate the current users.
|
||||
if AuthProvider.active.providable_type == DatabaseProvider.name
|
||||
User.all.each do |user|
|
||||
# Concerns local database provider
|
||||
user.update_attribute(:auth_token, nil)
|
||||
user.update(auth_token: nil)
|
||||
end
|
||||
else
|
||||
# Concerns any providers except local database
|
||||
@ -54,7 +53,6 @@ namespace :fablab do
|
||||
|
||||
desc 'notify users that the auth provider has changed'
|
||||
task notify_changed: :environment do
|
||||
|
||||
I18n.locale = I18n.default_locale
|
||||
|
||||
# notify every users if the provider is not local database provider
|
||||
|
@ -3,7 +3,6 @@
|
||||
# PayZen relative tasks
|
||||
namespace :fablab do
|
||||
namespace :payzen do
|
||||
|
||||
# example: rails fablab:payzen:replay_on_payment_success[54a35f3f6fdd729ac72b6da0,53,57,3,247]
|
||||
# to find the parameters, search the logs, example:
|
||||
# Started POST "/api/payzen/confirm_payment" for 93.27.29.108 at 2022-04-04 20:26:12 +0000
|
||||
@ -22,7 +21,7 @@ namespace :fablab do
|
||||
# ], "payment_method"=>"card"}, "order_id"=>"704cc55e23f00ac3d238d8de"}}
|
||||
desc 'replay PayzenController#on_payment_success for a given event'
|
||||
task :replay_on_payment_success, %i[gateway_item_id user_id event_id nb_reserve_places slot_id] => :environment do |_task, args|
|
||||
ActiveRecord::Base.logger = Logger.new STDOUT
|
||||
ActiveRecord::Base.logger = Logger.new $stdout
|
||||
|
||||
gateway_item_type = 'PayZen::Order'
|
||||
|
||||
|
@ -20,7 +20,7 @@ namespace :fablab do
|
||||
setting_id: setting.id,
|
||||
user_id: User.admins.first.id,
|
||||
value: 'false',
|
||||
created_at: DateTime.parse(args.date)
|
||||
created_at: Time.zone.parse(args.date)
|
||||
)
|
||||
else
|
||||
setting = Setting.find_by(name: 'invoice_VAT-rate')
|
||||
@ -28,7 +28,7 @@ namespace :fablab do
|
||||
setting_id: setting.id,
|
||||
user_id: User.admins.first.id,
|
||||
value: args.rate,
|
||||
created_at: DateTime.parse(args.date)
|
||||
created_at: Time.zone.parse(args.date)
|
||||
)
|
||||
end
|
||||
end
|
||||
@ -120,15 +120,15 @@ namespace :fablab do
|
||||
Group.find_by(slug: 'admins').destroy
|
||||
if Setting.get('user_validation_required')
|
||||
print "\e[91m::\e[0m \e[1mValidating the 'admins'...\e[0m\n"
|
||||
User.admins.each { |admin| admin.update(validated_at: DateTime.current) if admin.validated_at.nil? }
|
||||
User.admins.each { |admin| admin.update(validated_at: Time.current) if admin.validated_at.nil? }
|
||||
end
|
||||
print "\e[32m✅\e[0m \e[1mDone\e[0m\n"
|
||||
end
|
||||
|
||||
desc 'generate acconting lines'
|
||||
task build_accounting_lines: :environment do
|
||||
start_date = Invoice.order(created_at: :asc).first&.created_at || DateTime.current
|
||||
end_date = DateTime.current
|
||||
start_date = Invoice.order(created_at: :asc).first&.created_at || Time.current
|
||||
end_date = Time.current
|
||||
AccountingLine.where(date: start_date..end_date).destroy_all
|
||||
Accounting::AccountingService.new.build(start_date&.beginning_of_day, end_date.end_of_day)
|
||||
puts '-> Done'
|
||||
|
@ -3,7 +3,6 @@
|
||||
# Stripe relative tasks
|
||||
namespace :fablab do
|
||||
namespace :stripe do
|
||||
|
||||
desc 'find any invoices with incoherent total between stripe and DB'
|
||||
task :find_incoherent_invoices, [:start_date] => :environment do |_task, args|
|
||||
puts 'DEPRECATION WARNING: Will not work for invoices created from version 4.1.0 and above'
|
||||
@ -61,8 +60,9 @@ namespace :fablab do
|
||||
|
||||
desc 'set stripe as the default payment gateway'
|
||||
task set_gateway: :environment do
|
||||
if Setting.find_by(name: 'stripe_public_key').try(:value) && Setting.find_by(name: 'stripe_secret_key').try(:value)
|
||||
Setting.set('payment_gateway', 'stripe') unless Setting.find_by(name: 'payment_gateway').try(:value)
|
||||
if Setting.find_by(name: 'stripe_public_key').try(:value) && Setting.find_by(name: 'stripe_secret_key').try(:value) &&
|
||||
!Setting.find_by(name: 'payment_gateway').try(:value)
|
||||
Setting.set('payment_gateway', 'stripe')
|
||||
end
|
||||
end
|
||||
|
||||
@ -72,7 +72,7 @@ namespace :fablab do
|
||||
task reset_cards: :environment do
|
||||
unless Rails.env.test?
|
||||
print "You're about to detach all payment cards from all customers. This was only made for test mode. Are you sure? (y/n) "
|
||||
confirm = STDIN.gets.chomp
|
||||
confirm = $stdin.gets.chomp
|
||||
next unless confirm == 'y'
|
||||
end
|
||||
User.all.each do |user|
|
||||
|
@ -13,5 +13,4 @@ class OpenApi::TrainingsTest < ActionDispatch::IntegrationTest
|
||||
get '/open_api/v1/trainings', headers: open_api_headers(@token)
|
||||
assert_response :success
|
||||
end
|
||||
|
||||
end
|
||||
|
@ -1,8 +1,10 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
require 'test_helper'
|
||||
|
||||
class EventPriceCategoryTest < ActiveSupport::TestCase
|
||||
test "event price's category cannot be empty" do
|
||||
epc = EventPriceCategory.new({price_category_id: 1, event_id: 3})
|
||||
epc = EventPriceCategory.new({ price_category_id: 1, event_id: 3 })
|
||||
assert epc.invalid?
|
||||
assert epc.errors[:amount].present?
|
||||
end
|
||||
|
@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
require 'test_helper'
|
||||
|
||||
class EventTest < ActiveSupport::TestCase
|
||||
|
@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
require 'test_helper'
|
||||
|
||||
class ExportTest < ActiveSupport::TestCase
|
||||
|
@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
require 'test_helper'
|
||||
|
||||
class PriceCategoryTest < ActiveSupport::TestCase
|
||||
|
@ -1,8 +1,10 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
require 'test_helper'
|
||||
|
||||
class TicketTest < ActiveSupport::TestCase
|
||||
test "ticket must have at least 1 seat" do
|
||||
t = Ticket.new({event_price_category_id: 1, booked: -1})
|
||||
test 'ticket must have at least 1 seat' do
|
||||
t = Ticket.new({ event_price_category_id: 1, booked: -1 })
|
||||
assert t.invalid?
|
||||
assert t.errors[:booked].present?
|
||||
end
|
||||
|
@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
require 'test_helper'
|
||||
|
||||
class WalletTest < ActiveSupport::TestCase
|
||||
|
@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
require 'test_helper'
|
||||
|
||||
class WalletTransactionTest < ActiveSupport::TestCase
|
||||
|
@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
require 'test_helper'
|
||||
|
||||
class UsersCreditsManagerTest < ActiveSupport::TestCase
|
||||
|
@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
require 'test_helper'
|
||||
|
||||
class UsersExportServiceTest < ActiveSupport::TestCase
|
||||
|
Loading…
Reference in New Issue
Block a user