1
0
Fork 0
This repository has been archived on 2023-03-27. You can view files and clone it, but cannot push or open issues or pull requests.
lpr-partynest/spec/policies/membership_app_policy_spec.rb

38 lines
1 KiB
Ruby
Raw Normal View History

2018-11-29 19:17:26 -05:00
# frozen_string_literal: true
require 'rails_helper'
RSpec.describe MembershipAppPolicy do
2018-12-13 00:16:24 -05:00
subject { described_class.new account, record }
let :resolved_scope do
described_class::Scope.new(account, MembershipApp.all).resolve
end
2018-12-13 00:36:00 -05:00
let!(:record) { create :membership_app, account: owner }
2018-12-13 00:16:24 -05:00
let!(:other_record) { create :membership_app }
let(:owner) { create %i[guest_account usual_account].sample }
context 'when owner is authenticated' do
2018-12-13 00:36:00 -05:00
let(:account) { owner }
2018-12-13 00:16:24 -05:00
it { is_expected.to permit_action :show }
it { is_expected.to permit_new_and_create_actions }
it { is_expected.to forbid_actions %i[index destroy] }
it { is_expected.to forbid_edit_and_update_actions }
specify { expect(resolved_scope).to be_empty }
end
for_account_types nil, :guest, :usual, :superuser do
it { is_expected.to permit_new_and_create_actions }
it { is_expected.to forbid_actions %i[index show destroy] }
it { is_expected.to forbid_edit_and_update_actions }
specify { expect(resolved_scope).to be_empty }
end
2018-11-29 19:17:26 -05:00
end