Exemplo n.º 1
0
			BeforeEach(func() {
				userFields := models.UserFields{GUID: "the-user-guid", Username: "******"}
				userRequirement.GetUserReturns(userFields)
			})

			It("tells the user it is removing the role", func() {
				Expect(err).NotTo(HaveOccurred())
				Expect(ui.Outputs()).To(ContainSubstrings(
					[]string{"Removing role", "OrgManager", "the-user-name", "the-org", "the-user-name"},
					[]string{"OK"},
				))
			})

			It("removes the role using the GUID", func() {
				Expect(err).NotTo(HaveOccurred())
				Expect(userRepo.UnsetOrgRoleByGUIDCallCount()).To(Equal(1))
				actualUserGUID, actualOrgGUID, actualRole := userRepo.UnsetOrgRoleByGUIDArgsForCall(0)
				Expect(actualUserGUID).To(Equal("the-user-guid"))
				Expect(actualOrgGUID).To(Equal("the-org-guid"))
				Expect(actualRole).To(Equal(models.RoleOrgManager))
			})

			Context("when the call to CC fails", func() {
				BeforeEach(func() {
					userRepo.UnsetOrgRoleByGUIDReturns(errors.New("user-repo-error"))
				})

				It("returns an error", func() {
					Expect(err).To(HaveOccurred())
					Expect(err.Error()).To(Equal("user-repo-error"))
				})