diff options
| author | Robert | 2017-11-17 11:32:47 +0100 |
|---|---|---|
| committer | Robert | 2017-11-17 14:53:03 +0100 |
| commit | 86082170302a5b07dc15fbc61b628bb89b775f04 (patch) | |
| tree | 1c0ec5babf179500d37c7bf79d4b2e9152a8a01c | |
| parent | 1b84658f5f3ab98f7338a319ad1dc2f3ee8a1842 (diff) | |
| download | chouette-core-86082170302a5b07dc15fbc61b628bb89b775f04.tar.bz2 | |
Refs: #4461@0.75h; Fixing netex_import after_create callback to after_commit on: :create
| -rw-r--r-- | db/schema.rb | 8 | ||||
| -rw-r--r-- | spec/models/import/netex_import_spec.rb | 7 | ||||
| -rw-r--r-- | spec/support/with_commit.rb | 10 |
3 files changed, 20 insertions, 5 deletions
diff --git a/db/schema.rb b/db/schema.rb index af6a51f7a..21aa73cd8 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -408,9 +408,9 @@ ActiveRecord::Schema.define(version: 20171114102438) do t.string "type" t.integer "parent_id", limit: 8 t.string "parent_type" - t.datetime "notified_parent_at" t.integer "current_step", default: 0 t.integer "total_steps", default: 0 + t.datetime "notified_parent_at" t.string "creator" end @@ -491,7 +491,8 @@ ActiveRecord::Schema.define(version: 20171114102438) do t.string "name" t.datetime "created_at" t.datetime "updated_at" - t.integer "sync_interval", default: 1 + t.integer "sync_interval", default: 1 + t.string "objectid_format" end create_table "lines", id: :bigserial, force: :cascade do |t| @@ -635,6 +636,7 @@ ActiveRecord::Schema.define(version: 20171114102438) do t.integer "created_from_id", limit: 8 t.boolean "ready", default: false t.integer "referential_suite_id", limit: 8 + t.string "objectid_format" end add_index "referentials", ["created_from_id"], name: "index_referentials_on_created_from_id", using: :btree @@ -712,6 +714,7 @@ ActiveRecord::Schema.define(version: 20171114102438) do t.string "name" t.datetime "created_at" t.datetime "updated_at" + t.string "objectid_format" end create_table "stop_areas", id: :bigserial, force: :cascade do |t| @@ -950,6 +953,7 @@ ActiveRecord::Schema.define(version: 20171114102438) do t.integer "line_referential_id", limit: 8 t.integer "stop_area_referential_id", limit: 8 t.integer "output_id", limit: 8 + t.string "objectid_format" end add_index "workbenches", ["line_referential_id"], name: "index_workbenches_on_line_referential_id", using: :btree diff --git a/spec/models/import/netex_import_spec.rb b/spec/models/import/netex_import_spec.rb index 4548bd7cc..8ffeed1f4 100644 --- a/spec/models/import/netex_import_spec.rb +++ b/spec/models/import/netex_import_spec.rb @@ -1,7 +1,8 @@ -RSpec.describe NetexImport, type: :model do +RSpec.describe NetexImport, type: [:model, :with_commit] do let( :boiv_iev_uri ){ URI("#{Rails.configuration.iev_url}/boiv_iev/referentials/importer/new?id=#{subject.id}")} + before do allow(Thread).to receive(:new).and_yield end @@ -11,7 +12,7 @@ RSpec.describe NetexImport, type: :model do it 'will trigger the Java API' do with_stubbed_request(:get, boiv_iev_uri) do |request| - subject.save! + with_commit{ subject.save! } expect(request).to have_been_requested end end @@ -22,7 +23,7 @@ RSpec.describe NetexImport, type: :model do it 'its status is forced to aborted and the Java API is not callled' do with_stubbed_request(:get, boiv_iev_uri) do |request| - subject.save! + with_commit{ subject.save! } expect(subject.reload.status).to eq('aborted') expect(request).not_to have_been_requested end diff --git a/spec/support/with_commit.rb b/spec/support/with_commit.rb new file mode 100644 index 000000000..2b4725f89 --- /dev/null +++ b/spec/support/with_commit.rb @@ -0,0 +1,10 @@ +module WithCommit + def with_commit + yield + subject._run_commit_callbacks + end +end + +RSpec.configure do |conf| + conf.include WithCommit, type: :with_commit +end |
