aboutsummaryrefslogtreecommitdiffstats
path: root/spec/models
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
parent1beccdf688a2a653d299bdf44c896f8381764fb9 (diff)
downloadchouette-core-43541cf4d0a461ac76bec4ea9ae16163a105f76a.tar.bz2
Fixes ReferentialCloning specs. Refs #52995299-merge-operation
Diffstat (limited to 'spec/models')
-rw-r--r--spec/models/chouette/time_table_spec.rb2
-rw-r--r--spec/models/referential_cloning_spec.rb30
2 files changed, 21 insertions, 11 deletions
diff --git a/spec/models/chouette/time_table_spec.rb b/spec/models/chouette/time_table_spec.rb
index 23f26395e..d4a726740 100644
--- a/spec/models/chouette/time_table_spec.rb
+++ b/spec/models/chouette/time_table_spec.rb
@@ -1275,7 +1275,7 @@ end
expected_ranges = [
Date.new(2017,12,1)..Date.new(2017,12,31),
- Date.new(2018,2,2)..Date.new(2017,3,1)
+ Date.new(2018,2,2)..Date.new(2018,3,1)
]
expect(time_table.periods.map(&:range)).to eq(expected_ranges)
end
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