<commit_before>require 'rails_helper'

module Renalware
  describe Ability, :type => :model do

    let(:super_admin) { create(:user, :approved, :super_admin) }
    let(:admin) { create(:user, :approved, :admin) }
    let(:clinician) { create(:user, :approved, :clinician) }

    it 'checks and defines permissions for super admins' do
      super_admin_ability = Ability.new(super_admin)
      expect(super_admin_ability.can?(:manage, :all)).to be true
    end
    it 'checks and defines permissions for admins' do
      admin_ability = Ability.new(admin)
      expect(admin_ability.can?(:manage, Drug.new)).to be true
      expect(admin_ability.cannot?(:manage, User.new)).to be true
    end
    it 'checks and defines permissions for clinicians' do
      clinician_ability = Ability.new(clinician)
      expect(clinician_ability.can?(:manage, Patient.new)).to be true
      expect(clinician_ability.cannot?(:manage, Drug.new)).to be true
      expect(clinician_ability.cannot?(:manage, User.new)).to be true
    end
  end
end<commit_msg>Updated ability spec test to allow admin to access user resources.<commit_after>require 'rails_helper'

module Renalware
  describe Ability, :type => :model do

    let(:super_admin) { create(:user, :approved, :super_admin) }
    let(:admin) { create(:user, :approved, :admin) }
    let(:clinician) { create(:user, :approved, :clinician) }

    it 'checks and defines permissions for super admins' do
      super_admin_ability = Ability.new(super_admin)
      expect(super_admin_ability.can?(:manage, :all)).to be true
    end
    it 'checks and defines permissions for admins' do
      admin_ability = Ability.new(admin)
      expect(admin_ability.can?(:manage, Drug.new)).to be true
      expect(admin_ability.cannot?(:manage, Role.new)).to be true
    end
    it 'checks and defines permissions for clinicians' do
      clinician_ability = Ability.new(clinician)
      expect(clinician_ability.can?(:manage, Patient.new)).to be true
      expect(clinician_ability.cannot?(:manage, Drug.new)).to be true
      expect(clinician_ability.cannot?(:manage, User.new)).to be true
    end
  end
end
{'fraction_non_alphanumeric': 0.11673699015471167, 'fraction_numerical': 0.0, 'mean_word_length': 4.009389671361502, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6185806', 'n_tokens_mistral': 691, 'n_tokens_neox': 638, 'n_words': 171}