aboutsummaryrefslogtreecommitdiffstats
path: root/spec/features
diff options
context:
space:
mode:
authorLuc Donnet2017-12-21 14:50:08 +0100
committerGitHub2017-12-21 14:50:08 +0100
commit7aec5b94868bc2e7473f7ded4be7a585fb7b174e (patch)
tree80218bcbec4d2740f6ca5be1d37bb0ba493cc879 /spec/features
parent9050a68f40829fc1b08e2f60c3eea9cf0c76e879 (diff)
parent610a3e133b6405b32ce5d8aa48be075d4b137b4f (diff)
downloadchouette-core-7aec5b94868bc2e7473f7ded4be7a585fb7b174e.tar.bz2
Merge pull request #150 from af83/5301-add_business_calendars
Refs #5301 First draft for Business Calendars
Diffstat (limited to 'spec/features')
-rw-r--r--spec/features/purchase_windows_permission_spec.rb55
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