Skip to content

Commit ebe5d1e

Browse files
committed
Can't push apps with app manifests if routes were shared
Rename method based on code review
1 parent cb5688e commit ebe5d1e

File tree

4 files changed

+10
-10
lines changed

4 files changed

+10
-10
lines changed

app/actions/manifest_route_update.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ def find_or_create_valid_route(app, manifest_route, user_audit_info)
9292
domain: existing_domain,
9393
manifest_triggered: true
9494
)
95-
elsif route.app_spaces_no_match?(app)
95+
elsif !route.available_in_space?(app.space)
9696
raise InvalidRoute.new('Routes cannot be mapped to destinations in different spaces')
9797
elsif manifest_route[:options] && route[:options] != manifest_route[:options]
9898
# remove nil values from options

app/controllers/v3/routes_controller.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -362,7 +362,7 @@ def validate_app_guids!(apps_hash, desired_app_guids)
362362
end
363363

364364
def validate_app_spaces!(apps_hash, route)
365-
return unless apps_hash.values.any? { |app| route.app_spaces_no_match?(app) }
365+
return unless apps_hash.values.any? { |app| !route.available_in_space?(app.space) }
366366

367367
unprocessable!("Routes destinations must be in either the route's space or the route's shared spaces")
368368
end

app/models/runtime/route.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -194,8 +194,8 @@ def self.user_visibility_filter(user)
194194
}
195195
end
196196

197-
def app_spaces_no_match?(app)
198-
app.space != space && shared_spaces.exclude?(app.space)
197+
def available_in_space?(other_space)
198+
other_space == space || shared_spaces.include?(other_space)
199199
end
200200

201201
delegate :in_suspended_org?, to: :space

spec/unit/models/runtime/route_spec.rb

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1578,13 +1578,13 @@ def assert_invalid_path(path)
15781578
let!(:app) { AppModel.make }
15791579
let!(:route) { Route.make(host: 'potato', domain: domain, path: '/some-path') }
15801580

1581-
it 'no space match and not shared and returns true' do
1582-
expect(route.app_spaces_no_match?(app)).to be(true)
1581+
it 'no space match and not shared and returns false' do
1582+
expect(route.available_in_space?(app.space)).to be(false)
15831583
end
15841584

1585-
it 'match space and returns false' do
1585+
it 'match space and returns true' do
15861586
route.space = app.space
1587-
expect(route.app_spaces_no_match?(app)).to be(false)
1587+
expect(route.available_in_space?(app.space)).to be(true)
15881588
end
15891589
end
15901590

@@ -1595,8 +1595,8 @@ def assert_invalid_path(path)
15951595
let!(:route) { Route.make(host: 'potato', domain: domain, path: '/some-path') }
15961596
let!(:shared_route) { route_share.create(route, [app.space], user_audit_info) }
15971597

1598-
it 'shared space match and returns false' do
1599-
expect(route.app_spaces_no_match?(app)).to be(false)
1598+
it 'shared space match and returns true' do
1599+
expect(route.available_in_space?(app.space)).to be(true)
16001600
end
16011601
end
16021602
end

0 commit comments

Comments
 (0)