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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
|
require 'spec_helper'
describe RoutesController do
login_user
let!(:referential) { create(:referential).switch }
let!(:route) { referential; Factory(:route) }
it { should be_kind_of(ChouetteController) }
shared_examples_for "redirected to referential_line_path(referential,line)" do
it "should redirect_to referential_line_path(referential,line)" do
response.should redirect_to( referential_line_path(referential,route.line) )
end
end
shared_examples_for "line and referential linked" do
it "assigns route.line as @line" do
assigns[:line].should == route.line
end
it "assigns referential as @referential" do
assigns[:referential].should == referential
end
end
shared_examples_for "route, line and referential linked" do
it "assigns route as @route" do
assigns[:route].should == route
end
it_behaves_like "line and referential linked"
end
describe "GET /index" do
before(:each) do
get :index, :line_id => route.line_id,
:referential_id => referential.id
end
it_behaves_like "line and referential linked"
it_behaves_like "redirected to referential_line_path(referential,line)"
end
describe "POST /create" do
before(:each) do
post :create, :line_id => route.line_id,
:referential_id => referential.id,
:route => { :name => "changed"}
end
it_behaves_like "line and referential linked"
it_behaves_like "redirected to referential_line_path(referential,line)"
end
describe "PUT /update" do
before(:each) do
put :update, :id => route.id, :line_id => route.line_id,
:referential_id => referential.id
end
it_behaves_like "route, line and referential linked"
it_behaves_like "redirected to referential_line_path(referential,line)"
end
describe "GET /show" do
before(:each) do
get :show, :id => route.id,
:line_id => route.line_id,
:referential_id => referential.id
end
it_behaves_like "route, line and referential linked"
it "assigns RouteMap.new( referential, route) as @map" do
assigns[:map].should be_an_instance_of(RouteMap)
assigns[:map].referential.should == referential
assigns[:map].route.should == route
end
it "assigns route.stop_points.paginate(:page => nil, :per_page => 10) as @stop_points" do
assigns[:stop_points].should == route.stop_points.paginate(:page => nil, :per_page => 10)
end
end
end
|