diff --git a/app/controllers/matches_controller.rb b/app/controllers/matches_controller.rb index 5a7bec9..e3596b8 100644 --- a/app/controllers/matches_controller.rb +++ b/app/controllers/matches_controller.rb @@ -16,22 +16,20 @@ def edit def update @match = Match.find(params[:id]) - + Taikai.transaction do @match.assign_attributes(match_params) changed_winner = @match.changes[:winner] @match.save! - if changed_winner - @match.select_winner(@match.winner) - end + @match.select_winner(@match.winner) if changed_winner end redirect_to action: 'index' rescue ActiveRecord::RecordInvalid @teams = @taikai - .participating_dojos.map(&:teams).flatten - .sort_by(&:shortname) - render :edit, status: :unprocessable_entity + .participating_dojos.map(&:teams).flatten + .sort_by(&:shortname) + render :edit, status: :unprocessable_entity end def select_winner diff --git a/app/controllers/participants_controller.rb b/app/controllers/participants_controller.rb index f25e9e2..f364290 100644 --- a/app/controllers/participants_controller.rb +++ b/app/controllers/participants_controller.rb @@ -98,9 +98,9 @@ def import notices << "#{row['Prénom']} #{row['Nom']}" end - if !@participant.save - alerts << "#{row['Prénom']} #{row['Nom']}" - end + + alerts << "#{row['Prénom']} #{row['Nom']}" unless @participant.save + end flash[:notice] = t :import_notices, names: notices.join(', '), count: notices.size if notices.any? flash[:alert] = t :import_alerts, names: alerts.join(', '), count: alerts.size if alerts.any? diff --git a/config/initializers/new_framework_defaults_7_1.rb b/config/initializers/new_framework_defaults_7_1.rb index 4ba0297..3dc295d 100644 --- a/config/initializers/new_framework_defaults_7_1.rb +++ b/config/initializers/new_framework_defaults_7_1.rb @@ -241,7 +241,6 @@ # this file): # config.active_support.cache_format_version = 7.1 - ### # Configure Action View to use HTML5 standards-compliant sanitizers when they are supported on your # platform. @@ -253,7 +252,6 @@ #++ # Rails.application.config.action_view.sanitizer_vendor = Rails::HTML::Sanitizer.best_supported_vendor - ### # Configure Action Text to use an HTML5 standards-compliant sanitizer when it is supported on your # platform. @@ -265,14 +263,12 @@ #++ # Rails.application.config.action_text.sanitizer_vendor = Rails::HTML::Sanitizer.best_supported_vendor - ### # Configure the log level used by the DebugExceptions middleware when logging # uncaught exceptions during requests. #++ # Rails.application.config.action_dispatch.debug_exception_log_level = :error - ### # Configure the test helpers in Action View, Action Dispatch, and rails-dom-testing to use HTML5 # parsers. diff --git a/db/migrate/20240120150525_add_service_name_to_active_storage_blobs.active_storage.rb b/db/migrate/20240120150525_add_service_name_to_active_storage_blobs.active_storage.rb index a15c6ce..d60e88a 100644 --- a/db/migrate/20240120150525_add_service_name_to_active_storage_blobs.active_storage.rb +++ b/db/migrate/20240120150525_add_service_name_to_active_storage_blobs.active_storage.rb @@ -6,9 +6,8 @@ def up unless column_exists?(:active_storage_blobs, :service_name) add_column :active_storage_blobs, :service_name, :string - if configured_service = ActiveStorage::Blob.service.name - ActiveStorage::Blob.unscoped.update_all(service_name: configured_service) - end + configured_service = ActiveStorage::Blob.service.name + ActiveStorage::Blob.unscoped.update_all(service_name: configured_service) if configured_service change_column :active_storage_blobs, :service_name, :string, null: false end diff --git a/db/migrate/20240120150526_create_active_storage_variant_records.active_storage.rb b/db/migrate/20240120150526_create_active_storage_variant_records.active_storage.rb index 94ac83a..6239449 100644 --- a/db/migrate/20240120150526_create_active_storage_variant_records.active_storage.rb +++ b/db/migrate/20240120150526_create_active_storage_variant_records.active_storage.rb @@ -14,14 +14,15 @@ def change end private - def primary_key_type - config = Rails.configuration.generators - config.options[config.orm][:primary_key_type] || :primary_key - end - def blobs_primary_key_type - pkey_name = connection.primary_key(:active_storage_blobs) - pkey_column = connection.columns(:active_storage_blobs).find { |c| c.name == pkey_name } - pkey_column.bigint? ? :bigint : pkey_column.type - end + def primary_key_type + config = Rails.configuration.generators + config.options[config.orm][:primary_key_type] || :primary_key + end + + def blobs_primary_key_type + pkey_name = connection.primary_key(:active_storage_blobs) + pkey_column = connection.columns(:active_storage_blobs).find { |c| c.name == pkey_name } + pkey_column.bigint? ? :bigint : pkey_column.type + end end diff --git a/lib/tasks/deploy.rake b/lib/tasks/deploy.rake index 4b0107b..83f9992 100644 --- a/lib/tasks/deploy.rake +++ b/lib/tasks/deploy.rake @@ -1,6 +1,5 @@ # rubocop:disable Layout/LineLength - namespace :deploy do desc "Deploy staging" task staging: :environment do @@ -135,7 +134,7 @@ namespace :deploy do --resource-group #{rg_name} \ --location #{region} ) - + sh %( az containerapp create \ --name #{ca_name} \ @@ -181,7 +180,7 @@ namespace :deploy do --client-type none \ --secret name=pikaichu secret-uri=https://#{kv_name}.vault.azure.net/secrets/#{secret_name} \ --customized-keys AZURE_POSTGRESQL_PASSWORD=DATABASE_URL - ) + ) sh %( az containerapp registry set \ diff --git a/test/application_system_test_case.rb b/test/application_system_test_case.rb index 59f2633..4a00745 100644 --- a/test/application_system_test_case.rb +++ b/test/application_system_test_case.rb @@ -28,7 +28,7 @@ class ApplicationSystemTestCase < ActionDispatch::SystemTestCase Capybara::Selenium::Driver.new(app, browser: :chrome, options: browser_options, timeout: 30).tap do |drv| - #drv.download_path = DownloadHelpers::PATH + # drv.download_path = DownloadHelpers::PATH end end :test diff --git a/test/controllers/leaderboard_controller_test.rb b/test/controllers/leaderboard_controller_test.rb index 1f29e07..2204cf8 100644 --- a/test/controllers/leaderboard_controller_test.rb +++ b/test/controllers/leaderboard_controller_test.rb @@ -11,8 +11,12 @@ class LeaderboardControllerTest < ActionDispatch::IntegrationTest end TAIKAI_DATA.each do |form, distributed, total_num_arrows, scoring| - test "#{form} #{distributed ? :distributed : :local} #{total_num_arrows} #{scoring} should get show" do - @taikai = Taikai.find_by(form: form, distributed: distributed, total_num_arrows: total_num_arrows, scoring: scoring) + dist = distributed ? :distributed : :local + test "#{form} #{dist} #{total_num_arrows} #{scoring} should get show" do + @taikai = Taikai.find_by(form: form, + distributed: distributed, + total_num_arrows: total_num_arrows, + scoring: scoring) @taikai.current_user = users(:jean_bon) @taikai.transition_to! :registration diff --git a/test/factories/taikais.rb b/test/factories/taikais.rb index e291c1f..4f4056b 100644 --- a/test/factories/taikais.rb +++ b/test/factories/taikais.rb @@ -38,7 +38,7 @@ # Do not change display_name, used for fixture naming display_name: "Participating Dojo#{index + 1} #{taikai.name}", dojo: dojo, - taikai: taikai) + taikai: taikai) end create(:staff, diff --git a/test/helpers/create_fixtures.rb b/test/helpers/create_fixtures.rb index 1377bc1..531e7d6 100644 --- a/test/helpers/create_fixtures.rb +++ b/test/helpers/create_fixtures.rb @@ -145,14 +145,14 @@ def create_taikais distributed: distributed, total_num_arrows: 4, scoring: scoring do |taikai| - taikai.matches.create!(index: 1, level: 3, team1: taikai.teams[0], team2: taikai.teams[1]) - taikai.matches.create!(index: 2, level: 3, team1: taikai.teams[2], team2: taikai.teams[3]) - taikai.matches.create!(index: 3, level: 3, team1: taikai.teams[4], team2: taikai.teams[5]) - taikai.matches.create!(index: 4, level: 3, team1: taikai.teams[6], team2: taikai.teams[7]) - taikai.matches.create!(index: 1, level: 2) - taikai.matches.create!(index: 2, level: 2) - taikai.matches.create!(index: 1, level: 1) - taikai.matches.create!(index: 2, level: 1) + taikai.matches.create!(index: 1, level: 3, team1: taikai.teams[0], team2: taikai.teams[1]) + taikai.matches.create!(index: 2, level: 3, team1: taikai.teams[2], team2: taikai.teams[3]) + taikai.matches.create!(index: 3, level: 3, team1: taikai.teams[4], team2: taikai.teams[5]) + taikai.matches.create!(index: 4, level: 3, team1: taikai.teams[6], team2: taikai.teams[7]) + taikai.matches.create!(index: 1, level: 2) + taikai.matches.create!(index: 2, level: 2) + taikai.matches.create!(index: 1, level: 1) + taikai.matches.create!(index: 2, level: 1) end [12, 20].each do |total_num_arrows| diff --git a/test/models/taikai_test.rb b/test/models/taikai_test.rb index f6ab68c..b12df37 100644 --- a/test/models/taikai_test.rb +++ b/test/models/taikai_test.rb @@ -11,7 +11,8 @@ class TaikaiTest < ActiveSupport::TestCase end TAIKAI_DATA.each do |form, distributed, total_num_arrows, scoring| - test "#{form} #{distributed ? :distributed : :local} #{total_num_arrows} #{scoring} validates" do + dist = distributed ? :distributed : :local + test "#{form} #{dist} #{total_num_arrows} #{scoring} validates" do @taikai.scoring = scoring @taikai.distributed = distributed @taikai.form = form diff --git a/test/system/taikais_test.rb b/test/system/taikais_test.rb index 289a53b..e4d9b31 100644 --- a/test/system/taikais_test.rb +++ b/test/system/taikais_test.rb @@ -36,9 +36,9 @@ class TaikaisTest < ApplicationSystemTestCase assert_selector 'p.title', text: 'Ajouter un Taikai' - form_label = { - individual: 'Individuel', - team: 'En équipe', + form_label = { + individual: 'Individuel', + team: 'En équipe', '2in1': '2 en 1', matches: 'Matchs' }[form]