Skip to content

Commit 8581965

Browse files
committed
Can't push apps with app manifests if routes were shared
Check if route shared with space and don't throw error if shared
1 parent 3e1d2f4 commit 8581965

File tree

2 files changed

+18
-2
lines changed

2 files changed

+18
-2
lines changed

app/actions/manifest_route_update.rb

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,8 +90,12 @@ def find_or_create_valid_route(app, manifest_route, user_audit_info)
9090
domain: existing_domain,
9191
manifest_triggered: true
9292
)
93-
elsif route.space.guid != app.space_guid
94-
raise InvalidRoute.new('Routes cannot be mapped to destinations in different spaces')
93+
elsif route.space.guid != app.space_guid
94+
# check if route is shared with space
95+
spaces = route.shared_spaces
96+
if (spaces.blank?) || (!spaces.any? { |space| space.values[:id] == app.space.id })
97+
raise InvalidRoute.new('Routes cannot be mapped to destinations in different spaces')
98+
end
9599
end
96100

97101
return route

spec/unit/actions/manifest_route_update_spec.rb

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,18 @@ module VCAP::CloudController
121121
'Routes cannot be mapped to destinations in different spaces')
122122
end
123123
end
124+
125+
context 'when the route is shared' do
126+
let!(:route_share) { RouteShare.new }
127+
let!(:outside_app) { AppModel.make }
128+
let!(:shared_route) { route_share.create(route, [outside_app.space], user_audit_info) }
129+
130+
it 'succeeds after route share' do
131+
expect do
132+
ManifestRouteUpdate.update(outside_app.guid, message, user_audit_info)
133+
end.not_to raise_error
134+
end
135+
end
124136
end
125137
end
126138

0 commit comments

Comments
 (0)