aboutsummaryrefslogtreecommitdiffstats
path: root/spec
diff options
context:
space:
mode:
Diffstat (limited to 'spec')
-rw-r--r--spec/factories/chouette_routes.rb14
-rw-r--r--spec/features/routes_spec.rb58
-rw-r--r--spec/models/chouette/route_spec.rb78
3 files changed, 25 insertions, 125 deletions
diff --git a/spec/factories/chouette_routes.rb b/spec/factories/chouette_routes.rb
index 047c35912..e872d24f5 100644
--- a/spec/factories/chouette_routes.rb
+++ b/spec/factories/chouette_routes.rb
@@ -4,23 +4,23 @@ FactoryGirl.define do
sequence(:name) { |n| "Route #{n}" }
sequence(:published_name) { |n| "Long route #{n}" }
sequence(:number) { |n| "#{n}" }
- sequence(:wayback_code) { |n| Chouette::Wayback.new( n % 2) }
- sequence(:direction_code) { |n| Chouette::Direction.new( n % 12) }
+ sequence(:wayback) { |n| Chouette::Route.wayback.values[n % 2] }
+ sequence(:direction) { |n| Chouette::Route.direction.values[n % 12] }
sequence(:objectid) { |n| "test:Route:#{n}" }
-
+
association :line, :factory => :line
-
+
factory :route do
transient do
stop_points_count 5
end
-
+
after(:create) do |route, evaluator|
create_list(:stop_point, evaluator.stop_points_count, route: route)
end
-
+
end
end
-
+
end
diff --git a/spec/features/routes_spec.rb b/spec/features/routes_spec.rb
index 22091b7c9..70f3448ab 100644
--- a/spec/features/routes_spec.rb
+++ b/spec/features/routes_spec.rb
@@ -28,52 +28,18 @@ describe "Routes", :type => :feature do
end
end
- # Fixme #1780
- # describe "from line's page, create a new route" do
- # it "return to line's page that display new route" do
- # visit referential_line_path(referential,line)
- # click_link "Ajouter une séquence d'arrêts"
- # fill_in "route_name", :with => "A to B"
- # fill_in "Indice", :with => "AB"
- # select 'aller', :from => "route_direction_code"
- # select 'aller', :from => "route_wayback_code"
- # click_button("Créer séquence d'arrêts")
- # expect(page).to have_content("A to B")
- # end
- # end
-
- # describe "from line's page, select a route and edit it" do
- # it "return to line's page with changed name" do
- # visit referential_line_path(referential,line)
- # click_link "#{route.name}"
- # click_link "Modifier cette séquence d'arrêts"
- # fill_in "route_name", :with => "#{route.name}-changed"
- # click_button("Modifier séquence d'arrêts")
- # expect(page).to have_content("#{route.name}-changed")
- # end
- # end
-
- # describe "from line's page, select a route and delete it" do
- # it "return to line's page without route name" do
- # visit referential_line_path(referential,line)
- # click_link "#{route.name}"
- # click_link "Supprimer cette séquence d'arrêts"
- # expect(page).not_to have_content(route.name)
- # end
- # end
-
- # describe "from route's page, select edit boarding/alighting and update it" do
- # it "Edits boarding/alighting properties on route stops" do
- # visit referential_line_route_path(referential, line, route)
- # click_link I18n.t('routes.actions.edit_boarding_alighting')
- # expect(page).to have_content(I18n.t('routes.edit_boarding_alighting.title'))
- # stop_points.each do |sp|
- # expect(page).to have_content(sp.stop_area.name)
- # expect(page).to have_content(sp.for_boarding)
- # expect(page).to have_content(sp.for_alighting)
- # end
- # end
- # end
+ describe "from line's page, create a new route" do
+ it "return to line's page that display new route" do
+ visit referential_line_path(referential,line)
+ click_link "Ajouter une séquence d'arrêts"
+ fill_in "route_name", :with => "A to B"
+ fill_in "Indice", :with => "AB"
+ select 'Aller', :from => "route_direction"
+ select 'Aller', :from => "route_wayback"
+ click_button("Créer séquence d'arrêts")
+ expect(page).to have_content("A to B")
+ end
+ end
describe "Modifies boarding/alighting properties on route stops" do
it "Puts (http) an update request" do
diff --git a/spec/models/chouette/route_spec.rb b/spec/models/chouette/route_spec.rb
index 1acc5a0f7..0392485d8 100644
--- a/spec/models/chouette/route_spec.rb
+++ b/spec/models/chouette/route_spec.rb
@@ -3,17 +3,21 @@ require 'spec_helper'
describe Chouette::Route, :type => :model do
subject { create(:route) }
- it { is_expected.to validate_uniqueness_of :objectid }
-
describe '#objectid' do
subject { super().objectid }
it { is_expected.to be_kind_of(Chouette::ObjectId) }
end
+ it { is_expected.to enumerize(:direction).in(:straight_forward, :backward, :clockwise, :counter_clockwise, :north, :north_west, :west, :south_west, :south, :south_east, :east, :north_east) }
+ it { is_expected.to enumerize(:wayback).in(:straight_forward, :backward) }
+
#it { is_expected.to validate_presence_of :name }
it { is_expected.to validate_presence_of :line }
+ it { is_expected.to validate_uniqueness_of :objectid }
#it { is_expected.to validate_presence_of :wayback_code }
#it { is_expected.to validate_presence_of :direction_code }
+ it { is_expected.to validate_inclusion_of(:direction).in_array(%i(straight_forward backward clockwise counter_clockwise north north_west west south_west south south_east east north_east)) }
+ it { is_expected.to validate_inclusion_of(:wayback).in_array(%i(straight_forward backward)) }
context "reordering methods" do
let( :bad_stop_point_ids){subject.stop_points.map { |sp| sp.id + 1}}
@@ -165,74 +169,4 @@ describe Chouette::Route, :type => :model do
end
end
end
-
- describe "#direction_code" do
- def self.legacy_directions
- %w{A R ClockWise CounterClockWise North NorthWest West SouthWest
- South SouthEast East NorthEast}
- end
- legacy_directions.each do |direction|
- context "when direction is #{direction}" do
- direction_code = Chouette::Direction.new( Chouette::Route.direction_binding[ direction])
- it "should be #{direction_code}" do
- subject.direction = direction
- expect(subject.direction_code).to eq(direction_code)
- end
- end
- end
- context "when direction is nil" do
- it "should be nil" do
- subject.direction = nil
- expect(subject.direction_code).to be_nil
- end
- end
- end
- describe "#direction_code=" do
- context "when unknown direction is provided" do
- it "should change direction to nil" do
- subject.direction_code = "dummy"
- expect(subject.direction).to be_nil
- end
- end
- context "when an existing direction (west) is provided" do
- it "should change direction Direction.west" do
- subject.direction_code = "west"
- expect(subject.direction).to eq("West")
- end
- end
- end
- describe "#wayback_code" do
- def self.legacy_waybacks
- %w{A R}
- end
- legacy_waybacks.each do |wayback|
- context "when wayback is #{wayback}" do
- wayback_code = Chouette::Wayback.new( Chouette::Route.wayback_binding[ wayback])
- it "should be #{wayback_code}" do
- subject.wayback = wayback
- expect(subject.wayback_code).to eq(wayback_code)
- end
- end
- end
- context "when wayback is nil" do
- it "should be nil" do
- subject.wayback = nil
- expect(subject.wayback_code).to be_nil
- end
- end
- end
- describe "#wayback_code=" do
- context "when unknown wayback is provided" do
- it "should change wayback to nil" do
- subject.wayback_code = "dummy"
- expect(subject.wayback).to be_nil
- end
- end
- context "when an existing wayback (straight_forward) is provided" do
- it "should change wayback Wayback.straight_forward" do
- subject.wayback_code = "straight_forward"
- expect(subject.wayback).to eq("A")
- end
- end
- end
end