Skip to content

Conversation

@staaldraad
Copy link

Add and delete users from a team

Add and delete users from a team
Copy link
Contributor

@Ziinc Ziinc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

as discussed, would also need private:admin scope for pseudo rbac

|> add_access_token(user, "private")
|> post(~p"/api/teams/#{main_team.token}/members", %{email: new_member.email})
|> response(204)
|> assert_schema("AcceptedResponse") == ""
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should return created user, should also be a 201 since we're creating a team_user

Comment on lines +245 to +254
test "returns not found if doesn't own the team", %{conn: conn, main_team: main_team} do
invalid_user = insert(:user)
new_member = insert(:user)

assert conn
|> add_access_token(invalid_user, "private")
|> post(~p"/api/teams/#{main_team.token}/members", %{email: new_member.email})
|> json_response(404)
|> assert_schema("NotFoundResponse") == %{error: "Not Found"}
end
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

401 would be more appropriate.

would also need a 400 test for bad team_user attrs

end
end

describe "remove_member/2" do
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
describe "remove_member/2" do
describe "remove_member/2 for team_user with user record" do

Also needs a test for team_user with when there is no user record, which is when they are invited without having a prior account.

end

describe "add_member/2" do
test "adds an existing user to a team", %{
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also needs case where there is no existing user record and we only create the record on team_users table

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants