team_user_spec.rb revision 6514d548e755dd1067259c3eea6b7c05859a84d1
15263a1fe962b15de60448a4d3eaa271d7a7affcEugen Kuksarequire 'spec_helper'
7c7a19761235efff584ee65a1c6dc4aa1735ff64Eugen Kuksa let(:team_admin) { create :user } # admin in team
7c7a19761235efff584ee65a1c6dc4aa1735ff64Eugen Kuksa let(:team_user) { create :user } # non-admin in team
7c7a19761235efff584ee65a1c6dc4aa1735ff64Eugen Kuksa let(:admin_user) { create :team_user, user: team_admin }
15263a1fe962b15de60448a4d3eaa271d7a7affcEugen Kuksa let(:non_admim_user) { team.team_users.non_admin.first }
15263a1fe962b15de60448a4d3eaa271d7a7affcEugen Kuksa it 'have 2 members' do
15263a1fe962b15de60448a4d3eaa271d7a7affcEugen Kuksa expect(team.team_users.count).to eq(2)
15263a1fe962b15de60448a4d3eaa271d7a7affcEugen Kuksa it 'have a admin' do
15263a1fe962b15de60448a4d3eaa271d7a7affcEugen Kuksa expect(team.team_users.admin.first.user).to eq(team_admin)
15263a1fe962b15de60448a4d3eaa271d7a7affcEugen Kuksa it 'have a non-admin' do
15263a1fe962b15de60448a4d3eaa271d7a7affcEugen Kuksa expect(team.team_users.non_admin.first.user).to eq(team_user)
15263a1fe962b15de60448a4d3eaa271d7a7affcEugen Kuksa it 'remove non-admin' do
15263a1fe962b15de60448a4d3eaa271d7a7affcEugen Kuksa expect(non_admim_user.destroy).to be_truthy
15263a1fe962b15de60448a4d3eaa271d7a7affcEugen Kuksa it 'not destroy the last admin' do
6514d548e755dd1067259c3eea6b7c05859a84d1Eugen Kuksa expect { admin_user.destroy }.
15263a1fe962b15de60448a4d3eaa271d7a7affcEugen Kuksa to raise_error(Permission::PowerVaccuumError)
15263a1fe962b15de60448a4d3eaa271d7a7affcEugen Kuksa it 'not remove the last admin flag' do
15263a1fe962b15de60448a4d3eaa271d7a7affcEugen Kuksa expect { admin_user.update_attribute :admin, false }.
15263a1fe962b15de60448a4d3eaa271d7a7affcEugen Kuksa to raise_error(Permission::PowerVaccuumError)