diff options
| author | Alban Peignier | 2016-11-19 19:42:03 +0100 |
|---|---|---|
| committer | Alban Peignier | 2016-11-19 19:59:24 +0100 |
| commit | bc1ec22d68233c74cbc93b2810f4e479a5e4b5ff (patch) | |
| tree | e2a21878c6c7b3fa986b1f688610035f551f356a /spec/support | |
| parent | a3482213380844cdea5c75f6f6e84267b6c72135 (diff) | |
| download | chouette-core-bc1ec22d68233c74cbc93b2810f4e479a5e4b5ff.tar.bz2 | |
Use code to define and find 'first' Organisation in specs. Refs #1782
Diffstat (limited to 'spec/support')
| -rw-r--r-- | spec/support/devise.rb | 4 | ||||
| -rw-r--r-- | spec/support/referential.rb | 10 |
2 files changed, 9 insertions, 5 deletions
diff --git a/spec/support/devise.rb b/spec/support/devise.rb index d33812e6f..2258fefbb 100644 --- a/spec/support/devise.rb +++ b/spec/support/devise.rb @@ -2,7 +2,7 @@ module DeviseRequestHelper include Warden::Test::Helpers def login_user - organisation = Organisation.where(:name => "first").first_or_create(attributes_for(:organisation)) + organisation = Organisation.where(:code => "first").first_or_create(attributes_for(:organisation)) @user ||= create(:user, :organisation => organisation) login_as @user, :scope => :user # post_via_redirect user_session_path, 'user[email]' => @user.email, 'user[password]' => @user.password @@ -33,7 +33,7 @@ module DeviseControllerHelper def login_user before(:each) do @request.env["devise.mapping"] = Devise.mappings[:user] - organisation = Organisation.where(:name => "first").first_or_create(attributes_for(:organisation)) + organisation = Organisation.where(:code => "first").first_or_create(attributes_for(:organisation)) user = create(:user, :organisation => organisation) sign_in user end 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 |
