Expect(err).ToNot(HaveOccurred()) Expect(servicePlanVisibilityRepo.CreateCallCount()).To(Equal(0)) Expect(allPlansWereSet).To(BeTrue()) }) }) Context("when disabling access to all plans for a single org", func() { It("deletes the associated visibilities for all limited plans", func() { serviceBuilder.GetServiceByNameForOrgReturns(publicAndLimitedService, nil) servicePlanVisibilityRepo.SearchReturns([]models.ServicePlanVisibilityFields{visibility1}, nil) allPlansSet, err := actor.UpdateOrgForService("my-public-and-limited-service", "org-1", false) Expect(err).ToNot(HaveOccurred()) Expect(servicePlanVisibilityRepo.DeleteCallCount()).To(Equal(1)) Expect(allPlansSet).To(BeFalse()) services := servicePlanVisibilityRepo.SearchArgsForCall(0) Expect(services["organization_guid"]).To(Equal("org-1-guid")) visibilityGuid := servicePlanVisibilityRepo.DeleteArgsForCall(0) Expect(visibilityGuid).To(Equal("visibility-guid-1")) }) It("Does not try to update service plans if they are all public", func() { serviceBuilder.GetServiceByNameForOrgReturns(publicService, nil) allPlansWereSet, err := actor.UpdateOrgForService("my-public-and-limited-service", "org-1", false) Expect(err).ToNot(HaveOccurred()) Expect(servicePlanVisibilityRepo.DeleteCallCount()).To(Equal(0)) Expect(allPlansWereSet).To(BeTrue()) })