aboutsummaryrefslogtreecommitdiffstats
path: root/spec/features/routes_permissions_spec.rb
diff options
context:
space:
mode:
authorRobert2017-05-15 17:38:38 +0200
committerRobert2017-05-18 18:42:22 +0200
commitbfec2b6e73747193052639ee2bbf4340409510dc (patch)
tree0d37ba9564781b5db7ba2edf7f8de53a06c91b33 /spec/features/routes_permissions_spec.rb
parent8872c4707b806ff4ae412de99a561495c20fbc51 (diff)
downloadchouette-core-bfec2b6e73747193052639ee2bbf4340409510dc.tar.bz2
Refs: #3144; calendar, line_footnotes and routes speced (spec/features)
Diffstat (limited to 'spec/features/routes_permissions_spec.rb')
-rw-r--r--spec/features/routes_permissions_spec.rb42
1 files changed, 42 insertions, 0 deletions
diff --git a/spec/features/routes_permissions_spec.rb b/spec/features/routes_permissions_spec.rb
new file mode 100644
index 000000000..36c13b24a
--- /dev/null
+++ b/spec/features/routes_permissions_spec.rb
@@ -0,0 +1,42 @@
+# -*- coding: utf-8 -*-
+require 'spec_helper'
+
+describe "Routes", :type => :feature do
+ login_user
+
+ let(:line) { create :line }
+ let(:route) { create(:route, :line => line) }
+
+
+ describe 'permissions' do
+ before do
+ @user.update(organisation: referential.organisation)
+ allow_any_instance_of(RoutePolicy).to receive(:edit?).and_return permission
+ allow_any_instance_of(RoutePolicy).to receive(:destroy?).and_return permission
+ visit path
+ end
+
+ describe 'on show view' do
+ let( :path ){ referential_line_route_path(referential, line, route) }
+
+ context 'if present → ' do
+ let( :permission ){ true }
+ it 'view shows the corresponding buttons' do
+ expected_edit_url = edit_referential_line_route_path(referential, line, route)
+ expected_delete_url = referential_line_route_path(referential, line, route)
+ expect( page ).to have_link('Editer', href: expected_edit_url)
+ expect( page ).to have_link('Supprimer', href: expected_delete_url)
+ end
+ end
+
+ context 'if absent → ' do
+ let( :permission ){ false }
+ it 'view does not show the corresponding buttons' do
+ expect( page ).not_to have_link('Editer')
+ expect( page ).not_to have_link('Supprimer')
+ end
+ end
+ end
+
+ end
+end