diff --git a/.codeclimate.yml b/.codeclimate.yml index e5b31b3e..db96aa55 100644 --- a/.codeclimate.yml +++ b/.codeclimate.yml @@ -1,8 +1,5 @@ version: 2 plugins: - rubocop: - enabled: true - channel: rubocop-0-70 brakeman: enabled: true bundler-audit: diff --git a/.github/actions/setup-test-environment/action.yml b/.github/actions/setup-test-environment/action.yml new file mode 100644 index 00000000..9ec34cc6 --- /dev/null +++ b/.github/actions/setup-test-environment/action.yml @@ -0,0 +1,31 @@ +name: 'Set up test environment' +description: 'Set up test environment for mapknitter' + +services: + mysql: + image: mysql:5.7 + env: + MYSQL_ROOT_PASSWORD: root + ports: + - 3306 + options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3 +runs: + using: 'composite' + steps: + - name: Setup database + shell: bash + env: + RAILS_ENV: test + DB_USER: root + DB_PASS: root + # tell Rails to use proper port for MySQL + DB_PORT: ${{ job.services.mysql.ports[3306] }} + DISABLE_BOOTSNAP: true + run: | + cp config/database.yml.example config/database.yml + cp db/schema.rb.example db/schema.rb + cp config/config.yml.example config/config.yml + sudo systemctl start mysql + mysql -uroot -proot -e "CREATE DATABASE mapknitter_test;" + bundle exec rake db:schema:load db:migrate --trace + sudo apt-get install -y gdal-bin diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml new file mode 100644 index 00000000..8642e461 --- /dev/null +++ b/.github/workflows/tests.yml @@ -0,0 +1,166 @@ +name: CI/CD workflow +on: [pull_request] + +jobs: + rubocop: + name: Code style suggestions + runs-on: ubuntu-latest + steps: + - name: Checkout repository + uses: actions/checkout@v2 + - name: Prepare Ruby + uses: ruby/setup-ruby@v1 + with: + ruby-version: 2.4.6 + bundler-cache: true + - name: Rubocop report + env: + FORCE_COLOR: 1 + run: bundle exec rubocop --color --fail-fast + + unit-tests: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - uses: ruby/setup-ruby@v1 + with: + ruby-version: 2.4.6 + bundler-cache: true + - uses: ./.github/actions/setup-test-environment + - uses: egordm/gha-yarn-node-cache@v1 + - name: Install packages + run: yarn install + - name: 'Model Tests' + env: + RAILS_ENV: test + DB_PASSWORD: root + DB_PORT: ${{ job.services.mysql.ports[3306] }} + DISABLE_BOOTSNAP: true + run: | + bundle exec rails test test:models + + integration-tests: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - uses: ruby/setup-ruby@v1 + with: + ruby-version: 2.4.6 + bundler-cache: true + - uses: ./.github/actions/setup-test-environment + - uses: egordm/gha-yarn-node-cache@v1 + - name: Install JavaScript dependencies with Yarn + run: yarn check || yarn install; + - name: 'Integration Tests' + env: + RAILS_ENV: test + DB_PASSWORD: root + DB_PORT: ${{ job.services.mysql.ports[3306] }} + DISABLE_BOOTSNAP: true + run: bundle exec rails test test:integration + + controller-tests: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - uses: ruby/setup-ruby@v1 + with: + ruby-version: 2.4.6 + bundler-cache: true + - uses: ./.github/actions/setup-test-environment + - uses: egordm/gha-yarn-node-cache@v1 + - name: Install JavaScript dependencies with Yarn + run: yarn check || yarn install; + - name: 'Controller Tests' + env: + RAILS_ENV: test + DB_PASSWORD: root + DB_PORT: ${{ job.services.mysql.ports[3306] }} + DISABLE_BOOTSNAP: true + run: bundle exec rails test test:controllers + + system-tests: + runs-on: ubuntu-latest + services: + redis: + image: redis + # Set health checks to wait until redis has started + options: >- + --health-cmd "redis-cli ping" + --health-interval 10s + --health-timeout 5s + --health-retries 5 + ports: + # Maps port 6379 on service container to the host + - 6379:6379 + steps: + - uses: actions/checkout@v2 + - uses: ruby/setup-ruby@v1 + with: + ruby-version: 2.4.6 + bundler-cache: true + - uses: nanasess/setup-chromedriver@v1.0.1 + - uses: ./.github/actions/setup-test-environment + - uses: egordm/gha-yarn-node-cache@v1 + - name: Install JavaScript dependencies with Yarn + run: yarn check || yarn install; + - name: 'System Tests' + env: + RAILS_ENV: test + DB_PASSWORD: root + DB_PORT: ${{ job.services.mysql.ports[3306] }} + REDIS_HOST: localhost + REDIS_PORT: 6379 + run: | + export DISPLAY=:99 + chromedriver --url-base=/wd/hub & + bundle exec rails test test:system + - name: Archive system test screenshots + uses: actions/upload-artifact@v2 + with: + name: system-test-screenshots + path: tmp/screenshots/* + + docker-build-check-development: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - uses: ruby/setup-ruby@v1 + with: + ruby-version: 2.4.6 + bundler-cache: true + - uses: ./.github/actions/setup-test-environment + - name: 'Development Docker Build' + run: docker build -t mapknitter -f dockerfiles/development . + + docker-build-check-production: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - uses: ruby/setup-ruby@v1 + with: + ruby-version: 2.4.6 + bundler-cache: true + - uses: ./.github/actions/setup-test-environment + - name: 'Development Docker Build' + run: docker build -t mapknitter -f dockerfiles/production . + + assets-precompilation: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - uses: ruby/setup-ruby@v1 + with: + ruby-version: 2.4.6 + bundler-cache: true + - uses: ./.github/actions/setup-test-environment + - uses: egordm/gha-yarn-node-cache@v1 + - name: Install JavaScript dependencies with Yarn + run: yarn check || yarn install; + - name: 'Asset Precompilation' + env: + RAILS_ENV: production + DB_PASSWORD: root + DB_PORT: ${{ job.services.mysql.ports[3306] }} + DISABLE_BOOTSNAP: true + run: bundle exec rails assets:precompile diff --git a/.rubocop.yml b/.rubocop.yml index 5e2f5d28..7570c2fa 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -1,10 +1,13 @@ +require: rubocop-rails require: rubocop-performance # Start with Spotifys style guide as a base then customize from there inherit_from: - - .rubocop_shopify_styleguide.yml - .rubocop_todo.yml +inherit_gem: + rubocop-shopify: rubocop.yml + # Apply rule to all cops AllCops: Include: @@ -12,7 +15,7 @@ AllCops: - '/Rakefile' - '/config.ru' Exclude: - - 'vendor/*' + - 'vendor/**/*' - 'node_modules/**/*' - 'spec/**/*' - 'bin/*' diff --git a/.rubocop_shopify_styleguide.yml b/.rubocop_shopify_styleguide.yml deleted file mode 100644 index 8c9f268a..00000000 --- a/.rubocop_shopify_styleguide.yml +++ /dev/null @@ -1,1090 +0,0 @@ -# http://shopify.github.io/ruby-style-guide/rubocop.yml -# - -Layout/AccessModifierIndentation: - EnforcedStyle: indent - SupportedStyles: - - outdent - - indent - IndentationWidth: - -Style/Alias: - EnforcedStyle: prefer_alias_method - SupportedStyles: - - prefer_alias - - prefer_alias_method - -Layout/AlignHash: - EnforcedHashRocketStyle: key - EnforcedColonStyle: key - EnforcedLastArgumentHashStyle: ignore_implicit - SupportedLastArgumentHashStyles: - - always_inspect - - always_ignore - - ignore_implicit - - ignore_explicit - -Layout/AlignParameters: - EnforcedStyle: with_fixed_indentation - SupportedStyles: - - with_first_parameter - - with_fixed_indentation - IndentationWidth: - -Style/AndOr: - EnforcedStyle: always - SupportedStyles: - - always - - conditionals - -Style/BarePercentLiterals: - EnforcedStyle: bare_percent - SupportedStyles: - - percent_q - - bare_percent - -Style/BlockDelimiters: - EnforcedStyle: line_count_based - SupportedStyles: - - line_count_based - - semantic - - braces_for_chaining - ProceduralMethods: - - benchmark - - bm - - bmbm - - create - - each_with_object - - measure - - new - - realtime - - tap - - with_object - FunctionalMethods: - - let - - let! - - subject - - watch - IgnoredMethods: - - lambda - - proc - - it - -Style/BracesAroundHashParameters: - EnforcedStyle: no_braces - SupportedStyles: - - braces - - no_braces - - context_dependent - -Layout/CaseIndentation: - EnforcedStyle: end - SupportedStyles: - - case - - end - IndentOneStep: false - IndentationWidth: - -Style/ClassAndModuleChildren: - EnforcedStyle: nested - SupportedStyles: - - nested - - compact - -Style/ClassCheck: - EnforcedStyle: is_a? - SupportedStyles: - - is_a? - - kind_of? - -Style/CommandLiteral: - EnforcedStyle: backticks - SupportedStyles: - - backticks - - percent_x - - mixed - AllowInnerBackticks: false - -Style/ConditionalAssignment: - EnforcedStyle: assign_to_condition - SupportedStyles: - - assign_to_condition - - assign_inside_condition - SingleLineConditionsOnly: true - -Layout/DotPosition: - EnforcedStyle: leading - SupportedStyles: - - leading - - trailing - -Style/EmptyElse: - EnforcedStyle: both - SupportedStyles: - - empty - - nil - - both - -Layout/EmptyLineBetweenDefs: - AllowAdjacentOneLineDefs: false - -Layout/EmptyLinesAroundBlockBody: - EnforcedStyle: no_empty_lines - SupportedStyles: - - empty_lines - - no_empty_lines - -Layout/EmptyLinesAroundClassBody: - EnforcedStyle: no_empty_lines - SupportedStyles: - - empty_lines - - empty_lines_except_namespace - - no_empty_lines - -Layout/EmptyLinesAroundModuleBody: - EnforcedStyle: no_empty_lines - SupportedStyles: - - empty_lines - - empty_lines_except_namespace - - no_empty_lines - -Layout/ExtraSpacing: - AllowForAlignment: true - ForceEqualSignAlignment: false - -Naming/FileName: - Exclude: [] - ExpectMatchingDefinition: false - Regex: - IgnoreExecutableScripts: true - -Layout/IndentFirstArgument: - EnforcedStyle: consistent - SupportedStyles: - - consistent - - special_for_inner_method_call - - special_for_inner_method_call_in_parentheses - IndentationWidth: - -Style/For: - EnforcedStyle: each - SupportedStyles: - - for - - each - -Style/FormatString: - EnforcedStyle: format - SupportedStyles: - - format - - sprintf - - percent - -Style/FrozenStringLiteralComment: - Details: >- - Add `# frozen_string_literal: true` to the top of the file. Frozen string - literals will become the default in a future Ruby version, and we want to - make sure we're ready. - SupportedStyles: - - when_needed - - always - - never - -Style/HashSyntax: - EnforcedStyle: ruby19 - SupportedStyles: - - ruby19 - - hash_rockets - - no_mixed_keys - - ruby19_no_mixed_keys - UseHashRocketsWithSymbolValues: false - PreferHashRocketsForNonAlnumEndingSymbols: false - -Layout/IndentationConsistency: - EnforcedStyle: normal - SupportedStyles: - - normal - - rails - -Layout/IndentationWidth: - Width: 2 - -Layout/IndentFirstArrayElement: - EnforcedStyle: consistent - SupportedStyles: - - special_inside_parentheses - - consistent - - align_brackets - IndentationWidth: - -Layout/IndentAssignment: - IndentationWidth: - -Layout/IndentFirstHashElement: - EnforcedStyle: consistent - SupportedStyles: - - special_inside_parentheses - - consistent - - align_braces - IndentationWidth: - -Style/LambdaCall: - EnforcedStyle: call - SupportedStyles: - - call - - braces - -Style/Next: - EnforcedStyle: skip_modifier_ifs - MinBodyLength: 3 - SupportedStyles: - - skip_modifier_ifs - - always - -Style/NonNilCheck: - IncludeSemanticChanges: false - -Style/MethodDefParentheses: - EnforcedStyle: require_parentheses - SupportedStyles: - - require_parentheses - - require_no_parentheses - - require_no_parentheses_except_multiline - -Naming/MethodName: - EnforcedStyle: snake_case - SupportedStyles: - - snake_case - - camelCase - -Layout/MultilineArrayBraceLayout: - EnforcedStyle: symmetrical - SupportedStyles: - - symmetrical - - new_line - - same_line - -Layout/MultilineHashBraceLayout: - EnforcedStyle: symmetrical - SupportedStyles: - - symmetrical - - new_line - - same_line - -Layout/MultilineMethodCallBraceLayout: - EnforcedStyle: symmetrical - SupportedStyles: - - symmetrical - - new_line - - same_line - -Layout/MultilineMethodCallIndentation: - EnforcedStyle: indented - SupportedStyles: - - aligned - - indented - - indented_relative_to_receiver - IndentationWidth: 2 - -Layout/MultilineMethodDefinitionBraceLayout: - EnforcedStyle: symmetrical - SupportedStyles: - - symmetrical - - new_line - - same_line - -Style/NumericLiteralPrefix: - EnforcedOctalStyle: zero_only - SupportedOctalStyles: - - zero_with_o - - zero_only - -Style/ParenthesesAroundCondition: - AllowSafeAssignment: true - -Style/PercentLiteralDelimiters: - PreferredDelimiters: - '%': '()' - '%i': '()' - '%q': '()' - '%Q': '()' - '%r': '{}' - '%s': '()' - '%w': '()' - '%W': '()' - '%x': '()' - -Style/PercentQLiterals: - EnforcedStyle: lower_case_q - SupportedStyles: - - lower_case_q - - upper_case_q - -Naming/PredicateName: - NamePrefix: - - is_ - NamePrefixBlacklist: - - is_ - NameWhitelist: - - is_a? - Exclude: - - 'spec/**/*' - -Style/PreferredHashMethods: - EnforcedStyle: short - SupportedStyles: - - short - - verbose - -Style/RaiseArgs: - EnforcedStyle: exploded - SupportedStyles: - - compact - - exploded - -Style/RedundantReturn: - AllowMultipleReturnValues: false - -Style/RegexpLiteral: - EnforcedStyle: slashes - SupportedStyles: - - slashes - - percent_r - - mixed - AllowInnerSlashes: false - -Style/SafeNavigation: - ConvertCodeThatCanStartToReturnNil: false - Enabled: true - -Lint/SafeNavigationChain: - Enabled: true - -Style/Semicolon: - AllowAsExpressionSeparator: false - -Style/SignalException: - EnforcedStyle: only_raise - SupportedStyles: - - only_raise - - only_fail - - semantic - -Style/SingleLineMethods: - AllowIfMethodIsEmpty: true - -Layout/SpaceBeforeFirstArg: - AllowForAlignment: true - -Style/SpecialGlobalVars: - EnforcedStyle: use_english_names - SupportedStyles: - - use_perl_names - - use_english_names - -Style/StabbyLambdaParentheses: - EnforcedStyle: require_parentheses - SupportedStyles: - - require_parentheses - - require_no_parentheses - -Style/StringLiteralsInInterpolation: - EnforcedStyle: single_quotes - SupportedStyles: - - single_quotes - - double_quotes - -Layout/SpaceAroundBlockParameters: - EnforcedStyleInsidePipes: no_space - SupportedStylesInsidePipes: - - space - - no_space - -Layout/SpaceAroundEqualsInParameterDefault: - EnforcedStyle: space - SupportedStyles: - - space - - no_space - -Layout/SpaceAroundOperators: - AllowForAlignment: true - -Layout/SpaceBeforeBlockBraces: - EnforcedStyle: space - EnforcedStyleForEmptyBraces: space - SupportedStyles: - - space - - no_space - -Layout/SpaceInsideBlockBraces: - EnforcedStyle: space - SupportedStyles: - - space - - no_space - EnforcedStyleForEmptyBraces: no_space - SpaceBeforeBlockParameters: true - -Layout/SpaceInsideHashLiteralBraces: - EnforcedStyle: space - EnforcedStyleForEmptyBraces: no_space - SupportedStyles: - - space - - no_space - - compact - -Layout/SpaceInsideStringInterpolation: - EnforcedStyle: no_space - SupportedStyles: - - space - - no_space - -Style/SymbolProc: - IgnoredMethods: - - respond_to - - define_method - -Style/TernaryParentheses: - EnforcedStyle: require_no_parentheses - SupportedStyles: - - require_parentheses - - require_no_parentheses - AllowSafeAssignment: true - -Layout/TrailingBlankLines: - EnforcedStyle: final_newline - SupportedStyles: - - final_newline - - final_blank_line - -Style/TrivialAccessors: - ExactNameMatch: true - AllowPredicates: true - AllowDSLWriters: false - IgnoreClassMethods: false - Whitelist: - - to_ary - - to_a - - to_c - - to_enum - - to_h - - to_hash - - to_i - - to_int - - to_io - - to_open - - to_path - - to_proc - - to_r - - to_regexp - - to_str - - to_s - - to_sym - -Naming/VariableName: - EnforcedStyle: snake_case - SupportedStyles: - - snake_case - - camelCase - -Style/WhileUntilModifier: - Enabled: true - -Style/WordArray: - EnforcedStyle: percent - SupportedStyles: - - percent - - brackets - MinSize: 0 - WordRegex: !ruby/regexp /\A[\p{Word}\n\t]+\z/ - -Layout/BlockAlignment: - EnforcedStyleAlignWith: either - SupportedStylesAlignWith: - - either - - start_of_block - - start_of_line - -Layout/DefEndAlignment: - EnforcedStyleAlignWith: start_of_line - SupportedStylesAlignWith: - - start_of_line - - def - -Lint/InheritException: - EnforcedStyle: runtime_error - SupportedStyles: - - runtime_error - - standard_error - -Lint/UnusedBlockArgument: - IgnoreEmptyBlocks: true - AllowUnusedKeywordArguments: false - -Lint/UnusedMethodArgument: - AllowUnusedKeywordArguments: false - IgnoreEmptyMethods: true - -Performance/RedundantMerge: - MaxKeyValuePairs: 2 - -Rails/ActionFilter: - EnforcedStyle: action - SupportedStyles: - - action - - filter - Include: - - app/controllers/**/*.rb - -Rails/Date: - EnforcedStyle: flexible - SupportedStyles: - - strict - - flexible - -Rails/DynamicFindBy: - Whitelist: - - find_by_sql - -Rails/Exit: - Include: - - app/**/*.rb - - config/**/*.rb - - lib/**/*.rb - Exclude: - - 'lib/**/*.rake' - -Rails/FindBy: - Include: - - app/models/**/*.rb - -Rails/FindEach: - Include: - - app/models/**/*.rb - -Rails/HasAndBelongsToMany: - Include: - - app/models/**/*.rb - -Rails/NotNullColumn: - Include: - - db/migrate/*.rb - -Rails/Output: - Include: - - app/**/*.rb - - config/**/*.rb - - db/**/*.rb - - lib/**/*.rb - -Rails/ReadWriteAttribute: - Include: - - app/models/**/*.rb - -Rails/RequestReferer: - EnforcedStyle: referer - SupportedStyles: - - referer - - referrer - -Rails/SafeNavigation: - ConvertTry: false - -Rails/ScopeArgs: - Include: - - app/models/**/*.rb - -Rails/TimeZone: - EnforcedStyle: flexible - SupportedStyles: - - strict - - flexible - -Rails/UniqBeforePluck: - EnforcedStyle: conservative - SupportedStyles: - - conservative - - aggressive - -Rails/Validation: - Include: - - app/models/**/*.rb - -Naming/AccessorMethodName: - Enabled: true - -Layout/AlignArray: - Enabled: true - -Style/ArrayJoin: - Enabled: true - -Naming/AsciiIdentifiers: - Enabled: true - -Style/Attr: - Enabled: true - -Style/BeginBlock: - Enabled: true - -Style/BlockComments: - Enabled: true - -Layout/BlockEndNewline: - Enabled: true - -Style/CaseEquality: - Enabled: true - -Style/CharacterLiteral: - Enabled: true - -Naming/ClassAndModuleCamelCase: - Enabled: true - -Style/ClassMethods: - Enabled: true - -Style/ClassVars: - Enabled: true - -Layout/ClosingParenthesisIndentation: - Enabled: true - -Style/ColonMethodCall: - Enabled: true - -Layout/CommentIndentation: - Enabled: true - -Naming/ConstantName: - Enabled: true - -Style/DefWithParentheses: - Enabled: true - -Style/EachForSimpleLoop: - Enabled: true - -Style/EachWithObject: - Enabled: true - -Layout/ElseAlignment: - Enabled: true - -Style/EmptyCaseCondition: - Enabled: true - -Layout/EmptyLines: - Enabled: true - -Layout/EmptyLinesAroundAccessModifier: - Enabled: true - -Layout/EmptyLinesAroundMethodBody: - Enabled: true - -Style/EmptyLiteral: - Enabled: true - -Style/EndBlock: - Enabled: true - -Layout/EndOfLine: - Enabled: true - -Style/EvenOdd: - Enabled: true - -Layout/InitialIndentation: - Enabled: true - -Lint/FlipFlop: - Enabled: true - -Style/IfInsideElse: - Enabled: true - -Style/IfUnlessModifierOfIfUnless: - Enabled: true - -Style/IfWithSemicolon: - Enabled: true - -Style/IdenticalConditionalBranches: - Enabled: true - -Style/InfiniteLoop: - Enabled: true - -Layout/LeadingCommentSpace: - Enabled: true - -Style/LineEndConcatenation: - Enabled: true - -Style/MethodCallWithoutArgsParentheses: - Enabled: true - -Style/MultilineBlockChain: - Enabled: true - -Layout/MultilineBlockLayout: - Enabled: true - -Style/MultilineIfThen: - Enabled: true - -Style/MultilineMemoization: - Enabled: true - -Style/MultilineTernaryOperator: - Enabled: true - -Style/NegatedIf: - Enabled: true - -Style/NegatedWhile: - Enabled: true - -Style/NestedModifier: - Enabled: true - -Style/NestedParenthesizedCalls: - Enabled: true - -Style/NestedTernaryOperator: - Enabled: true - -Style/NilComparison: - Enabled: true - -Style/Not: - Enabled: true - -Style/OneLineConditional: - Enabled: true - -Naming/BinaryOperatorParameterName: - Enabled: true - -Style/OptionalArguments: - Enabled: true - -Style/ParallelAssignment: - Enabled: true - -Style/PerlBackrefs: - Enabled: true - -Style/Proc: - Enabled: true - -Style/RedundantBegin: - Enabled: true - -Style/RedundantException: - Enabled: true - -Style/RedundantFreeze: - Enabled: true - -Style/RedundantParentheses: - Enabled: true - -Style/RedundantSelf: - Enabled: true - -Layout/RescueEnsureAlignment: - Enabled: true - -Style/RescueModifier: - Enabled: true - -Style/SelfAssignment: - Enabled: true - -Layout/SpaceAfterColon: - Enabled: true - -Layout/SpaceAfterComma: - Enabled: true - -Layout/SpaceAfterMethodName: - Enabled: true - -Layout/SpaceAfterNot: - Enabled: true - -Layout/SpaceAfterSemicolon: - Enabled: true - -Layout/SpaceBeforeComma: - Enabled: true - -Layout/SpaceBeforeComment: - Enabled: true - -Layout/SpaceBeforeSemicolon: - Enabled: true - -Layout/SpaceAroundKeyword: - Enabled: true - -Layout/SpaceInsideArrayPercentLiteral: - Enabled: true - -Layout/SpaceInsidePercentLiteralDelimiters: - Enabled: true - -Layout/SpaceInsideArrayLiteralBrackets: - Enabled: true - -Layout/SpaceInsideParens: - Enabled: true - -Layout/SpaceInsideRangeLiteral: - Enabled: true - -Style/SymbolLiteral: - Enabled: true - -Layout/Tab: - Enabled: true - -Layout/TrailingWhitespace: - Enabled: true - -Style/UnlessElse: - Enabled: true - -Style/UnneededCapitalW: - Enabled: true - -Style/UnneededInterpolation: - Enabled: true - -Style/UnneededPercentQ: - Enabled: true - -Style/VariableInterpolation: - Enabled: true - -Style/WhenThen: - Enabled: true - -Style/WhileUntilDo: - Enabled: true - -Style/ZeroLengthPredicate: - Enabled: true - -Layout/IndentHeredoc: - EnforcedStyle: squiggly - -Lint/AmbiguousOperator: - Enabled: true - -Lint/AmbiguousRegexpLiteral: - Enabled: true - -Lint/CircularArgumentReference: - Enabled: true - -Layout/ConditionPosition: - Enabled: true - -Lint/Debugger: - Enabled: true - -Lint/DeprecatedClassMethods: - Enabled: true - -Lint/DuplicateMethods: - Enabled: true - -Lint/DuplicatedKey: - Enabled: true - -Lint/EachWithObjectArgument: - Enabled: true - -Lint/ElseLayout: - Enabled: true - -Lint/EmptyEnsure: - Enabled: true - -Lint/EmptyInterpolation: - Enabled: true - -Lint/EndInMethod: - Enabled: true - -Lint/EnsureReturn: - Enabled: true - -Lint/FloatOutOfRange: - Enabled: true - -Lint/FormatParameterMismatch: - Enabled: true - -Lint/HandleExceptions: - Enabled: true - -Lint/ImplicitStringConcatenation: - Description: Checks for adjacent string literals on the same line, which could - better be represented as a single string literal. - -Lint/IneffectiveAccessModifier: - Description: Checks for attempts to use `private` or `protected` to set the visibility - of a class method, which does not work. - -Lint/LiteralAsCondition: - Enabled: true - -Lint/LiteralInInterpolation: - Enabled: true - -Lint/Loop: - Description: Use Kernel#loop with break rather than begin/end/until or begin/end/while - for post-loop tests. - -Lint/NestedMethodDefinition: - Enabled: true - -Lint/NextWithoutAccumulator: - Description: Do not omit the accumulator when calling `next` in a `reduce`/`inject` - block. - -Lint/NonLocalExitFromIterator: - Enabled: true - -Lint/ParenthesesAsGroupedExpression: - Enabled: true - -Lint/PercentStringArray: - Enabled: true - -Lint/PercentSymbolArray: - Enabled: true - -Lint/RandOne: - Description: Checks for `rand(1)` calls. Such calls always return `0` and most - likely a mistake. - -Lint/RequireParentheses: - Enabled: true - -Lint/RescueException: - Enabled: true - -Lint/ShadowedException: - Enabled: true - -Lint/ShadowingOuterLocalVariable: - Enabled: true - -Lint/StringConversionInInterpolation: - Enabled: true - -Lint/UnderscorePrefixedVariableName: - Enabled: true - -Lint/UnifiedInteger: - Enabled: true - -Lint/UnneededSplatExpansion: - Enabled: true - -Lint/UnreachableCode: - Enabled: true - -Lint/UselessAccessModifier: - ContextCreatingMethods: [] - -Lint/UselessComparison: - Enabled: true - -Lint/UselessElseWithoutRescue: - Enabled: true - -Lint/UselessSetterCall: - Enabled: true - -Lint/Void: - Enabled: true - -Performance/CaseWhenSplat: - Enabled: true - -Performance/Count: - SafeMode: true - -Performance/Detect: - SafeMode: true - -Performance/DoubleStartEndWith: - Enabled: true - -Performance/EndWith: - Enabled: true - -Performance/FixedSize: - Enabled: true - -Performance/FlatMap: - EnabledForFlattenWithoutParams: false - -Performance/RangeInclude: - Enabled: true - -Performance/RedundantBlockCall: - Enabled: true - -Performance/RedundantMatch: - Enabled: true - -Style/RedundantSortBy: - Enabled: true - -Performance/ReverseEach: - Enabled: true - -Style/Sample: - Enabled: true - -Performance/Size: - Enabled: true - -Performance/CompareWithBlock: - Enabled: true - -Performance/StartWith: - Enabled: true - -Performance/StringReplacement: - Enabled: true - -Rails/DelegateAllowBlank: - Enabled: true - -Rails/HttpPositionalArguments: - Include: - - spec/**/* - - test/**/* - -Rails/OutputSafety: - Enabled: true - -Rails/PluralizationGrammar: - Enabled: true - -Security/Eval: - Enabled: true - -Security/JSONLoad: - Enabled: true - -Style/ModuleFunction: - EnforcedStyle: extend_self diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index a7ab4486..ef4afdcc 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -1,142 +1,7 @@ # This configuration was generated by # `rubocop --auto-gen-config` -# on 2019-03-02 16:51:15 +0100 using RuboCop version 0.65.0. +# on 2021-08-31 01:32:53 UTC using RuboCop version 1.12.1. # The point is for the user to remove these configuration records # one by one as the offenses are removed from the code base. # Note that changes in the inspected code, or installation of new # versions of RuboCop, may require this file to be generated again. - -# Offense count: 180 -Metrics/AbcSize: - Max: 178 - -# Offense count: 13 -# Configuration parameters: CountComments, ExcludedMethods. -# ExcludedMethods: refine -Metrics/BlockLength: - Max: 257 - -# Offense count: 24 -# Configuration parameters: CountBlocks. -Metrics/BlockNesting: - Max: 6 - -# Offense count: 50 -Metrics/CyclomaticComplexity: - Max: 28 - -# Offense count: 171 -# Configuration parameters: CountComments, ExcludedMethods. -Metrics/MethodLength: - Max: 86 - -# Offense count: 2 -# Configuration parameters: CountComments. -Metrics/ModuleLength: - Max: 347 - -# Offense count: 60 -Metrics/PerceivedComplexity: - Max: 33 - -# Offense count: 7 -# Configuration parameters: EnforcedStyle. -# SupportedStyles: snake_case, camelCase -Naming/MethodName: - Exclude: - - 'app/controllers/tag_controller.rb' - - 'app/models/doc_list.rb' - - 'app/models/search_request.rb' - - 'app/services/search_service.rb' - -# Offense count: 8 -# Configuration parameters: NamePrefix, NamePrefixBlacklist, NameWhitelist, MethodDefinitionMacros. -# NamePrefix: is_, has_, have_ -# NamePrefixBlacklist: is_, has_, have_ -# NameWhitelist: is_a? -# MethodDefinitionMacros: define_method, define_singleton_method -Naming/PredicateName: - Exclude: - - 'spec/**/*' - - 'app/controllers/openid_controller.rb' - - 'app/models/drupal_file.rb' - - 'app/models/image.rb' - - 'app/models/node.rb' - - 'app/models/revision.rb' - - 'app/models/tag.rb' - - 'app/models/user.rb' - -# Offense count: 3 -# Configuration parameters: MinNameLength, AllowNamesEndingInNumbers, AllowedNames, ForbiddenNames. -# AllowedNames: io, id, to, by, on, in, at, ip, db -Naming/UncommunicativeMethodParamName: - Exclude: - - 'app/models/doc_list.rb' - - -# Offense count: 9 -# Configuration parameters: EnforcedStyle. -# SupportedStyles: snake_case, camelCase -Naming/VariableName: - Exclude: - - 'app/models/concerns/node_shared.rb' - - 'app/models/doc_list.rb' - - 'app/models/revision.rb' - - 'app/models/search_request.rb' - -# Offense count: 2 -Security/Open: - Exclude: - - 'app/models/image.rb' - - 'app/models/node.rb' - - -# Offense count: 26 -# Configuration parameters: MinBodyLength. -Style/GuardClause: - Exclude: - - 'app/controllers/admin_controller.rb' - - 'app/controllers/application_controller.rb' - - 'app/controllers/features_controller.rb' - - 'app/controllers/notes_controller.rb' - - 'app/controllers/openid_controller.rb' - - 'app/controllers/users_controller.rb' - - 'app/helpers/application_helper.rb' - - 'app/helpers/comment_helper.rb' - - 'app/models/comment.rb' - - 'app/models/node.rb' - - 'app/models/spamaway.rb' - - 'app/models/user.rb' - - 'app/models/user_tag.rb' - - 'app/services/search_criteria.rb' - -# Offense count: 2 -Style/IdenticalConditionalBranches: - Exclude: - # - 'app/controllers/answers_controller.rb' - -# Offense count: 45 -# Cop supports --auto-correct. -Style/IfUnlessModifier: - Enabled: false - - -# Offense count: 1 -Style/MixinUsage: - Exclude: - - 'app/controllers/application_controller.rb' - -# Offense count: 16 -# Cop supports --auto-correct. -# Configuration parameters: AutoCorrect, EnforcedStyle, IgnoredMethods. -# SupportedStyles: predicate, comparison -Style/NumericPredicate: - Exclude: - - 'spec/**/*' - - 'app/controllers/application_controller.rb' - - 'app/controllers/users_controller.rb' - - 'app/controllers/wiki_controller.rb' - - 'app/jobs/digest_mail_job.rb' - - 'app/models/comment.rb' - - 'app/models/concerns/statistics.rb' - - 'app/models/user.rb' diff --git a/Gemfile b/Gemfile index d3d773cd..2e845b83 100644 --- a/Gemfile +++ b/Gemfile @@ -52,8 +52,6 @@ group :dependencies do end group :test do - gem 'rubocop', '~> 0.70.0' - gem 'rubocop-performance' gem 'ruby-prof' gem 'rails-perftest' gem 'rails-controller-testing' @@ -74,15 +72,19 @@ group :development, :test do gem 'faker', '~> 2.12.0' gem 'pry-rails', '~> 0.3.9' gem 'action-cable-testing' + gem 'rubocop', require: false + gem 'rubocop-performance' + gem 'rubocop-rails', require: false + gem 'rubocop-shopify', require: false end group :development do gem 'jshintrb', '~> 0.3.0' gem 'mini_racer', platforms: :ruby gem 'listen', '~> 3.2.1' - gem 'web-console', '~> 3.3' gem 'spring' gem 'spring-watcher-listen', '~> 2.0.0' + gem 'web-console', '~> 3.3' end group :sqlite do diff --git a/Gemfile.lock b/Gemfile.lock index b9ebdd95..f9a8b88c 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -6,72 +6,72 @@ GEM ZenTest (4.12.0) action-cable-testing (0.6.1) actioncable (>= 5.0) - actioncable (5.2.4.3) - actionpack (= 5.2.4.3) + actioncable (5.2.6) + actionpack (= 5.2.6) nio4r (~> 2.0) websocket-driver (>= 0.6.1) - actionmailer (5.2.4.3) - actionpack (= 5.2.4.3) - actionview (= 5.2.4.3) - activejob (= 5.2.4.3) + actionmailer (5.2.6) + actionpack (= 5.2.6) + actionview (= 5.2.6) + activejob (= 5.2.6) mail (~> 2.5, >= 2.5.4) rails-dom-testing (~> 2.0) - actionpack (5.2.4.3) - actionview (= 5.2.4.3) - activesupport (= 5.2.4.3) + actionpack (5.2.6) + actionview (= 5.2.6) + activesupport (= 5.2.6) rack (~> 2.0, >= 2.0.8) rack-test (>= 0.6.3) rails-dom-testing (~> 2.0) rails-html-sanitizer (~> 1.0, >= 1.0.2) - actionview (5.2.4.3) - activesupport (= 5.2.4.3) + actionview (5.2.6) + activesupport (= 5.2.6) builder (~> 3.1) erubi (~> 1.4) rails-dom-testing (~> 2.0) rails-html-sanitizer (~> 1.0, >= 1.0.3) - activejob (5.2.4.3) - activesupport (= 5.2.4.3) + activejob (5.2.6) + activesupport (= 5.2.6) globalid (>= 0.3.6) - activemodel (5.2.4.3) - activesupport (= 5.2.4.3) - activerecord (5.2.4.3) - activemodel (= 5.2.4.3) - activesupport (= 5.2.4.3) + activemodel (5.2.6) + activesupport (= 5.2.6) + activerecord (5.2.6) + activemodel (= 5.2.6) + activesupport (= 5.2.6) arel (>= 9.0) - activestorage (5.2.4.3) - actionpack (= 5.2.4.3) - activerecord (= 5.2.4.3) - marcel (~> 0.3.1) - activesupport (5.2.4.3) + activestorage (5.2.6) + actionpack (= 5.2.6) + activerecord (= 5.2.6) + marcel (~> 1.0.0) + activesupport (5.2.6) concurrent-ruby (~> 1.0, >= 1.0.2) i18n (>= 0.7, < 2) minitest (~> 5.1) tzinfo (~> 1.1) - addressable (2.7.0) + addressable (2.8.0) public_suffix (>= 2.0.2, < 5.0) ansi (1.5.0) arel (9.0.0) - ast (2.4.0) - autoprefixer-rails (10.0.0.2) + ast (2.4.2) + autoprefixer-rails (10.0.3.0) execjs - aws-eventstream (1.1.0) - aws-partitions (1.383.0) - aws-sdk-core (3.109.1) + aws-eventstream (1.1.1) + aws-partitions (1.492.0) + aws-sdk-core (3.119.1) aws-eventstream (~> 1, >= 1.0.2) aws-partitions (~> 1, >= 1.239.0) aws-sigv4 (~> 1.1) jmespath (~> 1.0) - aws-sdk-kms (1.39.0) - aws-sdk-core (~> 3, >= 3.109.0) + aws-sdk-kms (1.47.0) + aws-sdk-core (~> 3, >= 3.119.0) aws-sigv4 (~> 1.1) - aws-sdk-s3 (1.83.1) - aws-sdk-core (~> 3, >= 3.109.0) + aws-sdk-s3 (1.100.0) + aws-sdk-core (~> 3, >= 3.119.0) aws-sdk-kms (~> 1) aws-sigv4 (~> 1.1) - aws-sigv4 (1.2.2) + aws-sigv4 (1.2.4) aws-eventstream (~> 1, >= 1.0.2) bindex (0.8.1) - bootsnap (1.4.8) + bootsnap (1.4.9) msgpack (~> 1.0) bootstrap-sass (3.4.1) autoprefixer-rails (>= 5.2.1) @@ -88,21 +88,37 @@ GEM xpath (~> 3.2) childprocess (3.0.0) climate_control (0.2.0) - codecov (0.2.11) - json - simplecov - coderay (1.1.2) - concurrent-ruby (1.1.7) + codecov (0.6.0) + simplecov (>= 0.15, < 0.22) + coderay (1.1.3) + concurrent-ruby (1.1.9) crass (1.0.6) - docile (1.3.2) - erubi (1.9.0) - execjs (2.7.0) + docile (1.3.5) + erubi (1.10.0) + execjs (2.8.1) faker (2.12.0) i18n (>= 1.6, < 2) - faraday (1.0.1) + faraday (1.7.1) + faraday-em_http (~> 1.0) + faraday-em_synchrony (~> 1.0) + faraday-excon (~> 1.1) + faraday-httpclient (~> 1.0.1) + faraday-net_http (~> 1.0) + faraday-net_http_persistent (~> 1.1) + faraday-patron (~> 1.0) + faraday-rack (~> 1.0) multipart-post (>= 1.2, < 3) - ffi (1.12.2) - friendly_id (5.3.0) + ruby2_keywords (>= 0.0.4) + faraday-em_http (1.0.0) + faraday-em_synchrony (1.0.0) + faraday-excon (1.1.0) + faraday-httpclient (1.0.1) + faraday-net_http (1.0.1) + faraday-net_http_persistent (1.2.0) + faraday-patron (1.0.0) + faraday-rack (1.0.0) + ffi (1.15.3) + friendly_id (5.4.2) activerecord (>= 4.0.0) geokit (1.13.1) geokit-rails (1.1.4) @@ -112,11 +128,10 @@ GEM httparty (0.18.1) mime-types (~> 3.0) multi_xml (>= 0.5.2) - i18n (1.8.5) + i18n (1.8.10) concurrent-ruby (~> 1.0) image_science (1.3.1) RubyInline (~> 3.9) - jaro_winkler (1.5.4) jmespath (1.4.0) jquery-rails (4.4.0) rails-dom-testing (>= 1, < 3) @@ -126,41 +141,43 @@ GEM execjs multi_json (>= 1.3) rake - json (2.3.1) - libv8 (7.3.492.27.1) + json (2.5.1) + libv8-node (15.14.0.1) libxml-ruby (3.1.0) listen (3.2.1) rb-fsevent (~> 0.10, >= 0.10.3) rb-inotify (~> 0.9, >= 0.9.10) - loofah (2.6.0) + loofah (2.12.0) crass (~> 1.0.2) nokogiri (>= 1.5.9) mail (2.7.1) mini_mime (>= 0.1.1) - marcel (0.3.3) - mimemagic (~> 0.3.2) + marcel (1.0.1) method_source (1.0.0) mime-types (3.3.1) mime-types-data (~> 3.2015) - mime-types-data (3.2020.0512) - mini_magick (4.10.1) - mini_mime (1.0.2) + mime-types-data (3.2021.0704) + mimemagic (0.3.10) + nokogiri (~> 1) + rake + mini_magick (4.11.0) + mini_mime (1.1.1) mini_portile2 (2.4.0) - mini_racer (0.2.15) - libv8 (> 7.3) - minitest (5.14.2) - minitest-reporters (1.4.2) + mini_racer (0.4.0) + libv8-node (~> 15.14.0.0) + minitest (5.14.4) + minitest-reporters (1.4.3) ansi builder minitest (>= 5.0) ruby-progressbar - msgpack (1.3.3) - multi_json (1.14.1) + msgpack (1.4.2) + multi_json (1.15.0) multi_xml (0.6.0) multipart-post (2.1.1) mysql2 (0.5.3) net-http-persistent (2.9.4) - nio4r (2.5.2) + nio4r (2.5.8) nokogiri (1.10.10) mini_portile2 (~> 2.4.0) oa-core (0.3.2) @@ -170,7 +187,7 @@ GEM ruby-openid-apps-discovery (~> 1.2.0) open_id_authentication (1.3.0) rack-openid (~> 1.3) - paper_trail (11.0.0) + paper_trail (11.1.0) activerecord (>= 5.2) request_store (~> 1.1) paperclip (6.1.0) @@ -179,20 +196,20 @@ GEM mime-types mimemagic (~> 0.3.0) terrapin (~> 0.6.0) - parallel (1.19.1) - parser (2.7.1.1) - ast (~> 2.4.0) - passenger (6.0.6) + parallel (1.20.1) + parser (3.0.2.0) + ast (~> 2.4.1) + passenger (6.0.10) rack rake (>= 0.8.1) popper_js (1.16.0) - pry (0.13.1) + pry (0.14.1) coderay (~> 1.1) method_source (~> 1.0) pry-rails (0.3.9) pry (>= 0.10.4) - public_suffix (4.0.5) - puma (4.3.6) + public_suffix (4.0.6) + puma (4.3.8) nio4r (~> 2.0) rack (2.2.3) rack-openid (1.3.1) @@ -203,18 +220,18 @@ GEM rack_session_access (0.2.0) builder (>= 2.0.0) rack (>= 1.0.0) - rails (5.2.4.3) - actioncable (= 5.2.4.3) - actionmailer (= 5.2.4.3) - actionpack (= 5.2.4.3) - actionview (= 5.2.4.3) - activejob (= 5.2.4.3) - activemodel (= 5.2.4.3) - activerecord (= 5.2.4.3) - activestorage (= 5.2.4.3) - activesupport (= 5.2.4.3) + rails (5.2.6) + actioncable (= 5.2.6) + actionmailer (= 5.2.6) + actionpack (= 5.2.6) + actionview (= 5.2.6) + activejob (= 5.2.6) + activemodel (= 5.2.6) + activerecord (= 5.2.6) + activestorage (= 5.2.6) + activesupport (= 5.2.6) bundler (>= 1.3.0) - railties (= 5.2.4.3) + railties (= 5.2.6) sprockets-rails (>= 2.0.0) rails-controller-testing (1.0.5) actionpack (>= 5.0.1.rc1) @@ -223,27 +240,28 @@ GEM rails-dom-testing (2.0.3) activesupport (>= 4.2.0) nokogiri (>= 1.6) - rails-html-sanitizer (1.3.0) + rails-html-sanitizer (1.4.2) loofah (~> 2.3) rails-perftest (0.0.7) - railties (5.2.4.3) - actionpack (= 5.2.4.3) - activesupport (= 5.2.4.3) + railties (5.2.6) + actionpack (= 5.2.6) + activesupport (= 5.2.6) method_source rake (>= 0.8.7) thor (>= 0.19.0, < 2.0) rainbow (3.0.0) - rake (13.0.1) - rb-fsevent (0.10.3) + rake (13.0.6) + rb-fsevent (0.11.0) rb-inotify (0.10.1) ffi (~> 1.0) rdiscount (2.2.0.2) recaptcha (5.5.0) json - redcarpet (3.5.0) - regexp_parser (1.7.1) + redcarpet (3.5.1) + regexp_parser (1.8.2) request_store (1.5.0) rack (>= 1.4) + rexml (3.2.5) right_aws_api (0.3.5) right_cloud_api_base (>= 0.2.6) right_cloud_api_base (0.2.6) @@ -252,28 +270,40 @@ GEM net-http-persistent (~> 2.9) redcarpet (>= 3.0.0) ruby-hmac (>= 0.4.0) - rubocop (0.70.0) - jaro_winkler (~> 1.5.1) + rubocop (1.12.1) parallel (~> 1.10) - parser (>= 2.6) + parser (>= 3.0.0.0) rainbow (>= 2.2.2, < 4.0) + regexp_parser (>= 1.8, < 3.0) + rexml + rubocop-ast (>= 1.2.0, < 2.0) ruby-progressbar (~> 1.7) - unicode-display_width (>= 1.4.0, < 1.7) - rubocop-performance (1.3.0) - rubocop (>= 0.68.0) + unicode-display_width (>= 1.4.0, < 3.0) + rubocop-ast (1.4.1) + parser (>= 2.7.1.5) + rubocop-performance (1.10.2) + rubocop (>= 0.90.0, < 2.0) + rubocop-ast (>= 0.4.0) + rubocop-rails (2.9.1) + activesupport (>= 4.2.0) + rack (>= 1.1) + rubocop (>= 0.90.0, < 2.0) + rubocop-shopify (2.0.1) + rubocop (~> 1.11) ruby-hmac (0.4.0) ruby-openid (2.9.2) ruby-openid-apps-discovery (1.2.0) ruby-openid (>= 2.1.7) - ruby-prof (1.3.2) - ruby-progressbar (1.10.1) - rubyzip (2.3.0) + ruby-prof (1.4.2) + ruby-progressbar (1.11.0) + ruby2_keywords (0.0.5) + rubyzip (2.3.2) sass (3.7.4) sass-listen (~> 4.0.0) sass-listen (4.0.0) rb-fsevent (~> 0.9, >= 0.9.4) rb-inotify (~> 0.9, >= 0.9.7) - sassc (2.3.0) + sassc (2.4.0) ffi (~> 1.9) sassc-rails (2.1.2) railties (>= 4.0.0) @@ -284,15 +314,15 @@ GEM selenium-webdriver (3.142.7) childprocess (>= 0.5, < 4.0) rubyzip (>= 1.2.2) - sentry-raven (3.0.4) + sentry-raven (3.1.2) faraday (>= 1.0) simplecov (0.18.5) docile (~> 1.1) simplecov-html (~> 0.11) - simplecov-html (0.12.2) - skylight (4.3.1) - skylight-core (= 4.3.1) - skylight-core (4.3.1) + simplecov-html (0.12.3) + skylight (4.3.2) + skylight-core (= 4.3.2) + skylight-core (4.3.2) activesupport (>= 4.2.0) spring (2.1.1) spring-watcher-listen (2.0.1) @@ -301,32 +331,32 @@ GEM sprockets (3.7.2) concurrent-ruby (~> 1.0) rack (> 1, < 3) - sprockets-rails (3.2.1) + sprockets-rails (3.2.2) actionpack (>= 4.0) activesupport (>= 4.0) sprockets (>= 3.0.0) sqlite3 (1.4.2) terrapin (0.6.0) climate_control (>= 0.0.3, < 1.0) - thor (1.0.1) + thor (1.1.0) thread_safe (0.3.6) tilt (2.0.10) turbolinks (5.2.1) turbolinks-source (~> 5.2) turbolinks-source (5.2.0) - tzinfo (1.2.7) + tzinfo (1.2.9) thread_safe (~> 0.1) - tzinfo-data (1.2020.1) + tzinfo-data (1.2021.1) tzinfo (>= 1.0.0) uglifier (4.2.0) execjs (>= 0.3.0, < 3) - unicode-display_width (1.6.1) + unicode-display_width (2.0.0) web-console (3.7.0) actionview (>= 5.0) activemodel (>= 5.0) bindex (>= 0.4.0) railties (>= 5.0) - websocket-driver (0.7.2) + websocket-driver (0.7.5) websocket-extensions (>= 0.1.0) websocket-extensions (0.1.5) will_paginate (3.3.0) @@ -377,8 +407,10 @@ DEPENDENCIES rdiscount (= 2.2.0.2) recaptcha (~> 5.5.0) right_aws_api (~> 0.3.5) - rubocop (~> 0.70.0) + rubocop rubocop-performance + rubocop-rails + rubocop-shopify ruby-openid (~> 2.9) ruby-prof sass @@ -403,4 +435,4 @@ RUBY VERSION ruby 2.4.6p354 BUNDLED WITH - 1.17.3 + 2.2.26 diff --git a/app/channels/application_cable/connection.rb b/app/channels/application_cable/connection.rb index a76243b2..e8fc033e 100644 --- a/app/channels/application_cable/connection.rb +++ b/app/channels/application_cable/connection.rb @@ -9,7 +9,8 @@ module ApplicationCable private def find_verified_user - User.find(cookies.signed["user_id"]) + reject_unauthorized_connection if cookies.signed["user_id"].nil? + User.find(cookies.signed["user_id"].id) rescue ActiveRecord::RecordNotFound reject_unauthorized_connection end diff --git a/app/channels/concurrent_editing_channel.rb b/app/channels/concurrent_editing_channel.rb index 35ea0bb7..893e136d 100644 --- a/app/channels/concurrent_editing_channel.rb +++ b/app/channels/concurrent_editing_channel.rb @@ -3,7 +3,7 @@ class ConcurrentEditingChannel < ApplicationCable::Channel def subscribed # Called first to connect user to the channel. - stream_from "concurrent_editing_channel:#{params[:mapSlug]}" + stream_from("concurrent_editing_channel:#{params[:mapSlug]}") end def unsubscribed @@ -12,6 +12,6 @@ class ConcurrentEditingChannel < ApplicationCable::Channel def sync(changes) # Responsible for broadcasting the updated warpables or simply images to the user's connected on this channel. - ActionCable.server.broadcast "concurrent_editing_channel:#{changes['map_slug']}", changes + ActionCable.server.broadcast("concurrent_editing_channel:#{changes["map_slug"]}", changes) end end diff --git a/app/controllers/annotations_controller.rb b/app/controllers/annotations_controller.rb index 0a0f780f..0ae53314 100644 --- a/app/controllers/annotations_controller.rb +++ b/app/controllers/annotations_controller.rb @@ -5,7 +5,7 @@ class AnnotationsController < ApplicationController before_action :find_map def index - render file: 'annotations/index.json.erb', content_type: 'application/json' + render(file: 'annotations/index.json.erb', content_type: 'application/json') end def create @@ -20,38 +20,38 @@ class AnnotationsController < ApplicationController style: geojson[:properties][:style] ) @annotation.user_id = current_user.id if logged_in? - redirect_to map_annotation_url(@map, @annotation) if @annotation.save + redirect_to(map_annotation_url(@map, @annotation)) if @annotation.save end end end def show - @annotation = Annotation.find params[:id] - render file: 'annotations/show.json.erb', content_type: 'application/json' + @annotation = Annotation.find(params[:id]) + render(file: 'annotations/show.json.erb', content_type: 'application/json') end def update - @annotation = Annotation.find params[:id] + @annotation = Annotation.find(params[:id]) geojson = params[:annotation] return if @annotation.user_id.nil? || current_user.can_edit?(@annotation) Annotation.update(@annotation.id, - coordinates: geojson[:geometry][:coordinates], - text: geojson[:properties][:textContent], - style: geojson[:properties][:style]) - render file: 'annotations/update.json.erb', - content_type: 'application/json' + coordinates: geojson[:geometry][:coordinates], + text: geojson[:properties][:textContent], + style: geojson[:properties][:style]) + render(file: 'annotations/update.json.erb', + content_type: 'application/json') end def destroy - @annotation = Annotation.find params[:id] + @annotation = Annotation.find(params[:id]) # if current_user.can_delete?(@annotation) @annotation.delete - head :ok + head(:ok) # end end def find_map - @map = Map.find params[:map_id] + @map = Map.find(params[:map_id]) end end diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 782efc64..d63c492f 100755 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -41,7 +41,7 @@ class ApplicationController < ActionController::Base unless logged_in? path_info = request.env['PATH_INFO'] flash[:warning] = 'You must be logged in to access this section' - redirect_to '/login?back_to=' + path_info.to_param # halts request cycle + redirect_to('/login?back_to=' + path_info.to_param) # halts request cycle end end @@ -51,7 +51,7 @@ class ApplicationController < ActionController::Base begin user_id && User.find(user_id) ? true : false rescue StandardError - return false + false end end diff --git a/app/controllers/comments_controller.rb b/app/controllers/comments_controller.rb index b147be42..7291e441 100644 --- a/app/controllers/comments_controller.rb +++ b/app/controllers/comments_controller.rb @@ -14,24 +14,24 @@ class CommentsController < ApplicationController end respond_to do |format| - format.html { render partial: 'comments/comment', locals: { comment: @comment } } - format.json { render json: @comment, status: :created } + format.html { render(partial: 'comments/comment', locals: { comment: @comment }) } + format.json { render(json: @comment, status: :created) } end else # we intercept this message in /app/assets/javascripts/maps.js - render plain: 'Login required.' + render(plain: 'Login required.') end end def update - @comment = Comment.find params[:id] + @comment = Comment.find(params[:id]) if logged_in? && current_user.can_edit?(@comment) @comment.update_attributes(comment_params) - redirect_to @comment.map + redirect_to(@comment.map) else flash[:error] = 'You do not have permissions to update that comment.' - redirect_to '/login' + redirect_to('/login') end end @@ -44,7 +44,7 @@ class CommentsController < ApplicationController else flash[:error] = 'You do not have permission to delete that comment.' end - redirect_to @comment.map + redirect_to(@comment.map) end private diff --git a/app/controllers/export_controller.rb b/app/controllers/export_controller.rb index 87376dad..e117ac3b 100644 --- a/app/controllers/export_controller.rb +++ b/app/controllers/export_controller.rb @@ -23,12 +23,12 @@ class ExportController < ApplicationController # https://mapknitter.org/warps/yale-farm/yale-farm.jpg def jpg - send_file 'public/warps/' + params[:id] + '/' + params[:id] + '.jpg' + send_file('public/warps/' + params[:id] + '/' + params[:id] + '.jpg') end # https://mapknitter.org/warps/yale-farm/yale-farm-geo.tif def geotiff - send_file 'public/warps/' + params[:id] + '/' + params[:id] + '-geo.tif' + send_file('public/warps/' + params[:id] + '/' + params[:id] + '-geo.tif') end def cancel @@ -39,12 +39,12 @@ class ExportController < ApplicationController export.save if params[:exports] flash[:notice] = 'Export cancelled.' - redirect_to '/exports' + redirect_to('/exports') else - render plain: 'cancelled' + render(plain: 'cancelled') end else - render plain: 'You must be logged in to export, unless the map is anonymous.' + render(plain: 'You must be logged in to export, unless the map is anonymous.') end end @@ -52,19 +52,19 @@ class ExportController < ApplicationController map = Map.find_by(id: params[:id]) export = map.export output = if export.present? - if export.status == 'complete' - 'complete' - elsif export.status == 'none' - 'export not running' - elsif export.status == 'failed' - 'export failed' - else - export.status - end - else - 'export has not been run' + if export.status == 'complete' + 'complete' + elsif export.status == 'none' + 'export not running' + elsif export.status == 'failed' + 'export failed' + else + export.status + end + else + 'export has not been run' end - render plain: output, layout: false + render(plain: output, layout: false) end def status @@ -72,12 +72,12 @@ class ExportController < ApplicationController if export = map.export if export.export_url.present? status_response = ExporterClient.new(export.export_url).status - render json: status_response + render(json: status_response) else - render json: export.to_json + render(json: export.to_json) end else - render json: { status: 'export has not been run' } + render(json: { status: 'export has not been run' }) end end @@ -93,12 +93,12 @@ class ExportController < ApplicationController map_id: params[:map_id], bands_string: 'default bands_string' ) - render json: export.to_json + render(json: export.to_json) end # for demoing remote url functionality during testing def external_url_test - render json: Export.last.to_json + render(json: Export.last.to_json) end private diff --git a/app/controllers/feeds_controller.rb b/app/controllers/feeds_controller.rb index 12740d81..8b814bb6 100644 --- a/app/controllers/feeds_controller.rb +++ b/app/controllers/feeds_controller.rb @@ -8,18 +8,18 @@ class FeedsController < ApplicationController .group('maps.id') .order('id DESC') .limit(20) - render layout: false, template: 'feeds/all' + render(layout: false, template: 'feeds/all') response.headers['Content-Type'] = 'application/xml; charset=utf-8' end def clean - render layout: false, template: 'feeds/clean' + render(layout: false, template: 'feeds/clean') response.headers['Content-Type'] = 'application/xml; charset=utf-8' end def license @maps = @maps.where(license: params[:id]) - render layout: false, template: 'feeds/license' + render(layout: false, template: 'feeds/license') response.headers['Content-Type'] = 'application/xml; charset=utf-8' end @@ -33,17 +33,17 @@ class FeedsController < ApplicationController images += map.warpables end @feed = (@maps + images).sort_by(&:created_at) - render layout: false, template: 'feeds/author' + render(layout: false, template: 'feeds/author') response.headers['Content-Type'] = 'application/xml; charset=utf-8' end def tag - @tag = Tag.find_by_name params[:id] + @tag = Tag.find_by_name(params[:id]) @maps = @tag.maps.paginate(page: params[:page], per_page: 24) - render layout: false, template: 'feeds/tag' + render(layout: false, template: 'feeds/tag') response.headers['Content-Type'] = 'application/xml; charset=utf-8' rescue NoMethodError - render plain: "No maps with tag #{params[:id]}" + render(plain: "No maps with tag #{params[:id]}") end private diff --git a/app/controllers/front_ui_controller.rb b/app/controllers/front_ui_controller.rb index fd9a0371..0842aa9f 100644 --- a/app/controllers/front_ui_controller.rb +++ b/app/controllers/front_ui_controller.rb @@ -10,9 +10,9 @@ class FrontUiController < ApplicationController # TODO: these could use optimization but are better than prev: tag = Tag.where(name: 'featured').first @mappers = if tag - User.where(login: tag.maps.collect(&:author)) - else - [] + User.where(login: tag.maps.collect(&:author)) + else + [] end end @@ -39,7 +39,7 @@ class FrontUiController < ApplicationController session[:lat] = lat session[:lon] = lon - head 200, content_type: "text/html" + head(200, content_type: "text/html") end def about diff --git a/app/controllers/images_controller.rb b/app/controllers/images_controller.rb index 91b146f1..abb3b6f7 100644 --- a/app/controllers/images_controller.rb +++ b/app/controllers/images_controller.rb @@ -1,8 +1,8 @@ require 'open-uri' class ImagesController < ApplicationController rescue_from Errno::ENOENT, Errno::ETIMEDOUT, - OpenURI::HTTPError, Timeout::Error, - with: :url_upload_not_found + OpenURI::HTTPError, Timeout::Error, + with: :url_upload_not_found protect_from_forgery except: %i(update delete) # Convert model to json without including root name. Eg. 'warpable' ActiveRecord::Base.include_root_in_json = false @@ -14,10 +14,10 @@ class ImagesController < ApplicationController if params[:url][0..42] == 'https://s3.amazonaws.com/grassrootsmapping/' url = URI.parse(params[:url]) result = Net::HTTP.get_response(url) - send_data result.body, type: result.content_type, disposition: 'inline' + send_data(result.body, type: result.content_type, disposition: 'inline') end else - redirect_to params[:url] + redirect_to(params[:url]) end end @@ -32,46 +32,46 @@ class ImagesController < ApplicationController map.save respond_to do |format| if @warpable.save - format.html { render json: [@warpable.fup_json].to_json, content_type: 'text/html' } - format.json { render json: { files: [@warpable.fup_json] }, status: :created, location: @warpable.image.url } + format.html { render(json: [@warpable.fup_json].to_json, content_type: 'text/html') } + format.json { render(json: { files: [@warpable.fup_json] }, status: :created, location: @warpable.image.url) } else - format.html { render action: 'new' } - format.json { render json: { files: [@warpable.fup_error_json] }, layout: false } + format.html { render(action: 'new') } + format.json { render(json: { files: [@warpable.fup_error_json] }, layout: false) } end end end # mapknitter.org/import//?url=http://myurl.com/image.jpg def import - map = Map.find_by_name params[:name] + map = Map.find_by_name(params[:name]) @warpable = Warpable.new @warpable.map_id = map.id @warpable.url = params[:url] map.updated_at = Time.now map.save if @warpable.save - redirect_to '/maps/' + params[:name] + redirect_to('/maps/' + params[:name]) else flash[:notice] = 'Sorry, the image failed to import.' - redirect_to '/map/edit/' + params[:name] + redirect_to('/map/edit/' + params[:name]) end end def url_upload_not_found flash[:notice] = 'Sorry, the URL you provided was not valid.' - redirect_to '/map/edit/' + params[:id] + redirect_to('/map/edit/' + params[:id]) end def show - @image = Warpable.find params[:id] + @image = Warpable.find(params[:id]) respond_to do |format| format.html - format.json { render json: @image.map(&:fup_json) } + format.json { render(json: @image.map(&:fup_json)) } end end def update - @warpable = Warpable.find params[:warpable_id] + @warpable = Warpable.find(params[:warpable_id]) if Map.find(@warpable.map_id).anonymous? || logged_in? nodes = [] @@ -94,11 +94,11 @@ class ImagesController < ApplicationController @warpable.save respond_to do |format| - format.html { render html: 'success' } - format.json { render json: @warpable.map.fetch_map_data } + format.html { render(html: 'success') } + format.json { render(json: @warpable.map.fetch_map_data) } end else - render plain: 'You must be logged in to update the image, unless the map is anonymous.' + render(plain: 'You must be logged in to update the image, unless the map is anonymous.') end end @@ -106,7 +106,7 @@ class ImagesController < ApplicationController @warpable = Warpable.find(params[:id]) version = @warpable.versions.find(params[:version]) version.reify&.save - redirect_to @warpable.map + redirect_to(@warpable.map) end def destroy @@ -114,15 +114,15 @@ class ImagesController < ApplicationController if (logged_in? && current_user.can_edit?(@warpable.map)) || @warpable.map.anonymous? @warpable.destroy respond_to do |format| - format.html { render html: { notice: 'Image was successfully destroyed.' } } - format.json { render json: @warpable } + format.html { render(html: { notice: 'Image was successfully destroyed.' }) } + format.json { render(json: @warpable) } end else respond_to do |format| msg = "You do not have privileges to delete this image" flash[:notice] = msg - format.html { redirect_to @warpable.map } - format.json { render json: msg, status: 401 } + format.html { redirect_to(@warpable.map) } + format.json { render(json: msg, status: 401) } end end end diff --git a/app/controllers/maps_controller.rb b/app/controllers/maps_controller.rb index 4b43fc8b..f7f7c5f3 100644 --- a/app/controllers/maps_controller.rb +++ b/app/controllers/maps_controller.rb @@ -11,7 +11,7 @@ class MapsController < ApplicationController def index # show only maps with at least 1 image to reduce spammer interest - redirect_to '/gallery' + redirect_to('/gallery') # @maps = Map.page(params[:page]) # .per_page(20) # .where(archived: false, password: '') @@ -26,7 +26,7 @@ class MapsController < ApplicationController def map @maps = Map.map - render layout: false + render(layout: false) end def new @@ -46,10 +46,10 @@ class MapsController < ApplicationController end if @map.save - redirect_to "/maps/#{@map.slug}/edit" + redirect_to("/maps/#{@map.slug}/edit") else flash.now[:errors] = @map.errors.full_messages - render 'new' + render('new') end end @@ -60,7 +60,7 @@ class MapsController < ApplicationController .sample(4) @unpaginated = true @users = @map.authors - render layout: 'application' + render(layout: 'application') end def archive @@ -80,8 +80,8 @@ class MapsController < ApplicationController def embed @map.zoom ||= 12 @embed = true - response.headers.except! 'X-Frame-Options' # allow use of embed in iframes - render template: 'maps/edit' + response.headers.except!('X-Frame-Options') # allow use of embed in iframes + render(template: 'maps/edit') end def annotate @@ -102,7 +102,7 @@ class MapsController < ApplicationController save_tags(@map) @map.save - redirect_to action: 'show' + redirect_to(action: 'show') end def destroy @@ -112,29 +112,29 @@ class MapsController < ApplicationController redirect_back(fallback_location: "/") else flash[:error] = 'Only admins or map owners may delete maps.' - redirect_to @map + redirect_to(@map) end end # used by leaflet to fetch corner coords of each warpable def images - render json: @map.warpables + render(json: @map.warpables) end # run the export def export @map = Map.find_by(id: params[:id]) if logged_in? || Rails.env.development? || verify_recaptcha(model: @map, message: "ReCAPTCHA thinks you're not a human!") - render plain: @map.run_export(current_user, params[:resolution].to_f) + render(plain: @map.run_export(current_user, params[:resolution].to_f)) else - render plain: 'You must be logged in to export, unless the map is anonymous.' + render(plain: 'You must be logged in to export, unless the map is anonymous.') end end # render list of exports def exports @map = Map.find_by(id: params[:id]) - render partial: 'maps/exports', layout: false + render(partial: 'maps/exports', layout: false) end # list by region @@ -155,8 +155,8 @@ class MapsController < ApplicationController map.image_urls = map.warpables.map { |warpable| warpable.image.url } end respond_to do |format| - format.html { render 'maps/index', layout: 'application' } - format.json { render json: @maps.to_json(methods: :image_urls) } + format.html { render('maps/index', layout: 'application') } + format.json { render(json: @maps.to_json(methods: :image_urls)) } end end @@ -166,13 +166,13 @@ class MapsController < ApplicationController @maps = Map.where(password: '', license: params[:id]) .order('updated_at DESC') .paginate(page: params[:page], per_page: 24) - render 'maps/index', layout: 'application' + render('maps/index', layout: 'application') end def featured @title = 'Featured maps' @maps = Map.featured.paginate(page: params[:page], per_page: 24) - render 'maps/index', layout: 'application' + render('maps/index', layout: 'application') end def search @@ -188,12 +188,12 @@ class MapsController < ApplicationController .except(:styles, :email) @authors = User.where(login: Map.featured.collect(&:author)) .paginate(page: params[:mappers], per_page: 20) - format.html { render 'front_ui/gallery', layout: 'application' } + format.html { render('front_ui/gallery', layout: 'application') } else @title = "Search results for '#{data}'" @maps = Map.search(data).paginate(page: params[:page], per_page: 24) - format.html { render 'front_ui/gallery', layout: 'application' } - format.json { render json: @maps } + format.html { render('front_ui/gallery', layout: 'application') } + format.json { render(json: @maps) } end end end diff --git a/app/controllers/sessions_controller.rb b/app/controllers/sessions_controller.rb index 1fa1eb49..7af6e4fc 100644 --- a/app/controllers/sessions_controller.rb +++ b/app/controllers/sessions_controller.rb @@ -6,7 +6,7 @@ class SessionsController < ApplicationController def new if logged_in? - redirect_to "/" + redirect_to("/") else @referer = params[:back_to] end @@ -21,25 +21,25 @@ class SessionsController < ApplicationController openid_url = CGI.unescape(open_id) # here it is localhost:3000/people/admin/identity for admin # possibly user is providing the whole URL - if openid_url.include? "publiclab" - if openid_url.include? "http" + if openid_url.include?("publiclab") + if openid_url.include?("http") # params[:subaction] contains the value of the provider # provider implies ['github', 'google_oauth2', 'twitter', 'facebook'] url = if params[:subaction] - # provider based authentication - openid_url + "/" + params[:subaction] - else - # form based authentication - openid_url + # provider based authentication + openid_url + "/" + params[:subaction] + else + # form based authentication + openid_url end end else url = if params[:subaction] - # provider based authentication - @openid_url_base + openid_url + @openid_url_suffix + "/" + params[:subaction] - else - # form based authentication - @openid_url_base + openid_url + @openid_url_suffix + # provider based authentication + @openid_url_base + openid_url + @openid_url_suffix + "/" + params[:subaction] + else + # form based authentication + @openid_url_base + openid_url + @openid_url_suffix end end openid_authentication(url, back_to) @@ -52,14 +52,14 @@ class SessionsController < ApplicationController successful_login('', nil) else flash[:error] = "Forbidden" - redirect_to "/" + redirect_to("/") end end def logout session[:user_id] = nil flash[:success] = "You have successfully logged out." - redirect_to '/' + '?_=' + Time.now.to_i.to_s + redirect_to('/' + '?_=' + Time.now.to_i.to_s) end protected @@ -88,13 +88,13 @@ class SessionsController < ApplicationController @user.save! rescue ActiveRecord::RecordInvalid => e puts e - failed_login "User can not be associated to local account. Probably the account already exists with different capitalization!" + failed_login("User can not be associated to local account. Probably the account already exists with different capitalization!") return end end nonce = params[:n] if nonce - tmp = Sitetmp.find_by nonce: nonce + tmp = Sitetmp.find_by(nonce: nonce) if tmp data = tmp.attributes data.delete("nonce") @@ -105,12 +105,12 @@ class SessionsController < ApplicationController end @current_user = @user if site - successful_login back_to, site.id + successful_login(back_to, site.id) else - successful_login back_to, nil + successful_login(back_to, nil) end else - failed_login result.message + failed_login(result.message) return false end end @@ -120,19 +120,19 @@ class SessionsController < ApplicationController def failed_login(message = "Authentication failed.") flash[:danger] = message - redirect_to '/' + redirect_to('/') end def successful_login(back_to, id) session[:user_id] = @current_user.id flash[:success] = "You have successfully logged in." if id - redirect_to '/sites/' + id.to_s + '/upload' + redirect_to('/sites/' + id.to_s + '/upload') else if back_to - redirect_to back_to + redirect_to(back_to) else - redirect_to '/sites' + redirect_to('/sites') end end end diff --git a/app/controllers/tags_controller.rb b/app/controllers/tags_controller.rb index f9607b9d..e59062bf 100644 --- a/app/controllers/tags_controller.rb +++ b/app/controllers/tags_controller.rb @@ -5,22 +5,22 @@ class TagsController < ApplicationController @map = Map.find_by(slug: params[:map_id]) if logged_in? save_tags(@map) - redirect_to @map + redirect_to(@map) else flash[:error] = 'You must be logged in to add tags' - redirect_to "/login?back_to=/maps/#{@map.slug}" + redirect_to("/login?back_to=/maps/#{@map.slug}") end end def show - @tag = Tag.find_by_name params[:id] + @tag = Tag.find_by_name(params[:id]) @maps = @tag.maps.paginate(page: params[:page], per_page: 24) @title = "Maps tagged with ' #{@tag.name} '" tag = Tag.where(name: 'featured').first # note that this is not a join table but the .maps method still works @unpaginated = true @authors = User.where(login: tag.maps.collect(&:author)) if tag @authors ||= [] - render template: 'tags/index' + render(template: 'tags/index') end def destroy @@ -29,10 +29,10 @@ class TagsController < ApplicationController if logged_in? && current_user.can_delete?(@tag) @tag.delete flash[:notice] = "Tag #{@tag.name} deleted." - redirect_to @tag.map + redirect_to(@tag.map) else flash[:error] = 'You must be logged in to delete tags.' - redirect_to '/login' + redirect_to('/login') end end diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 5dc4f187..00a2c062 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -15,7 +15,7 @@ class UsersController < ApplicationController .group('maps.user_id') .order(sort_column + ' ' + sort_direction) .paginate(page: params[:page], per_page: 24) - render 'users/index' + render('users/index') end private @@ -30,6 +30,6 @@ class UsersController < ApplicationController def user_params params.require(:user).permit(:login, :email, :name, - :password, :password_confirmation) + :password, :password_confirmation) end end diff --git a/app/controllers/utility_controller.rb b/app/controllers/utility_controller.rb index 31264639..fdbdf938 100644 --- a/app/controllers/utility_controller.rb +++ b/app/controllers/utility_controller.rb @@ -5,6 +5,6 @@ class UtilityController < ApplicationController # /z/x/y.png # /z/x/(2*z-y-1).png y = 2**params[:z].to_i - params[:y].to_i - 1 - redirect_to "/tms/#{params[:id]}/#{params[:z]}/#{params[:x]}/#{y}.png" + redirect_to("/tms/#{params[:id]}/#{params[:z]}/#{params[:x]}/#{y}.png") end end diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 5d8039ef..f306a8a0 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -19,13 +19,13 @@ module ApplicationHelper unless object.nil? || object.errors.blank? html << "
\n" html << if message.blank? - if object.new_record? - "\t\t
There was a problem creating the #{object.class.name.humanize.downcase}
\n" - else - "\t\t
There was a problem updating the #{object.class.name.humanize.downcase}
\n" - end - else - "
#{message}
" + if object.new_record? + "\t\t
There was a problem creating the #{object.class.name.humanize.downcase}
\n" + else + "\t\t
There was a problem updating the #{object.class.name.humanize.downcase}
\n" + end + else + "
#{message}
" end html << "\t\t