aboutsummaryrefslogtreecommitdiffstats
path: root/spec
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
parent6fd69ca92e3090a2a8b7b73e7511bc1070290e22 (diff)
downloadchouette-core-61d0662dd923169c5c5aa1d4624f04d6e9dbe43d.tar.bz2
add subscription
Diffstat (limited to 'spec')
-rw-r--r--spec/factories.rb9
-rw-r--r--spec/requests/referentials_spec.rb10
-rw-r--r--spec/requests/stop_points_spec.rb1
-rw-r--r--spec/support/devise.rb6
-rw-r--r--spec/support/referential.rb6
5 files changed, 22 insertions, 10 deletions
diff --git a/spec/factories.rb b/spec/factories.rb
index c530ea650..87387f3f5 100644
--- a/spec/factories.rb
+++ b/spec/factories.rb
@@ -1,17 +1,18 @@
FactoryGirl.define do
+ factory :organisation do |f|
+ f.sequence(:name) { |n| "Organisation #{n}" }
+ end
+
factory :referential do |f|
f.sequence(:name) { |n| "Test #{n}" }
f.sequence(:slug) { |n| "test_#{n}" }
f.sequence(:prefix) { |n| "test_#{n}" }
+ f.association :organisation
f.time_zone "Europe/Paris"
end
- factory :organisation do |f|
- f.sequence(:name) { |n| "Organisation #{n}" }
- end
-
factory :user do |f|
f.association :organisation
f.sequence(:email) { |n| "chouette#{n}@dryade.priv" }
diff --git a/spec/requests/referentials_spec.rb b/spec/requests/referentials_spec.rb
index 094add627..9203de16d 100644
--- a/spec/requests/referentials_spec.rb
+++ b/spec/requests/referentials_spec.rb
@@ -12,8 +12,14 @@ describe "Referentials" do
end
context "when several referentials exist" do
+
+ def retrieve_referential_by_slug( slug)
+ @user.organisation.referentials.find_by_slug(slug) ||
+ create(:referential, :slug => slug, :name => slug, :organisation => @user.organisation)
+ end
- let!(:referentials) { Array.new(2) { create(:referential) } }
+ let!(:referentials) { [ retrieve_referential_by_slug("aa"),
+ retrieve_referential_by_slug("bb")] }
it "should show n referentials" do
pending
@@ -44,7 +50,7 @@ describe "Referentials" do
end
describe "destroy" do
- let(:referential) { create(:referential) }
+ let(:referential) { create(:referential, :organisation => @user.organisation) }
it "should remove referential" do
pending "Unauthorized DELETE (ticket #14)"
diff --git a/spec/requests/stop_points_spec.rb b/spec/requests/stop_points_spec.rb
index 87b34413c..f2805263d 100644
--- a/spec/requests/stop_points_spec.rb
+++ b/spec/requests/stop_points_spec.rb
@@ -20,6 +20,7 @@ describe "StopPoints" do
end
describe "from route's page, go to new stop point page" do
it "display route's stop points" do
+
visit referential_line_route_path(referential,line,route)
click_link "Gérer les arrêts de la séquence"
click_link "Ajouter un arrêt à la séquence"
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