BeforeEach(func() {
						flagRepo.FindByNameReturns(models.FeatureFlag{Enabled: true}, nil)
					})

					Context("when setting role succeed", func() {
						It("uses the new endpoint to set space role by name", func() {
							runCommand("my-user", "some-org", "some-space", "SpaceManager")

							Expect(userRepo.SetSpaceRoleCalled).To(BeFalse())
							Expect(userRepo.SetSpaceRoleByUsernameCalled).To(BeTrue())
						})
					})

					Context("when setting role fails", func() {
						It("returns the error to user", func() {
							userRepo.SetSpaceRoleByUsernameError = errors.New("oh no, it is broken")

							runCommand("my-user", "some-org", "some-space", "SpaceManager")

							Expect(ui.Outputs).To(ContainSubstrings(
								[]string{"FAILED"},
								[]string{"it is broken"},
							))

						})
					})
				})

				Context("when feature flag 'set_roles_by_username' is disabled", func() {
					BeforeEach(func() {
						flagRepo.FindByNameReturns(models.FeatureFlag{Enabled: false}, nil)