diff options
| author | Luc Donnet | 2017-12-21 12:03:20 +0100 |
|---|---|---|
| committer | Luc Donnet | 2017-12-21 13:57:03 +0100 |
| commit | 9a090ecdedac38eeff0aed137e311525e73832e9 (patch) | |
| tree | 2578a07ed502062e8fb8116202cf7eb673c3dc10 /spec/features | |
| parent | b6606b25148b958a1f8d5502d95c7db12ef224b0 (diff) | |
| download | chouette-core-9a090ecdedac38eeff0aed137e311525e73832e9.tar.bz2 | |
Fix edit, i18n and add feature spec for purchase window Refs #5301 @3
Diffstat (limited to 'spec/features')
| -rw-r--r-- | spec/features/purchase_windows_permission_spec.rb | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/spec/features/purchase_windows_permission_spec.rb b/spec/features/purchase_windows_permission_spec.rb new file mode 100644 index 000000000..e74fb5c17 --- /dev/null +++ b/spec/features/purchase_windows_permission_spec.rb @@ -0,0 +1,55 @@ +# -*- coding: utf-8 -*- +require 'spec_helper' + +describe "PurchaseWindows", :type => :feature do + login_user + + let(:purchase_window) { create :purchase_window, referential: first_referential} + + describe 'permissions' do + before do + allow_any_instance_of(PurchaseWindowPolicy).to receive(:create?).and_return permission + allow_any_instance_of(PurchaseWindowPolicy).to receive(:destroy?).and_return permission + allow_any_instance_of(PurchaseWindowPolicy).to receive(:update?).and_return permission + visit path + end + + context 'on show view' do + let( :path ){ referential_purchase_window_path(first_referential, purchase_window) } + + context 'if present → ' do + let( :permission ){ true } + it 'view shows the corresponding buttons' do + expect(page).to have_content(I18n.t('purchase_windows.actions.edit')) + expect(page).to have_content(I18n.t('purchase_windows.actions.destroy')) + end + end + + context 'if absent → ' do + let( :permission ){ false } + it 'view does not show the corresponding buttons' do + expect(page).not_to have_content(I18n.t('purchase_windows.actions.edit')) + expect(page).not_to have_content(I18n.t('purchase_windows.actions.destroy')) + end + end + end + + context 'on index view' do + let( :path ){ referential_purchase_windows_path(first_referential) } + + context 'if present → ' do + let( :permission ){ true } + it 'index shows an edit button' do + expect(page).to have_content(I18n.t('purchase_windows.actions.new')) + end + end + + context 'if absent → ' do + let( :permission ){ false } + it 'index does not show any edit button' do + expect(page).not_to have_content(I18n.t('purchase_windows.actions.new')) + end + end + end + end +end |
