|
| 1 | +require 'rails_helper' |
| 2 | + |
| 3 | +RSpec.describe CustomLinkPolicy do |
| 4 | + subject { described_class } |
| 5 | + |
| 6 | + let(:user) { create(:user, casa_org: organization) } |
| 7 | + let(:casa_org) { create :casa_org } |
| 8 | + let(:organization) { build(:casa_org) } |
| 9 | + let(:volunteer) { create :volunteer, :with_single_case, casa_org: organization } |
| 10 | + let(:supervisor) { create :supervisor, casa_org: organization } |
| 11 | + let(:casa_admin) { create :casa_admin, casa_org: organization } |
| 12 | + let(:all_casa_admin) { create :all_casa_admin } |
| 13 | + let(:custom_link) { create(:custom_link, casa_org: organization) } |
| 14 | + let(:valid_attributes) { { text: 'Link Text', url: 'http://example.com', active: true, casa_org: organization } } |
| 15 | + let(:invalid_attributes) { { text: '', url: 'invalid', active: nil } } |
| 16 | + let(:other_org_admin) { create(:casa_admin) } |
| 17 | + |
| 18 | + permissions :create?, :edit?, :new?, :show?, :update? do |
| 19 | + it 'allows same org casa_admins' do |
| 20 | + expect(subject).to permit(casa_admin, custom_link) |
| 21 | + end |
| 22 | + |
| 23 | + it 'does not allow different org casa_admins' do |
| 24 | + expect(subject).not_to permit(other_org_admin, custom_link) |
| 25 | + end |
| 26 | + |
| 27 | + it 'does not permit supervisor' do |
| 28 | + expect(subject).not_to permit(supervisor, custom_link) |
| 29 | + end |
| 30 | + |
| 31 | + it 'does not permit volunteer' do |
| 32 | + expect(subject).not_to permit(volunteer, custom_link) |
| 33 | + end |
| 34 | + end |
| 35 | +end |
0 commit comments