diff options
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 |
