aboutsummaryrefslogtreecommitdiffstats
path: root/spec
diff options
context:
space:
mode:
authorRobert2017-04-24 14:16:52 +0200
committerRobert2017-04-24 14:16:52 +0200
commit2d19e65fa8d8ac037c7f00a638111788b7ee002c (patch)
tree830fe41ac13743f75f2c16f41dfd1ff399b99a9b /spec
parent5003acfc533baa824fed11cf6f82f86393b3a0f6 (diff)
parent1cbed80c913420c76ac7d3716b9d8c4bf4e14278 (diff)
downloadchouette-core-2d19e65fa8d8ac037c7f00a638111788b7ee002c.tar.bz2
conflict resolution and asset recompilation
Diffstat (limited to 'spec')
-rw-r--r--spec/controllers/route_stop_points_controller_spec.rb23
-rw-r--r--spec/controllers/routes_controller_spec.rb2
-rw-r--r--spec/controllers/vehicle_journey_imports_controller_spec.rb2
-rw-r--r--spec/factories/chouette_routing_constraint_zones.rb7
-rw-r--r--spec/features/lines_spec.rb8
-rw-r--r--spec/features/networks_spec.rb2
-rw-r--r--spec/features/referentials_spec.rb53
-rw-r--r--spec/features/routes_spec.rb4
-rw-r--r--spec/features/routing_constraint_zones_spec.rb3
-rw-r--r--spec/features/time_tables_spec.rb63
-rw-r--r--spec/features/workbenches_spec.rb17
-rw-r--r--spec/fixtures/users.json24
-rw-r--r--spec/helpers/exports_helper_spec.rb2
-rw-r--r--spec/helpers/help_helper_spec.rb2
-rw-r--r--spec/helpers/imports_helper_spec.rb2
-rw-r--r--spec/helpers/referentials_helper_spec.rb2
-rw-r--r--spec/javascripts/time_table/actions_spec.js27
-rw-r--r--spec/javascripts/time_table/reducers/metas_spec.js49
-rw-r--r--spec/javascripts/vehicle_journeys/reducers/filters_spec.js8
-rw-r--r--spec/lib/af83/stored_procedure_spec.rb20
-rwxr-xr-xspec/lib/af83/stored_procedures/clone_schema_spec.rb166
-rw-r--r--spec/models/chouette/routing_constraint_zone_spec.rb43
-rw-r--r--spec/models/chouette/vehicle_journey_spec.rb108
-rw-r--r--spec/models/compliance_check_task_spec.rb9
-rw-r--r--spec/models/import_spec.rb2
-rw-r--r--spec/models/ninoxe_extension_spec.rb22
-rw-r--r--spec/models/organisation_spec.rb2
-rw-r--r--spec/models/referential_metadata_spec.rb13
-rw-r--r--spec/models/user_spec.rb20
-rw-r--r--spec/models/vehicle_journey_import_spec.rb4
-rw-r--r--spec/routing/companies_spec.rb6
-rw-r--r--spec/routing/group_of_lines_spec.rb6
-rw-r--r--spec/routing/networks_spec.rb6
-rw-r--r--spec/routing/time_tables_spec.rb8
-rw-r--r--spec/spec_helper.rb20
-rw-r--r--spec/support/devise.rb6
-rw-r--r--spec/support/pg_catalog.rb82
-rw-r--r--spec/support/type_ids_modelable.rb (renamed from spec/support/type_ids_modelable_spec.rb)0
-rw-r--r--spec/views/companies/show.html.erb_spec.rb2
-rw-r--r--spec/views/connection_links/show.html.erb_spec.rb2
-rw-r--r--spec/views/layouts/application.html.erb_spec.rb2
-rw-r--r--spec/views/lines/show.html.erb_spec.rb2
-rw-r--r--spec/views/organisations/show.html.erb2
-rw-r--r--spec/views/routes/show.html.erb_spec.rb2
-rw-r--r--spec/views/stop_areas/show.html.erb_spec.rb2
-rw-r--r--spec/views/time_tables/edit.html.erb_spec.rb16
-rw-r--r--spec/views/time_tables/index.html.erb_spec.rb22
-rw-r--r--spec/views/time_tables/show.html.erb_spec.rb7
-rw-r--r--spec/workers/referential_cloning_worker_spec.rb47
49 files changed, 769 insertions, 180 deletions
diff --git a/spec/controllers/route_stop_points_controller_spec.rb b/spec/controllers/route_stop_points_controller_spec.rb
new file mode 100644
index 000000000..2f5fa41c7
--- /dev/null
+++ b/spec/controllers/route_stop_points_controller_spec.rb
@@ -0,0 +1,23 @@
+require 'spec_helper'
+
+RSpec.describe RouteStopPointsController, type: :controller do
+ login_user
+
+ let(:referential) { Referential.first }
+ let!(:line) { create :line }
+ let!(:route) { create :route, line: line }
+
+ describe 'GET index' do
+ before(:each) { get :index, referential_id: referential.id, line_id: line.id, route_id: route.id, format: :json }
+
+ it 'returns HTTP success' do
+ expect(response).to be_success
+ end
+
+ it 'returns a JSON of stop areas' do
+ expect(response.body).to eq(route.stop_points.map { |sp| { id: sp.id, name: sp.name } }.to_json)
+ end
+ end
+end
+
+
diff --git a/spec/controllers/routes_controller_spec.rb b/spec/controllers/routes_controller_spec.rb
index de6d16c8b..18067dec7 100644
--- a/spec/controllers/routes_controller_spec.rb
+++ b/spec/controllers/routes_controller_spec.rb
@@ -9,7 +9,7 @@ describe RoutesController, :type => :controller do
shared_examples_for "redirected to referential_line_path(referential,line)" do
it "should redirect_to referential_line_path(referential,line)" do
- #response.should redirect_to( referential_line_path(referential,route.line) )
+ # expect(response).to redirect_to( referential_line_path(referential,route.line) )
end
end
shared_examples_for "line and referential linked" do
diff --git a/spec/controllers/vehicle_journey_imports_controller_spec.rb b/spec/controllers/vehicle_journey_imports_controller_spec.rb
index ef1ec882a..633f90b70 100644
--- a/spec/controllers/vehicle_journey_imports_controller_spec.rb
+++ b/spec/controllers/vehicle_journey_imports_controller_spec.rb
@@ -2,6 +2,4 @@ require 'spec_helper'
describe ImportTasksController, :type => :controller do
login_user
-
-
end
diff --git a/spec/factories/chouette_routing_constraint_zones.rb b/spec/factories/chouette_routing_constraint_zones.rb
index 9a2529483..8ef2ddb43 100644
--- a/spec/factories/chouette_routing_constraint_zones.rb
+++ b/spec/factories/chouette_routing_constraint_zones.rb
@@ -1,7 +1,10 @@
FactoryGirl.define do
factory :routing_constraint_zone, class: Chouette::RoutingConstraintZone do
sequence(:name) { |n| "Routing constraint zone #{n}" }
- stop_area_ids { [create(:stop_area).id, create(:stop_area).id] }
- association :line, factory: :line
+ association :route, factory: :route
+ after(:build) do |zone|
+ route = Chouette::Route.find(zone.route_id)
+ zone.stop_point_ids = route.stop_points.pluck(:id).first(2)
+ end
end
end
diff --git a/spec/features/lines_spec.rb b/spec/features/lines_spec.rb
index bbe3c757b..e7e1e601c 100644
--- a/spec/features/lines_spec.rb
+++ b/spec/features/lines_spec.rb
@@ -20,10 +20,10 @@ describe "Lines", :type => :feature do
end
it 'allows only R in CRUD' do
- expect(page).to have_content(I18n.t('actions.show'))
- expect(page).not_to have_content(I18n.t('actions.edit'))
- expect(page).not_to have_content(I18n.t('actions.destroy'))
- expect(page).not_to have_content(I18n.t('actions.add'))
+ expect(page).to have_link(I18n.t('actions.show'))
+ expect(page).not_to have_link(I18n.t('actions.edit'), href: edit_referential_line_path(referential, lines.first))
+ expect(page).not_to have_link(I18n.t('actions.destroy'), href: referential_line_path(referential, lines.first))
+ expect(page).not_to have_link(I18n.t('actions.add'), href: new_referential_line_path(referential))
end
context 'filtering' do
diff --git a/spec/features/networks_spec.rb b/spec/features/networks_spec.rb
index 523b2e898..75070e7fa 100644
--- a/spec/features/networks_spec.rb
+++ b/spec/features/networks_spec.rb
@@ -81,7 +81,7 @@ describe "Networks", :type => :feature do
# click_link "Supprimer ce réseau"
# page.evaluate_script('window.confirm = function() { return true; }')
# click_button "Valider"
- # page.should have_no_content(subject.name)
+ # expect(page).to have_no_content(subject.name)
# end
# end
diff --git a/spec/features/referentials_spec.rb b/spec/features/referentials_spec.rb
index ebaf70bca..3c2258a3a 100644
--- a/spec/features/referentials_spec.rb
+++ b/spec/features/referentials_spec.rb
@@ -55,6 +55,59 @@ describe "Referentials", :type => :feature do
expect(page).to have_link(I18n.t('actions.edit'), href: edit_referential_path(referential))
end
end
+
+ context 'user has the permission to create referentials' do
+ it 'shows the clone link for referetnial' do
+ expect(page).to have_link(I18n.t('actions.clone'), href: new_referential_path(from: referential.id))
+ end
+ end
+
+ context 'user does not have the permission to create referentials' do
+ it 'does not show the clone link for referetnial' do
+ @user.update_attribute(:permissions, [])
+ visit referential_path(referential)
+ expect(page).not_to have_link(I18n.t('actions.clone'), href: new_referential_path(from: referential.id))
+ end
+ end
+
+ context 'user has the permission to edit referentials' do
+ it 'shows the link to edit the referential' do
+ expect(page).to have_link(I18n.t('actions.edit'), href: edit_referential_path(referential))
+ end
+
+ it 'shows the link to archive the referential' do
+ expect(page).to have_link(I18n.t('actions.archive'), href: archive_referential_path(referential))
+ end
+ end
+
+ context 'user does not have the permission to edit referentials' do
+ before(:each) do
+ @user.update_attribute(:permissions, [])
+ visit referential_path(referential)
+ end
+
+ it 'does not show the link to edit the referential' do
+ expect(page).not_to have_link(I18n.t('actions.edit'), href: edit_referential_path(referential))
+ end
+
+ it 'does not show the link to archive the referential' do
+ expect(page).not_to have_link(I18n.t('actions.archive'), href: archive_referential_path(referential))
+ end
+ end
+
+ context 'user has the permission to destroy referentials' do
+ it 'shows the link to destroy the referential' do
+ expect(page).to have_link(I18n.t('actions.destroy'), href: referential_path(referential))
+ end
+ end
+
+ context 'user does not have the permission to destroy referentials' do
+ it 'does not show the destroy link for referetnial' do
+ @user.update_attribute(:permissions, [])
+ visit referential_path(referential)
+ expect(page).not_to have_link(I18n.t('actions.destroy'), href: referential_path(referential))
+ end
+ end
end
describe "create" do
diff --git a/spec/features/routes_spec.rb b/spec/features/routes_spec.rb
index 36d0e8f87..4b90a6ec6 100644
--- a/spec/features/routes_spec.rb
+++ b/spec/features/routes_spec.rb
@@ -102,7 +102,7 @@ describe "Routes", :type => :feature 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_content(I18n.t('actions.edit'))
+ expect(page).not_to have_link(I18n.t('actions.edit'), href: edit_referential_line_route_path(referential, line, route))
end
end
@@ -136,7 +136,7 @@ describe "Routes", :type => :feature 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_content(I18n.t('actions.destroy'))
+ expect(page).not_to have_link(I18n.t('actions.destroy'), href: referential_line_route_path(referential, line, route))
end
end
end
diff --git a/spec/features/routing_constraint_zones_spec.rb b/spec/features/routing_constraint_zones_spec.rb
index d1c39e211..9e8c7dad4 100644
--- a/spec/features/routing_constraint_zones_spec.rb
+++ b/spec/features/routing_constraint_zones_spec.rb
@@ -6,7 +6,8 @@ describe 'RoutingConstraintZones', type: :feature do
let(:referential) { Referential.first }
let!(:line) { create :line }
- let!(:routing_constraint_zones) { Array.new(2) { create :routing_constraint_zone, line: line } }
+ let!(:route) { create :route, line: line }
+ let!(:routing_constraint_zones) { Array.new(2) { create :routing_constraint_zone, route: route } }
let(:routing_constraint_zone) { routing_constraint_zones.first }
describe 'index' do
diff --git a/spec/features/time_tables_spec.rb b/spec/features/time_tables_spec.rb
index 8e0b62c89..06ae9bac3 100644
--- a/spec/features/time_tables_spec.rb
+++ b/spec/features/time_tables_spec.rb
@@ -18,7 +18,7 @@ describe "TimeTables", :type => :feature do
context 'user has permission to create time tables' do
it 'shows a create link for time tables' do
- expect(page).to have_content(I18n.t('time_tables.actions.new'))
+ expect(page).to have_content(I18n.t('actions.add'))
end
end
@@ -26,13 +26,13 @@ describe "TimeTables", :type => :feature do
it 'does not show a create link for time tables' do
@user.update_attribute(:permissions, [])
visit referential_time_tables_path(referential)
- expect(page).not_to have_content(I18n.t('time_tables.actions.new'))
+ expect(page).not_to have_content(I18n.t('actions.add'))
end
end
context 'user has permission to edit time tables' do
it 'shows an edit button for time tables' do
- expect(page).to have_css('span.fa.fa-pencil')
+ expect(page).to have_content(I18n.t('actions.edit'))
end
end
@@ -40,13 +40,13 @@ describe "TimeTables", :type => :feature do
it 'does not show a edit link for time tables' do
@user.update_attribute(:permissions, [])
visit referential_time_tables_path(referential)
- expect(page).not_to have_css('span.fa.fa-pencil')
+ expect(page).not_to have_content(I18n.t('actions.add'))
end
end
context 'user has permission to destroy time tables' do
it 'shows a destroy button for time tables' do
- expect(page).to have_css('span.fa.fa-trash-o')
+ expect(page).to have_content(I18n.t('actions.delete'))
end
end
@@ -54,7 +54,7 @@ describe "TimeTables", :type => :feature do
it 'does not show a destroy button for time tables' do
@user.update_attribute(:permissions, [])
visit referential_time_tables_path(referential)
- expect(page).not_to have_css('span.fa.fa-trash-o')
+ expect(page).not_to have_content(I18n.t('actions.delete'))
end
end
@@ -67,33 +67,33 @@ describe "TimeTables", :type => :feature do
expect(page).to have_content(time_tables.first.comment)
end
- context 'user has permission to create time tables' do
- it 'shows a create link for time tables' do
- expect(page).to have_content(I18n.t('time_tables.actions.new'))
- end
-
- it 'does not show link to duplicate the time table' do
- expect(page).to have_content(I18n.t('time_tables.actions.duplicate'))
- end
- end
+ # context 'user has permission to create time tables' do
+ # it 'shows a create link for time tables' do
+ # expect(page).to have_content(I18n.t('time_tables.actions.new'))
+ # end
+ #
+ # it 'does not show link to duplicate the time table' do
+ # expect(page).to have_content(I18n.t('time_tables.actions.duplicate'))
+ # end
+ # end
context 'user does not have permission to create time tables' do
it 'does not show a create link for time tables' do
@user.update_attribute(:permissions, [])
visit referential_time_table_path(referential, time_table)
- expect(page).not_to have_content(I18n.t('time_tables.actions.new'))
+ expect(page).not_to have_content(I18n.t('actions.add'))
end
it 'does not show link to duplicate the time table' do
@user.update_attribute(:permissions, [])
visit referential_time_table_path(referential, time_table)
- expect(page).not_to have_content(I18n.t('time_tables.actions.duplicate'))
+ expect(page).not_to have_content(I18n.t('actions.duplicate'))
end
end
context 'user has permission to edit time tables' do
it 'shows the edit link for time table' do
- expect(page).to have_content(I18n.t('time_tables.actions.edit'))
+ expect(page).to have_content(I18n.t('actions.edit'))
end
end
@@ -101,13 +101,13 @@ describe "TimeTables", :type => :feature do
it 'does not show the edit link for time table' do
@user.update_attribute(:permissions, [])
visit referential_time_table_path(referential, time_table)
- expect(page).not_to have_content(I18n.t('time_tables.actions.edit'))
+ expect(page).not_to have_content(I18n.t('actions.edit'))
end
end
context 'user has permission to destroy time tables' do
it 'shows the destroy link for time table' do
- expect(page).to have_content(I18n.t('time_tables.actions.destroy'))
+ expect(page).to have_content(I18n.t('actions.destroy'))
end
end
@@ -115,30 +115,11 @@ describe "TimeTables", :type => :feature do
it 'does not show a destroy link for time table' do
@user.update_attribute(:permissions, [])
visit referential_time_table_path(referential, time_table)
- expect(page).not_to have_content(I18n.t('time_tables.actions.destroy'))
+ expect(page).not_to have_content(I18n.t('actions.destroy'))
end
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 "Editer ce calendrier"
- fill_in "Nom", :with => "TimeTable Modified"
- click_button("Editer calendrier")
- expect(page).to have_content("TimeTable Modified")
- end
- end
+ # No more test for the form, as it is now managed by React/Redux.
end
diff --git a/spec/features/workbenches_spec.rb b/spec/features/workbenches_spec.rb
index 608746e56..0a71a0b6b 100644
--- a/spec/features/workbenches_spec.rb
+++ b/spec/features/workbenches_spec.rb
@@ -18,11 +18,26 @@ describe 'Workbenches', type: :feature do
let!(:ready_referential) { create :referential, workbench: workbench, metadatas: referential_metadatas, ready: true, organisation: @user.organisation }
let!(:unready_referential) { create :referential, workbench: workbench }
+ before(:each) { visit workbench_path(workbench) }
+
it 'shows ready referentials belonging to that workbench by default' do
- visit workbench_path(workbench)
expect(page).to have_content(ready_referential.name)
expect(page).not_to have_content(unready_referential.name)
end
+
+ context 'user has the permission to create referentials' do
+ it 'shows the link for a new referetnial' do
+ expect(page).to have_link(I18n.t('referentials.actions.new'), href: new_referential_path(workbench_id: workbenches.first))
+ end
+ end
+
+ context 'user does not have the permission to create referentials' do
+ it 'does not show the clone link for referetnial' do
+ @user.update_attribute(:permissions, [])
+ visit referential_path(referential)
+ expect(page).not_to have_link(I18n.t('referentials.actions.new'), href: new_referential_path(workbench_id: workbenches.first))
+ end
+ end
end
describe 'create new Referential' do
diff --git a/spec/fixtures/users.json b/spec/fixtures/users.json
index f4236a29e..6f50e402c 100644
--- a/spec/fixtures/users.json
+++ b/spec/fixtures/users.json
@@ -58,7 +58,8 @@
"locked_at": null,
"profile": "Administrateur",
"organization_name": "STIF",
- "organization_code": "STIF"
+ "organization_code": "STIF",
+ "permissions": []
}, {
"id": 5,
"username": "laure.dubuc",
@@ -71,7 +72,8 @@
"locked_at": null,
"profile": "Administrateur",
"organization_name": "STIF",
- "organization_code": "STIF"
+ "organization_code": "STIF",
+ "permissions": []
}, {
"id": 6,
"username": "thomas.haddad",
@@ -84,7 +86,8 @@
"locked_at": null,
"profile": "Administrateur",
"organization_name": "STIF",
- "organization_code": "STIF"
+ "organization_code": "STIF",
+ "permissions": []
}, {
"id": 7,
"username": "jean-paul.lescouzeres",
@@ -97,7 +100,8 @@
"locked_at": null,
"profile": "Administrateur",
"organization_name": "STIF",
- "organization_code": "STIF"
+ "organization_code": "STIF",
+ "permissions": []
}, {
"id": 8,
"username": "xinhui.xu",
@@ -110,7 +114,8 @@
"locked_at": null,
"profile": "Administrateur",
"organization_name": "STIF",
- "organization_code": "STIF"
+ "organization_code": "STIF",
+ "permissions": []
}, {
"id": 9,
"username": "edouard.maffert",
@@ -123,7 +128,8 @@
"locked_at": null,
"profile": "Administrateur",
"organization_name": "STIF",
- "organization_code": "STIF"
+ "organization_code": "STIF",
+ "permissions": []
}, {
"id": 9,
"username": "vlatka.pavisic",
@@ -152,7 +158,8 @@
"locked_at": null,
"profile": "Référent IV Transporteur",
"organization_name": "RATP",
- "organization_code": "RATP"
+ "organization_code": "RATP",
+ "permissions": []
}, {
"id": 11,
"username": "jane.doe",
@@ -165,5 +172,6 @@
"locked_at": "2016-08-05T12:34:03.995Z",
"profile": "Référent IV Transporteur",
"organization_name": "RATP",
- "organization_code": "RATP"
+ "organization_code": "RATP",
+ "permissions": []
}]
diff --git a/spec/helpers/exports_helper_spec.rb b/spec/helpers/exports_helper_spec.rb
index fec8252d5..3d6b8e70e 100644
--- a/spec/helpers/exports_helper_spec.rb
+++ b/spec/helpers/exports_helper_spec.rb
@@ -6,7 +6,7 @@ require 'spec_helper'
# describe ExportsHelper do
# describe "string concat" do
# it "concats two strings with spaces" do
-# helper.concat_strings("this","that").should == "this that"
+# expect(helper.concat_strings("this","that")).to == "this that"
# end
# end
# end
diff --git a/spec/helpers/help_helper_spec.rb b/spec/helpers/help_helper_spec.rb
index 3df091c10..0b0de512b 100644
--- a/spec/helpers/help_helper_spec.rb
+++ b/spec/helpers/help_helper_spec.rb
@@ -6,7 +6,7 @@ require 'spec_helper'
# describe HelpHelper do
# describe "string concat" do
# it "concats two strings with spaces" do
-# helper.concat_strings("this","that").should == "this that"
+# expect(helper.concat_strings("this","that")).to == "this that"
# end
# end
# end
diff --git a/spec/helpers/imports_helper_spec.rb b/spec/helpers/imports_helper_spec.rb
index ec3bb05c5..12cddeb25 100644
--- a/spec/helpers/imports_helper_spec.rb
+++ b/spec/helpers/imports_helper_spec.rb
@@ -6,7 +6,7 @@ require 'spec_helper'
# describe ImportsHelper do
# describe "string concat" do
# it "concats two strings with spaces" do
-# helper.concat_strings("this","that").should == "this that"
+# expect(helper.concat_strings("this","that")).to == "this that"
# end
# end
# end
diff --git a/spec/helpers/referentials_helper_spec.rb b/spec/helpers/referentials_helper_spec.rb
index 6efc13822..6b659dc8b 100644
--- a/spec/helpers/referentials_helper_spec.rb
+++ b/spec/helpers/referentials_helper_spec.rb
@@ -6,7 +6,7 @@ require 'spec_helper'
# describe ReferentialsHelper do
# describe "string concat" do
# it "concats two strings with spaces" do
-# helper.concat_strings("this","that").should == "this that"
+# expect(helper.concat_strings("this","that")).to == "this that"
# end
# end
# end
diff --git a/spec/javascripts/time_table/actions_spec.js b/spec/javascripts/time_table/actions_spec.js
new file mode 100644
index 000000000..c628a0f57
--- /dev/null
+++ b/spec/javascripts/time_table/actions_spec.js
@@ -0,0 +1,27 @@
+var actions = require('es6_browserified/time_tables/actions')
+
+describe('actions', () => {
+ it('should create an action to update dayTypes', () => {
+ const expectedAction = {
+ type: 'UPDATE_DAY_TYPES',
+ index: 1
+ }
+ expect(actions.updateDayTypes(1)).toEqual(expectedAction)
+ })
+
+ it('should create an action to update comment', () => {
+ const expectedAction = {
+ type: 'UPDATE_COMMENT',
+ comment: 'test'
+ }
+ expect(actions.updateComment('test')).toEqual(expectedAction)
+ })
+
+ it('should create an action to update color', () => {
+ const expectedAction = {
+ type: 'UPDATE_COLOR',
+ color: '#ffffff'
+ }
+ expect(actions.updateColor('#ffffff')).toEqual(expectedAction)
+ })
+})
diff --git a/spec/javascripts/time_table/reducers/metas_spec.js b/spec/javascripts/time_table/reducers/metas_spec.js
new file mode 100644
index 000000000..e3729dc2a
--- /dev/null
+++ b/spec/javascripts/time_table/reducers/metas_spec.js
@@ -0,0 +1,49 @@
+var metasReducer = require('es6_browserified/time_tables/reducers/metas')
+
+let state = {}
+
+describe('status reducer', () => {
+ beforeEach(() => {
+ state = {
+ comment: 'test',
+ day_types: [true, true, true, true, true, true, true],
+ tags: ['t1'],
+ color: 'blue'
+ }
+ })
+
+ it('should return the initial state', () => {
+ expect(
+ metasReducer(undefined, {})
+ ).toEqual({})
+ })
+
+ it('should handle UPDATE_DAY_TYPES', () => {
+ const arr = [false, true, true, true, true, true, true]
+ expect(
+ metasReducer(state, {
+ type: 'UPDATE_DAY_TYPES',
+ index: 0
+ })
+ ).toEqual(Object.assign({}, state, {day_types: arr}))
+ })
+
+ it('should handle UPDATE_COMMENT', () => {
+ expect(
+ metasReducer(state, {
+ type: 'UPDATE_COMMENT',
+ comment: 'title'
+ })
+ ).toEqual(Object.assign({}, state, {comment: 'title'}))
+ })
+
+ it('should handle UPDATE_COLOR', () => {
+ expect(
+ metasReducer(state, {
+ type: 'UPDATE_COLOR',
+ color: '#ffffff'
+ })
+ ).toEqual(Object.assign({}, state, {color: '#ffffff'}))
+ })
+
+})
diff --git a/spec/javascripts/vehicle_journeys/reducers/filters_spec.js b/spec/javascripts/vehicle_journeys/reducers/filters_spec.js
index 84608243b..d5cdff430 100644
--- a/spec/javascripts/vehicle_journeys/reducers/filters_spec.js
+++ b/spec/javascripts/vehicle_journeys/reducers/filters_spec.js
@@ -29,7 +29,7 @@ describe('filters reducer', () => {
},
journeyPattern: {},
timetable: {},
- withoutSchedule: false,
+ withoutSchedule: true,
},
queryString: ''
}
@@ -61,7 +61,7 @@ describe('filters reducer', () => {
it('should handle TOGGLE_WITHOUT_SCHEDULE', () => {
let rslt = JSON.parse(JSON.stringify(state.query))
- rslt.withoutSchedule = true
+ rslt.withoutSchedule = false
expect(
statusReducer(state, {
type: 'TOGGLE_WITHOUT_SCHEDULE'
@@ -143,8 +143,8 @@ describe('filters reducer', () => {
).toEqual(Object.assign({}, state, {query: newQuery}))
})
- it('should handle SELECT_JP_FILTER', () => {
- let strResult = "q%5Bjourney_pattern_id_eq%5D=undefined&q%5Btime_tables_id_eq%5D=undefined&q%5Bvehicle_journey_at_stops_departure_time_gteq%5D=11%3A11&q%5Bvehicle_journey_at_stops_departure_time_lteq%5D=22%3A22"
+ it('should handle CREATE_QUERY_STRING', () => {
+ let strResult = "q%5Bjourney_pattern_id_eq%5D=undefined&q%5Btime_tables_id_eq%5D=undefined&q%5Bvehicle_journey_at_stops_departure_time_gteq%5D=11%3A11&q%5Bvehicle_journey_at_stops_departure_time_lteq%5D=22%3A22&q%5Bvehicle_journey_without_departure_time%5D=true"
expect(
statusReducer(state, {
type: 'CREATE_QUERY_STRING',
diff --git a/spec/lib/af83/stored_procedure_spec.rb b/spec/lib/af83/stored_procedure_spec.rb
new file mode 100644
index 000000000..2530d7fc1
--- /dev/null
+++ b/spec/lib/af83/stored_procedure_spec.rb
@@ -0,0 +1,20 @@
+require 'rails_helper'
+
+RSpec.describe StoredProcedures do
+
+
+ before do
+ described_class.create_stored_procedure(:clone_schema)
+ end
+
+ let( :source_schema_name ){ "parissudest201604" }
+ let( :dest_schema_name ){ "#{source_schema_name}_v1"}
+
+ context "Error cases" do
+ it "raises an error if stored procedure does not exist" do
+ expect{ described_class.invoke_stored_procedure(:idonotexist) }
+ .to raise_error(ArgumentError, %r{no such stored procedure "idonotexist"})
+ end
+ end
+
+end
diff --git a/spec/lib/af83/stored_procedures/clone_schema_spec.rb b/spec/lib/af83/stored_procedures/clone_schema_spec.rb
new file mode 100755
index 000000000..4de3379ea
--- /dev/null
+++ b/spec/lib/af83/stored_procedures/clone_schema_spec.rb
@@ -0,0 +1,166 @@
+require 'spec_helper'
+
+include Support::PGCatalog
+
+RSpec.describe StoredProcedures do
+ let( :source_schema ){ "source_schema" }
+ let( :target_schema ){ "target_schema" }
+ let( :child_table ){ "children" }
+ let( :parent_table ){ "parents" }
+
+ before do
+ create_schema_with_tables
+ StoredProcedures.create_stored_procedure :clone_schema
+ end
+
+ context "meta specs describe source schema's introspection" do
+ it "table information is correctly read" do
+ expect(get_table_information(source_schema, child_table))
+ .to eq([{"table_schema"=>"source_schema",
+ "table_name"=>"children",
+ "table_type"=>"BASE TABLE",
+ "self_referencing_column_name"=>nil,
+ "reference_generation"=>nil,
+ "user_defined_type_catalog"=>nil,
+ "user_defined_type_schema"=>nil,
+ "user_defined_type_name"=>nil,
+ "is_insertable_into"=>"YES",
+ "is_typed"=>"NO",
+ "commit_action"=>nil}])
+
+ expect( get_table_information(target_schema, child_table) ).to be_empty
+ end
+
+ it "sequences are correctly read", :meta do
+ expect(get_sequences(source_schema, child_table))
+ .to eq([{"sequence_name"=>"#{child_table}_id_seq",
+ "last_value"=>"1",
+ "start_value"=>"1",
+ "increment_by"=>"1",
+ "max_value"=>"9223372036854775807",
+ "min_value"=>"1",
+ "cache_value"=>"1",
+ "log_cnt"=>"0",
+ "is_cycled"=>"f",
+ "is_called"=>"f"}])
+
+ expect(get_sequences(source_schema, parent_table))
+ .to eq([{"sequence_name"=>"#{parent_table}_id_seq",
+ "last_value"=>"1",
+ "start_value"=>"1",
+ "increment_by"=>"1",
+ "max_value"=>"9223372036854775807",
+ "min_value"=>"1",
+ "cache_value"=>"1",
+ "log_cnt"=>"0",
+ "is_cycled"=>"f",
+ "is_called"=>"f"}])
+ end
+
+ it "shows foreign key constraints are correctly read" do
+ expect( get_foreign_keys(source_schema, child_table) )
+ .to eq([{
+ "constraint_name" => "children_parents",
+ "constraint_def" => "FOREIGN KEY (parents_id) REFERENCES source_schema.parents(id)"}])
+ end
+ end
+
+ context "before cloning" do
+ it "target schema does not exist" do
+ expect( get_schema_oid(target_schema) ).to be_nil
+ end
+ end
+
+ context "after cloning" do
+ before do
+ described_class.invoke_stored_procedure(:clone_schema, source_schema, target_schema, false)
+ end
+
+ it "target schema does exist" do
+ expect( get_schema_oid(target_schema) ).not_to be_nil
+ end
+
+ it "table information is correctly read" do
+ expect(get_table_information(source_schema, child_table))
+ .to eq([{"table_schema"=>"source_schema",
+ "table_name"=>"children",
+ "table_type"=>"BASE TABLE",
+ "self_referencing_column_name"=>nil,
+ "reference_generation"=>nil,
+ "user_defined_type_catalog"=>nil,
+ "user_defined_type_schema"=>nil,
+ "user_defined_type_name"=>nil,
+ "is_insertable_into"=>"YES",
+ "is_typed"=>"NO",
+ "commit_action"=>nil}])
+
+ expect( get_table_information(target_schema, child_table))
+ .to eq([{"table_schema"=>"target_schema",
+ "table_name"=>"children",
+ "table_type"=>"BASE TABLE",
+ "self_referencing_column_name"=>nil,
+ "reference_generation"=>nil,
+ "user_defined_type_catalog"=>nil,
+ "user_defined_type_schema"=>nil,
+ "user_defined_type_name"=>nil,
+ "is_insertable_into"=>"YES",
+ "is_typed"=>"NO",
+ "commit_action"=>nil}])
+ end
+
+ it "has the correct sequences" do
+ expect(get_sequences(target_schema, child_table))
+ .to eq([{"sequence_name"=>"#{child_table}_id_seq",
+ "last_value"=>"1",
+ "start_value"=>"1",
+ "increment_by"=>"1",
+ "max_value"=>"9223372036854775807",
+ "min_value"=>"1",
+ "cache_value"=>"1",
+ "log_cnt"=>"0",
+ "is_cycled"=>"f",
+ "is_called"=>"f"}])
+
+ expect(get_sequences(target_schema, parent_table))
+ .to eq([{"sequence_name"=>"#{parent_table}_id_seq",
+ "last_value"=>"1",
+ "start_value"=>"1",
+ "increment_by"=>"1",
+ "max_value"=>"9223372036854775807",
+ "min_value"=>"1",
+ "cache_value"=>"1",
+ "log_cnt"=>"0",
+ "is_cycled"=>"f",
+ "is_called"=>"f"}])
+ end
+
+ it "has the correct foreign keys" do
+ expect( get_foreign_keys(target_schema, child_table) )
+ .to eq([{
+ "constraint_name" => "children_parents",
+ "constraint_def" => "FOREIGN KEY (parents_id) REFERENCES target_schema.parents(id)"}])
+ end
+
+ end
+
+end
+
+def create_schema_with_tables
+ execute("CREATE SCHEMA IF NOT EXISTS #{source_schema}")
+ execute <<-EOSQL
+ DROP SCHEMA IF EXISTS #{source_schema} CASCADE;
+ CREATE SCHEMA #{source_schema};
+
+ CREATE TABLE #{source_schema}.#{parent_table} (
+ id bigserial PRIMARY KEY
+ );
+ CREATE TABLE #{source_schema}.#{child_table} (
+ id bigserial PRIMARY KEY,
+ #{parent_table}_id bigint
+ );
+ ALTER TABLE #{source_schema}.#{child_table}
+ ADD CONSTRAINT #{child_table}_#{parent_table}
+ FOREIGN KEY( #{parent_table}_id ) REFERENCES #{source_schema}.#{parent_table}(id);
+ EOSQL
+end
+
diff --git a/spec/models/chouette/routing_constraint_zone_spec.rb b/spec/models/chouette/routing_constraint_zone_spec.rb
index d991538ba..87ee9e9ac 100644
--- a/spec/models/chouette/routing_constraint_zone_spec.rb
+++ b/spec/models/chouette/routing_constraint_zone_spec.rb
@@ -3,11 +3,48 @@ require 'spec_helper'
describe Chouette::RoutingConstraintZone, type: :model do
subject { create(:routing_constraint_zone) }
+ let!(:routing_constraint_zone) { create(:routing_constraint_zone) }
it { is_expected.to validate_presence_of :name }
- it { is_expected.to validate_presence_of :stop_area_ids }
- it { is_expected.to validate_presence_of :line_id }
# shoulda matcher to validate length of array ?
- xit { is_expected.to validate_length_of(:stop_area_ids).is_at_least(2) }
+ xit { is_expected.to validate_length_of(:stop_point_ids).is_at_least(2) }
+
+ describe 'validations' do
+ it 'validates the presence of route_id' do
+ expect {
+ routing_constraint_zone.update!(route_id: nil)
+ }.to raise_error(NoMethodError)
+ end
+
+ it 'validates the presence of stop_point_ids' do
+ expect {
+ routing_constraint_zone.update!(stop_point_ids: [])
+ }.to raise_error(ActiveRecord::RecordInvalid)
+ end
+
+ it 'validates that stop points belong to the route' do
+ route = create(:route)
+ expect {
+ routing_constraint_zone.update!(route_id: route.id)
+ }.to raise_error(ActiveRecord::RecordInvalid)
+ end
+
+ it 'validates that not all stop points from the route are selected' do
+ routing_constraint_zone.stop_points = routing_constraint_zone.route.stop_points
+ expect {
+ routing_constraint_zone.save!
+ }.to raise_error(ActiveRecord::RecordInvalid)
+ end
+ end
+
+ describe 'deleted stop areas' do
+ it 'does not have them in stop_area_ids' do
+ stop_point = routing_constraint_zone.route.stop_points.last
+ routing_constraint_zone.stop_points << stop_point
+ routing_constraint_zone.save!
+ routing_constraint_zone.route.stop_points.last.destroy!
+ expect(routing_constraint_zone.stop_points.map(&:id)).not_to include(stop_point.id)
+ end
+ end
end
diff --git a/spec/models/chouette/vehicle_journey_spec.rb b/spec/models/chouette/vehicle_journey_spec.rb
index fab9cd5e8..b394dd504 100644
--- a/spec/models/chouette/vehicle_journey_spec.rb
+++ b/spec/models/chouette/vehicle_journey_spec.rb
@@ -1,23 +1,30 @@
require 'spec_helper'
describe Chouette::VehicleJourney, :type => :model do
describe "state_update" do
+
+ def vehicle_journey_at_stop_to_state vjas
+ at_stop = {'stop_area_object_id' => vjas.stop_point.stop_area.objectid }
+ [:id, :connecting_service_id, :boarding_alighting_possibility].map do |att|
+ at_stop[att.to_s] = vjas.send(att) unless vjas.send(att).nil?
+ end
+
+ [:arrival_time, :departure_time].map do |att|
+ at_stop[att.to_s] = {
+ 'hour' => vjas.send(att).strftime('%H'),
+ 'minute' => vjas.send(att).strftime('%M'),
+ }
+ end
+ at_stop
+ end
+
def vehicle_journey_to_state vj
vj.attributes.slice('objectid', 'published_journey_name', 'journey_pattern_id', 'company_id').tap do |item|
item['vehicle_journey_at_stops'] = []
+ item['time_tables'] = []
+ item['footnotes'] = []
- vj.vehicle_journey_at_stops.each do |vs|
- at_stops = {'stop_area_object_id' => vs.stop_point.stop_area.objectid }
- [:id, :connecting_service_id, :boarding_alighting_possibility].map do |att|
- at_stops[att.to_s] = vs.send(att) unless vs.send(att).nil?
- end
-
- [:arrival_time, :departure_time].map do |att|
- at_stops[att.to_s] = {
- 'hour' => vs.send(att).strftime('%H'),
- 'minute' => vs.send(att).strftime('%M'),
- }
- end
- item['vehicle_journey_at_stops'] << at_stops
+ vj.vehicle_journey_at_stops.each do |vjas|
+ item['vehicle_journey_at_stops'] << vehicle_journey_at_stop_to_state(vjas)
end
end
end
@@ -40,7 +47,36 @@ describe Chouette::VehicleJourney, :type => :model do
expect(vj.published_journey_name).to eq 'dummy'
end
- it 'should update vj journey_pattern' do
+ it 'should save vehicle_journey_at_stops of newly created vj' do
+ new_vj = build(:vehicle_journey, objectid: nil, published_journey_name: 'dummy', route: route, journey_pattern: journey_pattern)
+ new_vj.vehicle_journey_at_stops << build(:vehicle_journey_at_stop,
+ :vehicle_journey => new_vj,
+ :stop_point => create(:stop_point),
+ :arrival_time => '2000-01-01 01:00:00 UTC',
+ :departure_time => '2000-01-01 03:00:00 UTC')
+
+ collection << vehicle_journey_to_state(new_vj)
+ expect {
+ Chouette::VehicleJourney.state_update(route, collection)
+ }.to change {Chouette::VehicleJourneyAtStop.count}.by(1)
+ end
+
+ it 'should not save vehicle_journey_at_stops of newly created vj if all departure time is set to 00:00' do
+ new_vj = build(:vehicle_journey, objectid: nil, published_journey_name: 'dummy', route: route, journey_pattern: journey_pattern)
+ 2.times do
+ new_vj.vehicle_journey_at_stops << build(:vehicle_journey_at_stop,
+ :vehicle_journey => new_vj,
+ :stop_point => create(:stop_point),
+ :arrival_time => '2000-01-01 00:00:00 UTC',
+ :departure_time => '2000-01-01 00:00:00 UTC')
+ end
+ collection << vehicle_journey_to_state(new_vj)
+ expect {
+ Chouette::VehicleJourney.state_update(route, collection)
+ }.not_to change {Chouette::VehicleJourneyAtStop.count}
+ end
+
+ it 'should update vj journey_pattern association' do
state['journey_pattern'] = create(:journey_pattern).attributes.slice('id', 'name', 'objectid')
Chouette::VehicleJourney.state_update(route, collection)
@@ -48,6 +84,36 @@ describe Chouette::VehicleJourney, :type => :model do
expect(vehicle_journey.reload.journey_pattern_id).to eq state['journey_pattern']['id']
end
+ it 'should update vj time_tables association from state' do
+ 2.times{state['time_tables'] << create(:time_table).attributes.slice('id', 'comment', 'objectid')}
+ vehicle_journey.update_has_and_belongs_to_many_from_state(state)
+
+ expect(vehicle_journey.reload.time_tables.map(&:id)).to eq(state['time_tables'].map{|tt| tt['id']})
+ end
+
+ it 'should clear vj time_tableas association when remove from state' do
+ vehicle_journey.time_tables << create(:time_table)
+ state['time_tables'] = []
+ vehicle_journey.update_has_and_belongs_to_many_from_state(state)
+
+ expect(vehicle_journey.reload.time_tables).to be_empty
+ end
+
+ it 'should update vj footnote association from state' do
+ 2.times{state['footnotes'] << create(:footnote, line: route.line).attributes.slice('id', 'code', 'label', 'line_id')}
+ vehicle_journey.update_has_and_belongs_to_many_from_state(state)
+
+ expect(vehicle_journey.reload.footnotes.map(&:id)).to eq(state['footnotes'].map{|tt| tt['id']})
+ end
+
+ it 'should clear vj footnote association from state' do
+ vehicle_journey.footnotes << create(:footnote)
+ state['footnotes'] = []
+ vehicle_journey.update_has_and_belongs_to_many_from_state(state)
+
+ expect(vehicle_journey.reload.footnotes).to be_empty
+ end
+
it 'should update vj company' do
state['company'] = create(:company).attributes.slice('id', 'name', 'objectid')
Chouette::VehicleJourney.state_update(route, collection)
@@ -124,14 +190,22 @@ describe Chouette::VehicleJourney, :type => :model do
describe '.vehicle_journey_at_stops_matrix' do
it 'should fill missing VehicleJourneyAtStop with dummy' do
- vehicle_journey.vehicle_journey_at_stops.last.destroy
- expect(vehicle_journey.reload.vehicle_journey_at_stops.map(&:id).count).to eq(route.stop_points.map(&:id).count - 1)
+ vehicle_journey.journey_pattern.stop_points.delete_all
+ vehicle_journey.vehicle_journey_at_stops.delete_all
+ expect(vehicle_journey.reload.vehicle_journey_at_stops).to be_empty
at_stops = vehicle_journey.reload.vehicle_journey_at_stops_matrix
- expect(at_stops.last.id).to be_nil
+ at_stops.map{|stop| expect(stop.stop_point_id).to be_nil }
expect(at_stops.count).to eq route.stop_points.count
end
+ it 'should fill VehicleJourneyAtStop with new vjas when vj has been save without departure time' do
+ vehicle_journey.vehicle_journey_at_stops.destroy_all
+
+ at_stops = vehicle_journey.reload.vehicle_journey_at_stops_matrix
+ expect(at_stops.map(&:stop_point_id)).to eq vehicle_journey.journey_pattern.stop_points.map(&:id)
+ end
+
it 'should keep index order of VehicleJourneyAtStop' do
vehicle_journey.vehicle_journey_at_stops[3].destroy
at_stops = vehicle_journey.reload.vehicle_journey_at_stops_matrix
diff --git a/spec/models/compliance_check_task_spec.rb b/spec/models/compliance_check_task_spec.rb
index 2e5379de7..a062fdb58 100644
--- a/spec/models/compliance_check_task_spec.rb
+++ b/spec/models/compliance_check_task_spec.rb
@@ -1,5 +1,8 @@
# require 'spec_helper'
+# TODO: Can we get rid of this???
+# *************************
+
# describe ComplianceCheckTask, :type => :model do
# subject { Factory( :compliance_check_task ) }
@@ -274,19 +277,19 @@
# #
# # it "should create a ComplianceCheckResult :started when started" do
# # subject.validate
-# # subject.compliance_check_results.first.should be_log_message(:key => "started")
+ # expect(subject.compliance_check_results.first).to be_log_message(:key => "started")
# # end
# #
# # it "should create a ComplianceCheckResult :completed when completed" do
# # subject.validate
-# # subject.compliance_check_results.last.should be_log_message(:key => "completed")
+ # expect(subject.compliance_check_results.last).to be_log_message(:key => "completed")
# # end
# #
# # it "should create a ComplianceCheckResult :failed when failed" do
# # pending
# # # subject.loader.stub(:export).and_raise("export failed")
# # subject.validate
-# # subject.compliance_check_results.last.should be_log_message(:key => "failed")
+ # expect(subject.compliance_check_results.last).to be_log_message(:key => "failed")
# # end
# #
# # end
diff --git a/spec/models/import_spec.rb b/spec/models/import_spec.rb
index e34f368ae..a2855d086 100644
--- a/spec/models/import_spec.rb
+++ b/spec/models/import_spec.rb
@@ -4,7 +4,7 @@ RSpec.describe Import, :type => :model do
it { should belong_to(:referential) }
it { should belong_to(:workbench) }
- it { should enumerize(:status).in(:new, :pending, :successful, :failed, :canceled) }
+ it { should enumerize(:status).in(:new, :pending, :successful, :failed, :canceled, :running, :aborted ) }
it { should validate_presence_of(:file) }
end
diff --git a/spec/models/ninoxe_extension_spec.rb b/spec/models/ninoxe_extension_spec.rb
index b8892f053..016e10496 100644
--- a/spec/models/ninoxe_extension_spec.rb
+++ b/spec/models/ninoxe_extension_spec.rb
@@ -8,23 +8,23 @@ describe Chouette::StopArea do
# FIXME #821
# it "should return referential projection " do
# subject.referential.projection_type='27572'
- # subject.projection.should == subject.referential.projection_type
+ # expect(subject.projection).to eq(subject.referential.projection_type)
# end
# it "should return projection coordinates when referential has projection" do
# subject.latitude = 45
# subject.longitude = 0
# subject.referential.projection_type='27572'
- # subject.projection_x.should_not be_nil
- # subject.projection_y.should_not be_nil
+ # expect(subject.projection_x).not_to be_nil
+ # expect(subject.projection_y).not_to be_nil
# end
# it "should return nil projection coordinates when referential has no projection" do
# subject.latitude = 45
# subject.longitude = 0
# subject.referential.projection_type=nil
- # subject.projection_x.should be_nil
- # subject.projection_y.should be_nil
+ # expect(subject.projection_x).to be_nil
+ # expect(subject.projection_y).to be_nil
# end
end
@@ -34,25 +34,25 @@ describe Chouette::AccessPoint do
subject {create(:access_point)}
- it "should return referential projection " do
+ it "should return referential projection" do
subject.referential.projection_type='27572'
- subject.projection.should == subject.referential.projection_type
+ expect(subject.projection).to eq(subject.referential.projection_type)
end
it "should return projection coordinates when referential has projection" do
subject.latitude = 45
subject.longitude = 0
subject.referential.projection_type='27572'
- subject.projection_x.should_not be_nil
- subject.projection_y.should_not be_nil
+ expect(subject.projection_x).not_to be_nil
+ expect(subject.projection_y).not_to be_nil
end
it "should return nil projection coordinates when referential has no projection" do
subject.latitude = 45
subject.longitude = 0
subject.referential.projection_type=nil
- subject.projection_x.should be_nil
- subject.projection_y.should be_nil
+ expect(subject.projection_x).to be_nil
+ expect(subject.projection_y).to be_nil
end
end
diff --git a/spec/models/organisation_spec.rb b/spec/models/organisation_spec.rb
index 9b4235755..527f71015 100644
--- a/spec/models/organisation_spec.rb
+++ b/spec/models/organisation_spec.rb
@@ -10,7 +10,7 @@ describe Organisation, :type => :model do
it "create a rule_parameter_set" do
organisation = create(:organisation)
- organisation.rule_parameter_sets.size.should == 1
+ expect(organisation.rule_parameter_sets.size).to eq(1)
end
describe "Portail sync" do
diff --git a/spec/models/referential_metadata_spec.rb b/spec/models/referential_metadata_spec.rb
index ede589860..0f628c8d1 100644
--- a/spec/models/referential_metadata_spec.rb
+++ b/spec/models/referential_metadata_spec.rb
@@ -118,6 +118,19 @@ RSpec.describe ReferentialMetadata, :type => :model do
end
+ describe "#periodes" do
+
+ let(:referential_metadata) { create(:referential_metadata).reload }
+
+ it "should not exclude end" do
+ expect(referential_metadata.periodes).to_not be_empty
+ referential_metadata.periodes.each do |periode|
+ expect(periode).to_not be_exclude_end
+ end
+ end
+
+ end
+
describe "before_validation" do
let(:referential_metadata) do
create(:referential_metadata).tap do |metadata|
diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb
index f56680fc0..5c7aa0b98 100644
--- a/spec/models/user_spec.rb
+++ b/spec/models/user_spec.rb
@@ -14,7 +14,7 @@ describe User, :type => :model do
:organisation_code => '0083',
:organisation_name => 'af83',
:functional_scope => "[\"STIF:CODIFLIGNE:Line:C00840\", \"STIF:CODIFLIGNE:Line:C00086\"]",
- :permissions => nil
+ :permissions => []
}
ticket.user = "john.doe"
ticket.success = true
@@ -119,27 +119,11 @@ describe User, :type => :model do
it 'should give edit permissions to user if user has "edit offer" permission in portail' do
User.portail_sync
expect(User.find_by(username: 'vlatka.pavisic').permissions).not_to be_empty
- expect(User.find_by(username: 'pierre.vabre').permissions).to be_nil
+ expect(User.find_by(username: 'pierre.vabre').permissions).to be_empty
end
end
end
- describe 'validations' do
- it 'validates uniqueness of pemissions' do
- user = build :user, permissions: Array.new(2, 'calendars.shared')
- expect {
- user.save!
- }.to raise_error(ActiveRecord::RecordInvalid)
- end
-
- it 'validates no pemission is an empty string' do
- user = build :user, permissions: ['']
- expect {
- user.save!
- }.to raise_error(ActiveRecord::RecordInvalid)
- end
- end
-
describe "#destroy" do
let!(:organisation){create(:organisation)}
let!(:user){create(:user, :organisation => organisation)}
diff --git a/spec/models/vehicle_journey_import_spec.rb b/spec/models/vehicle_journey_import_spec.rb
index c4d452f84..a743bdecb 100644
--- a/spec/models/vehicle_journey_import_spec.rb
+++ b/spec/models/vehicle_journey_import_spec.rb
@@ -119,7 +119,7 @@ describe VehicleJourneyImport, :type => :model do
it "should return false when stop points in file are not the same in the route" do
vehicle_journey_import = VehicleJourneyImport.new(:route => other_route, :file => valid_file)
- expect { vehicle_journey_import.load_imported_vehicle_journeys }.to raise_exception
+ expect { vehicle_journey_import.load_imported_vehicle_journeys }.to raise_error(RuntimeError)
end
# it "should return errors when vehicle journeys in file are invalid" do
@@ -130,7 +130,7 @@ describe VehicleJourneyImport, :type => :model do
it "should return errors when vehicle journey at stops in file are invalid" do
vehicle_journey_import = VehicleJourneyImport.new(:route => route, :file => invalid_file_on_vjas)
- expect { vehicle_journey_import.load_imported_vehicle_journeys }.to raise_exception
+ expect { vehicle_journey_import.load_imported_vehicle_journeys }.to raise_error(ArgumentError)
end
it "should return errors when vehicle journey at stops are not in ascendant order" do
diff --git a/spec/routing/companies_spec.rb b/spec/routing/companies_spec.rb
index df16079f3..774431dc3 100644
--- a/spec/routing/companies_spec.rb
+++ b/spec/routing/companies_spec.rb
@@ -3,19 +3,19 @@ require 'spec_helper'
describe CompaniesController do
describe "routing" do
it "not recognize #routes" do
- get( "/line_referentials/1/companies/2/routes").should_not route_to(
+ expect(get( "/line_referentials/1/companies/2/routes")).not_to route_to(
:controller => "companies", :action => "routes",
:line_referential_id => "1", :id => "2"
)
end
it "not recognize #lines" do
- get( "/line_referentials/1/companies/2/lines").should_not route_to(
+ expect(get( "/line_referentials/1/companies/2/lines")).not_to route_to(
:controller => "companies", :action => "lines",
:line_referential_id => "1", :id => "2"
)
end
it "recognize and generate #show" do
- get( "/line_referentials/1/companies/2").should route_to(
+ expect(get( "/line_referentials/1/companies/2")).to route_to(
:controller => "companies", :action => "show",
:line_referential_id => "1", :id => "2"
)
diff --git a/spec/routing/group_of_lines_spec.rb b/spec/routing/group_of_lines_spec.rb
index 8bc437249..2a7262893 100644
--- a/spec/routing/group_of_lines_spec.rb
+++ b/spec/routing/group_of_lines_spec.rb
@@ -3,19 +3,19 @@ require 'spec_helper'
describe GroupOfLinesController do
describe "routing" do
it "not recognize #routes" do
- get( "/line_referentials/1/group_of_lines/2/routes").should_not route_to(
+ expect(get( "/line_referentials/1/group_of_lines/2/routes")).not_to route_to(
:controller => "group_of_lines", :action => "routes",
:line_referential_id => "1", :id => "2"
)
end
it "not recognize #lines" do
- get( "/line_referentials/1/group_of_lines/2/lines").should_not route_to(
+ expect(get( "/line_referentials/1/group_of_lines/2/lines")).not_to route_to(
:controller => "group_of_lines", :action => "lines",
:line_referential_id => "1", :id => "2"
)
end
it "recognize and generate #show" do
- get( "/line_referentials/1/group_of_lines/2").should route_to(
+ expect(get( "/line_referentials/1/group_of_lines/2")).to route_to(
:controller => "group_of_lines", :action => "show",
:line_referential_id => "1", :id => "2"
)
diff --git a/spec/routing/networks_spec.rb b/spec/routing/networks_spec.rb
index 8d5366f88..941f98c1e 100644
--- a/spec/routing/networks_spec.rb
+++ b/spec/routing/networks_spec.rb
@@ -3,19 +3,19 @@ require 'spec_helper'
describe NetworksController do
describe "routing" do
it "not recognize #routes" do
- get( "/line_referentials/1/networks/2/routes").should_not route_to(
+ expect(get( "/line_referentials/1/networks/2/routes")).not_to route_to(
:controller => "networks", :action => "routes",
:line_referential_id => "1", :id => "2"
)
end
it "not recognize #lines" do
- get( "/line_referentials/1/networks/2/lines").should_not route_to(
+ expect(get( "/line_referentials/1/networks/2/lines")).not_to route_to(
:controller => "networks", :action => "lines",
:line_referential_id => "1", :id => "2"
)
end
it "recognize and generate #show" do
- get( "/line_referentials/1/networks/2").should route_to(
+ expect(get( "/line_referentials/1/networks/2")).to route_to(
:controller => "networks", :action => "show",
:line_referential_id => "1", :id => "2"
)
diff --git a/spec/routing/time_tables_spec.rb b/spec/routing/time_tables_spec.rb
index 45e426f4c..720ae0815 100644
--- a/spec/routing/time_tables_spec.rb
+++ b/spec/routing/time_tables_spec.rb
@@ -3,25 +3,25 @@ require 'spec_helper'
describe TimeTablesController do
describe "routing" do
it "not recognize #routes" do
- get( "/referentials/1/time_tables/2/routes").should_not route_to(
+ expect(get( "/referentials/1/time_tables/2/routes")).not_to route_to(
:controller => "time_tables", :action => "routes",
:referential_id => "1", :id => "2"
)
end
it "not recognize #lines" do
- get( "/referentials/1/time_tables/2/lines").should_not route_to(
+ expect(get( "/referentials/1/time_tables/2/lines")).not_to route_to(
:controller => "time_tables", :action => "lines",
:referential_id => "1", :id => "2"
)
end
it "not recognize #time_table_periods" do
- get( "/referentials/1/time_tables/2/time_table_periods").should_not route_to(
+ expect(get( "/referentials/1/time_tables/2/time_table_periods")).not_to route_to(
"time_table_periods#index",
:referential_id => "1", :time_table_id => "2"
)
end
it "recognize and generate #show" do
- get( "/referentials/1/time_tables/2").should route_to(
+ expect(get( "/referentials/1/time_tables/2")).to route_to(
:controller => "time_tables", :action => "show",
:referential_id => "1", :id => "2"
)
diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb
index dd062bc84..f66d721c9 100644
--- a/spec/spec_helper.rb
+++ b/spec/spec_helper.rb
@@ -51,7 +51,8 @@ RSpec.configure do |config|
#Capybara.exact = true
Capybara.javascript_driver = :poltergeist
- config.filter_run_excluding :js => true
+ config.filter_run_excluding :js => true
+ config.filter_run :wip => true
config.run_all_when_everything_filtered = true
config.include TokenInputHelper, :type => :feature
@@ -87,3 +88,20 @@ RSpec.configure do |config|
config.infer_spec_type_from_file_location!
end
+
+Shoulda::Matchers.configure do |config|
+ config.integrate do |with|
+ # Choose a test framework:
+ with.test_framework :rspec
+ # with.test_framework :minitest
+ # with.test_framework :minitest_4
+ # with.test_framework :test_unit
+
+ # Choose one or more libraries:
+ # with.library :active_record
+ # with.library :active_model
+ # with.library :action_controller
+ # Or, choose the following (which implies all of the above):
+ with.library :rails
+ end
+end
diff --git a/spec/support/devise.rb b/spec/support/devise.rb
index 0e3ceefac..14e316bea 100644
--- a/spec/support/devise.rb
+++ b/spec/support/devise.rb
@@ -8,7 +8,8 @@ module DeviseRequestHelper
'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',
'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'])
+ 'connection_links.create', 'connection_links.edit', 'connection_links.destroy', 'route_sections.create', 'route_sections.edit', 'route_sections.destroy',
+ 'referentials.create', 'referentials.edit', 'referentials.destroy'])
login_as @user, :scope => :user
# post_via_redirect user_session_path, 'user[email]' => @user.email, 'user[password]' => @user.password
end
@@ -44,7 +45,8 @@ module DeviseControllerHelper
'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',
'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'])
+ 'connection_links.create', 'connection_links.edit', 'connection_links.destroy', 'route_sections.create', 'route_sections.edit', 'route_sections.destroy',
+ 'referentials.create', 'referentials.edit', 'referentials.destroy'])
sign_in @user
end
end
diff --git a/spec/support/pg_catalog.rb b/spec/support/pg_catalog.rb
new file mode 100644
index 000000000..30992168e
--- /dev/null
+++ b/spec/support/pg_catalog.rb
@@ -0,0 +1,82 @@
+module Support
+ module PGCatalog
+
+ def get_columns(schema_name, table_name)
+ execute("SELECT * from information_schema.columns WHERE table_name = '#{table_name}' AND table_schema = '#{schema_name}'")
+ end
+ def get_foreign_keys(schema_oid, table_name)
+ schema_oid = get_schema_oid(schema_oid) unless Integer === schema_oid
+ return [] unless schema_oid
+ execute(foreign_key_query(schema_oid, table_name))
+ .to_a
+ end
+
+ def get_schema_oid(schema_name)
+ execute("SELECT oid FROM pg_namespace WHERE nspname = '#{schema_name}'")
+ .values
+ .flatten
+ .first
+ end
+
+ def get_sequences(schema_name, table_name)
+ sequences = execute <<-EOSQL
+ SELECT sequence_name FROM information_schema.sequences
+ WHERE sequence_schema = '#{schema_name}' AND sequence_name LIKE '#{table_name}%'
+ EOSQL
+ sequences.values.flatten.map do | sequence |
+ execute "SELECT * from #{schema_name}.#{sequence}"
+ end.flat_map(&:to_a)
+ end
+
+ def get_table_information(schema_name, table_name)
+ execute("SELECT * FROM information_schema.tables WHERE table_name = '#{table_name}' AND table_schema = '#{schema_name}'")
+ .to_a
+ .map(&without_keys("table_catalog"))
+ end
+
+
+ private
+ def base_connection
+ ActiveRecord::Base.connection
+ end
+
+ def execute(sql)
+ base_connection.execute(sql)
+ end
+
+ def foreign_key_query(schema_oid, table_name)
+ key = [:foreign_key_query, schema_oid, table_name]
+ get_or_create_query(key){ <<-EOQ
+ SELECT ct.conname AS constraint_name, pg_get_constraintdef(ct.oid) AS constraint_def
+ FROM pg_constraint ct JOIN pg_class rn ON rn.oid = ct.conrelid
+ WHERE connamespace = #{schema_oid} AND rn.relname = '#{table_name}' AND rn.relkind = 'r' AND ct.contype = 'f'
+ EOQ
+ }
+ end
+
+ def sequence_properties_query(schema_name, sequence_name)
+ key = [:sequence_properies_query, schema_name, sequence_name]
+ get_or_create_query(key){ <<-EOQ
+ Coming Soon
+ EOQ
+ }
+
+ end
+
+ def get_or_create_query(query_key, &query_value)
+ queries.fetch(query_key){ queries[query_key] = query_value.() }
+ end
+
+ def queries
+ @__queries__ ||= {}
+ end
+
+ def without_keys(*keys)
+ -> hashy do
+ hashy.inject({}) do |h, (k,v)|
+ keys.include?(k) ? h : h.merge(k => v)
+ end
+ end
+ end
+ end
+end
diff --git a/spec/support/type_ids_modelable_spec.rb b/spec/support/type_ids_modelable.rb
index 9ed341810..9ed341810 100644
--- a/spec/support/type_ids_modelable_spec.rb
+++ b/spec/support/type_ids_modelable.rb
diff --git a/spec/views/companies/show.html.erb_spec.rb b/spec/views/companies/show.html.erb_spec.rb
index f0a8a99d4..dbc544f63 100644
--- a/spec/views/companies/show.html.erb_spec.rb
+++ b/spec/views/companies/show.html.erb_spec.rb
@@ -12,7 +12,7 @@ describe "/companies/show", :type => :view do
# it "should display a map with class 'company'" do
# render
- # rendered.should have_selector("#map", :class => 'company')
+ # expect(rendered).to have_selector("#map", :class => 'company')
# end
it "should render a link to edit the company" do
diff --git a/spec/views/connection_links/show.html.erb_spec.rb b/spec/views/connection_links/show.html.erb_spec.rb
index 1a7ad3d16..c04a4f3f1 100644
--- a/spec/views/connection_links/show.html.erb_spec.rb
+++ b/spec/views/connection_links/show.html.erb_spec.rb
@@ -18,7 +18,7 @@ describe "/connection_links/show", :type => :view do
# it "should display a map with class 'connection_link'" do
# pending ": map not yet implemented"
# render
-# rendered.should have_selector("#map", :class => 'connection_link')
+# expect(rendered).to have_selector("#map", :class => 'connection_link')
# end
it "should render a link to edit the connection_link" do
diff --git a/spec/views/layouts/application.html.erb_spec.rb b/spec/views/layouts/application.html.erb_spec.rb
index 700084922..80e3e6f86 100644
--- a/spec/views/layouts/application.html.erb_spec.rb
+++ b/spec/views/layouts/application.html.erb_spec.rb
@@ -12,7 +12,7 @@ describe "/layouts/application", :type => :view do
it "should display referential name as title" #do
# render
- # rendered.should_not have_selector("h1")
+ # expect(rendered).not_to have_selector("h1")
# end
end
diff --git a/spec/views/lines/show.html.erb_spec.rb b/spec/views/lines/show.html.erb_spec.rb
index 939d6bc83..3a9efa0ce 100644
--- a/spec/views/lines/show.html.erb_spec.rb
+++ b/spec/views/lines/show.html.erb_spec.rb
@@ -19,7 +19,7 @@ describe "/lines/show", :type => :view do
# it "should display a map with class 'line'" do
# render
- # rendered.should have_selector("#map", :class => 'line')
+ # expect(rendered).to have_selector("#map", :class => 'line')
# end
# FIXME #2018
xit "should render a link to edit the line" do
diff --git a/spec/views/organisations/show.html.erb b/spec/views/organisations/show.html.erb
index 69f5e2956..84af3b044 100644
--- a/spec/views/organisations/show.html.erb
+++ b/spec/views/organisations/show.html.erb
@@ -10,7 +10,7 @@ describe "/organisations/show" do
it "should render each User" do
render
organisation.users.each do |user|
- rendered.should have_selector("div.user span.name", :text => user.name)
+ expect(rendered).to have_selector("div.user span.name", :text => user.name)
end
end
diff --git a/spec/views/routes/show.html.erb_spec.rb b/spec/views/routes/show.html.erb_spec.rb
index 787bf72d0..7557ede27 100644
--- a/spec/views/routes/show.html.erb_spec.rb
+++ b/spec/views/routes/show.html.erb_spec.rb
@@ -26,7 +26,7 @@ describe "/routes/show", :type => :view do
# it "should display a map with class 'line'" do
# render
- # rendered.should have_selector("#map", :class => 'line')
+ # expect(rendered).to have_selector("#map", :class => 'line')
# end
# it "should render a link to edit the route" do
diff --git a/spec/views/stop_areas/show.html.erb_spec.rb b/spec/views/stop_areas/show.html.erb_spec.rb
index 0c9c6663b..a22379402 100644
--- a/spec/views/stop_areas/show.html.erb_spec.rb
+++ b/spec/views/stop_areas/show.html.erb_spec.rb
@@ -14,7 +14,7 @@ describe "/stop_areas/show", :type => :view do
# it "should display a map with class 'stop_area'" do
# render
- # rendered.should have_selector("#map", :class => 'stop_area')
+ # expect(rendered).to have_selector("#map", :class => 'stop_area')
# end
it "should render a link to edit the stop_area" do
diff --git a/spec/views/time_tables/edit.html.erb_spec.rb b/spec/views/time_tables/edit.html.erb_spec.rb
index 18c5d6d85..c84c5eb74 100644
--- a/spec/views/time_tables/edit.html.erb_spec.rb
+++ b/spec/views/time_tables/edit.html.erb_spec.rb
@@ -5,19 +5,11 @@ describe "/time_tables/edit", :type => :view do
let!(:time_table) { assign(:time_table, create(:time_table) ) }
describe "test" do
- it "should render h2 with the group comment" do
- render
- expect(rendered).to have_selector("h2", :text => Regexp.new(time_table.comment))
- end
- end
-
- describe "form" do
- it "should render input for comment" do
+ it "should render h1 with the group comment" do
render
- expect(rendered).to have_selector("form") do
- with_tag "input[type=text][comment='time_table[comment]'][value=?]", time_table.comment
- end
+ expect(rendered).to have_selector("h1", :text => Regexp.new(time_table.comment))
end
-
end
+
+ # No more test for the form, as it is now managed by React/Redux.
end
diff --git a/spec/views/time_tables/index.html.erb_spec.rb b/spec/views/time_tables/index.html.erb_spec.rb
index 2679964c1..cea172ce9 100644
--- a/spec/views/time_tables/index.html.erb_spec.rb
+++ b/spec/views/time_tables/index.html.erb_spec.rb
@@ -10,16 +10,16 @@ describe "/time_tables/index", :type => :view 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
-
- it "should render a link to create a new group" do
- render
- expect(view.content_for(:sidebar)).to have_selector(".actions a[href='#{new_referential_time_table_path(referential)}']")
- end
+ # it "should render a show link for each group" do
+ # render
+ # time_tables.each do |time_table|
+ # expect(rendered).to have_selector("a[href='#{view.referential_time_table_path(referential, time_table)}']", :text => time_table.comment)
+ # end
+ # end
+ #
+ # it "should render a link to create a new group" do
+ # render
+ # expect(rendered).to have_selector("a[href='#{new_referential_time_table_path(referential)}']")
+ # 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 3b5d7f1f1..f429f9dec 100644
--- a/spec/views/time_tables/show.html.erb_spec.rb
+++ b/spec/views/time_tables/show.html.erb_spec.rb
@@ -13,18 +13,17 @@ describe "/time_tables/show", :type => :view do
it "should render h2 with the time_table comment" do
render
- expect(rendered).to have_selector("h2", :text => Regexp.new(time_table.comment))
+ expect(rendered).to have_selector("h1", :text => Regexp.new(time_table.comment))
end
it "should render a link to edit the time_table" do
render
- expect(view.content_for(:sidebar)).to have_selector(".actions a[href='#{view.edit_referential_time_table_path(referential, time_table)}']")
+ expect(rendered).to have_selector(" a[href='#{view.edit_referential_time_table_path(referential, time_table)}']")
end
it "should render a link to remove the time_table" do
render
- expect(view.content_for(:sidebar)).to have_selector(".actions a[href='#{view.referential_time_table_path(referential, time_table)}'][class='remove']")
+ expect(rendered).to have_selector(" a[href='#{view.referential_time_table_path(referential, time_table)}']")
end
end
-
diff --git a/spec/workers/referential_cloning_worker_spec.rb b/spec/workers/referential_cloning_worker_spec.rb
index dd7b33f23..85d771742 100644
--- a/spec/workers/referential_cloning_worker_spec.rb
+++ b/spec/workers/referential_cloning_worker_spec.rb
@@ -1,4 +1,45 @@
-require 'rails_helper'
-RSpec.describe ReferentialCloningWorker, type: :worker do
- pending "add some examples to (or delete) #{__FILE__}"
+require 'spec_helper'
+require 'ostruct'
+
+RSpec.describe ReferentialCloningWorker do
+
+ context "given a refererntial cloning" do
+
+ let( :id ){ double }
+
+ let( :worker ){ described_class.new }
+
+
+ let( :source_schema ){ "source_schema" }
+ let( :target_schema ){ "#{source_schema}_tmp" }
+ let( :referential_cloning ){ OpenStruct.new(source_referential: OpenStruct.new(slug: source_schema)) }
+
+ before do
+ expect( ReferentialCloning ).to receive(:find).with(id).and_return(referential_cloning)
+ expect( StoredProcedures )
+ .to receive(:invoke_stored_procedure)
+ .with(:clone_schema, source_schema, target_schema, true)
+
+ expect( worker ).to receive(:execute_sql).with( "DROP SCHEMA #{source_schema} CASCADE;" )
+
+ expect( referential_cloning ).to receive(:run!)
+ end
+
+ it "invokes the correct stored procedure, updates the database and the AASM" do
+ expect( worker ).to receive(:execute_sql).with( "ALTER SCHEMA #{target_schema} RENAME TO #{source_schema};" )
+ expect( referential_cloning ).to receive(:successful!)
+ worker.perform(id)
+ end
+
+ it "handles failure correctly" do
+ expect( worker )
+ .to receive(:execute_sql)
+ .with( "ALTER SCHEMA #{target_schema} RENAME TO #{source_schema};" )
+ .and_raise(RuntimeError)
+
+ expect( referential_cloning ).to receive(:failed!)
+ worker.perform(id)
+ end
+ end
+
end