Commit 654a85f3 authored by Tan Le's avatar Tan Le

Extend test for failed user delete case

When user is the sole owner of the group no explicit delete
options are enabled, the method is expected to return the
attempted delete user with error messages attached.

The test is to ensure we honour this interface and does not
cause unexpected failures from the callers.
parent 9ddd2535
...@@ -121,10 +121,17 @@ describe Users::DestroyService do ...@@ -121,10 +121,17 @@ describe Users::DestroyService do
before do before do
solo_owned.group_members = [member] solo_owned.group_members = [member]
service.execute(user) end
it 'returns the user with attached errors' do
expect(service.execute(user)).to be(user)
expect(user.errors.full_messages).to eq([
'You must transfer ownership or delete groups before you can remove user'
])
end end
it 'does not delete the user' do it 'does not delete the user' do
service.execute(user)
expect(User.find(user.id)).to eq user expect(User.find(user.id)).to eq user
end end
end end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment