diff --git a/CHANGELOG.md b/CHANGELOG.md index 6b7e5a948..0117c7bb1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,14 @@ # Changelog Fab-manager +## v4.5.2 2020 July 1st + +- Fix a bug: unable to set stripe public key in production +- Fix a bug: health API is broken if ElasticSearch is not present +- Fix a bug: unable to sync members with stripe +- Fix a bug: version check is not working +- Fix a bug: enabling auth_provider from the tests happens twice in coverall context +- [TODO DEPLOY] `rails fablab:maintenance:clean_workers` + ## v4.5.1 2020 July 1st - Ability to run the upgrade without interactions diff --git a/app/assets/javascripts/controllers/admin/invoices.js.erb b/app/assets/javascripts/controllers/admin/invoices.js.erb index d1e4edda4..ecbc2017b 100644 --- a/app/assets/javascripts/controllers/admin/invoices.js.erb +++ b/app/assets/javascripts/controllers/admin/invoices.js.erb @@ -1320,13 +1320,13 @@ Application.Controllers.controller('StripeKeysModalController', ['$scope', '$uib /* PUBLIC SCOPE */ // public key - $scope.publicKey = stripeKeys.stripe_public_key; + $scope.publicKey = stripeKeys.stripe_public_key || ''; // test status of the public key $scope.publicKeyStatus = undefined; // secret key - $scope.secretKey = stripeKeys.stripe_secret_key; + $scope.secretKey = stripeKeys.stripe_secret_key || ''; // test status of the secret key $scope.secretKeyStatus = undefined; @@ -1370,10 +1370,7 @@ Application.Controllers.controller('StripeKeysModalController', ['$scope', '$uib 'Content-Type': 'application/x-www-form-urlencoded' }, data: $httpParamSerializerJQLike({ - 'card[number]': 4242424242424242, - 'card[cvc]': 123, - 'card[exp_month]': 12, - 'card[exp_year]': today.getFullYear().toString().substring(2), + 'pii[id_number]': 'test', }) }).then(function () { $scope.publicKeyStatus = true; diff --git a/app/services/health_service.rb b/app/services/health_service.rb index 5926e6a4f..0c82bbf47 100644 --- a/app/services/health_service.rb +++ b/app/services/health_service.rb @@ -25,6 +25,8 @@ class HealthService !!response.body # rubocop:disable Style/DoubleNegation rescue Elasticsearch::Transport::Transport::Error false + rescue Faraday::ConnectionFailed + false end def self.migrations? diff --git a/config/application.rb b/config/application.rb index dfc8ef38c..9c3b9c138 100644 --- a/config/application.rb +++ b/config/application.rb @@ -74,7 +74,7 @@ module Fablab plugins&.each(&:notify_after_initialize) require 'version' - Version.check_and_schedule + Version.check end end end diff --git a/config/schedule.yml b/config/schedule.yml index 40cf7d255..feef96be8 100644 --- a/config/schedule.yml +++ b/config/schedule.yml @@ -37,6 +37,14 @@ close_period_reminder_worker: free_disk_space: cron: "0 5 * * 0" # every sunday at 5am class: "FreeDiskSpaceWorker" - queue: default + queue: system + +# schedule a version check, every week at the current day+time +# this will prevent that all the instances query the hub simultaneously +<% m = DateTime.current.minute - 1; h = DateTime.current.hour; d = DateTime.current.cwday %> +version_check: + cron: <%="#{m} #{h} * * #{d}" %> + class: 'VersionCheckWorker' + queue: system <%= PluginRegistry.insert_code('yml.schedule') %> diff --git a/config/sidekiq.yml b/config/sidekiq.yml index 685a5835b..1abddf065 100644 --- a/config/sidekiq.yml +++ b/config/sidekiq.yml @@ -7,4 +7,5 @@ - [default, 5] - [devise_mailer, 3] - [mailers, 3] - - [elasticsearch, 2] \ No newline at end of file + - [elasticsearch, 2] + - [system, 1] diff --git a/lib/tasks/fablab/maintenance.rake b/lib/tasks/fablab/maintenance.rake index b2121b596..af2d7eb72 100644 --- a/lib/tasks/fablab/maintenance.rake +++ b/lib/tasks/fablab/maintenance.rake @@ -82,5 +82,14 @@ namespace :fablab do require 'version' puts Version.current end + + desc 'clean the cron workers' + task clean_workers: :environment do + + Sidekiq::Cron::Job.destroy_all! + Sidekiq::Queue.new('system').clear + Sidekiq::Queue.new('default').clear + Sidekiq::DeadSet.new.clear + end end end diff --git a/lib/tasks/fablab/stripe.rake b/lib/tasks/fablab/stripe.rake index 83b903590..8fa685318 100644 --- a/lib/tasks/fablab/stripe.rake +++ b/lib/tasks/fablab/stripe.rake @@ -49,7 +49,7 @@ namespace :fablab do desc 'sync users to the stripe database' task sync_members: :environment do puts 'We create all non-existing customers on stripe. This may take a while, please wait...' - SyncMembersOnStripeWorker.perform + SyncMembersOnStripeWorker.new.perform puts 'Done' end diff --git a/lib/version.rb b/lib/version.rb index 75666e664..90b5388a2 100644 --- a/lib/version.rb +++ b/lib/version.rb @@ -17,21 +17,11 @@ class Version json['up_to_date'] end - # periodically retrieve the last published version from the hub and save it into the database - def self.check_and_schedule - job_name = 'Automatic version check' + # retrieve the last published version from the hub and save it into the database + def self.check return if (Rails.env.development? || Rails.env.test?) && ENV['FORCE_VERSION_CHECK'] != 'true' - job = Sidekiq::Cron::Job.find name: job_name - unless job - # schedule a version check, every week at the current day+time - # this will prevent that all the instances query the hub simultaneously - m = DateTime.current.minute - h = DateTime.current.hour - d = DateTime.current.cwday - job = Sidekiq::Cron::Job.new(name: job_name, cron: "#{m} #{h} * * #{d}", class: 'VersionCheckWorker') - job.save - end - job.enque! + # check the version + VersionCheckWorker.perform_async end end diff --git a/package.json b/package.json index 2a0c25431..2f6634ea9 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "fab-manager", - "version": "4.5.1", + "version": "4.5.2", "description": "Fab-manager is the FabLab management solution. It provides a comprehensive, web-based, open-source tool to simplify your administrative tasks and your marker's projects.", "keywords": [ "fablab", diff --git a/test/integration/auth_providers_test.rb b/test/integration/auth_providers_test.rb index 1f230e0b4..d985ab580 100644 --- a/test/integration/auth_providers_test.rb +++ b/test/integration/auth_providers_test.rb @@ -59,7 +59,7 @@ class AuthProvidersTest < ActionDispatch::IntegrationTest assert_equal 2, provider[:providable_attributes][:o_auth2_mappings_attributes].length # now let's activate this new provider - Fablab::Application.load_tasks + Fablab::Application.load_tasks if Rake::Task.tasks.empty? Rake::Task['fablab:auth:switch_provider'].invoke(name) db_provider.reload @@ -69,4 +69,4 @@ class AuthProvidersTest < ActionDispatch::IntegrationTest assert_not_nil u.auth_token end end -end \ No newline at end of file +end