aboutsummaryrefslogtreecommitdiffstats
path: root/spec/features/calendars_permissions_spec.rb
diff options
context:
space:
mode:
Diffstat (limited to 'spec/features/calendars_permissions_spec.rb')
-rw-r--r--spec/features/calendars_permissions_spec.rb55
1 files changed, 55 insertions, 0 deletions
diff --git a/spec/features/calendars_permissions_spec.rb b/spec/features/calendars_permissions_spec.rb
new file mode 100644
index 000000000..6eb0ea08e
--- /dev/null
+++ b/spec/features/calendars_permissions_spec.rb
@@ -0,0 +1,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