diff --git a/.DS_Store b/.DS_Store index 182f6f0..44875d5 100644 Binary files a/.DS_Store and b/.DS_Store differ diff --git a/.github/workflows/deployment.yml b/.github/workflows/deployment.yml index 0dcff6a..99de9c7 100644 --- a/.github/workflows/deployment.yml +++ b/.github/workflows/deployment.yml @@ -7,19 +7,23 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 - - run: | - sudo curl -o /usr/bin/framgia-ci https://raw.githubusercontent.com/framgia/ci-report-tool/master/dist/framgia-ci - sudo chmod +x /usr/bin/framgia-ci - sudo apt install python3-pip - sudo apt install libcurl4-openssl-dev libssl-dev - sudo apt-get install -y python3-setuptools - - run: | - yes | pip3 install wheel - pip3 install framgia-ci - pip3 uninstall --yes cleo clikit - yes | pip3 install cleo==0.6.8 - - name: Run CI + - run: sudo gem install bundler:1.17.2 + - uses: actions/cache@v2 + with: + path: api/vendor/bundle + key: ${{ runner.os }}-gems-${{ hashFiles('**/Gemfile.lock') }} + restore-keys: | + ${{ runner.os }}-gems- + - name: Install gemfilee run: | cd api - ls -la && pwd - framgia-ci run --local + bundle config path vendor/bundle + bundle install + - name: Rubocop + run: cd api && bundle exec rubocop -c .rubocop.yml + - name: Rails Best Practices + run: cd api && bundle exec rails_best_practices -e "db/schema.rb,db/migrate,vendor,app/models/application_record.rb" + - name: Rpec + run: cd api && bundle exec rspec --format documentation + - name: reek + run: cd api && bundle exec reek diff --git a/api/.DS_Store b/api/.DS_Store index 23fcee0..c188676 100644 Binary files a/api/.DS_Store and b/api/.DS_Store differ diff --git a/api/.rspec b/api/.rspec index 83e16f8..c99d2e7 100644 --- a/api/.rspec +++ b/api/.rspec @@ -1,2 +1 @@ ---color --require spec_helper diff --git a/api/.rubocop.yml b/api/.rubocop.yml index 666daa6..20950bb 100644 --- a/api/.rubocop.yml +++ b/api/.rubocop.yml @@ -13,24 +13,25 @@ inherit_from: AllCops: # Include gemspec and Rakefile Include: - - 'app/**/*' - - 'lib/**/*' - - '**/*.gemspec' - - 'Gemfile' + - "app/**/*" + - "lib/**/*" + - "**/*.gemspec" + - "Gemfile" Exclude: - - 'vendor/**/*' - - 'config/unicorn.rb' - - 'bin/*' - - 'db/**/*' - - 'spec/**/*' - - 'script/rails' - - 'config/**/*' - - 'app/views/**/*' - - 'app/assets/**/*' - - 'app/javascript/**/*' - - '.idea/**/*' - - '**/.DS_Store' - - '**/.keep' + - "vendor/**/*" + - "api/vendor/**/*" + - "config/unicorn.rb" + - "bin/*" + - "db/**/*" + - "spec/**/*" + - "script/rails" + - "config/**/*" + - "app/views/**/*" + - "app/assets/**/*" + - "app/javascript/**/*" + - ".idea/**/*" + - "**/.DS_Store" + - "**/.keep" # Indent private/protected/public as deep as method definitions Layout/AccessModifierIndentation: @@ -40,7 +41,7 @@ Layout/AccessModifierIndentation: - indent # Align the elements of a hash literal if they span more than one line. -Layout/AlignHash: +Layout/HashAlignment: # Alignment of entries using hash rocket as separator. Valid values are: # # key - left alignment of keys @@ -103,7 +104,7 @@ Layout/AlignHash: - ignore_implicit - ignore_explicit -Layout/AlignParameters: +Layout/ParameterAlignment: # Alignment of parameters in multi-line method calls. # # The `with_first_parameter` style aligns the following lines along the same column @@ -130,12 +131,6 @@ Metrics/AbcSize: # a Float. Max: 20 -Style/BracesAroundHashParameters: - EnforcedStyle: no_braces - SupportedStyles: - - braces - - no_braces - # Indentation of `when`. Layout/CaseIndentation: EnforcedStyle: case @@ -172,7 +167,7 @@ Style/ClassCheck: - kind_of? Metrics/ClassLength: - CountComments: false # count full line comments? + CountComments: false # count full line comments? Max: 100 # Align with the style guide. @@ -184,11 +179,11 @@ Style/CollectionMethods: # PreferredMethods: # find: detect PreferredMethods: - collect: 'map' - collect!: 'map!' - inject: 'reduce' - detect: 'find' - find_all: 'select' + collect: "map" + collect!: "map!" + inject: "reduce" + detect: "find" + find_all: "select" # Checks formatting of special comments Style/CommentAnnotation: @@ -233,9 +228,9 @@ Layout/EmptyLinesAroundModuleBody: Naming/FileName: Exclude: - - '**/Rakefile' - - '**/Gemfile' - - '**/Capfile' + - "**/Rakefile" + - "**/Gemfile" + - "**/Capfile" # Checks use of for or each in multiline loops. Style/For: @@ -268,7 +263,7 @@ Style/HashSyntax: - hash_rockets # Checks the indentation of the first key in a hash literal. -Layout/IndentFirstHashElement: +Layout/FirstHashElementIndentation: # The value `special_inside_parentheses` means that hash literals with braces # that have their opening brace on the same line as a surrounding opening # round parenthesis, shall have their first key indented relative to the @@ -287,13 +282,12 @@ Style/LambdaCall: - call - braces -Metrics/LineLength: - Max: 80 +Layout/LineLength: + Max: 120 AllowURI: true Exclude: - config/routes.rb - Style/Next: # With `always` all conditions at the end of an iteration needs to be # replace by next - with `skip_modifier_ifs` the modifier if like this one @@ -319,7 +313,7 @@ Style/MethodDefParentheses: - require_no_parentheses Metrics/MethodLength: - CountComments: false # count full line comments? + CountComments: false # count full line comments? Max: 10 Naming/MethodName: @@ -341,18 +335,18 @@ Style/ParenthesesAroundCondition: Style/PercentLiteralDelimiters: PreferredDelimiters: - '%': () - '%i': () - '%q': () - '%Q': () - '%r': '{}' - '%s': () - '%w': () - '%W': () - '%x': () + "%": () + "%i": () + "%q": () + "%Q": () + "%r": "{}" + "%s": () + "%w": () + "%W": () + "%x": () Naming/PredicateName: - NamePrefixBlacklist: + ForbiddenPrefixes: - get_ Style/RaiseArgs: @@ -361,7 +355,6 @@ Style/RaiseArgs: - compact # raise Exception.new(msg) - exploded # raise Exception, msg - Style/RedundantReturn: # When true allows code like `return x, y`. AllowMultipleReturnValues: false @@ -382,7 +375,6 @@ Style/SignalException: - only_fail - semantic - Style/SingleLineBlockParams: Methods: - reduce: @@ -430,7 +422,7 @@ Layout/SpaceInsideHashLiteralBraces: - space - no_space -Layout/TrailingBlankLines: +Layout/TrailingEmptyLines: EnforcedStyle: final_newline SupportedStyles: - final_newline @@ -483,7 +475,7 @@ Style/TrivialAccessors: # # Commonly used in DSLs AllowDSLWriters: false - Whitelist: + AllowedMethods: - to_ary - to_a - to_c diff --git a/api/.rubocop_disabled.yml b/api/.rubocop_disabled.yml index 6a7dd7c..e02c876 100644 --- a/api/.rubocop_disabled.yml +++ b/api/.rubocop_disabled.yml @@ -2,8 +2,8 @@ Style/FrozenStringLiteralComment: Description: >- - Add the frozen_string_literal comment to the top of files - to help transition from Ruby 2.3.0 to Ruby 3.0. + Add the frozen_string_literal comment to the top of files + to help transition from Ruby 2.3.0 to Ruby 3.0. Enabled: false Style/InlineComment: @@ -50,13 +50,13 @@ Metrics/CyclomaticComplexity: Description: "Avoid complex methods." Enabled: false -Layout/AlignArray: +Layout/ArrayAlignment: Description: >- - Align the elements of an array literal if they span more than - one line. + Align the elements of an array literal if they span more than + one line. Enabled: false -Style/UnneededPercentQ: +Style/RedundantPercentQ: Description: "Checks for %q/%Q when single quotes or double quotes would do." Enabled: false diff --git a/api/.rubocop_enabled.yml b/api/.rubocop_enabled.yml index 22aea2c..c33bc7c 100644 --- a/api/.rubocop_enabled.yml +++ b/api/.rubocop_enabled.yml @@ -8,16 +8,16 @@ Style/Alias: Description: "Use alias_method instead of alias." Enabled: true -Layout/AlignHash: +Layout/HashAlignment: Description: >- - Align the elements of a hash literal if they span more than - one line. + Align the elements of a hash literal if they span more than + one line. Enabled: true -Layout/AlignParameters: +Layout/ParameterAlignment: Description: >- - Align the parameters of a method call if they span more - than one line. + Align the parameters of a method call if they span more + than one line. Enabled: true Style/AndOr: @@ -54,13 +54,9 @@ Metrics/BlockNesting: Style/BlockDelimiters: Description: >- - Avoid using {...} for multi-line blocks (multiline chaining is - always ugly). - Prefer {...} over do...end for single-line blocks. - Enabled: true - -Style/BracesAroundHashParameters: - Description: "Enforce braces style inside hash parameters." + Avoid using {...} for multi-line blocks (multiline chaining is + always ugly). + Prefer {...} over do...end for single-line blocks. Enabled: true Style/CaseEquality: @@ -105,8 +101,8 @@ Style/ColonMethodCall: Style/CommentAnnotation: Description: >- - Checks formatting of special comments - (TODO, FIXME, OPTIMIZE, HACK, REVIEW). + Checks formatting of special comments + (TODO, FIXME, OPTIMIZE, HACK, REVIEW). Enabled: true Layout/CommentIndentation: @@ -211,14 +207,14 @@ Style/GuardClause: Style/HashSyntax: Description: >- - Prefer Ruby 1.9 hash syntax { a: 1, b: 2 } over 1.8 syntax - { :a => 1, :b => 2 }. + Prefer Ruby 1.9 hash syntax { a: 1, b: 2 } over 1.8 syntax + { :a => 1, :b => 2 }. Enabled: true Style/IfUnlessModifier: Description: >- - Favor modifier if/unless usage when you have a - single-line body. + Favor modifier if/unless usage when you have a + single-line body. Enabled: true Style/IfWithSemicolon: @@ -233,13 +229,13 @@ Layout/IndentationWidth: Description: "Use 2 spaces for indentation." Enabled: true -Layout/IndentFirstArrayElement: +Layout/FirstArrayElementIndentation: Description: >- - Checks the indentation of the first element in an array - literal. + Checks the indentation of the first element in an array + literal. Enabled: true -Layout/IndentFirstHashElement: +Layout/FirstHashElementIndentation: Description: "Checks the indentation of the first key in a hash literal." Enabled: true @@ -257,12 +253,12 @@ Layout/LeadingCommentSpace: Style/LineEndConcatenation: Description: >- - Use \ instead of + or << to concatenate two string literals at - line end. + Use \ instead of + or << to concatenate two string literals at + line end. Enabled: true -Metrics/LineLength: - Description: "Limit lines to 80 characters." +Layout/LineLength: + Description: "Limit lines to 120 characters." Enabled: true Style/MethodCallWithoutArgsParentheses: @@ -271,8 +267,8 @@ Style/MethodCallWithoutArgsParentheses: Style/MethodDefParentheses: Description: >- - Checks if the method definitions have or don"t have - parentheses. + Checks if the method definitions have or don"t have + parentheses. Enabled: true Naming/MethodName: @@ -293,14 +289,14 @@ Style/MultilineIfThen: Style/MultilineTernaryOperator: Description: >- - Avoid multi-line ?: (the ternary operator); - use if/unless instead. + Avoid multi-line ?: (the ternary operator); + use if/unless instead. Enabled: true Style/NegatedIf: Description: >- - Favor unless over if for negative conditions - (or control flow or). + Favor unless over if for negative conditions + (or control flow or). Enabled: true Style/NegatedWhile: @@ -329,14 +325,14 @@ Style/Not: Style/NumericLiterals: Description: >- - Add underscores to large numeric literals to improve their - readability. + Add underscores to large numeric literals to improve their + readability. Enabled: true Style/OneLineConditional: Description: >- - Favor the ternary operator(?:) over - if/then/else/end constructs. + Favor the ternary operator(?:) over + if/then/else/end constructs. Enabled: true Naming/BinaryOperatorParameterName: @@ -345,8 +341,8 @@ Naming/BinaryOperatorParameterName: Style/ParenthesesAroundCondition: Description: >- - Don't use parentheses around the condition of an - if/unless/while. + Don't use parentheses around the condition of an + if/unless/while. Enabled: true Style/PercentLiteralDelimiters: @@ -387,10 +383,10 @@ Style/RedundantSelf: Style/RegexpLiteral: Description: >- - Use %r for regular expressions matching more than - `MaxSlashes` '/' characters. - Use %r only for regular expressions matching more than - `MaxSlashes` '/' character. + Use %r for regular expressions matching more than + `MaxSlashes` '/' characters. + Use %r only for regular expressions matching more than + `MaxSlashes` '/' character. Enabled: true Style/RescueModifier: @@ -419,8 +415,8 @@ Style/SingleLineMethods: Layout/SpaceBeforeFirstArg: Description: >- - Checks that exactly one space is used between a method name - and the first argument for method calls without parentheses. + Checks that exactly one space is used between a method name + and the first argument for method calls without parentheses. Enabled: true Layout/SpaceAfterColon: @@ -437,8 +433,8 @@ Layout/SpaceAroundKeyword: Layout/SpaceAfterMethodName: Description: >- - Never put a space between a method name and the opening - parenthesis in a method definition. + Never put a space between a method name and the opening + parenthesis in a method definition. Enabled: true Layout/SpaceAfterNot: @@ -451,8 +447,8 @@ Layout/SpaceAfterSemicolon: Layout/SpaceBeforeBlockBraces: Description: >- - Checks that the left block brace has or doesn't have space - before it. + Checks that the left block brace has or doesn't have space + before it. Enabled: true Layout/SpaceBeforeComma: @@ -461,8 +457,8 @@ Layout/SpaceBeforeComma: Layout/SpaceBeforeComment: Description: >- - Checks for missing space between code and a comment on the - same line. + Checks for missing space between code and a comment on the + same line. Enabled: true Layout/SpaceBeforeSemicolon: @@ -471,16 +467,16 @@ Layout/SpaceBeforeSemicolon: Layout/SpaceInsideBlockBraces: Description: >- - Checks that block braces have or don't have surrounding space. - For blocks taking parameters, checks that the left brace has - or doesn"t have trailing space. + Checks that block braces have or don't have surrounding space. + For blocks taking parameters, checks that the left brace has + or doesn"t have trailing space. Enabled: true Layout/SpaceAroundEqualsInParameterDefault: Description: >- - Checks that the equals signs in parameter default assignments - have or don't have surrounding space depending on - configuration. + Checks that the equals signs in parameter default assignments + have or don't have surrounding space depending on + configuration. Enabled: true Layout/SpaceAroundOperators: @@ -503,26 +499,26 @@ Style/StringLiterals: Description: "Checks if uses of quotes match the configured preference." Enabled: true -Layout/Tab: +Layout/IndentationStyle: Description: "No hard tabs." Enabled: true -Layout/TrailingBlankLines: +Layout/TrailingEmptyLines: Description: "Checks trailing blank lines and final newline." Enabled: true Style/TrailingCommaInArguments: - Description: 'Checks for trailing comma in argument lists.' - StyleGuide: '#no-trailing-params-comma' + Description: "Checks for trailing comma in argument lists." + StyleGuide: "#no-trailing-params-comma" Enabled: true Style/TrailingCommaInArrayLiteral: - Description: 'Checks for trailing comma in array literals.' - StyleGuide: '#no-trailing-array-commas' + Description: "Checks for trailing comma in array literals." + StyleGuide: "#no-trailing-array-commas" Enabled: true Style/TrailingCommaInHashLiteral: - Description: 'Checks for trailing comma in hash literals.' + Description: "Checks for trailing comma in hash literals." Enabled: true Layout/TrailingWhitespace: @@ -535,11 +531,11 @@ Style/TrivialAccessors: Style/UnlessElse: Description: >- - Never use unless with else. Rewrite these with the positive - case first. + Never use unless with else. Rewrite these with the positive + case first. Enabled: true -Style/UnneededCapitalW: +Style/RedundantCapitalW: Description: "Checks for %W when interpolation is not needed." Enabled: true @@ -549,8 +545,8 @@ Style/CommandLiteral: Style/VariableInterpolation: Description: >- - Don't interpolate global, instance and class variables - directly in strings. + Don't interpolate global, instance and class variables + directly in strings. Enabled: true Naming/VariableName: @@ -567,8 +563,8 @@ Style/WhileUntilDo: Style/WhileUntilModifier: Description: >- - Favor modifier while/until usage when you have a - single-line body. + Favor modifier while/until usage when you have a + single-line body. Enabled: true Style/WordArray: @@ -580,14 +576,14 @@ Style/WordArray: Lint/AmbiguousOperator: Description: >- - Checks for ambiguous operators in the first argument of a - method invocation without parentheses. + Checks for ambiguous operators in the first argument of a + method invocation without parentheses. Enabled: true Lint/AmbiguousRegexpLiteral: Description: >- - Checks for ambiguous regexp literals in the first argument of - a method invocation without parenthesis. + Checks for ambiguous regexp literals in the first argument of + a method invocation without parenthesis. Enabled: true Layout/BlockAlignment: @@ -626,10 +622,6 @@ Layout/EndAlignment: Description: "Align ends correctly." Enabled: true -Lint/EndInMethod: - Description: "END blocks should not be placed inside method definitions." - Enabled: true - Lint/EnsureReturn: Description: "Never use return in an ensure block." Enabled: true @@ -638,7 +630,7 @@ Security/Eval: Description: "The use of eval represents a serious security risk." Enabled: true -Lint/HandleExceptions: +Lint/SuppressedException: Description: "Don't suppress exception." Enabled: true @@ -648,20 +640,20 @@ Lint/LiteralInInterpolation: Lint/Loop: Description: >- - Use Kernel#loop with break rather than begin/end/until or - begin/end/while for post-loop tests. + Use Kernel#loop with break rather than begin/end/until or + begin/end/while for post-loop tests. Enabled: true Lint/ParenthesesAsGroupedExpression: Description: >- - Checks for method calls with a space before the opening - parenthesis. + Checks for method calls with a space before the opening + parenthesis. Enabled: true Lint/RequireParentheses: Description: >- - Use parentheses in the method call to avoid confusion - about precedence. + Use parentheses in the method call to avoid confusion + about precedence. Enabled: true Lint/RescueException: @@ -670,11 +662,11 @@ Lint/RescueException: Lint/ShadowingOuterLocalVariable: Description: >- - Do not use the same name as outer local variable - for block arguments or block local variables. + Do not use the same name as outer local variable + for block arguments or block local variables. Enabled: true -Lint/StringConversionInInterpolation: +Lint/RedundantStringCoercion: Description: "Checks for Object#to_s usage in string interpolation." Enabled: true @@ -702,10 +694,6 @@ Lint/UselessAssignment: Description: "Checks for useless assignment to a local variable." Enabled: true -Lint/UselessComparison: - Description: "Checks for comparison of something with itself." - Enabled: true - Lint/UselessElseWithoutRescue: Description: "Checks for useless `else` in `begin..end` without `rescue`." Enabled: true @@ -718,6 +706,10 @@ Lint/Void: Description: "Possible use of operator/literal/variable in void context." Enabled: true +Lint/AmbiguousBlockAssociation: + Description: "This cop checks for ambiguous block association with method when param passed without parentheses." + Enabled: true + ##################### Rails ################################## Rails/ActionFilter: diff --git a/api/Gemfile b/api/Gemfile index d261344..37245c6 100644 --- a/api/Gemfile +++ b/api/Gemfile @@ -1,45 +1,27 @@ -source 'https://rubygems.org' -git_source(:github) { |repo| "https://github.com/#{repo}.git" } +source "https://rubygems.org" +git_source(:github){|repo| "https://github.com/#{repo}.git"} -ruby '2.6.3' +gem "bootsnap", ">= 1.4.2", require: false +gem "mysql2", ">= 0.4.4" +gem "puma", "~> 4.1" +gem "rails", "~> 6.0.3", ">= 6.0.3.2" -# Bundle edge Rails instead: gem 'rails', github: 'rails/rails' -gem 'rails', '~> 6.0.3', '>= 6.0.3.2' -# Use sqlite3 as the database for Active Record -gem 'sqlite3', '~> 1.4' -# Use Puma as the app server -gem 'puma', '~> 4.1' -gem "rails_best_practices" -gem "rubocop", "~> 0.74.0", require: false -gem "rubocop-checkstyle_formatter", require: false -gem "rubocop-rails", "~> 2.3.2", require: false -# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder -# gem 'jbuilder', '~> 2.7' -# Use Redis adapter to run Action Cable in production -# gem 'redis', '~> 4.0' -# Use Active Model has_secure_password -# gem 'bcrypt', '~> 3.1.7' - -# Use Active Storage variant -# gem 'image_processing', '~> 1.2' - -# Reduces boot times through caching; required in config/boot.rb -gem 'bootsnap', '>= 1.4.2', require: false - -# Use Rack CORS for handling Cross-Origin Resource Sharing (CORS), making cross-origin AJAX possible -# gem 'rack-cors' - -group :development, :test do - # Call 'byebug' anywhere in the code to stop execution and get a debugger console - gem 'byebug', platforms: [:mri, :mingw, :x64_mingw] +group :development do + gem "listen", "~> 3.2" + gem "spring" + gem "spring-watcher-listen", "~> 2.0.0" end group :development do - gem 'listen', '~> 3.2' - # Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring - gem 'spring' - gem 'spring-watcher-listen', '~> 2.0.0' + gem "rails_best_practices" + gem "reek" + gem "rubocop", require: false + gem "rubocop-rails", "~> 2.3.2", require: false end -# Windows does not include zoneinfo files, so bundle the tzinfo-data gem -gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby] +gem "tzinfo-data", platforms: [:mingw, :mswin, :x64_mingw, :jruby] + +group :development, :test do + gem "factory_bot_rails" + gem "rspec-rails" +end diff --git a/api/Gemfile.lock b/api/Gemfile.lock index 2a491e6..e80480c 100644 --- a/api/Gemfile.lock +++ b/api/Gemfile.lock @@ -56,22 +56,33 @@ GEM minitest (~> 5.1) tzinfo (~> 1.1) zeitwerk (~> 2.2, >= 2.2.2) + ast (2.4.1) bootsnap (1.4.8) msgpack (~> 1.0) builder (3.2.4) - byebug (11.1.3) + code_analyzer (0.5.2) + sexp_processor concurrent-ruby (1.1.7) crass (1.0.6) + diff-lcs (1.4.4) erubi (1.9.0) + erubis (2.7.0) + factory_bot (6.1.0) + activesupport (>= 5.0.0) + factory_bot_rails (6.1.0) + factory_bot (~> 6.1.0) + railties (>= 5.0.0) ffi (1.13.1) globalid (0.4.2) activesupport (>= 4.2.0) i18n (1.8.5) concurrent-ruby (~> 1.0) + json (2.3.1) + kwalify (0.7.2) listen (3.2.1) rb-fsevent (~> 0.10, >= 0.10.3) rb-inotify (~> 0.9, >= 0.9.10) - loofah (2.6.0) + loofah (2.7.0) crass (~> 1.0.2) nokogiri (>= 1.5.9) mail (2.7.1) @@ -84,9 +95,14 @@ GEM mini_portile2 (2.4.0) minitest (5.14.1) msgpack (1.3.3) + mysql2 (0.5.3) nio4r (2.5.2) nokogiri (1.10.10) mini_portile2 (~> 2.4.0) + parallel (1.19.2) + parser (2.7.1.4) + ast (~> 2.4.1) + psych (3.1.0) puma (4.3.5) nio4r (~> 2.0) rack (2.2.3) @@ -112,17 +128,67 @@ GEM nokogiri (>= 1.6) rails-html-sanitizer (1.3.0) loofah (~> 2.3) + rails_best_practices (1.20.0) + activesupport + code_analyzer (>= 0.5.1) + erubis + i18n + json + require_all (~> 3.0) + ruby-progressbar railties (6.0.3.2) actionpack (= 6.0.3.2) activesupport (= 6.0.3.2) method_source rake (>= 0.8.7) thor (>= 0.20.3, < 2.0) + rainbow (3.0.0) rake (13.0.1) rb-fsevent (0.10.4) rb-inotify (0.10.1) ffi (~> 1.0) - spring (2.1.0) + reek (6.0.1) + kwalify (~> 0.7.0) + parser (>= 2.5.0.0, < 2.8, != 2.5.1.1) + psych (~> 3.1.0) + rainbow (>= 2.0, < 4.0) + regexp_parser (1.7.1) + require_all (3.0.0) + rexml (3.2.4) + rspec-core (3.9.2) + rspec-support (~> 3.9.3) + rspec-expectations (3.9.2) + diff-lcs (>= 1.2.0, < 2.0) + rspec-support (~> 3.9.0) + rspec-mocks (3.9.1) + diff-lcs (>= 1.2.0, < 2.0) + rspec-support (~> 3.9.0) + rspec-rails (4.0.1) + actionpack (>= 4.2) + activesupport (>= 4.2) + railties (>= 4.2) + rspec-core (~> 3.9) + rspec-expectations (~> 3.9) + rspec-mocks (~> 3.9) + rspec-support (~> 3.9) + rspec-support (3.9.3) + rubocop (0.89.1) + parallel (~> 1.10) + parser (>= 2.7.1.1) + rainbow (>= 2.2.2, < 4.0) + regexp_parser (>= 1.7) + rexml + rubocop-ast (>= 0.3.0, < 1.0) + ruby-progressbar (~> 1.7) + unicode-display_width (>= 1.4.0, < 2.0) + rubocop-ast (0.3.0) + parser (>= 2.7.1.4) + rubocop-rails (2.3.2) + rack (>= 1.1) + rubocop (>= 0.72.0) + ruby-progressbar (1.10.1) + sexp_processor (4.15.0) + spring (2.1.1) spring-watcher-listen (2.0.1) listen (>= 2.7, < 4.0) spring (>= 1.2, < 3.0) @@ -133,11 +199,11 @@ GEM actionpack (>= 4.0) activesupport (>= 4.0) sprockets (>= 3.0.0) - sqlite3 (1.4.2) thor (1.0.1) thread_safe (0.3.6) tzinfo (1.2.7) thread_safe (~> 0.1) + unicode-display_width (1.7.0) websocket-driver (0.7.3) websocket-extensions (>= 0.1.0) websocket-extensions (0.1.5) @@ -148,17 +214,19 @@ PLATFORMS DEPENDENCIES bootsnap (>= 1.4.2) - byebug + factory_bot_rails listen (~> 3.2) + mysql2 (>= 0.4.4) puma (~> 4.1) rails (~> 6.0.3, >= 6.0.3.2) + rails_best_practices + reek + rspec-rails + rubocop + rubocop-rails (~> 2.3.2) spring spring-watcher-listen (~> 2.0.0) - sqlite3 (~> 1.4) tzinfo-data -RUBY VERSION - ruby 2.6.3p62 - BUNDLED WITH - 1.17.2 + 2.1.4 diff --git a/api/Rakefile b/api/Rakefile index e85f913..9a5ea73 100644 --- a/api/Rakefile +++ b/api/Rakefile @@ -1,6 +1,6 @@ # Add your own tasks in files placed in lib/tasks ending in .rake, # for example lib/tasks/capistrano.rake, and they will automatically be available to Rake. -require_relative 'config/application' +require_relative "config/application" Rails.application.load_tasks diff --git a/api/app/mailers/application_mailer.rb b/api/app/mailers/application_mailer.rb index 286b223..3c34c81 100644 --- a/api/app/mailers/application_mailer.rb +++ b/api/app/mailers/application_mailer.rb @@ -1,4 +1,4 @@ class ApplicationMailer < ActionMailer::Base - default from: 'from@example.com' - layout 'mailer' + default from: "from@example.com" + layout "mailer" end diff --git a/api/bin/bundle b/api/bin/bundle index 524dfd3..50f94d7 100755 --- a/api/bin/bundle +++ b/api/bin/bundle @@ -11,7 +11,7 @@ require "rubygems" m = Module.new do - module_function + module_function def invoked_as_script? File.expand_path($0) == File.expand_path(__FILE__) @@ -23,15 +23,17 @@ m = Module.new do def cli_arg_version return unless invoked_as_script? # don't want to hijack other binstubs - return unless "update".start_with?(ARGV.first || " ") # must be running `bundle update` + unless "update".start_with?(ARGV.first || " ") + return + end # must be running `bundle update` + bundler_version = nil update_index = nil ARGV.each_with_index do |a, i| - if update_index && update_index.succ == i && a =~ Gem::Version::ANCHORED_VERSION_PATTERN - bundler_version = a - end + bundler_version = a if update_index && update_index.succ == i && a =~ Gem::Version::ANCHORED_VERSION_PATTERN next unless a =~ /\A--bundler(?:[= ](#{Gem::Version::VERSION_PATTERN}))?\z/ - bundler_version = $1 || ">= 0.a" + + bundler_version = Regexp.last_match(1) || ">= 0.a" update_index = i end bundler_version @@ -39,9 +41,9 @@ m = Module.new do def gemfile gemfile = ENV["BUNDLE_GEMFILE"] - return gemfile if gemfile && !gemfile.empty? + return gemfile if gemfile.present? - File.expand_path("../../Gemfile", __FILE__) + File.expand_path("../Gemfile", __dir__) end def lockfile @@ -55,8 +57,10 @@ m = Module.new do def lockfile_version return unless File.file?(lockfile) + lockfile_contents = File.read(lockfile) return unless lockfile_contents =~ /\n\nBUNDLED WITH\n\s{2,}(#{Gem::Version::VERSION_PATTERN})\n/ + Regexp.last_match(1) end @@ -74,7 +78,7 @@ m = Module.new do activate_bundler(bundler_version.dup) end - def activate_bundler(bundler_version) + def activate_bundler bundler_version if Gem::Version.correct?(bundler_version) && Gem::Version.new(bundler_version).release < Gem::Version.new("2.0") bundler_version = "< 2" end @@ -82,10 +86,14 @@ m = Module.new do gem "bundler", bundler_version end return if gem_error.nil? + require_error = activation_error_handling do require "bundler/version" end - return if require_error.nil? && Gem::Requirement.new(bundler_version).satisfied_by?(Gem::Version.new(Bundler::VERSION)) + if require_error.nil? && Gem::Requirement.new(bundler_version).satisfied_by?(Gem::Version.new(Bundler::VERSION)) + return + end + warn "Activating bundler (#{bundler_version}) failed:\n#{gem_error.message}\n\nTo install the version of bundler this project requires, run `gem install bundler -v '#{bundler_version}'`" exit 42 end @@ -100,6 +108,4 @@ end m.load_bundler! -if m.invoked_as_script? - load Gem.bin_path("bundler", "bundle") -end +load Gem.bin_path("bundler", "bundle") if m.invoked_as_script? diff --git a/api/bin/rails b/api/bin/rails index 5badb2f..36b01a1 100755 --- a/api/bin/rails +++ b/api/bin/rails @@ -1,9 +1,9 @@ #!/usr/bin/env ruby begin - load File.expand_path('../spring', __FILE__) + load File.expand_path("spring", __dir__) rescue LoadError => e - raise unless e.message.include?('spring') + raise unless e.message.include?("spring") end -APP_PATH = File.expand_path('../config/application', __dir__) -require_relative '../config/boot' -require 'rails/commands' +APP_PATH = File.expand_path("../config/application", __dir__) +require_relative "../config/boot" +require "rails/commands" diff --git a/api/bin/rake b/api/bin/rake index d87d5f5..660472a 100755 --- a/api/bin/rake +++ b/api/bin/rake @@ -1,9 +1,9 @@ #!/usr/bin/env ruby begin - load File.expand_path('../spring', __FILE__) + load File.expand_path("spring", __dir__) rescue LoadError => e - raise unless e.message.include?('spring') + raise unless e.message.include?("spring") end -require_relative '../config/boot' -require 'rake' +require_relative "../config/boot" +require "rake" Rake.application.run diff --git a/api/bin/setup b/api/bin/setup index 0e39e8c..59536c4 100755 --- a/api/bin/setup +++ b/api/bin/setup @@ -1,10 +1,10 @@ #!/usr/bin/env ruby -require 'fileutils' +require "fileutils" # path to your application root. -APP_ROOT = File.expand_path('..', __dir__) +APP_ROOT = File.expand_path("..", __dir__) -def system!(*args) +def system! *args system(*args) || abort("\n== Command #{args} failed ==") end @@ -13,9 +13,9 @@ FileUtils.chdir APP_ROOT do # This script is idempotent, so that you can run it at anytime and get an expectable outcome. # Add necessary setup steps to this file. - puts '== Installing dependencies ==' - system! 'gem install bundler --conservative' - system('bundle check') || system!('bundle install') + puts "== Installing dependencies ==" + system! "gem install bundler --conservative" + system("bundle check") || system!("bundle install") # puts "\n== Copying sample files ==" # unless File.exist?('config/database.yml') @@ -23,11 +23,11 @@ FileUtils.chdir APP_ROOT do # end puts "\n== Preparing database ==" - system! 'bin/rails db:prepare' + system! "bin/rails db:prepare" puts "\n== Removing old logs and tempfiles ==" - system! 'bin/rails log:clear tmp:clear' + system! "bin/rails log:clear tmp:clear" puts "\n== Restarting application server ==" - system! 'bin/rails restart' + system! "bin/rails restart" end diff --git a/api/bin/spring b/api/bin/spring index d89ee49..de47257 100755 --- a/api/bin/spring +++ b/api/bin/spring @@ -4,14 +4,14 @@ # It gets overwritten when you run the `spring binstub` command. unless defined?(Spring) - require 'rubygems' - require 'bundler' + require "rubygems" + require "bundler" lockfile = Bundler::LockfileParser.new(Bundler.default_lockfile.read) - spring = lockfile.specs.detect { |spec| spec.name == 'spring' } + spring = lockfile.specs.detect{|spec| spec.name == "spring"} if spring Gem.use_paths Gem.dir, Bundler.bundle_path.to_s, *Gem.path - gem 'spring', spring.version - require 'spring/binstub' + gem "spring", spring.version + require "spring/binstub" end end diff --git a/api/config.ru b/api/config.ru index f7ba0b5..441e6ff 100644 --- a/api/config.ru +++ b/api/config.ru @@ -1,5 +1,5 @@ # This file is used by Rack-based servers to start the application. -require_relative 'config/environment' +require_relative "config/environment" run Rails.application diff --git a/api/config/application.rb b/api/config/application.rb index 890387e..3c9702f 100644 --- a/api/config/application.rb +++ b/api/config/application.rb @@ -1,4 +1,4 @@ -require_relative 'boot' +require_relative "boot" require "rails" # Pick the frameworks you want: diff --git a/api/config/boot.rb b/api/config/boot.rb index b9e460c..988a5dd 100644 --- a/api/config/boot.rb +++ b/api/config/boot.rb @@ -1,4 +1,4 @@ -ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../Gemfile', __dir__) +ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../Gemfile", __dir__) -require 'bundler/setup' # Set up gems listed in the Gemfile. -require 'bootsnap/setup' # Speed up boot time by caching expensive operations. +require "bundler/setup" # Set up gems listed in the Gemfile. +require "bootsnap/setup" # Speed up boot time by caching expensive operations. diff --git a/api/config/database.yml b/api/config/database.yml index 4a8a1b2..665eea6 100644 --- a/api/config/database.yml +++ b/api/config/database.yml @@ -1,25 +1,54 @@ -# SQLite. Versions 3.8.0 and up are supported. -# gem install sqlite3 +# MySQL. Versions 5.5.8 and up are supported. # -# Ensure the SQLite 3 gem is defined in your Gemfile -# gem 'sqlite3' +# Install the MySQL driver +# gem install mysql2 +# +# Ensure the MySQL gem is defined in your Gemfile +# gem 'mysql2' +# +# And be sure to use new-style password hashing: +# https://dev.mysql.com/doc/refman/5.7/en/password-hashing.html # default: &default - adapter: sqlite3 + adapter: mysql2 + encoding: utf8mb4 pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %> - timeout: 5000 + username: root + password: + host: localhost development: <<: *default - database: db/development.sqlite3 + database: api_development # Warning: The database defined as "test" will be erased and # re-generated from your development database when you run "rake". # Do not set this db to the same as development or production. test: <<: *default - database: db/test.sqlite3 + database: api_test +# As with config/credentials.yml, you never want to store sensitive information, +# like your database password, in your source code. If your source code is +# ever seen by anyone, they now have access to your database. +# +# Instead, provide the password as a unix environment variable when you boot +# the app. Read https://guides.rubyonrails.org/configuring.html#configuring-a-database +# for a full rundown on how to provide these environment variables in a +# production deployment. +# +# On Heroku and other platform providers, you may have a full connection URL +# available as an environment variable. For example: +# +# DATABASE_URL="mysql2://myuser:mypass@localhost/somedatabase" +# +# You can use this database configuration with: +# +# production: +# url: <%= ENV['DATABASE_URL'] %> +# production: <<: *default - database: db/production.sqlite3 + database: api_production + username: api + password: <%= ENV['API_DATABASE_PASSWORD'] %> diff --git a/api/config/environment.rb b/api/config/environment.rb index 426333b..cac5315 100644 --- a/api/config/environment.rb +++ b/api/config/environment.rb @@ -1,5 +1,5 @@ # Load the Rails application. -require_relative 'application' +require_relative "application" # Initialize the Rails application. Rails.application.initialize! diff --git a/api/config/environments/development.rb b/api/config/environments/development.rb index 698f159..7827545 100644 --- a/api/config/environments/development.rb +++ b/api/config/environments/development.rb @@ -14,10 +14,10 @@ # Enable/disable caching. By default caching is disabled. # Run rails dev:cache to toggle caching. - if Rails.root.join('tmp', 'caching-dev.txt').exist? + if Rails.root.join("tmp", "caching-dev.txt").exist? config.cache_store = :memory_store config.public_file_server.headers = { - 'Cache-Control' => "public, max-age=#{2.days.to_i}" + "Cache-Control" => "public, max-age=#{2.days.to_i}" } else config.action_controller.perform_caching = false @@ -42,7 +42,6 @@ # Highlight code that triggered database queries in logs. config.active_record.verbose_query_logs = true - # Raises error for missing translations. # config.action_view.raise_on_missing_translations = true diff --git a/api/config/environments/production.rb b/api/config/environments/production.rb index 8cb401a..4f7c45b 100644 --- a/api/config/environments/production.rb +++ b/api/config/environments/production.rb @@ -11,7 +11,7 @@ config.eager_load = true # Full error reports are disabled and caching is turned on. - config.consider_all_requests_local = false + config.consider_all_requests_local = false # Ensures that a master key has been made available in either ENV["RAILS_MASTER_KEY"] # or in config/master.key. This key is used to decrypt credentials (and other encrypted files). @@ -19,7 +19,7 @@ # Disable serving static files from the `/public` folder by default since # Apache or NGINX already handles this. - config.public_file_server.enabled = ENV['RAILS_SERVE_STATIC_FILES'].present? + config.public_file_server.enabled = ENV["RAILS_SERVE_STATIC_FILES"].present? # Enable serving of images, stylesheets, and JavaScripts from an asset server. # config.action_controller.asset_host = 'http://assets.example.com' @@ -44,7 +44,7 @@ config.log_level = :debug # Prepend all log lines with the following tags. - config.log_tags = [ :request_id ] + config.log_tags = [:request_id] # Use a different cache store in production. # config.cache_store = :mem_cache_store diff --git a/api/config/environments/test.rb b/api/config/environments/test.rb index 0cb2424..88a1347 100644 --- a/api/config/environments/test.rb +++ b/api/config/environments/test.rb @@ -1,10 +1,6 @@ -# The test environment is used exclusively to run your application's -# test suite. You never need to work with it otherwise. Remember that -# your test database is "scratch space" for the test suite and is wiped -# and recreated between test runs. Don't rely on the data there! + Rails.application.configure do - # Settings specified here will take precedence over those in config/application.rb. config.cache_classes = false config.action_view.cache_template_loading = true @@ -17,7 +13,7 @@ # Configure public file server for tests with Cache-Control for performance. config.public_file_server.enabled = true config.public_file_server.headers = { - 'Cache-Control' => "public, max-age=#{1.hour.to_i}" + "Cache-Control" => "public, max-age=#{1.hour.to_i}" } # Show full error reports and disable caching. diff --git a/api/config/puma.rb b/api/config/puma.rb index 5ed4437..d91a8e6 100644 --- a/api/config/puma.rb +++ b/api/config/puma.rb @@ -4,20 +4,20 @@ # 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. # -max_threads_count = ENV.fetch("RAILS_MAX_THREADS") { 5 } -min_threads_count = ENV.fetch("RAILS_MIN_THREADS") { max_threads_count } +max_threads_count = ENV.fetch("RAILS_MAX_THREADS"){5} +min_threads_count = ENV.fetch("RAILS_MIN_THREADS"){max_threads_count} threads min_threads_count, max_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 `pidfile` that Puma will use. -pidfile ENV.fetch("PIDFILE") { "tmp/pids/server.pid" } +pidfile ENV.fetch("PIDFILE"){"tmp/pids/server.pid"} # Specifies the number of `workers` to boot in clustered mode. # Workers are forked web server processes. If using threads and workers together diff --git a/api/spec/rails_helper.rb b/api/spec/rails_helper.rb new file mode 100644 index 0000000..d761692 --- /dev/null +++ b/api/spec/rails_helper.rb @@ -0,0 +1,64 @@ +# This file is copied to spec/ when you run 'rails generate rspec:install' +require "spec_helper" +ENV["RAILS_ENV"] ||= "test" +require File.expand_path("../config/environment", __dir__) +# Prevent database truncation if the environment is production +abort("The Rails environment is running in production mode!") if Rails.env.production? +require "rspec/rails" +# Add additional requires below this line. Rails is not loaded until this point! + +# Requires supporting ruby files with custom matchers and macros, etc, in +# spec/support/ and its subdirectories. Files matching `spec/**/*_spec.rb` are +# run as spec files by default. This means that files in spec/support that end +# in _spec.rb will both be required and run as specs, causing the specs to be +# run twice. It is recommended that you do not name files matching this glob to +# end with _spec.rb. You can configure this pattern with the --pattern +# option on the command line or in ~/.rspec, .rspec or `.rspec-local`. +# +# The following line is provided for convenience purposes. It has the downside +# of increasing the boot-up time by auto-requiring all files in the support +# directory. Alternatively, in the individual `*_spec.rb` files, manually +# require only the support files necessary. +# +# Dir[Rails.root.join('spec', 'support', '**', '*.rb')].sort.each { |f| require f } + +# Checks for pending migrations and applies them before tests are run. +# If you are not using ActiveRecord, you can remove these lines. +begin + ActiveRecord::Migration.maintain_test_schema! +rescue ActiveRecord::PendingMigrationError => e + puts e.to_s.strip + exit 1 +end +RSpec.configure do |config| + # Remove this line if you're not using ActiveRecord or ActiveRecord fixtures + config.fixture_path = "#{::Rails.root}/spec/fixtures" + + # If you're not using ActiveRecord, or you'd prefer not to run each of your + # examples within a transaction, remove the following line or assign false + # instead of true. + config.use_transactional_fixtures = true + + # You can uncomment this line to turn off ActiveRecord support entirely. + # config.use_active_record = false + + # RSpec Rails can automatically mix in different behaviours to your tests + # based on their file location, for example enabling you to call `get` and + # `post` in specs under `spec/controllers`. + # + # You can disable this behaviour by removing the line below, and instead + # explicitly tag your specs with their type, e.g.: + # + # RSpec.describe UsersController, type: :controller do + # # ... + # end + # + # The different available types are documented in the features, such as in + # https://relishapp.com/rspec/rspec-rails/docs + config.infer_spec_type_from_file_location! + + # Filter lines from Rails gems in backtraces. + config.filter_rails_from_backtrace! + # arbitrary gems may also be filtered via: + # config.filter_gems_from_backtrace("gem name") +end diff --git a/api/spec/spec_helper.rb b/api/spec/spec_helper.rb new file mode 100644 index 0000000..15a3872 --- /dev/null +++ b/api/spec/spec_helper.rb @@ -0,0 +1,94 @@ +# This file was generated by the `rails generate rspec:install` command. Conventionally, all +# specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`. +# The generated `.rspec` file contains `--require spec_helper` which will cause +# this file to always be loaded, without a need to explicitly require it in any +# files. +# +# Given that it is always loaded, you are encouraged to keep this file as +# light-weight as possible. Requiring heavyweight dependencies from this file +# will add to the boot time of your test suite on EVERY test run, even for an +# individual file that may not need all of that loaded. Instead, consider making +# a separate helper file that requires the additional dependencies and performs +# the additional setup, and require it from the spec files that actually need +# it. +# +# See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration +RSpec.configure do |config| + # rspec-expectations config goes here. You can use an alternate + # assertion/expectation library such as wrong or the stdlib/minitest + # assertions if you prefer. + config.expect_with :rspec do |expectations| + # This option will default to `true` in RSpec 4. It makes the `description` + # and `failure_message` of custom matchers include text for helper methods + # defined using `chain`, e.g.: + # be_bigger_than(2).and_smaller_than(4).description + # # => "be bigger than 2 and smaller than 4" + # ...rather than: + # # => "be bigger than 2" + expectations.include_chain_clauses_in_custom_matcher_descriptions = true + end + + # rspec-mocks config goes here. You can use an alternate test double + # library (such as bogus or mocha) by changing the `mock_with` option here. + config.mock_with :rspec do |mocks| + # Prevents you from mocking or stubbing a method that does not exist on + # a real object. This is generally recommended, and will default to + # `true` in RSpec 4. + mocks.verify_partial_doubles = true + end + + # This option will default to `:apply_to_host_groups` in RSpec 4 (and will + # have no way to turn it off -- the option exists only for backwards + # compatibility in RSpec 3). It causes shared context metadata to be + # inherited by the metadata hash of host groups and examples, rather than + # triggering implicit auto-inclusion in groups with matching metadata. + config.shared_context_metadata_behavior = :apply_to_host_groups + + # The settings below are suggested to provide a good initial experience + # with RSpec, but feel free to customize to your heart's content. + # # This allows you to limit a spec run to individual examples or groups + # # you care about by tagging them with `:focus` metadata. When nothing + # # is tagged with `:focus`, all examples get run. RSpec also provides + # # aliases for `it`, `describe`, and `context` that include `:focus` + # # metadata: `fit`, `fdescribe` and `fcontext`, respectively. + # config.filter_run_when_matching :focus + # + # # Allows RSpec to persist some state between runs in order to support + # # the `--only-failures` and `--next-failure` CLI options. We recommend + # # you configure your source control system to ignore this file. + # config.example_status_persistence_file_path = "spec/examples.txt" + # + # # Limits the available syntax to the non-monkey patched syntax that is + # # recommended. For more details, see: + # # - http://rspec.info/blog/2012/06/rspecs-new-expectation-syntax/ + # # - http://www.teaisaweso.me/blog/2013/05/27/rspecs-new-message-expectation-syntax/ + # # - http://rspec.info/blog/2014/05/notable-changes-in-rspec-3/#zero-monkey-patching-mode + # config.disable_monkey_patching! + # + # # Many RSpec users commonly either run the entire suite or an individual + # # file, and it's useful to allow more verbose output when running an + # # individual spec file. + # if config.files_to_run.one? + # # Use the documentation formatter for detailed output, + # # unless a formatter has already been configured + # # (e.g. via a command-line flag). + # config.default_formatter = "doc" + # end + # + # # Print the 10 slowest examples and example groups at the + # # end of the spec run, to help surface which specs are running + # # particularly slow. + # config.profile_examples = 10 + # + # # Run specs in random order to surface order dependencies. If you find an + # # order dependency and want to debug it, you can fix the order by providing + # # the seed, which is printed after each run. + # # --seed 1234 + # config.order = :random + # + # # Seed global randomization in this process using the `--seed` CLI option. + # # Setting this allows you to use `--seed` to deterministically reproduce + # # test failures related to randomization by passing the same `--seed` value + # # as the one that triggered the failure. + # Kernel.srand config.seed +end diff --git a/api/test/test_helper.rb b/api/test/test_helper.rb index d5300f8..d713e37 100644 --- a/api/test/test_helper.rb +++ b/api/test/test_helper.rb @@ -1,6 +1,6 @@ -ENV['RAILS_ENV'] ||= 'test' -require_relative '../config/environment' -require 'rails/test_help' +ENV["RAILS_ENV"] ||= "test" +require_relative "../config/environment" +require "rails/test_help" class ActiveSupport::TestCase # Run tests in parallel with specified workers