Skip to content

Commit 330a6b9

Browse files
committed
Adds test for mounting multiple apps as one
Fixes routing to get specs working
1 parent 1421517 commit 330a6b9

File tree

3 files changed

+14
-2
lines changed

3 files changed

+14
-2
lines changed

.rubocop_todo.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,6 @@ Metrics/CyclomaticComplexity:
5050
# URISchemes: http, https
5151
Metrics/LineLength:
5252
Max: 215
53-
5453
# Offense count: 57
5554
# Configuration parameters: CountComments.
5655
Metrics/MethodLength:
@@ -60,6 +59,8 @@ Metrics/MethodLength:
6059
# Configuration parameters: CountComments.
6160
Metrics/ModuleLength:
6261
Max: 212
62+
Exclude:
63+
- 'spec/grape/dsl/routing_spec.rb'
6364

6465
# Offense count: 21
6566
Metrics/PerceivedComplexity:

lib/grape/dsl/routing.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,8 @@ def mount(mounts, opts = {})
8181
mounts = { mounts => '/' } unless mounts.respond_to?(:each_pair)
8282
mounts.each_pair do |app, path|
8383
if app.respond_to?(:mount_instance)
84-
return mount(app.mount_instance(configuration: opts[:with] || {}) => path)
84+
mount(app.mount_instance(configuration: opts[:with] || {}) => path)
85+
next
8586
end
8687
in_setting = inheritable_setting
8788

spec/grape/dsl/routing_spec.rb

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,16 @@ class Dummy
7070

7171
expect(app2.inheritable_setting.to_hash[:namespace_stackable]).to eq(mount_path: ['/app1', '/app2'])
7272
end
73+
74+
it 'mounts multiple routes at once' do
75+
base_app = Class.new(Grape::API)
76+
app1 = Class.new(Grape::API)
77+
app2 = Class.new(Grape::API)
78+
base_app.mount(app1 => '/app1', app2 => '/app2')
79+
80+
expect(app1.inheritable_setting.to_hash[:namespace_stackable]).to eq(mount_path: ['/app1'])
81+
expect(app2.inheritable_setting.to_hash[:namespace_stackable]).to eq(mount_path: ['/app2'])
82+
end
7383
end
7484

7585
describe '.route' do

0 commit comments

Comments
 (0)