aboutsummaryrefslogtreecommitdiffstats
path: root/spec/models/referential_spec.rb
blob: 505630586f9659b6d3d32bda2fb1be745b3d6233 (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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
require 'spec_helper'

describe Referential, :type => :model do

  it "create a rule_parameter_set" do
    referential = Factory.create(:referential)
    expect(referential.rule_parameter_sets.size).to eq(1)
  end
end

describe Chouette::StopArea, :type => :model do
  # check override methods

   subject {Factory(:stop_area)}

    it "should return referential projection " do
      subject.referential.projection_type='27572'
      expect(subject.projection).to eq(subject.referential.projection_type)
    end

    it "should return projection coordinates when referential has projection" do
      subject.latitude = 45
      subject.longitude = 0
      subject.referential.projection_type='27572'
      expect(subject.projection_x).not_to be_nil
      expect(subject.projection_y).not_to be_nil
    end

    it "should return nil projection coordinates when referential has no projection" do
      subject.latitude = 45
      subject.longitude = 0
      subject.referential.projection_type=nil
      expect(subject.projection_x).to be_nil
      expect(subject.projection_y).to be_nil
    end

end

describe Chouette::AccessPoint, :type => :model do
  # check override methods

   subject {Factory(:access_point)}

    it "should return referential projection " do
      subject.referential.projection_type='27572'
      expect(subject.projection).to eq(subject.referential.projection_type)
    end

    it "should return projection coordinates when referential has projection" do
      subject.latitude = 45
      subject.longitude = 0
      subject.referential.projection_type='27572'
      expect(subject.projection_x).not_to be_nil
      expect(subject.projection_y).not_to be_nil
    end

    it "should return nil projection coordinates when referential has no projection" do
      subject.latitude = 45
      subject.longitude = 0
      subject.referential.projection_type=nil
      expect(subject.projection_x).to be_nil
      expect(subject.projection_y).to be_nil
    end

end