describe UserPolicy do
  let(:policy) { described_class.new(user: user) }

  describe '#manage?' do
    subject { policy.apply(:manage?) }

    context 'when the user is admin' do
      let(:user) { build(:admin) }
      it { is_expected.to eq true }
    end
    context 'when the user is ta' do
      let(:user) { build(:ta) }
      it { is_expected.to eq false }
    end
    context 'when the user is student' do
      let(:user) { build(:student) }
      it { is_expected.to eq false }
    end
  end

  describe '#destroy?' do
    subject { policy.apply(:destroy?) }

    context 'when the user is admin' do
      let(:user) { build(:admin) }
      it { is_expected.to eq false }
    end
    context 'when the user is ta' do
      let(:user) { build(:ta) }
      it { is_expected.to eq false }
    end
    context 'when the user is student' do
      let(:user) { build(:student) }
      it { is_expected.to eq false }
    end
  end
end

describe UserPolicy do
  include PolicyHelper

  describe '#manage?' do
    subject { policy(nil, user) }

    context 'when the user is admin' do
      let(:user) { build(:admin) }
      it { is_expected.to pass :manage? }
    end
    context 'when the user is ta' do
      let(:user) { build(:ta) }
      it { is_expected.not_to pass :manage? }
    end
    context 'when the user is student' do
      let(:user) { build(:student) }
      it { is_expected.not_to pass :manage? }
    end
  end

  describe '#destroy?' do
    subject { policy(nil, user) }

    context 'when the user is admin' do
      let(:user) { build(:admin) }
      it { is_expected.not_to pass :destroy? }
    end
    context 'when the user is ta' do
      let(:user) { build(:ta) }
      it { is_expected.not_to pass :destroy? }
    end
    context 'when the user is student' do
      let(:user) { build(:student) }
      it { is_expected.not_to pass :destroy? }
    end
  end
end

Update user creation auth tests to use custom matcher
users: Update user creation auth tests to use custom matcher
