From 2a1b23c9bd1d4e2e97814ea9190892f2981b365d Mon Sep 17 00:00:00 2001 From: Michel Etienne Date: Wed, 27 Aug 2014 14:18:30 +0200 Subject: stop area duplication: enforce tests --- spec/models/stop_area_copy_spec.rb | 40 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 spec/models/stop_area_copy_spec.rb 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 -- cgit v1.2.3