| 1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
 | RSpec.describe GroupOfLinePolicy, type: :policy do
  let( :record ){ build_stubbed :group_of_line }
  before { stub_policy_scope(record) }
  #
  #  Non Destructive
  #  ---------------
  context 'Non Destructive actions →' do
    permissions :index? do
      it_behaves_like 'always allowed', 'anything', archived_and_finalised: true
    end
    permissions :show? do
      it_behaves_like 'always allowed', 'anything', archived_and_finalised: true
    end
  end
  #
  #  Destructive
  #  -----------
  context 'Destructive actions →' do
    permissions :create? do
      it_behaves_like 'always forbidden', 'group_of_lines.create', archived_and_finalised: true
    end
    permissions :destroy? do
      it_behaves_like 'always forbidden', 'group_of_lines.destroy', archived_and_finalised: true
    end
    permissions :edit? do
      it_behaves_like 'always forbidden', 'group_of_lines.update', archived_and_finalised: true
    end
    permissions :new? do
      it_behaves_like 'always forbidden', 'group_of_lines.create', archived_and_finalised: true
    end
    permissions :update? do
      it_behaves_like 'always forbidden', 'group_of_lines.update', archived_and_finalised: true
    end
  end
end
 |