blob: 8144c16e2126d201864a9bab24087895a6368ca5 (
plain)
| 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
43
 | # coding: utf-8
RSpec.describe StopAreaPolicy, type: :policy do
  let( :record ){ build_stubbed :stop_area }
  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 'permitted policy', 'stop_areas.create'
    end
    permissions :destroy? do
      it_behaves_like 'permitted policy', 'stop_areas.destroy'
    end
    permissions :edit? do
      it_behaves_like 'permitted policy', 'stop_areas.update'
    end
    permissions :new? do
      it_behaves_like 'permitted policy', 'stop_areas.create'
    end
    permissions :update? do
      it_behaves_like 'permitted policy', 'stop_areas.update'
    end
  end
end
 |