Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/fetchers/service_broker_list_fetcher.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ module VCAP::CloudController
class ServiceBrokerListFetcher < BaseListFetcher
class << self
def fetch(message:, permitted_space_guids: nil, eager_loaded_associations: [])
dataset = ServiceBroker.dataset.eager(eager_loaded_associations)
dataset = ServiceBroker.dataset.eager(eager_loaded_associations).eager(:space)

dataset = dataset.join(:spaces, id: Sequel[:service_brokers][:space_id]) if permitted_space_guids || message.requested?(:space_guids)

Expand Down
7 changes: 7 additions & 0 deletions spec/unit/fetchers/service_broker_list_fetcher_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,13 @@ module VCAP::CloudController
expect(dataset.all.first.associations.key?(:labels)).to be true
expect(dataset.all.first.associations.key?(:annotations)).to be false
end

it 'sets space to nil for global brokers and to the space object for space-scoped brokers' do
brokers = fetcher.fetch(message:).all.index_by(&:name)

expect(brokers[broker.name].associations[:space]).to be_nil
expect(brokers[space_scoped_broker_1.name].associations[:space]).to eq(space_1)
end
end

context 'when filtering by space GUIDs' do
Expand Down
Loading