aboutsummaryrefslogtreecommitdiffstats
path: root/spec/models/referential_cloning_spec.rb
diff options
context:
space:
mode:
authorAlban Peignier2018-01-05 10:22:26 +0100
committerAlban Peignier2018-01-05 10:23:29 +0100
commit43541cf4d0a461ac76bec4ea9ae16163a105f76a (patch)
tree16412d2eab6cb3a0cf49ffaeeca9e5a07492e9d5 /spec/models/referential_cloning_spec.rb
parent1beccdf688a2a653d299bdf44c896f8381764fb9 (diff)
downloadchouette-core-43541cf4d0a461ac76bec4ea9ae16163a105f76a.tar.bz2
Fixes ReferentialCloning specs. Refs #52995299-merge-operation
Diffstat (limited to 'spec/models/referential_cloning_spec.rb')
-rw-r--r--spec/models/referential_cloning_spec.rb30
1 files changed, 20 insertions, 10 deletions
diff --git a/spec/models/referential_cloning_spec.rb b/spec/models/referential_cloning_spec.rb
index 4327c98aa..815e05a67 100644
--- a/spec/models/referential_cloning_spec.rb
+++ b/spec/models/referential_cloning_spec.rb
@@ -36,40 +36,50 @@ RSpec.describe ReferentialCloning, :type => :model do
let(:cloner) { double }
- before do
- allow(AF83::SchemaCloner).to receive(:new).and_return cloner
- allow(cloner).to receive(:clone_schema)
- end
-
it 'creates a schema cloner with source and target schemas and clone schema' do
expect(AF83::SchemaCloner).to receive(:new).with(source_referential.slug, target_referential.slug).and_return(cloner)
expect(cloner).to receive(:clone_schema)
referential_cloning.clone!
end
+ end
+
+ describe '#clone_with_status!' do
+ let(:referential_cloning) do
+ ReferentialCloning.new(target_referential: Referential.new(slug: "target"))
+ end
+
+ before do
+ allow(referential_cloning).to receive(:clone!)
+ end
+
+ it 'invokes clone! method' do
+ expect(referential_cloning).to receive(:clone!)
+ referential_cloning.clone_with_status!
+ end
context 'when clone_schema is performed without error' do
it "should have successful status" do
- referential_cloning.clone!
+ referential_cloning.clone_with_status!
expect(referential_cloning.status).to eq("successful")
end
end
context 'when clone_schema raises an error' do
it "should have failed status" do
- expect(cloner).to receive(:clone_schema).and_raise("#fail")
- referential_cloning.clone!
+ expect(referential_cloning).to receive(:clone!).and_raise("#fail")
+ referential_cloning.clone_with_status!
expect(referential_cloning.status).to eq("failed")
end
end
it "defines started_at" do
- referential_cloning.clone!
+ referential_cloning.clone_with_status!
expect(referential_cloning.started_at).not_to be_nil
end
it "defines ended_at" do
- referential_cloning.clone!
+ referential_cloning.clone_with_status!
expect(referential_cloning.ended_at).not_to be_nil
end