aboutsummaryrefslogtreecommitdiffstats
path: root/spec/models/workbench_spec.rb
diff options
context:
space:
mode:
Diffstat (limited to 'spec/models/workbench_spec.rb')
-rw-r--r--spec/models/workbench_spec.rb23
1 files changed, 22 insertions, 1 deletions
diff --git a/spec/models/workbench_spec.rb b/spec/models/workbench_spec.rb
index f83342f75..653b896dc 100644
--- a/spec/models/workbench_spec.rb
+++ b/spec/models/workbench_spec.rb
@@ -20,7 +20,14 @@ RSpec.describe Workbench, :type => :model do
it { should have_many(:stop_areas).through(:stop_area_referential) }
- it { should validate_presence_of(:output) }
+ it do
+ # This callback interferes with the validation test
+ Workbench.skip_callback(:validation, :before, :initialize_output)
+
+ should validate_presence_of(:output)
+
+ Workbench.set_callback(:validation, :before, :initialize_output)
+ end
context '.lines' do
let!(:ids) { ['STIF:CODIFLIGNE:Line:C00840', 'STIF:CODIFLIGNE:Line:C00086'] }
@@ -36,4 +43,18 @@ RSpec.describe Workbench, :type => :model do
expect(lines.map(&:objectid)).to include(*ids)
end
end
+
+ describe ".create" do
+ it "must automatically create a ReferentialSuite when being created" do
+ workbench = Workbench.create
+ expect(workbench.output).to be_an_instance_of(ReferentialSuite)
+ end
+
+ it "must not overwrite a given ReferentialSuite" do
+ referential_suite = ReferentialSuite.create
+ workbench = Workbench.create(output: referential_suite)
+
+ expect(workbench.output).to eq(referential_suite)
+ end
+ end
end