aboutsummaryrefslogtreecommitdiffstats
path: root/spec
diff options
context:
space:
mode:
authorRobert2017-11-17 11:32:47 +0100
committerRobert2017-11-17 14:53:03 +0100
commit86082170302a5b07dc15fbc61b628bb89b775f04 (patch)
tree1c0ec5babf179500d37c7bf79d4b2e9152a8a01c /spec
parent1b84658f5f3ab98f7338a319ad1dc2f3ee8a1842 (diff)
downloadchouette-core-86082170302a5b07dc15fbc61b628bb89b775f04.tar.bz2
Refs: #4461@0.75h; Fixing netex_import after_create callback to after_commit on: :create
Diffstat (limited to 'spec')
-rw-r--r--spec/models/import/netex_import_spec.rb7
-rw-r--r--spec/support/with_commit.rb10
2 files changed, 14 insertions, 3 deletions
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