aboutsummaryrefslogtreecommitdiffstats
path: root/spec/models
diff options
context:
space:
mode:
authorMichel Etienne2014-08-27 14:18:30 +0200
committerMichel Etienne2014-08-27 14:18:30 +0200
commit2a1b23c9bd1d4e2e97814ea9190892f2981b365d (patch)
treeb319897908faa72e2bfd2c850abae610e0684650 /spec/models
parent5e502c1984f579f8ed54e8d83091399c0c86e2d7 (diff)
downloadchouette-core-2a1b23c9bd1d4e2e97814ea9190892f2981b365d.tar.bz2
stop area duplication: enforce tests
Diffstat (limited to 'spec/models')
-rw-r--r--spec/models/stop_area_copy_spec.rb40
1 files changed, 40 insertions, 0 deletions
diff --git a/spec/models/stop_area_copy_spec.rb b/spec/models/stop_area_copy_spec.rb
new file mode 100644
index 000000000..66aa56d30
--- /dev/null
+++ b/spec/models/stop_area_copy_spec.rb
@@ -0,0 +1,40 @@
+# -*- coding: utf-8 -*-
+require 'spec_helper'
+
+describe StopAreaCopy do
+
+ subject { StopAreaCopy.new(:source_id => 1, :hierarchy => "child", :area_type => "Quay") }
+
+ it { should validate_presence_of :source_id }
+ it { should validate_presence_of :hierarchy }
+ it { should validate_presence_of :area_type }
+
+
+ describe ".save" do
+
+ it "should create a child for source" do
+ source = Chouette::StopArea.new( :area_type => "CommercialStopPoint", :name => "test1" )
+ source.save
+ subject.source_id = source.id
+ subject.hierarchy = "child"
+ subject.area_type = "Quay"
+ subject.save
+ source.reload
+ source.children.length.should == 1
+ source.children[0].name.should == "test1"
+ end
+ it "should create a parent for source" do
+ source = Chouette::StopArea.new( :area_type => "CommercialStopPoint", :name => "test2" )
+ source.save
+ subject.source_id = source.id
+ subject.hierarchy = "parent"
+ subject.area_type = "StopPlace"
+ subject.save
+ source.reload
+ source.parent.should_not be_nil
+ source.parent.name.should == 'test2'
+ end
+
+ end
+
+end