aboutsummaryrefslogtreecommitdiffstats
path: root/spec
diff options
context:
space:
mode:
Diffstat (limited to 'spec')
-rw-r--r--spec/features/routes_spec.rb14
-rw-r--r--spec/support/devise.rb4
-rw-r--r--spec/views/connection_links/index.html.erb_spec.rb12
-rw-r--r--spec/views/connection_links/show.html.erb_spec.rb6
-rw-r--r--spec/views/lines/show.html.erb_spec.rb5
-rw-r--r--spec/views/time_tables/index.html.erb_spec.rb12
-rw-r--r--spec/views/time_tables/show.html.erb_spec.rb8
7 files changed, 46 insertions, 15 deletions
diff --git a/spec/features/routes_spec.rb b/spec/features/routes_spec.rb
index e82987811..7f1917862 100644
--- a/spec/features/routes_spec.rb
+++ b/spec/features/routes_spec.rb
@@ -4,13 +4,15 @@ require 'spec_helper'
describe "Routes", :type => :feature do
login_user
- let!(:line) { create(:line) }
+ let(:line) { create :line }
let!(:route) { create(:route, :line => line) }
let!(:route2) { create(:route, :line => line) }
#let!(:stop_areas) { Array.new(4) { create(:stop_area) } }
let!(:stop_points) { Array.new(4) { create(:stop_point, :route => route) } }
let!(:journey_pattern) { create(:journey_pattern, route: route) }
+ 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)
@@ -22,7 +24,7 @@ describe "Routes", :type => :feature do
describe "from line's page to route's page" do
it "display route properties" do
- visit referential_line_path(referential,line)
+ visit referential_line_path(referential, line)
click_link "#{route.name}"
expect(page).to have_content(route.name)
expect(page).to have_content(route.number)
@@ -31,7 +33,7 @@ describe "Routes", :type => :feature do
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)
+ visit referential_line_path(referential, line)
click_link "Ajouter un itinéraire"
fill_in "route_name", :with => "A to B"
# select 'Aller', :from => "route_direction"
@@ -110,6 +112,12 @@ describe "Routes", :type => :feature do
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'))
+ 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, [])
diff --git a/spec/support/devise.rb b/spec/support/devise.rb
index 0eba265ac..f692edab8 100644
--- a/spec/support/devise.rb
+++ b/spec/support/devise.rb
@@ -6,7 +6,9 @@ module DeviseRequestHelper
@user ||= create(:user, :organisation => organisation,
:permissions => ['routes.create', 'routes.edit', 'routes.destroy', 'journey_patterns.create', 'journey_patterns.edit', 'journey_patterns.destroy',
'vehicle_journeys.create', 'vehicle_journeys.edit', 'vehicle_journeys.destroy', 'time_tables.create', 'time_tables.edit', 'time_tables.destroy',
- 'footnotes.edit', 'footnotes.create', 'footnotes.destroy', 'routing_constraint_zones.create', 'routing_constraint_zones.edit', 'routing_constraint_zones.destroy'])
+ 'footnotes.edit', 'footnotes.create', 'footnotes.destroy', 'routing_constraint_zones.create', 'routing_constraint_zones.edit', 'routing_constraint_zones.destroy',
+ 'access_points.create', 'access_points.edit', 'access_points.destroy', 'access_links.create', 'access_links.edit', 'access_links.destroy',
+ 'connection_links.create', 'connection_links.edit', 'connection_links.destroy', 'route_sections.create', 'route_sections.edit', 'route_sections.destroy'])
login_as @user, :scope => :user
# post_via_redirect user_session_path, 'user[email]' => @user.email, 'user[password]' => @user.password
end
diff --git a/spec/views/connection_links/index.html.erb_spec.rb b/spec/views/connection_links/index.html.erb_spec.rb
index 51029a2f8..a01380094 100644
--- a/spec/views/connection_links/index.html.erb_spec.rb
+++ b/spec/views/connection_links/index.html.erb_spec.rb
@@ -3,12 +3,16 @@ require 'spec_helper'
describe "/connection_links/index", :type => :view do
assign_referential
- let!(:connection_links) { assign :connection_links, Array.new(2) { create(:connection_link) }.paginate }
+ let!(:connection_links) { assign :connection_links, Array.new(2) { create(:connection_link) }.paginate }
let!(:search) { assign :q, Ransack::Search.new(Chouette::ConnectionLink) }
- it "should render a show link for each group" do
- render
- connection_links.each do |connection_link|
+ before do
+ allow(view).to receive_messages(current_organisation: referential.organisation)
+ end
+
+ it "should render a show link for each group" do
+ render
+ connection_links.each do |connection_link|
expect(rendered).to have_selector(".connection_link a[href='#{view.referential_connection_link_path(referential, connection_link)}']", :text => connection_link.name)
end
end
diff --git a/spec/views/connection_links/show.html.erb_spec.rb b/spec/views/connection_links/show.html.erb_spec.rb
index 7be74ad7c..1a7ad3d16 100644
--- a/spec/views/connection_links/show.html.erb_spec.rb
+++ b/spec/views/connection_links/show.html.erb_spec.rb
@@ -1,11 +1,15 @@
require 'spec_helper'
describe "/connection_links/show", :type => :view do
-
+
assign_referential
let!(:connection_link) { assign(:connection_link, create(:connection_link)) }
let!(:map) { assign(:map, double(:to_html => '<div id="map"/>'.html_safe)) }
+ before do
+ allow(view).to receive_messages(current_organisation: referential.organisation)
+ end
+
it "should render h2 with the connection_link name" do
render
expect(rendered).to have_selector("h2", :text => Regexp.new(connection_link.name))
diff --git a/spec/views/lines/show.html.erb_spec.rb b/spec/views/lines/show.html.erb_spec.rb
index 9f929f432..65475e296 100644
--- a/spec/views/lines/show.html.erb_spec.rb
+++ b/spec/views/lines/show.html.erb_spec.rb
@@ -2,11 +2,16 @@ require 'spec_helper'
describe "/lines/show", :type => :view do
+ assign_referential
let!(:line) { assign :line, create(:line) }
let!(:line_referential) { assign :line_referential, line.line_referential }
let!(:routes) { assign :routes, Array.new(2) { create(:route, :line => line) }.paginate }
let!(:map) { assign(:map, double(:to_html => '<div id="map"/>'.html_safe)) }
+ before do
+ allow(view).to receive_messages(current_organisation: referential.organisation)
+ end
+
it "should render h2 with the line name" do
render
expect(rendered).to have_selector("h2", :text => Regexp.new(line.name))
diff --git a/spec/views/time_tables/index.html.erb_spec.rb b/spec/views/time_tables/index.html.erb_spec.rb
index 84cea756e..2679964c1 100644
--- a/spec/views/time_tables/index.html.erb_spec.rb
+++ b/spec/views/time_tables/index.html.erb_spec.rb
@@ -3,12 +3,16 @@ require 'spec_helper'
describe "/time_tables/index", :type => :view do
assign_referential
- let!(:time_tables) { assign :time_tables, Array.new(2){ create(:time_table) }.paginate }
+ let!(:time_tables) { assign :time_tables, Array.new(2){ create(:time_table) }.paginate }
let!(:search) { assign :q, Ransack::Search.new(Chouette::TimeTable) }
- it "should render a show link for each group" do
- render
- time_tables.each do |time_table|
+ before do
+ allow(view).to receive_messages(current_organisation: referential.organisation)
+ end
+
+ it "should render a show link for each group" do
+ render
+ time_tables.each do |time_table|
expect(rendered).to have_selector(".time_table a[href='#{view.referential_time_table_path(referential, time_table)}']", :text => time_table.comment)
end
end
diff --git a/spec/views/time_tables/show.html.erb_spec.rb b/spec/views/time_tables/show.html.erb_spec.rb
index 352d67f4f..3b5d7f1f1 100644
--- a/spec/views/time_tables/show.html.erb_spec.rb
+++ b/spec/views/time_tables/show.html.erb_spec.rb
@@ -1,13 +1,17 @@
require 'spec_helper'
describe "/time_tables/show", :type => :view do
-
+
assign_referential
let!(:time_table) { assign(:time_table, create(:time_table)) }
let!(:year) { assign(:year, Date.today.cwyear) }
let!(:time_table_combination) {assign(:time_table_combination, TimeTableCombination.new)}
- it "should render h2 with the time_table comment" do
+ before do
+ allow(view).to receive_messages(current_organisation: referential.organisation)
+ end
+
+ it "should render h2 with the time_table comment" do
render
expect(rendered).to have_selector("h2", :text => Regexp.new(time_table.comment))
end