-
Notifications
You must be signed in to change notification settings - Fork 369
Can't move routes to other orgs if the space has the same name as owner space #4341
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
philippthun
merged 2 commits into
cloudfoundry:main
from
nookala:snookala/fix-move-route-space-name
May 8, 2025
Merged
Changes from 1 commit
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -7,6 +7,7 @@ module VCAP::CloudController | |
| let(:route) { Route.make domain: SharedDomain.make, space: original_owning_space } | ||
| let(:original_owning_space) { Space.make name: 'original_owning_space' } | ||
| let(:target_space) { Space.make name: 'target_space' } | ||
| let(:target_space_dup_name) { Space.make name: 'original_owning_space' } | ||
| let(:shared_space) { Space.make name: 'shared_space' } | ||
| let(:user_audit_info) { UserAuditInfo.new(user_guid: 'user-guid-1', user_email: '[email protected]') } | ||
|
|
||
|
|
@@ -17,7 +18,7 @@ module VCAP::CloudController | |
|
|
||
| it 'makes the target space the new owner' do | ||
| RouteTransferOwner.transfer(route, target_space, user_audit_info) | ||
| expect(route.space.name).to eq target_space.name | ||
| expect(route.space.id).to eq target_space.id | ||
| end | ||
|
|
||
| context 'route was previously shared with the target space' do | ||
|
|
@@ -26,25 +27,32 @@ module VCAP::CloudController | |
| end | ||
|
|
||
| it 'removes the target space from the list of shared spaces' do | ||
| expect(route.shared_spaces.map(&:name)).to include target_space.name | ||
| expect(route.shared_spaces.map(&:id)).to include target_space.id | ||
| RouteTransferOwner.transfer(route, target_space, user_audit_info) | ||
| route.reload | ||
| expect(route.shared_spaces.map(&:name)).not_to include target_space.name | ||
| expect(route.shared_spaces.map(&:id)).not_to include target_space.id | ||
| end | ||
| end | ||
|
|
||
| it 'shares the route with the original owning space' do | ||
| expect(route.shared_spaces.map(&:name)).not_to include original_owning_space.name | ||
| expect(route.shared_spaces.map(&:id)).not_to include original_owning_space.id | ||
| RouteTransferOwner.transfer(route, target_space, user_audit_info) | ||
| route.reload | ||
| expect(route.shared_spaces.map(&:name)).to include original_owning_space.name | ||
| expect(route.shared_spaces.map(&:id)).to include original_owning_space.id | ||
| end | ||
|
|
||
| context 'target space is already the owning space' do | ||
| it 'does nothing and succeeds' do | ||
| expect { RouteTransferOwner.transfer(route, original_owning_space, user_audit_info) }.not_to raise_error | ||
| expect(route.shared_spaces.map(&:name)).not_to include original_owning_space.name | ||
| expect(route.space.name).to eq original_owning_space.name | ||
| expect(route.shared_spaces.map(&:id)).not_to include original_owning_space.id | ||
| expect(route.space.id).to eq original_owning_space.id | ||
| end | ||
| end | ||
|
|
||
| context 'target space has the same name as the owning space' do | ||
| it 'makes the target space with the same name the new owner' do | ||
| RouteTransferOwner.transfer(route, target_space_dup_name, user_audit_info) | ||
| expect(route.space.id).to eq target_space.id | ||
| end | ||
| end | ||
|
|
||
|
|
@@ -65,25 +73,25 @@ module VCAP::CloudController | |
| expect_any_instance_of(Repositories::RouteEventRepository).not_to receive(:record_route_transfer_owner).with( | ||
| route, user_audit_info, original_owning_space, target_space.guid | ||
| ) | ||
| expect(route.space.name).to eq original_owning_space.name | ||
| expect(route.space.id).to eq original_owning_space.id | ||
| expect do | ||
| RouteTransferOwner.transfer(route, target_space, user_audit_info) | ||
| end.to raise_error('db failure') | ||
| route.reload | ||
| expect(route.space.name).to eq original_owning_space.name | ||
| expect(route.space.id).to eq original_owning_space.id | ||
| end | ||
|
|
||
| it 'does not change the shared spaces' do | ||
| expect_any_instance_of(Repositories::RouteEventRepository).not_to receive(:record_route_transfer_owner).with( | ||
| route, user_audit_info, original_owning_space, target_space.guid | ||
| ) | ||
| expect(route.shared_spaces.length).to eq 1 | ||
| expect(route.shared_spaces.map(&:name)).to include shared_space.name | ||
| expect(route.shared_spaces.map(&:id)).to include shared_space.id | ||
| expect do | ||
| RouteTransferOwner.transfer(route, target_space, user_audit_info) | ||
| end.to raise_error('db failure') | ||
| route.reload | ||
| expect(route.shared_spaces.map(&:name)).to include shared_space.name | ||
| expect(route.shared_spaces.map(&:id)).to include shared_space.id | ||
| expect(route.shared_spaces.length).to eq 1 | ||
| end | ||
| end | ||
|
|
||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.