From 741ed73cf5aff3dcee6edaad312c8ffc6370422d Mon Sep 17 00:00:00 2001 From: Andy Brett Date: Wed, 24 Feb 2021 11:43:53 -0800 Subject: [PATCH] add specs for enterprises with nil or unknown category --- .../api/cached_enterprise_serializer_spec.rb | 22 +++++++++++++++++++ ...terprise_shopfront_list_serializer_spec.rb | 22 +++++++++++++++++++ 2 files changed, 44 insertions(+) diff --git a/spec/serializers/api/cached_enterprise_serializer_spec.rb b/spec/serializers/api/cached_enterprise_serializer_spec.rb index 523348e74e..9517b31a80 100644 --- a/spec/serializers/api/cached_enterprise_serializer_spec.rb +++ b/spec/serializers/api/cached_enterprise_serializer_spec.rb @@ -97,4 +97,26 @@ describe Api::CachedEnterpriseSerializer do end end end + + describe '#icon' do + context "enterpise has a unrecognized category" do + before do + allow(enterprise).to receive(:category) { "unknown_category" } + end + + it "returns the map producer icon" do + expect(cached_enterprise_serializer.icon).to eq("/map_icons/map_001-producer-only.svg") + end + end + + context "enterpise has a nil category" do + before do + allow(enterprise).to receive(:category) { nil } + end + + it "returns the map producer icon" do + expect(cached_enterprise_serializer.icon).to eq("/map_icons/map_001-producer-only.svg") + end + end + end end diff --git a/spec/serializers/api/enterprise_shopfront_list_serializer_spec.rb b/spec/serializers/api/enterprise_shopfront_list_serializer_spec.rb index 2e6c200355..964c52e295 100644 --- a/spec/serializers/api/enterprise_shopfront_list_serializer_spec.rb +++ b/spec/serializers/api/enterprise_shopfront_list_serializer_spec.rb @@ -19,4 +19,26 @@ describe Api::EnterpriseShopfrontListSerializer do it "serializes icons" do expect(serializer.to_json).to match "map_005-hub.svg" end + + describe '#icon' do + context "enterpise has a unrecognized category" do + before do + allow(enterprise).to receive(:category) { "unknown_category" } + end + + it "returns the map producer icon" do + expect(serializer.icon).to eq("/map_icons/map_001-producer-only.svg") + end + end + + context "enterpise has a nil category" do + before do + allow(enterprise).to receive(:category) { nil } + end + + it "returns the map producer icon" do + expect(serializer.icon).to eq("/map_icons/map_001-producer-only.svg") + end + end + end end