diff options
| author | cedricnjanga | 2018-03-07 07:42:56 -0800 |
|---|---|---|
| committer | Johan Van Ryseghem | 2018-03-29 11:28:28 +0200 |
| commit | 501ac1902cfa3f9163cbabbb9bca66ac22a059b8 (patch) | |
| tree | f8f29f1b83aafb834191d27d89f4203a8ecb07a3 /spec | |
| parent | dca8f770251cae1fda3a1bca1d06210f8e55ddcf (diff) | |
| download | chouette-core-501ac1902cfa3f9163cbabbb9bca66ac22a059b8.tar.bz2 | |
Refs #6075 Set defaults attributes for stop point depending on stop area kind
Diffstat (limited to 'spec')
| -rw-r--r-- | spec/models/chouette/route/route_stop_points_spec.rb | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/spec/models/chouette/route/route_stop_points_spec.rb b/spec/models/chouette/route/route_stop_points_spec.rb index 03c53b4cf..037c22f7e 100644 --- a/spec/models/chouette/route/route_stop_points_spec.rb +++ b/spec/models/chouette/route/route_stop_points_spec.rb @@ -78,15 +78,32 @@ RSpec.describe Chouette::Route, :type => :model do end describe "#stop_points" do + let(:first_stop_point) { subject.stop_points.first} context "#find_by_stop_area" do context "when arg is first quay id" do - let(:first_stop_point) { subject.stop_points.first} it "should return first quay" do expect(subject.stop_points.find_by_stop_area( first_stop_point.stop_area_id)).to eq( first_stop_point) end end end + + context 'defaults attributes' do + it 'should have the correct default attributes' do + first_stop_point.stop_area.update_attributes(kind: 'non_commercial') + subject.stop_points.each do |sp| + sp.run_callbacks(:commit) + if sp.stop_area.commercial? + expect(sp.for_boarding).to eq('normal') + expect(sp.for_alighting).to eq('normal') + else + expect(sp.for_boarding).to eq('forbidden') + expect(sp.for_alighting).to eq('forbidden') + end + end + end + end end + describe "#stop_areas" do let(:line){ create(:line)} let(:route_1){ create(:route, :line => line)} |
