Rubocop -A
This commit is contained in:
parent
0baa7901b2
commit
c3af6f9232
|
|
@ -11,9 +11,10 @@ class TournamentsController < ApplicationController
|
|||
# GET /tournaments
|
||||
def index
|
||||
type = index_params.fetch(:type, 'public')
|
||||
if type == 'public'
|
||||
case type
|
||||
when 'public'
|
||||
tournaments = Tournament.where(public: true).order(:created_at)
|
||||
elsif type == 'private'
|
||||
when 'private'
|
||||
tournaments = Tournament.where(owner: current_user, public: false).order(:created_at)
|
||||
else
|
||||
# invalid type specified
|
||||
|
|
|
|||
|
|
@ -1,7 +1,8 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class Match < ApplicationRecord
|
||||
enum state: %i[single_team not_ready not_started in_progress finished undecided]
|
||||
enum state: { single_team: 0, not_ready: 1, not_started: 2, in_progress: 3, finished: 4,
|
||||
undecided: 5 }
|
||||
|
||||
belongs_to :stage, optional: true
|
||||
belongs_to :group, optional: true
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class Stage < ApplicationRecord
|
||||
enum state: %i[playoff_stage intermediate_stage in_progress finished]
|
||||
enum state: { playoff_stage: 0, intermediate_stage: 1, in_progress: 2, finished: 3 }
|
||||
|
||||
belongs_to :tournament
|
||||
has_many :matches, dependent: :destroy
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ class GroupStageService
|
|||
raise 'Cannot generate group stage without groups' if groups.length.zero?
|
||||
|
||||
# raise an error if the average group size is not a whole number
|
||||
raise 'Groups need to be equal size' unless (groups.flatten.length.to_f / groups.length.to_f % 1).zero?
|
||||
raise 'Groups need to be equal size' unless (groups.flatten.length.to_f / groups.length % 1).zero?
|
||||
|
||||
groups = groups.map(&method(:get_group_object_from)).each_with_index { |group, i| group.number = i + 1 }
|
||||
Stage.new level: -1, groups: groups, state: :in_progress
|
||||
|
|
|
|||
|
|
@ -37,7 +37,7 @@ module TurniereBackend
|
|||
config.middleware.insert_before 0, Rack::Cors do
|
||||
allow do
|
||||
origins '*'
|
||||
resource '*', headers: :any, methods: :any, expose: ['access-token', 'client', 'expiry', 'uid']
|
||||
resource '*', headers: :any, methods: :any, expose: %w[access-token client expiry uid]
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -69,7 +69,7 @@ Rails.application.configure do
|
|||
# config.logger = ActiveSupport::TaggedLogging.new(Syslog::Logger.new 'app-name')
|
||||
|
||||
if ENV['RAILS_LOG_TO_STDOUT'].present?
|
||||
logger = ActiveSupport::Logger.new(STDOUT)
|
||||
logger = ActiveSupport::Logger.new($stdout)
|
||||
logger.formatter = config.log_formatter
|
||||
config.logger = ActiveSupport::TaggedLogging.new(logger)
|
||||
end
|
||||
|
|
|
|||
|
|
@ -6,16 +6,16 @@
|
|||
# the maximum value specified for Puma. Default is set to 5 threads for minimum
|
||||
# and maximum; this matches the default thread size of Active Record.
|
||||
#
|
||||
threads_count = ENV.fetch('RAILS_MAX_THREADS') { 5 }
|
||||
threads_count = ENV.fetch('RAILS_MAX_THREADS', 5)
|
||||
threads threads_count, threads_count
|
||||
|
||||
# Specifies the `port` that Puma will listen on to receive requests; default is 3000.
|
||||
#
|
||||
port ENV.fetch('PORT') { 3000 }
|
||||
port ENV.fetch('PORT', 3000)
|
||||
|
||||
# Specifies the `environment` that Puma will run in.
|
||||
#
|
||||
environment ENV.fetch('RAILS_ENV') { 'development' }
|
||||
environment ENV.fetch('RAILS_ENV', 'development')
|
||||
|
||||
# Specifies the number of `workers` to boot in clustered mode.
|
||||
# Workers are forked webserver processes. If using threads and workers together
|
||||
|
|
|
|||
|
|
@ -4,13 +4,13 @@ IMAGE_NAME = 'turniere/backend'
|
|||
|
||||
namespace :docker do
|
||||
desc 'Build docker image'
|
||||
task :build, [:tag] do |_, args|
|
||||
task build: :environment, [:tag] do |_, args|
|
||||
args.with_defaults(tag: 'latest')
|
||||
sh "docker build -t #{IMAGE_NAME}:#{args.tag} ."
|
||||
end
|
||||
|
||||
desc 'Tag docker image with Travis build number'
|
||||
task :tag do
|
||||
task tag: :environment do
|
||||
next if ENV['TRAVIS_PULL_REQUEST'] != 'false'
|
||||
|
||||
tag = "build#{ENV['TRAVIS_BUILD_NUMBER']}"
|
||||
|
|
@ -18,7 +18,7 @@ namespace :docker do
|
|||
end
|
||||
|
||||
desc 'Push docker image'
|
||||
task :push do
|
||||
task push: :environment do
|
||||
sh "docker push #{IMAGE_NAME}"
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -60,7 +60,7 @@ RSpec.describe TournamentsController, type: :controller do
|
|||
apply_authentication_headers_for @another_user
|
||||
get :index, params: params
|
||||
tournaments = deserialize_response response
|
||||
expect(tournaments.filter { |t| t[:public] }.size).to eq(0)
|
||||
expect(tournaments.count { |t| t[:public] }).to eq(0)
|
||||
end
|
||||
end
|
||||
|
||||
|
|
@ -80,7 +80,7 @@ RSpec.describe TournamentsController, type: :controller do
|
|||
apply_authentication_headers_for @another_user
|
||||
get :index, params: params
|
||||
tournaments = deserialize_response response
|
||||
expect(tournaments.filter { |t| !t[:public] }.size).to eq(0)
|
||||
expect(tournaments.count { |t| !t[:public] }).to eq(0)
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -44,7 +44,7 @@ RSpec.describe AddPlayoffsToTournament, type: :interactor do
|
|||
end
|
||||
|
||||
it 'adds playoffs to the tournament' do
|
||||
test = group_stage_tournament_context.tournament.stages[1..-1]
|
||||
test = group_stage_tournament_context.tournament.stages[1..]
|
||||
expect(test).to match_array(@stages)
|
||||
end
|
||||
end
|
||||
|
|
|
|||
Loading…
Reference in New Issue