예제 #1
0
				userFields := models.UserFields{Guid: "the-user-guid", Username: "******"}
				userRequirement.GetUserReturns(userFields)
			})

			It("tells the user it is removing the role", func() {
				cmd.Execute(flagContext)
				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() {
				cmd.Execute(flagContext)
				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("OrgManager"))
			})

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

				It("panics and prints a failure message", func() {
					Expect(func() { cmd.Execute(flagContext) }).To(Panic())
					Expect(ui.Outputs).To(BeInDisplayOrder(
						[]string{"FAILED"},
						[]string{"user-repo-error"},
예제 #2
0
	Context("when logged in", func() {
		BeforeEach(func() {
			requirementsFactory.LoginSuccess = true

			user := models.UserFields{}
			user.Username = "******"
			user.Guid = "some-user-guid"
			org := models.Organization{}
			org.Name = "some-org"
			org.Guid = "some-org-guid"

			requirementsFactory.UserFields = user
			requirementsFactory.Organization = org
		})

		It("unsets a user's org role", func() {
			runCommand("my-username", "my-org", "OrgManager")

			Expect(ui.Outputs).To(ContainSubstrings(
				[]string{"Removing role", "OrgManager", "my-username", "my-org", "my-user"},
				[]string{"OK"},
			))

			userGUID, orgGUID, role := userRepo.UnsetOrgRoleByGuidArgsForCall(0)
			Expect(userGUID).To(Equal("some-user-guid"))
			Expect(role).To(Equal(models.ORG_MANAGER))
			Expect(orgGUID).To(Equal("some-org-guid"))
		})
	})
})