From bc1ec22d68233c74cbc93b2810f4e479a5e4b5ff Mon Sep 17 00:00:00 2001 From: Alban Peignier Date: Sat, 19 Nov 2016 19:42:03 +0100 Subject: Use code to define and find 'first' Organisation in specs. Refs #1782 --- spec/support/referential.rb | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'spec/support/referential.rb') diff --git a/spec/support/referential.rb b/spec/support/referential.rb index 03f5a0977..57b510f69 100644 --- a/spec/support/referential.rb +++ b/spec/support/referential.rb @@ -1,7 +1,11 @@ module ReferentialHelper def first_referential - Referential.where(:slug => "first").take! + Referential.find_by!(:slug => "first") + end + + def first_organisation + Organisation.find_by!(code: "first") end def self.included(base) @@ -38,7 +42,7 @@ RSpec.configure do |config| # Truncating doesn't drop schemas, ensure we're clean here, first *may not* exist Apartment::Tenant.drop('first') rescue nil # Create the default tenant for our tests - organisation = Organisation.create!(:name => "first") + organisation = Organisation.create!(code: "first", name: "first") line_referential = LineReferential.find_or_create_by(name: "first") do |referential| referential.add_member organisation, owner: true @@ -48,7 +52,7 @@ RSpec.configure do |config| end workbench = Workbench.create!(:name => "first", organisation: organisation, line_referential: line_referential, stop_area_referential: stop_area_referential) - Referential.create! prefix: "first", name: "first", slug: "first", organisation: organisation, workbench: workbench + referential = Referential.create! prefix: "first", name: "first", slug: "first", organisation: organisation, workbench: workbench end config.before(:each) do -- cgit v1.2.3