Skip to content

Commit

Permalink
Fixing rubocop violations
Browse files Browse the repository at this point in the history
  • Loading branch information
dbroeglin committed Feb 11, 2024
1 parent df1f3a7 commit d5e9525
Show file tree
Hide file tree
Showing 12 changed files with 43 additions and 45 deletions.
12 changes: 5 additions & 7 deletions app/controllers/matches_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions app/controllers/participants_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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?
Expand Down
4 changes: 0 additions & 4 deletions config/initializers/new_framework_defaults_7_1.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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.
Expand All @@ -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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
5 changes: 2 additions & 3 deletions lib/tasks/deploy.rake
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
# rubocop:disable Layout/LineLength


namespace :deploy do
desc "Deploy staging"
task staging: :environment do
Expand Down Expand Up @@ -135,7 +134,7 @@ namespace :deploy do
--resource-group #{rg_name} \
--location #{region}
)

sh %(
az containerapp create \
--name #{ca_name} \
Expand Down Expand Up @@ -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 \
Expand Down
2 changes: 1 addition & 1 deletion test/application_system_test_case.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 6 additions & 2 deletions test/controllers/leaderboard_controller_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion test/factories/taikais.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
16 changes: 8 additions & 8 deletions test/helpers/create_fixtures.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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|
Expand Down
3 changes: 2 additions & 1 deletion test/models/taikai_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions test/system/taikais_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down

0 comments on commit d5e9525

Please sign in to comment.