aboutsummaryrefslogtreecommitdiffstats
path: root/spec/support
diff options
context:
space:
mode:
authorMarc Florisson2012-08-29 18:47:22 +0200
committerMarc Florisson2012-08-29 18:47:22 +0200
commit61d0662dd923169c5c5aa1d4624f04d6e9dbe43d (patch)
tree19e5943eb061cf1bb09709cb236fa10007064e32 /spec/support
parent6fd69ca92e3090a2a8b7b73e7511bc1070290e22 (diff)
downloadchouette-core-61d0662dd923169c5c5aa1d4624f04d6e9dbe43d.tar.bz2
add subscription
Diffstat (limited to 'spec/support')
-rw-r--r--spec/support/devise.rb6
-rw-r--r--spec/support/referential.rb6
2 files changed, 8 insertions, 4 deletions
diff --git a/spec/support/devise.rb b/spec/support/devise.rb
index 444eb0fee..4e0e3a4d2 100644
--- a/spec/support/devise.rb
+++ b/spec/support/devise.rb
@@ -2,7 +2,8 @@ module DeviseRequestHelper
include Warden::Test::Helpers
def login_user
- @user ||= create :user
+ organisation = Organisation.find_by_name("first") || create(:organisation, :name => "first")
+ @user ||= create(:user, :organisation => organisation)
login_as @user, :scope => :user
# post_via_redirect user_session_path, 'user[email]' => @user.email, 'user[password]' => @user.password
end
@@ -32,7 +33,8 @@ module DeviseControllerHelper
def login_user
before(:each) do
@request.env["devise.mapping"] = Devise.mappings[:user]
- sign_in create(:user)
+ organisation = Organisation.find_by_name("first") || create(:organisation, :name => "first")
+ sign_in create(:user, :organisation => organisation)
end
end
end
diff --git a/spec/support/referential.rb b/spec/support/referential.rb
index 0d3a7b89a..892903228 100644
--- a/spec/support/referential.rb
+++ b/spec/support/referential.rb
@@ -1,7 +1,7 @@
module ReferentialHelper
def first_referential
- Referential.find_by_slug("first")
+ Organisation.find_by_name("first").referentials.find_by_slug("first")
end
def self.included(base)
@@ -27,7 +27,9 @@ RSpec.configure do |config|
config.include ReferentialHelper
config.before(:suite) do
- Referential.find_or_create_by_slug FactoryGirl.attributes_for(:referential, :slug => "first")
+ organisation = Organisation.find_or_create_by_name :name => "first"
+ organisation.referentials.find_by_slug("first" ) ||
+ FactoryGirl(:referential, :slug => "first", :organisation => organisation)
# FIXME in Rails 3.2 :
# Referential.where(:slug => 'first').first_or_create(FactoryGirl.attributes_for(:referential))
end