Merge pull request #9725 from vsmay98/9468-hide-all-references-hub-from-producers-profile

[Shopfront] Hide hub with "hide all references" setup in producers profiles
This commit is contained in:
Maikel
2022-10-10 13:11:49 +11:00
committed by GitHub
2 changed files with 10 additions and 1 deletions

View File

@@ -63,7 +63,7 @@ module Api
def hubs
ActiveModel::ArraySerializer.new(
enterprise.distributors, each_serializer: Api::EnterpriseThinSerializer
enterprise.distributors.not_hidden, each_serializer: Api::EnterpriseThinSerializer
)
end

View File

@@ -50,6 +50,15 @@ describe Api::EnterpriseShopfrontSerializer do
expect(serializer.serializable_hash[:hubs].to_json).to match hub.name
end
context 'when hub is marked as hidden' do
before { hub.update_column(:visible, 'hidden') }
it 'serializes an array of public hubs' do
expect(serializer.serializable_hash[:hubs]).to be_a ActiveModel::ArraySerializer
expect(serializer.serializable_hash[:hubs].to_json).not_to match hub.name
end
end
it "serializes an array of producers that are public or linked by links" do
expect(serializer.serializable_hash[:producers]).to be_a ActiveModel::ArraySerializer
expect(serializer.serializable_hash[:producers].to_json).to match producer.name