From 72806a4961e4240cff955c66fff1840e40301b89 Mon Sep 17 00:00:00 2001 From: Teddy Wing Date: Mon, 25 Sep 2017 16:17:04 +0200 Subject: Workbench: Validate presence of `output` Ensure all workbenches always have an associated `ReferentialSuite` by validating presence of the `output` attribute. In order to pass the 'should have a valid factory' test, we need to define a `ReferentialSuite` factory and set up a default association on `output` in the `Workbench` factory. We also need to add set `output` when creating a `Workbench` in `spec/support/referential.rb`, otherwise we get a validation error that breaks the tests. Clean up the formatting of that call. In order to pass a `ReferentialSuite`, I just create one above, but I'm not sure if I should be using a `find_or_create` mechanism like the other associated objects do above. Refs #3520 --- spec/models/workbench_spec.rb | 2 ++ 1 file changed, 2 insertions(+) (limited to 'spec/models/workbench_spec.rb') diff --git a/spec/models/workbench_spec.rb b/spec/models/workbench_spec.rb index 617f34bb1..f83342f75 100644 --- a/spec/models/workbench_spec.rb +++ b/spec/models/workbench_spec.rb @@ -20,6 +20,8 @@ RSpec.describe Workbench, :type => :model do it { should have_many(:stop_areas).through(:stop_area_referential) } + it { should validate_presence_of(:output) } + context '.lines' do let!(:ids) { ['STIF:CODIFLIGNE:Line:C00840', 'STIF:CODIFLIGNE:Line:C00086'] } let!(:organisation) { create :organisation, sso_attributes: { functional_scope: ids.to_json } } -- cgit v1.2.3