aboutsummaryrefslogtreecommitdiffstats
path: root/spec/models/chouette/group_of_line_spec.rb
blob: 8b2df69e596aa97989463c09352df36f7a381f39 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
require 'spec_helper'

describe Chouette::GroupOfLine, :type => :model do

  subject { create(:group_of_line) }
  it { should validate_presence_of :name }
  

  describe "#stop_areas" do
    let!(:line){create(:line, :group_of_lines => [subject])}
    let!(:route){create(:route, :line => line)}
    it "should retreive group of line's stop_areas" do
      expect(subject.stop_areas.count).to eq(route.stop_points.count)
    end
  end

  context "#line_tokens=" do
    let!(:line1){create(:line)}
    let!(:line2){create(:line)}

    it "should return associated line ids" do
      subject.update_attributes :line_tokens => [line1.id, line2.id].join(',')
      expect(subject.lines).to include( line1)
      expect(subject.lines).to include( line2)
    end
  end

end