OpenProject is the leading open source project management software.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 
openproject/modules/ldap_groups/spec/models/membership_spec.rb

29 lines
867 B

require 'spec_helper'
describe LdapGroups::Membership, type: :model do
describe 'destroy' do
let(:synchronized_group) { create :ldap_synchronized_group, group: }
let(:group) { create :group }
let(:user) { create :user }
before do
User.system.run_given do
synchronized_group.add_members! [user]
end
end
it 'is removed when the user is destroyed' do
expect(user.ldap_groups_memberships.count).to eq 1
membership = user.ldap_groups_memberships.first
expect(membership.group).to eq(synchronized_group)
expect(membership.user).to eq(user)
expect(synchronized_group.users.count).to eq(1)
user.destroy!
synchronized_group.reload
expect { membership.reload }.to raise_error(ActiveRecord::RecordNotFound)
expect(synchronized_group.users.count).to eq(0)
end
end
end