Skip to content
This repository has been archived by the owner on Jan 10, 2025. It is now read-only.

Commit

Permalink
Append engine mount
Browse files Browse the repository at this point in the history
  • Loading branch information
gmcgibbon committed Aug 4, 2020
1 parent 9d54dae commit d7e013f
Show file tree
Hide file tree
Showing 4 changed files with 71 additions and 38 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ Style/Alias:
- prefer_alias
- prefer_alias_method

Layout/AlignHash:
Layout/HashAlignment:
EnforcedHashRocketStyle: key
EnforcedColonStyle: key
EnforcedLastArgumentHashStyle: ignore_implicit
Expand All @@ -30,7 +30,7 @@ Layout/AlignHash:
- ignore_implicit
- ignore_explicit

Layout/AlignParameters:
Layout/ParameterAlignment:
EnforcedStyle: with_fixed_indentation
SupportedStyles:
- with_first_parameter
Expand Down Expand Up @@ -76,13 +76,6 @@ Style/BlockDelimiters:
- proc
- it

Style/BracesAroundHashParameters:
EnforcedStyle: no_braces
SupportedStyles:
- braces
- no_braces
- context_dependent

Layout/CaseIndentation:
EnforcedStyle: end
SupportedStyles:
Expand Down Expand Up @@ -172,7 +165,7 @@ Naming/FileName:
Regex:
IgnoreExecutableScripts: true

Layout/IndentFirstArgument:
Layout/FirstArgumentIndentation:
EnforcedStyle: consistent
SupportedStyles:
- consistent
Expand Down Expand Up @@ -225,18 +218,18 @@ Layout/IndentationConsistency:
Layout/IndentationWidth:
Width: 2

Layout/IndentFirstArrayElement:
Layout/FirstArrayElementIndentation:
EnforcedStyle: consistent
SupportedStyles:
- special_inside_parentheses
- consistent
- align_brackets
IndentationWidth:

Layout/IndentAssignment:
Layout/AssignmentIndentation:
IndentationWidth:

Layout/IndentFirstHashElement:
Layout/FirstHashElementIndentation:
EnforcedStyle: consistent
SupportedStyles:
- special_inside_parentheses
Expand Down Expand Up @@ -340,9 +333,9 @@ Style/PercentQLiterals:
Naming/PredicateName:
NamePrefix:
- is_
NamePrefixBlacklist:
ForbiddenPrefixes:
- is_
NameWhitelist:
AllowedMethods:
- is_a?
Exclude:
- 'spec/**/*'
Expand Down Expand Up @@ -467,7 +460,7 @@ Style/TernaryParentheses:
- require_no_parentheses
AllowSafeAssignment: true

Layout/TrailingBlankLines:
Layout/TrailingEmptyLines:
EnforcedStyle: final_newline
SupportedStyles:
- final_newline
Expand All @@ -478,7 +471,7 @@ Style/TrivialAccessors:
AllowPredicates: true
AllowDSLWriters: false
IgnoreClassMethods: false
Whitelist:
AllowedMethods:
- to_ary
- to_a
- to_c
Expand Down Expand Up @@ -509,7 +502,7 @@ Style/WhileUntilModifier:
Metrics/BlockNesting:
Max: 3

Metrics/LineLength:
Layout/LineLength:
Max: 120
AllowHeredoc: true
AllowURI: true
Expand Down Expand Up @@ -561,7 +554,7 @@ Lint/UnusedMethodArgument:
Naming/AccessorMethodName:
Enabled: true

Layout/AlignArray:
Layout/ArrayAlignment:
Enabled: true

Style/ArrayJoin:
Expand All @@ -584,6 +577,7 @@ Layout/BlockEndNewline:

Style/CaseEquality:
Enabled: true
AllowOnConstant: true

Style/CharacterLiteral:
Enabled: true
Expand Down Expand Up @@ -666,6 +660,9 @@ Style/IfWithSemicolon:
Style/IdenticalConditionalBranches:
Enabled: true

Layout/IndentationStyle:
Enabled: true

Style/InfiniteLoop:
Enabled: true

Expand Down Expand Up @@ -810,22 +807,19 @@ Layout/SpaceInsideRangeLiteral:
Style/SymbolLiteral:
Enabled: true

