blob: 6eb0ea08e59dd607688f2cf07f8281f953092cda (
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
|
# -*- coding: utf-8 -*-
require 'spec_helper'
describe 'Calendars', type: :feature do
login_user
let(:calendar) { create :calendar, organisation_id: 1 }
describe 'permissions' do
before do
allow_any_instance_of(CalendarPolicy).to receive(:edit?).and_return permission
allow_any_instance_of(CalendarPolicy).to receive(:destroy?).and_return permission
allow_any_instance_of(CalendarPolicy).to receive(:share?).and_return permission
visit path
end
context 'on show view' do
let( :path ){ calendar_path(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_calendar_path(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
end
end
|