aboutsummaryrefslogtreecommitdiffstats
path: root/spec/features/routes_spec.rb
diff options
context:
space:
mode:
authorRobert2017-07-03 15:34:11 +0200
committerRobert2017-07-04 21:54:04 +0200
commitc48ad4fde3056ef04645b73f7eab54ff867d370c (patch)
tree57af273b48f1ece1b5e16244d6957f407a5d9563 /spec/features/routes_spec.rb
parent747d333ffbcc8ee0c9f1daf93ccca32799434e04 (diff)
downloadchouette-core-c48ad4fde3056ef04645b73f7eab54ff867d370c.tar.bz2
Refs: #3478@1h
newapplication helper default authorization, (no if) -> * DefaultPolicy (all true) * Add some policies (LinePolicy) * Use `boiv:read` pour show, index * Adapted `table_builder`
Diffstat (limited to 'spec/features/routes_spec.rb')
-rw-r--r--spec/features/routes_spec.rb193
1 files changed, 96 insertions, 97 deletions
diff --git a/spec/features/routes_spec.rb b/spec/features/routes_spec.rb
index 28015f011..561725ddd 100644
--- a/spec/features/routes_spec.rb
+++ b/spec/features/routes_spec.rb
@@ -1,6 +1,3 @@
-# -*- coding: utf-8 -*-
-require 'spec_helper'
-
describe "Routes", :type => :feature do
login_user
@@ -13,130 +10,132 @@ describe "Routes", :type => :feature do
before { @user.update(organisation: referential.organisation) }
- describe "from lines page to a line page" do
- it "display line's routes" do
- visit referential_lines_path(referential)
- first(:link, 'Consulter').click
- expect(page).to have_content(route.name)
- expect(page).to have_content(route2.name)
+ with_permissions "boiv:read" do
+ context "from lines page to a line page" do
+ it "display line's routes" do
+ visit referential_lines_path(referential)
+ first(:link, 'Consulter').click
+ expect(page).to have_content(route.name)
+ expect(page).to have_content(route2.name)
+ end
end
- end
- describe "from line's page to route's page" do
- it "display route properties" do
- visit referential_line_path(referential, line)
- click_link "#{route.name}"
- expect(page).to have_content(route.name)
- expect(page).to have_content(route.number)
+ describe "from line's page to route's page" do
+ it "display route properties" do
+ visit referential_line_path(referential, line)
+ click_link "#{route.name}"
+ expect(page).to have_content(route.name)
+ expect(page).to have_content(route.number)
+ end
end
- end
- describe "from line's page, create a new route" do
- it "return to line's page that display new route" do
- visit referential_line_path(referential, line)
- click_link "Ajouter un itinéraire"
- fill_in "route_name", :with => "A to B"
- fill_in "route_published_name", :with => "Published A to B"
- # select 'Aller', :from => "route_direction"
- check('route[wayback]')
- click_button("Valider")
- expect(page).to have_content("A to B")
- expect(page).to have_content("Published A to B")
-
+ describe "from line's page, create a new route" do
+ it "return to line's page that display new route" do
+ visit referential_line_path(referential, line)
+ click_link "Ajouter un itinéraire"
+ fill_in "route_name", :with => "A to B"
+ fill_in "route_published_name", :with => "Published A to B"
+ # select 'Aller', :from => "route_direction"
+ check('route[wayback]')
+ click_button("Valider")
+ expect(page).to have_content("A to B")
+ expect(page).to have_content("Published A to B")
+
+ end
end
- end
- describe "Modifies boarding/alighting properties on route stops" do
- xit "Puts (http) an update request" do
- #visit edit_boarding_alighting_referential_line_route_path(referential, line, route)
- visit referential_line_route_path(referential, line, route)
-
- click_link I18n.t('routes.actions.edit_boarding_alighting')
- #select('', :from => '')
- # Changes the boarding of the first stop
- # Changes the alighting of the last stop
- # save
- #click_button(I18n.t('helpers.submit.update', model: I18n.t('activerecord.models.route.one')))
- click_button(I18n.t('helpers.submit.update', model: I18n.t('activerecord.models.route.one')))
+ describe "Modifies boarding/alighting properties on route stops" do
+ xit "Puts (http) an update request" do
+ #visit edit_boarding_alighting_referential_line_route_path(referential, line, route)
+ visit referential_line_route_path(referential, line, route)
+
+ click_link I18n.t('routes.actions.edit_boarding_alighting')
+ #select('', :from => '')
+ # Changes the boarding of the first stop
+ # Changes the alighting of the last stop
+ # save
+ #click_button(I18n.t('helpers.submit.update', model: I18n.t('activerecord.models.route.one')))
+ click_button(I18n.t('helpers.submit.update', model: I18n.t('activerecord.models.route.one')))
+ end
end
- end
- describe 'show' do
- before(:each) { visit referential_line_route_path(referential, line, route) }
+ describe 'show' do
+ before(:each) { visit referential_line_route_path(referential, line, route) }
- context 'user has permission to edit journey patterns' do
- skip "not sure the spec is correct or the code" do
- it 'shows edit links for journey patterns' do
- expect(page).to have_link(I18n.t('actions.edit'), href: edit_referential_line_route_journey_pattern_path(referential, line, route, journey_pattern))
+ context 'user has permission to edit journey patterns' do
+ skip "not sure the spec is correct or the code" do
+ it 'shows edit links for journey patterns' do
+ expect(page).to have_link(I18n.t('actions.edit'), href: edit_referential_line_route_journey_pattern_path(referential, line, route, journey_pattern))
+ end
end
end
- end
- context 'user does not have permission to edit journey patterns' do
- it 'does not show edit links for journey patterns' do
- @user.update_attribute(:permissions, [])
- visit referential_line_route_path(referential, line, route)
- expect(page).not_to have_link(I18n.t('actions.edit'), href: edit_referential_line_route_journey_pattern_path(referential, line, route, journey_pattern))
+ context 'user does not have permission to edit journey patterns' do
+ it 'does not show edit links for journey patterns' do
+ @user.update_attribute(:permissions, [])
+ visit referential_line_route_path(referential, line, route)
+ expect(page).not_to have_link(I18n.t('actions.edit'), href: edit_referential_line_route_journey_pattern_path(referential, line, route, journey_pattern))
+ end
end
- end
- context 'user has permission to destroy journey patterns' do
- it 'shows destroy links for journey patterns' do
- expect(page).to have_content(I18n.t('actions.destroy'))
+ context 'user has permission to destroy journey patterns' do
+ it 'shows destroy links for journey patterns' do
+ expect(page).to have_content(I18n.t('actions.destroy'))
+ end
end
- end
- context 'user does not have permission to destroy journey patterns' do
- it 'does not show destroy links for journey patterns' do
- @user.update_attribute(:permissions, [])
- visit referential_line_route_path(referential, line, route)
- expect(page).not_to have_link(I18n.t('actions.destroy'), href: referential_line_route_journey_pattern_path(referential, line, route, journey_pattern))
+ context 'user does not have permission to destroy journey patterns' do
+ it 'does not show destroy links for journey patterns' do
+ @user.update_attribute(:permissions, [])
+ visit referential_line_route_path(referential, line, route)
+ expect(page).not_to have_link(I18n.t('actions.destroy'), href: referential_line_route_journey_pattern_path(referential, line, route, journey_pattern))
+ end
end
end
- end
- describe 'referential line show' do
- before(:each) { visit referential_line_path(referential, line) }
+ describe 'referential line show' do
+ before(:each) { visit referential_line_path(referential, line) }
- context 'user has permission to edit routes' do
- it 'shows edit buttons for routes' do
- expect(page).to have_content(I18n.t('actions.edit'))
+ context 'user has permission to edit routes' do
+ it 'shows edit buttons for routes' do
+ expect(page).to have_content(I18n.t('actions.edit'))
+ end
end
- end
- context 'user does not have permission to edit routes' do
- it 'does not show edit buttons for routes' do
- @user.update_attribute(:permissions, [])
- visit referential_line_path(referential, line)
- expect(page).not_to have_link(I18n.t('actions.edit'), href: edit_referential_line_route_path(referential, line, route))
+ context 'user does not have permission to edit routes' do
+ it 'does not show edit buttons for routes' do
+ @user.update_attribute(:permissions, [])
+ visit referential_line_path(referential, line)
+ expect(page).not_to have_link(I18n.t('actions.edit'), href: edit_referential_line_route_path(referential, line, route))
+ end
end
- end
- context 'user has permission to create routes' do
- it 'shows link to a create route page' do
- expect(page).to have_content(I18n.t('routes.actions.new'))
+ context 'user has permission to create routes' do
+ it 'shows link to a create route page' do
+ expect(page).to have_content(I18n.t('routes.actions.new'))
+ end
end
- end
- context 'user belongs to another organisation' do
- xit 'does not show link to a create route page' do
- expect(page).not_to have_content(I18n.t('routes.actions.new'))
+ context 'user belongs to another organisation' do
+ xit 'does not show link to a create route page' do
+ expect(page).not_to have_content(I18n.t('routes.actions.new'))
+ end
end
- end
- context 'user does not have permission to create routes' do
- it 'does not show link to a create route page' do
- @user.update_attribute(:permissions, [])
- visit referential_line_path(referential, line)
- expect(page).not_to have_content(I18n.t('routes.actions.new'))
+ context 'user does not have permission to create routes' do
+ it 'does not show link to a create route page' do
+ @user.update_attribute(:permissions, [])
+ visit referential_line_path(referential, line)
+ expect(page).not_to have_content(I18n.t('routes.actions.new'))
+ end
end
- end
- context 'user does not have permission to destroy routes' do
- it 'does not show destroy buttons for routes' do
- @user.update_attribute(:permissions, [])
- visit referential_line_path(referential, line)
- expect(page).not_to have_link(I18n.t('actions.destroy'), href: referential_line_route_path(referential, line, route))
+ context 'user does not have permission to destroy routes' do
+ it 'does not show destroy buttons for routes' do
+ @user.update_attribute(:permissions, [])
+ visit referential_line_path(referential, line)
+ expect(page).not_to have_link(I18n.t('actions.destroy'), href: referential_line_route_path(referential, line, route))
+ end
end
end
end