aboutsummaryrefslogtreecommitdiffstats
path: root/spec/features
diff options
context:
space:
mode:
authorLuc Donnet2015-01-05 14:56:12 +0100
committerLuc Donnet2015-01-05 14:56:12 +0100
commit3bc6d313bebdc1f03e4021aabbc774a0cd97d938 (patch)
treeac5b8c6d8309012136606d9fd9b9a00290f486a8 /spec/features
parente632a4634b1762f4c73d11f1e5b127de9832a1ff (diff)
downloadchouette-core-3bc6d313bebdc1f03e4021aabbc774a0cd97d938.tar.bz2
Initialize rails 4 migration
Diffstat (limited to 'spec/features')
-rw-r--r--spec/features/companies_spec.rb52
-rw-r--r--spec/features/connection_links_spec.rb56
-rw-r--r--spec/features/journey_pattern_spec.rb60
-rw-r--r--spec/features/lines_spec.rb60
-rw-r--r--spec/features/networks_spec.rb72
-rw-r--r--spec/features/referentials_spec.rb62
-rw-r--r--spec/features/routes_spec.rb60
-rw-r--r--spec/features/stop_areas_spec.rb56
-rw-r--r--spec/features/stop_points_spec.rb30
-rw-r--r--spec/features/time_tables_spec.rb49
-rw-r--r--spec/features/vehicle_journey_imports_spec.rb68
11 files changed, 625 insertions, 0 deletions
diff --git a/spec/features/companies_spec.rb b/spec/features/companies_spec.rb
new file mode 100644
index 000000000..bcf73b631
--- /dev/null
+++ b/spec/features/companies_spec.rb
@@ -0,0 +1,52 @@
+# -*- coding: utf-8 -*-
+require 'spec_helper'
+
+describe "Companies", :type => :feature do
+ login_user
+
+ let!(:companies) { Array.new(2) { create :company } }
+ subject { companies.first }
+
+ describe "list" do
+ it "display companies" do
+ puts referential.inspect
+ visit referential_companies_path(referential)
+ expect(page).to have_content(companies.first.name)
+ expect(page).to have_content(companies.last.name)
+ end
+
+ end
+
+ describe "show" do
+ it "display company" do
+ visit referential_companies_path(referential)
+ click_link "#{companies.first.name}"
+ expect(page).to have_content(companies.first.name)
+ end
+
+ end
+
+ describe "new" do
+ it "creates company and return to show" do
+ visit referential_companies_path(referential)
+ click_link "Ajouter un transporteur"
+ fill_in "company_name", :with => "Company 1"
+ fill_in "Numéro d'enregistrement", :with => "test-1"
+ fill_in "Identifiant Neptune", :with => "test:Company:1"
+ click_button("Créer transporteur")
+ expect(page).to have_content("Company 1")
+ end
+ end
+
+ describe "edit and return to show" do
+ it "edit company" do
+ visit referential_company_path(referential, subject)
+ click_link "Modifier ce transporteur"
+ fill_in "Nom", :with => "Company Modified"
+ fill_in "Numéro d'enregistrement", :with => "test-1"
+ click_button("Modifier transporteur")
+ expect(page).to have_content("Company Modified")
+ end
+ end
+
+end
diff --git a/spec/features/connection_links_spec.rb b/spec/features/connection_links_spec.rb
new file mode 100644
index 000000000..985aba7a6
--- /dev/null
+++ b/spec/features/connection_links_spec.rb
@@ -0,0 +1,56 @@
+# -*- coding: utf-8 -*-
+require 'spec_helper'
+
+describe "ConnectionLinks", :type => :feature do
+ login_user
+
+ let!(:connection_links) { Array.new(2) { create(:connection_link) } }
+ subject { connection_links.first }
+
+ describe "list" do
+ it "display connection_links" do
+ visit referential_connection_links_path(referential)
+ expect(page).to have_content(connection_links.first.name)
+ expect(page).to have_content(connection_links.last.name)
+ end
+
+ end
+
+ describe "show" do
+ it "display connection_link" do
+ visit referential_connection_links_path(referential)
+ click_link "#{connection_links.first.name}"
+ expect(page).to have_content(connection_links.first.name)
+ end
+
+ it "display map" do
+ allow(subject).to receive(:stop_areas).and_return(Array.new(2) { Factory(:stop_area) })
+ visit referential_connection_links_path(referential)
+ click_link "#{connection_links.first.name}"
+ expect(page).to have_selector("#map", :class => 'connection_link')
+ end
+
+ end
+
+ describe "new" do
+ it "creates connection_link and return to show" do
+ visit referential_connection_links_path(referential)
+ click_link "Ajouter une correspondance"
+ fill_in "Nom", :with => "ConnectionLink 1"
+ fill_in "Identifiant Neptune", :with => "test:ConnectionLink:1"
+ click_button("Créer correspondance")
+ expect(page).to have_content("ConnectionLink 1")
+ end
+ end
+
+ describe "edit and return to show" do
+ it "edit connection_link" do
+ visit referential_connection_link_path(referential, subject)
+ click_link "Modifier cette correspondance"
+ fill_in "Nom", :with => "ConnectionLink Modified"
+ click_button("Modifier correspondance")
+ expect(page).to have_content("ConnectionLink Modified")
+ end
+ end
+
+end
diff --git a/spec/features/journey_pattern_spec.rb b/spec/features/journey_pattern_spec.rb
new file mode 100644
index 000000000..f57bf2952
--- /dev/null
+++ b/spec/features/journey_pattern_spec.rb
@@ -0,0 +1,60 @@
+# -*- coding: utf-8 -*-
+require 'spec_helper'
+
+describe "JourneyPatterns", :type => :feature do
+ login_user
+
+ let(:line) { Factory(:line) }
+ let(:route) { Factory(:route, :line => line) }
+ let(:journey_pattern) { Factory(:journey_pattern, :route => route) }
+
+ describe "from routes page to a journey_pattern page" do
+ it "display route's journey_patterns" do
+ pending
+ visit referential_line_route_path(referential,line,route)
+ expect(page).to have_content(journey_pattern.name)
+ end
+ end
+ describe "from route's page to journey_pattern's page" do
+ it "display journey_pattern properties" do
+ pending
+ visit referential_line_route_path(referential,line,route)
+ click_link "#{journey_pattern.name}"
+ expect(page).to have_content(journey_pattern.published_name)
+ expect(page).to have_content(journey_pattern.comment)
+ expect(page).to have_content(journey_pattern.registration_number)
+ end
+ end
+ describe "from route's page, create a new journey_pattern" do
+ it "return to route's page that display new journey_pattern" do
+ pending
+ visit referential_line_route_path(referential,line,route)
+ click_link "Ajouter une mission"
+ fill_in "Nom", :with => "A to B"
+ fill_in "Comment", :with => "AB"
+ click_button("Créer mission")
+ expect(page).to have_content("A to B")
+ end
+ end
+ describe "from route's page, select a journey_pattern and edit it" do
+ it "return to route's page with changed name" do
+ pending
+ visit referential_line_route_path(referential,line,route)
+ click_link "#{journey_pattern.name}"
+ click_link "Modifier cette mission"
+ fill_in "Nom", :with => "#{journey_pattern.name}-changed"
+ click_button("Modifier mission")
+ expect(page).to have_content("#{journey_pattern.name}-changed")
+ end
+ end
+ describe "from route's page, select a journey_pattern and delete it" do
+ it "return to route's page without journey_pattern name" do
+ pending
+ visit referential_line_route_path(referential,line,route)
+ click_link "#{journey_pattern.name}"
+ click_link "Supprimer cette mission"
+ expect(page).not_to have_content(journey_pattern.name)
+ end
+ end
+end
+
diff --git a/spec/features/lines_spec.rb b/spec/features/lines_spec.rb
new file mode 100644
index 000000000..4023c1f51
--- /dev/null
+++ b/spec/features/lines_spec.rb
@@ -0,0 +1,60 @@
+# -*- coding: utf-8 -*-
+require 'spec_helper'
+
+describe "Lines", :type => :feature do
+ login_user
+
+ let!(:network) { Factory(:network) }
+ let!(:company) { Factory(:company) }
+ let!(:lines) { Array.new(2) { Factory(:line_with_stop_areas, :network => network, :company => company) } }
+ subject { lines.first }
+
+ describe "list" do
+ it "display lines" do
+ visit referential_lines_path(referential)
+ expect(page).to have_content(lines.first.name)
+ expect(page).to have_content(lines.last.name)
+ end
+
+ end
+
+
+ describe "show" do
+ it "display line" do
+ visit referential_lines_path(referential)
+ click_link "#{lines.first.name}"
+ expect(page).to have_content(lines.first.name)
+ end
+
+ it "display map" do
+ visit referential_lines_path(referential)
+ click_link "#{lines.first.name}"
+ expect(page).to have_selector("#map", :class => 'line')
+ end
+
+ end
+
+ describe "new" do
+ it "creates line and return to show" do
+ visit referential_lines_path(referential)
+ click_link "Ajouter une ligne"
+ fill_in "Nom", :with => "Line 1"
+ fill_in "Numéro d'enregistrement", :with => "1"
+ fill_in "Identifiant Neptune", :with => "test:Line:999"
+ click_button("Créer ligne")
+ expect(page).to have_content("Line 1")
+ end
+ end
+
+ describe "edit and return to show" do
+ it "edit line" do
+ visit referential_line_path(referential, subject)
+ click_link "Modifier cette ligne"
+ fill_in "Nom", :with => "Line Modified"
+ fill_in "Numéro d'enregistrement", :with => "test-1"
+ click_button("Modifier ligne")
+ expect(page).to have_content("Line Modified")
+ end
+ end
+
+end
diff --git a/spec/features/networks_spec.rb b/spec/features/networks_spec.rb
new file mode 100644
index 000000000..3bfb63ffd
--- /dev/null
+++ b/spec/features/networks_spec.rb
@@ -0,0 +1,72 @@
+# -*- coding: utf-8 -*-
+require 'spec_helper'
+
+describe "Networks", :type => :feature do
+ login_user
+
+ let!(:networks) { Array.new(2) { Factory(:network) } }
+ subject { networks.first }
+
+ describe "list" do
+ it "display networks" do
+ visit referential_networks_path(referential)
+ expect(page).to have_content(networks.first.name)
+ expect(page).to have_content(networks.last.name)
+ end
+
+ end
+
+ describe "show" do
+ it "display network" do
+ allow(subject).to receive(:stop_areas).and_return(Array.new(2) { Factory(:stop_area) })
+ visit referential_networks_path(referential)
+ click_link "#{networks.first.name}"
+ expect(page).to have_content(networks.first.name)
+ end
+
+ it "display map" do
+ allow(subject).to receive(:stop_areas).and_return(Array.new(2) { Factory(:stop_area) })
+ visit referential_networks_path(referential)
+ click_link "#{networks.first.name}"
+ expect(page).to have_selector("#map", :class => 'network')
+ end
+
+ end
+
+ describe "new" do
+ it "creates network and return to show" do
+ allow(subject).to receive(:stop_areas).and_return(Array.new(2) { Factory(:stop_area) })
+ visit referential_networks_path(referential)
+ click_link "Ajouter un réseau"
+ fill_in "Nom", :with => "Network 1"
+ fill_in "Numéro d'enregistrement", :with => "test-1"
+ fill_in "Identifiant Neptune", :with => "test:GroupOfLine:1"
+ click_button("Créer réseau")
+ expect(page).to have_content("Network 1")
+ end
+ end
+
+ describe "edit and return to show" do
+ it "edit network" do
+ allow(subject).to receive(:stop_areas).and_return(Array.new(2) { Factory(:stop_area) })
+ visit referential_network_path(referential, subject)
+ click_link "Modifier ce réseau"
+ fill_in "Nom", :with => "Network Modified"
+ fill_in "Numéro d'enregistrement", :with => "test-1"
+ click_button("Modifier réseau")
+ expect(page).to have_content("Network Modified")
+ end
+ end
+
+ # describe "delete", :js => true do
+ # it "delete network and return to the list" do
+ # subject.stub(:stop_areas).and_return(Array.new(2) { Factory(:stop_area) })
+ # visit referential_network_path(referential, subject)
+ # click_link "Supprimer ce réseau"
+ # page.evaluate_script('window.confirm = function() { return true; }')
+ # click_button "Valider"
+ # page.should have_no_content(subject.name)
+ # end
+
+ # end
+end
diff --git a/spec/features/referentials_spec.rb b/spec/features/referentials_spec.rb
new file mode 100644
index 000000000..d4a21479f
--- /dev/null
+++ b/spec/features/referentials_spec.rb
@@ -0,0 +1,62 @@
+# -*- coding: utf-8 -*-
+require 'spec_helper'
+
+describe "Referentials", :type => :feature do
+ login_user
+
+ describe "index" do
+
+ it "should support no referential" do
+ visit referentials_path
+ expect(page).to have_content("Espaces de Données")
+ end
+
+ context "when several referentials exist" do
+
+ def retrieve_referential_by_slug( slug)
+ @user.organisation.referentials.find_by_slug(slug) ||
+ create(:referential, :slug => slug, :name => slug, :organisation => @user.organisation)
+ end
+
+ let!(:referentials) { [ retrieve_referential_by_slug("aa"),
+ retrieve_referential_by_slug("bb")] }
+
+ it "should show n referentials" do
+ visit referentials_path
+ expect(page).to have_content(referentials.first.name)
+ expect(page).to have_content(referentials.last.name)
+ end
+
+ end
+
+ end
+
+ describe "create" do
+
+ it "should" do
+ visit new_referential_path
+ fill_in "Nom", :with => "Test"
+ fill_in "Code", :with => "test"
+ fill_in "Point haut/droite de l'emprise par défaut", :with => "0.0, 0.0"
+ fill_in "Point bas/gauche de l'emprise par défaut", :with => "1.0, 1.0"
+ click_button "Créer Espace de Données"
+
+ expect(Referential.where(:name => "Test")).not_to be_nil
+ # CREATE SCHEMA
+ end
+
+ end
+
+ describe "destroy" do
+ let(:referential) { create(:referential, :organisation => @user.organisation) }
+
+ it "should remove referential" do
+ pending "Unauthorized DELETE (ticket #14)"
+ visit referential_path(referential)
+ click_link "Supprimer"
+ expect(Referential.where(:slug => referential.slug)).to be_blank
+ end
+
+ end
+
+end
diff --git a/spec/features/routes_spec.rb b/spec/features/routes_spec.rb
new file mode 100644
index 000000000..da4120309
--- /dev/null
+++ b/spec/features/routes_spec.rb
@@ -0,0 +1,60 @@
+# -*- coding: utf-8 -*-
+require 'spec_helper'
+
+describe "Routes", :type => :feature do
+ login_user
+
+ let!(:line) { Factory(:line) }
+ let!(:route) { Factory(:route, :line => line) }
+ let!(:route2) { Factory(:route, :line => line) }
+
+ describe "from lines page to a line page" do
+ it "display line's routes" do
+ pending
+ visit referential_lines_path(referential)
+ click_link "#{line.name}"
+ expect(page).to have_content(route.name)
+ expect(page).to have_content(route2.name)
+ end
+ end
+ describe "from line's page to route's page" do
+ it "display route properties" do
+ pending
+ 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
+ describe "from line's page, create a new route" do
+ it "return to line's page that display new route" do
+ pending
+ visit referential_line_path(referential,line)
+ click_link "Ajouter une séquence d'arrêts"
+ fill_in "Nom", :with => "A to B"
+ fill_in "Indice", :with => "AB"
+ click_button("Créer Séquence d'arrêts")
+ expect(page).to have_content("A to B")
+ end
+ end
+ describe "from line's page, select a route and edit it" do
+ it "return to line's page with changed name" do
+ pending
+ visit referential_line_path(referential,line)
+ click_link "#{route.name}"
+ click_link "Modifier cette séquence d'arrêts"
+ fill_in "Nom", :with => "#{route.name}-changed"
+ click_button("Modifier Séquence d'arrêts")
+ expect(page).to have_content("#{route.name}-changed")
+ end
+ end
+ describe "from line's page, select a route and delete it" do
+ it "return to line's page without route name" do
+ pending
+ visit referential_line_path(referential,line)
+ click_link "#{route.name}"
+ #click_link "Supprimer cette séquence d'arrêts"
+ #page.should_not have_content(route.name)
+ end
+ end
+end
diff --git a/spec/features/stop_areas_spec.rb b/spec/features/stop_areas_spec.rb
new file mode 100644
index 000000000..4d1b7e2bb
--- /dev/null
+++ b/spec/features/stop_areas_spec.rb
@@ -0,0 +1,56 @@
+# -*- coding: utf-8 -*-
+require 'spec_helper'
+
+describe "StopAreas", :type => :feature do
+ login_user
+
+ let!(:stop_areas) { Array.new(2) { Factory(:stop_area) } }
+ subject { stop_areas.first }
+
+ describe "list" do
+ it "display stop_areas" do
+ visit referential_stop_areas_path(referential)
+ expect(page).to have_content(stop_areas.first.name)
+ expect(page).to have_content(stop_areas.last.name)
+ end
+ end
+
+ describe "show" do
+ it "display stop_area" do
+ visit referential_stop_areas_path(referential)
+ click_link "#{stop_areas.first.name}"
+ expect(page).to have_content(stop_areas.first.name)
+ end
+
+ it "display map" do
+ visit referential_stop_areas_path(referential)
+ click_link "#{stop_areas.first.name}"
+ expect(page).to have_selector("#map", :class => 'stop_area')
+ end
+
+ end
+
+ describe "new" do
+ it "creates stop_area and return to show" do
+ visit referential_stop_areas_path(referential)
+ click_link "Ajouter un arrêt"
+ fill_in "Nom", :with => "StopArea 1"
+ fill_in "Numéro d'enregistrement", :with => "test-1"
+ fill_in "Identifiant Neptune", :with => "test:StopArea:1"
+ click_button("Créer arrêt")
+ expect(page).to have_content("StopArea 1")
+ end
+ end
+
+ describe "edit and return to show" do
+ it "edit stop_area" do
+ visit referential_stop_area_path(referential, subject)
+ click_link "Modifier cet arrêt"
+ fill_in "Nom", :with => "StopArea Modified"
+ fill_in "Numéro d'enregistrement", :with => "test-1"
+ click_button("Modifier arrêt")
+ expect(page).to have_content("StopArea Modified")
+ end
+ end
+
+end
diff --git a/spec/features/stop_points_spec.rb b/spec/features/stop_points_spec.rb
new file mode 100644
index 000000000..ec3aca475
--- /dev/null
+++ b/spec/features/stop_points_spec.rb
@@ -0,0 +1,30 @@
+# -*- coding: utf-8 -*-
+require 'spec_helper'
+
+describe "StopPoints", :type => :feature do
+ login_user
+
+ let(:line) { Factory(:line) }
+ let(:route) { Factory(:route, :line => line) }
+ let(:route2) { Factory(:route, :line => line) }
+
+ describe "from route's page to a stop points page" do
+ it "display route's stop points" do
+ pending
+ visit referential_line_route_path(referential,line,route)
+ click_link "Gérer les arrêts de la séquence"
+ route.stop_areas.each do |sa|
+ expect(page).to have_content(sa.name)
+ end
+ end
+ end
+ describe "from route's page, go to new stop point page" do
+ it "display route's stop points" do
+ pending
+ visit referential_line_route_path(referential,line,route)
+ click_link "Gérer les arrêts de la séquence"
+ click_link "Ajouter un arrêt à la séquence"
+ expect(page).to have_content( "Sélectionner un arrêt")
+ end
+ end
+end
diff --git a/spec/features/time_tables_spec.rb b/spec/features/time_tables_spec.rb
new file mode 100644
index 000000000..d9304c5ba
--- /dev/null
+++ b/spec/features/time_tables_spec.rb
@@ -0,0 +1,49 @@
+# -*- coding: utf-8 -*-
+require 'spec_helper'
+
+describe "TimeTables", :type => :feature do
+ login_user
+
+ let!(:time_tables) { Array.new(2) { create(:time_table) } }
+ subject { time_tables.first }
+
+ describe "list" do
+ it "display time_tables" do
+ visit referential_time_tables_path(referential)
+ expect(page).to have_content(time_tables.first.comment)
+ expect(page).to have_content(time_tables.last.comment)
+ end
+
+ end
+
+ describe "show" do
+ it "display time_table" do
+ visit referential_time_tables_path(referential)
+ click_link "#{time_tables.first.comment}"
+ expect(page).to have_content(time_tables.first.comment)
+ end
+
+ end
+
+ describe "new" do
+ it "creates time_table and return to show" do
+ visit referential_time_tables_path(referential)
+ click_link "Ajouter un calendrier"
+ fill_in "Nom", :with => "TimeTable 1"
+ fill_in "Identifiant Neptune", :with => "test:Timetable:1"
+ click_button("Créer Calendrier")
+ expect(page).to have_content("TimeTable 1")
+ end
+ end
+
+ describe "edit and return to show" do
+ it "edit time_table" do
+ visit referential_time_table_path(referential, subject)
+ click_link "Modifier ce calendrier"
+ fill_in "Nom", :with => "TimeTable Modified"
+ click_button("Modifier Calendrier")
+ expect(page).to have_content("TimeTable Modified")
+ end
+ end
+
+end
diff --git a/spec/features/vehicle_journey_imports_spec.rb b/spec/features/vehicle_journey_imports_spec.rb
new file mode 100644
index 000000000..3df9f1054
--- /dev/null
+++ b/spec/features/vehicle_journey_imports_spec.rb
@@ -0,0 +1,68 @@
+# -*- coding: utf-8 -*-
+require 'spec_helper'
+
+describe "VehicleJourneyImports", :type => :feature do
+ login_user
+
+ let!(:route) { create :route }
+
+ let(:valid_file_path) {
+ csv_file = update_csv_file_with_factory_data("vehicle_journey_imports_valid.csv")
+ File.path(csv_file)
+ }
+
+ let(:invalid_file_path) {
+ csv_file = update_csv_file_with_factory_data("vehicle_journey_imports_with_vjas_invalid.csv")
+ File.path(csv_file)
+ }
+
+ def update_csv_file_with_factory_data(filename)
+ csv_file = CSV.open("/tmp/#{filename}", "wb",{ :col_sep => ";"}) do |csv|
+ counter = 0
+ CSV.foreach( Rails.root.join("spec", "fixtures", "#{filename}").to_s , {:col_sep => ";"}) do |row|
+ if counter == 0
+ row2 = []
+ row.each do |cell|
+ cell = "" if cell == "import:VehicleJourney:1"
+ cell = "" if cell == "import:VehicleJourney:2"
+ cell = "" if cell == "import:VehicleJourney:3"
+ row2 << cell
+ end
+ csv << row2
+ elsif counter < 7
+ csv << row
+ else
+ csv << ( row[0] = route.stop_points[counter - 7].id; row)
+ end
+ counter += 1
+ end
+
+ end
+
+ File.open("/tmp/#{filename}")
+ end
+
+ describe "new" do
+ it "should create vehicle journey file and return to route show page" do
+ visit new_referential_line_route_vehicle_journey_import_path(referential, route.line, route)
+ attach_file('Fichier', valid_file_path)
+ click_button "Lancer l'import"
+ expect(page).to have_content(I18n.t("vehicle_journey_imports.new.success"))
+ expect(page).to have_content("Séquence d'arrêts #{route.name}")
+ end
+
+ it "should return error messages when file is invalid" do
+ visit new_referential_line_route_vehicle_journey_import_path(referential, route.line, route)
+ attach_file('Fichier', invalid_file_path)
+ click_button "Lancer l'import"
+ expect(page).to have_content(I18n.t("vehicle_journey_imports.errors.import_aborted"))
+ end
+
+ it "should return error message when file missing on upload" do
+ visit new_referential_line_route_vehicle_journey_import_path(referential, route.line, route)
+ click_button "Lancer l'import"
+ expect(page).to have_content(I18n.t("vehicle_journey_imports.errors.import_aborted"))
+ end
+ end
+
+end