diff options
| author | Robert | 2017-05-15 17:38:38 +0200 | 
|---|---|---|
| committer | Robert | 2017-05-18 18:42:22 +0200 | 
| commit | bfec2b6e73747193052639ee2bbf4340409510dc (patch) | |
| tree | 0d37ba9564781b5db7ba2edf7f8de53a06c91b33 /spec/features/calendars_permissions_spec.rb | |
| parent | 8872c4707b806ff4ae412de99a561495c20fbc51 (diff) | |
| download | chouette-core-bfec2b6e73747193052639ee2bbf4340409510dc.tar.bz2 | |
Refs: #3144; calendar, line_footnotes and routes speced (spec/features)
Diffstat (limited to 'spec/features/calendars_permissions_spec.rb')
| -rw-r--r-- | spec/features/calendars_permissions_spec.rb | 55 | 
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 | 
