Skip to content

Commit

Permalink
fix update organization membership and tests (#312)
Browse files Browse the repository at this point in the history
  • Loading branch information
ameesha authored Jun 26, 2024
1 parent 936a57a commit f81e341
Show file tree
Hide file tree
Showing 4 changed files with 194 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/workos/user_management.rb
Original file line number Diff line number Diff line change
Expand Up @@ -866,11 +866,11 @@ def create_organization_membership(user_id:, organization_id:, role_slug: nil)
# @param [String] role_slug The slug of the role to grant to this membership.
#
# @return [WorkOS::OrganizationMembership]
def update_organization_membership(organization_membership_id:, role_slug:)
def update_organization_membership(id:, role_slug:)
request = put_request(
path: "/user_management/organization_memberships/#{id}",
body: {
organization_membership_id: organization_membership_id,
id: id,
role_slug: role_slug,
},
auth: true,
Expand Down
27 changes: 27 additions & 0 deletions spec/lib/workos/user_management_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1074,6 +1074,33 @@
end
end

describe '.update_organization_membership' do
context 'with a valid id' do
it 'returns true' do
VCR.use_cassette('user_management/update_organization_membership/valid') do
organization_membership = WorkOS::UserManagement.update_organization_membership(
id: 'om_01H5JQDV7R7ATEYZDEG0W5PRYS',
role_slug: 'admin',
)

expect(organization_membership.organization_id).to eq('organization_01H5JQDV7R7ATEYZDEG0W5PRYS')
expect(organization_membership.user_id).to eq('user_01H5JQDV7R7ATEYZDEG0W5PRYS')
expect(organization_membership.role).to eq({ slug: 'admin' })
end
end
end

context 'with an invalid id' do
it 'raises an error' do
VCR.use_cassette('user_management/update_organization_membership/invalid') do
expect do
WorkOS::UserManagement.update_organization_membership(id: 'invalid', role_slug: 'admin')
end.to raise_error(WorkOS::NotFoundError, /Organization Membership not found/)
end
end
end
end

describe '.delete_organization_membership' do
context 'with a valid id' do
it 'returns true' do
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit f81e341

Please sign in to comment.