blob: 656c0dd780d5a672e5948b71a38e03b364b68fe3 (
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
|
RSpec.describe 'Calendars', type: :feature do
login_user
let(:calendar) { create :calendar, organisation: first_organisation, workgroup: first_workgroup }
let(:workgroup) { first_workgroup }
describe 'permissions' do
before do
allow_any_instance_of(CalendarPolicy).to receive(:create?).and_return permission
allow_any_instance_of(CalendarPolicy).to receive(:destroy?).and_return permission
allow_any_instance_of(CalendarPolicy).to receive(:edit?).and_return permission
allow_any_instance_of(CalendarPolicy).to receive(:share?).and_return permission
visit path
end
context 'on show view' do
let( :path ){ workgroup_calendar_path(workgroup, calendar) }
context 'if present → ' do
let( :permission ){ true }
it 'view shows the corresponding buttons' do
expect(page).to have_css('a.btn.btn-default', text: 'Editer')
expect(page).to have_css('a.btn.btn-primary', text: 'Supprimer')
end
end
context 'if absent → ' do
let( :permission ){ false }
it 'view does not show the corresponding buttons' do
expect(page).not_to have_css('a.btn.btn-default', text: 'Editer')
expect(page).not_to have_css('a.btn.btn-primary', text: 'Supprimer')
end
end
end
context 'on edit view' do
let( :path ){ edit_workgroup_calendar_path(workgroup, calendar) }
context 'if present → ' do
let( :permission ){ true }
it 'view shows the corresponding checkbox' do
expect( page ).to have_css('div.has_switch label.boolean[for=calendar_shared]')
end
end
context 'if absent → ' do
let( :permission ){ false }
it 'view does not show the corresponding checkbox' do
expect( page ).not_to have_css('div.has_switch label.boolean[for=calendar_shared]')
end
end
end
context 'on index view' do
let( :path ){ workgroup_calendars_path(workgroup) }
context 'if present → ' do
let( :permission ){ true }
it 'index shows an edit button' do
expect(page).to have_css('a.btn.btn-default', text: 'Créer')
end
end
context 'if absent → ' do
let( :permission ){ false }
it 'index does not show any edit button' do
expect(page).not_to have_css('a.btn.btn-default', text: 'Créer')
end
end
end
end
end
|