Layout/Tab:
Enabled: true

Layout/TrailingWhitespace:
Enabled: true

Style/UnlessElse:
Enabled: true

Style/UnneededCapitalW:
Style/RedundantCapitalW:
Enabled: true

Style/UnneededInterpolation:
Style/RedundantInterpolation:
Enabled: true

Style/UnneededPercentQ:
Style/RedundantPercentQ:
Enabled: true

Style/VariableInterpolation:
Expand All @@ -840,8 +834,8 @@ Style/WhileUntilDo:
Style/ZeroLengthPredicate:
Enabled: true

Layout/IndentHeredoc:
EnforcedStyle: squiggly
Layout/HeredocIndentation:
Enabled: true

Lint/AmbiguousOperator:
Enabled: true
Expand All @@ -864,7 +858,7 @@ Lint/DeprecatedClassMethods:
Lint/DuplicateMethods:
Enabled: true

Lint/DuplicatedKey:
Lint/DuplicateHashKey:
Enabled: true

Lint/EachWithObjectArgument:
Expand All @@ -879,9 +873,6 @@ Lint/EmptyEnsure:
Lint/EmptyInterpolation:
Enabled: true

Lint/EndInMethod:
Enabled: true

Lint/EnsureReturn:
Enabled: true

Expand All @@ -891,8 +882,8 @@ Lint/FloatOutOfRange:
Lint/FormatParameterMismatch:
Enabled: true

Lint/HandleExceptions:
Enabled: true
Lint/SuppressedException:
AllowComments: true

Lint/ImplicitStringConcatenation:
Description: Checks for adjacent string literals on the same line, which could
Expand Down Expand Up @@ -947,7 +938,7 @@ Lint/ShadowedException:
Lint/ShadowingOuterLocalVariable:
Enabled: true

Lint/StringConversionInInterpolation:
Lint/RedundantStringCoercion:
Enabled: true

Lint/UnderscorePrefixedVariableName:
Expand All @@ -956,13 +947,13 @@ Lint/UnderscorePrefixedVariableName:
Lint/UnifiedInteger:
Enabled: true

Lint/UnneededCopDisableDirective:
Lint/RedundantCopDisableDirective:
Enabled: true

Lint/UnneededCopEnableDirective:
Lint/RedundantCopEnableDirective:
Enabled: true

Lint/UnneededSplatExpansion:
Lint/RedundantSplatExpansion:
Enabled: true

Lint/UnreachableCode:
Expand Down Expand Up @@ -1025,3 +1016,6 @@ Style/ModuleFunction:

Lint/OrderedMagicComments:
Enabled: true

Lint/DeprecatedOpenSSLConstant:
Enabled: true
6 changes: 6 additions & 0 deletions gems/quilt_rails/lib/quilt_rails/engine.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,11 @@
module Quilt
class Engine < ::Rails::Engine
isolate_namespace Quilt

initializer(:mount_quilt, before: :add_builtin_route) do |app|
app.routes.append do
mount(Quilt::Engine, at: '/') unless has_named_route?(:quilt)
end
end
end
end
34 changes: 34 additions & 0 deletions gems/quilt_rails/test/controllers/routing_test.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# frozen_string_literal: true

require "test_helper"
require "action_controller"

module Quilt
class RoutingTest < ActionDispatch::IntegrationTest
include ActiveSupport::Testing::Isolation

setup { boot_dummy }

test "routes" do
assert_recognizes(
{ controller: "quilt/performance_report", action: "create" },
{ path: "/performance_report", method: "post" }
)
assert_recognizes(
{ controller: "quilt/ui", action: "index", path: "anything" },
{ path: "/anything" }
)
# Use after https://github.com/rails/rails/pull/39981 is released.
# assert_recognizes({ controller: "quilt/ui", action: "index" }, { path: "/" })
end

private

def boot_dummy
Rails.env = "development"
require_relative "../dummy/config/environment"
@routes = Rails.application.routes
@controller = nil
end
end
end
1 change: 0 additions & 1 deletion gems/quilt_rails/test/dummy/config/routes.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
# frozen_string_literal: true

Rails.application.routes.draw do
mount Quilt::Engine => "/"
end

0 comments on commit d7e013f

Please sign in to comment.