Commit d76e8dbc99d39b6cb53b8a139da8c53cccda5cd9
1 parent
fe8ccbdf
Exists in
master
and in
1 other branch
Removed unused routes, cleaned up rspec routing tests
Showing
14 changed files
with
18 additions
and
369 deletions
Show diff stats
app/controllers/choices_controller.rb
1 | class ChoicesController < InheritedResources::Base | 1 | class ChoicesController < InheritedResources::Base |
2 | respond_to :xml, :json | 2 | respond_to :xml, :json |
3 | - actions :show, :index, :create, :update | 3 | + actions :show, :index, :create, :update, :new |
4 | belongs_to :question | 4 | belongs_to :question |
5 | has_scope :active, :boolean => true, :only => :index | 5 | has_scope :active, :boolean => true, :only => :index |
6 | 6 |
app/controllers/densities_controller.rb
1 | class DensitiesController < InheritedResources::Base | 1 | class DensitiesController < InheritedResources::Base |
2 | respond_to :xml, :json | 2 | respond_to :xml, :json |
3 | before_filter :authenticate | 3 | before_filter :authenticate |
4 | + actions :index | ||
4 | 5 | ||
5 | def index | 6 | def index |
6 | if params[:question_id] | 7 | if params[:question_id] |
app/controllers/questions_controller.rb
1 | require 'fastercsv' | 1 | require 'fastercsv' |
2 | 2 | ||
3 | class QuestionsController < InheritedResources::Base | 3 | class QuestionsController < InheritedResources::Base |
4 | - actions :all, :except => [ :show ] | 4 | + actions :all, :except => [ :show, :edit, :delete ] |
5 | before_filter :authenticate | 5 | before_filter :authenticate |
6 | respond_to :xml, :json | 6 | respond_to :xml, :json |
7 | respond_to :csv, :only => :export #leave the option for xml export here | 7 | respond_to :csv, :only => :export #leave the option for xml export here |
app/controllers/visitors_controller.rb
1 | class VisitorsController < InheritedResources::Base | 1 | class VisitorsController < InheritedResources::Base |
2 | respond_to :xml, :json | 2 | respond_to :xml, :json |
3 | before_filter :authenticate | 3 | before_filter :authenticate |
4 | + actions :none | ||
4 | 5 | ||
5 | def objects_by_session_ids | 6 | def objects_by_session_ids |
6 | session_ids = params[:session_ids] | 7 | session_ids = params[:session_ids] |
config/routes.rb
1 | ActionController::Routing::Routes.draw do |map| | 1 | ActionController::Routing::Routes.draw do |map| |
2 | - #map.resources :clicks | ||
3 | - map.resources :densities | ||
4 | - map.resources :visitors, :collection => {:objects_by_session_ids => :post}, :member => {:votes => :get} | ||
5 | - map.resources :questions, :member => { :object_info_totals_by_date => :get, | ||
6 | - :object_info_by_visitor_id => :get, | ||
7 | - :export => :post, | ||
8 | - :activate => :put, | ||
9 | - :suspend => :put}, | 2 | + map.resources :densities, :only => :index |
3 | + map.resources :visitors, :only => :none, | ||
4 | + :collection => {:objects_by_session_ids => :post}, | ||
5 | + :member => {:votes => :get} | ||
6 | + map.resources :questions, :except => [:edit, :destroy], | ||
7 | + :member => {:object_info_totals_by_date => :get, | ||
8 | + :object_info_by_visitor_id => :get, | ||
9 | + :export => :post} , | ||
10 | :collection => {:all_num_votes_by_visitor_id => :get, | 10 | :collection => {:all_num_votes_by_visitor_id => :get, |
11 | :all_object_info_totals_by_date => :get, | 11 | :all_object_info_totals_by_date => :get, |
12 | :object_info_totals_by_question_id => :get, | 12 | :object_info_totals_by_question_id => :get, |
13 | :recent_votes_by_question_id => :get} do |question| | 13 | :recent_votes_by_question_id => :get} do |question| |
14 | - question.resources :items | ||
15 | - question.resources :prompts, :member => {:skip => :post, :vote => :post}, | ||
16 | - :collection => {:single => :get, :index => :get} | ||
17 | - question.resources :choices, :member => {:flag => :put, :votes => :get} | ||
18 | - end | ||
19 | - map.resources :algorithms | ||
20 | - map.connect "/questions/:question_id/prompts/:id/vote/:index", :controller => 'prompts', :action => 'vote' | 14 | + question.resources :prompts, :only => :show, |
15 | + :member => {:skip => :post, :vote => :post} | ||
16 | + question.resources :choices, :only => [:show, :index, :create, :update, :new], | ||
17 | + :member => {:flag => :put, :votes => :get} | ||
18 | + end | ||
21 | 19 | ||
22 | - | ||
23 | - | ||
24 | - | ||
25 | - map.learn '/learn', :controller => 'home', :action => 'learn' | ||
26 | - map.api '/api', :controller => 'home', :action => 'api' | ||
27 | - map.about '/about', :controller => 'home', :action => 'about' | ||
28 | map.root :controller => "clearance/sessions", :action => "new" | 20 | map.root :controller => "clearance/sessions", :action => "new" |
29 | 21 | ||
30 | - # rake routes | ||
31 | - # http://guides.rubyonrails.org/routing.html | ||
32 | end | 22 | end |
spec/controllers/visitors_controller_spec.rb
1 | require File.expand_path(File.dirname(__FILE__) + '/../spec_helper') | 1 | require File.expand_path(File.dirname(__FILE__) + '/../spec_helper') |
2 | 2 | ||
3 | describe VisitorsController do | 3 | describe VisitorsController do |
4 | - #Inherited resources has some issues with rspec, so this test case is not complete. | ||
5 | - # OTOH Inherited resources is largely unit tested, so this is not a huge issue | ||
6 | - | ||
7 | - before do | ||
8 | - controller.should_receive(:authenticate).with(no_args).once.and_return(true) | ||
9 | - end | ||
10 | - | ||
11 | - def mock_visitor(stubs={}) | ||
12 | - @mock_visitor ||= mock_model(Visitor, stubs) | ||
13 | - end | ||
14 | - | ||
15 | - describe "GET index" do | ||
16 | - it "assigns all visitors as @visitors" do | ||
17 | - Visitor.stub!(:find).with(:all).and_return([mock_visitor]) | ||
18 | - get :index | ||
19 | - assigns[:visitors].should == [mock_visitor] | ||
20 | - end | ||
21 | - end | ||
22 | - | ||
23 | - describe "GET show" do | ||
24 | - it "assigns the requested visitor as @visitor" do | ||
25 | - Visitor.stub!(:find).with("37").and_return(mock_visitor) | ||
26 | - get :show, :id => "37" | ||
27 | - assigns[:visitor].should equal(mock_visitor) | ||
28 | - end | ||
29 | - end | ||
30 | - | ||
31 | - describe "GET new" do | ||
32 | - it "assigns a new visitor as @visitor" do | ||
33 | - Visitor.stub!(:new).and_return(mock_visitor) | ||
34 | - get :new | ||
35 | - assigns[:visitor].should equal(mock_visitor) | ||
36 | - end | ||
37 | - end | ||
38 | - | ||
39 | - describe "GET edit" do | ||
40 | - it "assigns the requested visitor as @visitor" do | ||
41 | - Visitor.stub!(:find).with("37").and_return(mock_visitor) | ||
42 | - get :edit, :id => "37" | ||
43 | - assigns[:visitor].should equal(mock_visitor) | ||
44 | - end | ||
45 | - end | ||
46 | - | ||
47 | - describe "POST create" do | ||
48 | - | ||
49 | - describe "with valid params" do | ||
50 | - it "assigns a newly created visitor as @visitor" do | ||
51 | - Visitor.stub!(:new).with({'these' => 'params'}).and_return(mock_visitor(:save => true)) | ||
52 | - post :create, :visitor => {:these => 'params'} | ||
53 | - assigns[:visitor].should equal(mock_visitor) | ||
54 | - end | ||
55 | - | ||
56 | - end | ||
57 | - | ||
58 | - describe "with invalid params" do | ||
59 | - it "assigns a newly created but unsaved visitor as @visitor" do | ||
60 | - Visitor.stub!(:new).with({'these' => 'params'}).and_return(mock_visitor(:save => false)) | ||
61 | - post :create, :visitor => {:these => 'params'} | ||
62 | - assigns[:visitor].should equal(mock_visitor) | ||
63 | - end | ||
64 | - | ||
65 | - end | ||
66 | - | ||
67 | - end | ||
68 | - | ||
69 | - describe "PUT update" do | ||
70 | - | ||
71 | - describe "with valid params" do | ||
72 | - it "updates the requested visitor" do | ||
73 | - Visitor.should_receive(:find).with("37").and_return(mock_visitor) | ||
74 | - mock_visitor.should_receive(:update_attributes).with({'these' => 'params'}) | ||
75 | - put :update, :id => "37", :visitor => {:these => 'params'} | ||
76 | - end | ||
77 | - | ||
78 | - it "assigns the requested visitor as @visitor" do | ||
79 | - Visitor.stub!(:find).and_return(mock_visitor(:update_attributes => true)) | ||
80 | - put :update, :id => "1" | ||
81 | - assigns[:visitor].should equal(mock_visitor) | ||
82 | - end | ||
83 | - | ||
84 | - end | ||
85 | - | ||
86 | - describe "with invalid params" do | ||
87 | - it "updates the requested visitor" do | ||
88 | - Visitor.should_receive(:find).with("37").and_return(mock_visitor) | ||
89 | - mock_visitor.should_receive(:update_attributes).with({'these' => 'params'}) | ||
90 | - put :update, :id => "37", :visitor => {:these => 'params'} | ||
91 | - end | ||
92 | - | ||
93 | - it "assigns the visitor as @visitor" do | ||
94 | - Visitor.stub!(:find).and_return(mock_visitor(:update_attributes => false)) | ||
95 | - put :update, :id => "1" | ||
96 | - assigns[:visitor].should equal(mock_visitor) | ||
97 | - end | ||
98 | - | ||
99 | - end | ||
100 | - | ||
101 | - end | ||
102 | - | ||
103 | - describe "DELETE destroy" do | ||
104 | - it "destroys the requested visitor" do | ||
105 | - Visitor.should_receive(:find).with("37").and_return(mock_visitor) | ||
106 | - mock_visitor.should_receive(:destroy) | ||
107 | - delete :destroy, :id => "37" | ||
108 | - end | ||
109 | - | ||
110 | - end | ||
111 | 4 | ||
112 | end | 5 | end |
spec/routing/choices_routing_spec.rb
@@ -16,18 +16,10 @@ describe ChoicesController do | @@ -16,18 +16,10 @@ describe ChoicesController do | ||
16 | route_for(:controller => "choices", :action => "index", :question_id => @q.id.to_s).should == "/questions/#{@q.id}/choices" | 16 | route_for(:controller => "choices", :action => "index", :question_id => @q.id.to_s).should == "/questions/#{@q.id}/choices" |
17 | end | 17 | end |
18 | 18 | ||
19 | - it "maps #new" do | ||
20 | - route_for(:controller => "choices", :action => "new", :question_id => @q.id.to_s).should == "/questions/#{@q.id}/choices/new" | ||
21 | - end | ||
22 | - | ||
23 | it "maps #show" do | 19 | it "maps #show" do |
24 | route_for(:controller => "choices", :action => "show", :id => "1", :question_id => @q.id.to_s).should == "/questions/#{@q.id}/choices/1" | 20 | route_for(:controller => "choices", :action => "show", :id => "1", :question_id => @q.id.to_s).should == "/questions/#{@q.id}/choices/1" |
25 | end | 21 | end |
26 | 22 | ||
27 | - it "maps #edit" do | ||
28 | - route_for(:controller => "choices", :action => "edit", :id => "1", :question_id => @q.id.to_s).should == "/questions/#{@q.id}/choices/1/edit" | ||
29 | - end | ||
30 | - | ||
31 | it "maps #create" do | 23 | it "maps #create" do |
32 | route_for(:controller => "choices", :action => "create", :question_id => @q.id.to_s).should == {:path => "/questions/#{@q.id}/choices", :method => :post} | 24 | route_for(:controller => "choices", :action => "create", :question_id => @q.id.to_s).should == {:path => "/questions/#{@q.id}/choices", :method => :post} |
33 | end | 25 | end |
@@ -35,10 +27,6 @@ describe ChoicesController do | @@ -35,10 +27,6 @@ describe ChoicesController do | ||
35 | it "maps #update" do | 27 | it "maps #update" do |
36 | route_for(:controller => "choices", :action => "update", :id => "1", :question_id => @q.id.to_s).should == {:path =>"/questions/#{@q.id}/choices/1", :method => :put} | 28 | route_for(:controller => "choices", :action => "update", :id => "1", :question_id => @q.id.to_s).should == {:path =>"/questions/#{@q.id}/choices/1", :method => :put} |
37 | end | 29 | end |
38 | - | ||
39 | - it "maps #destroy" do | ||
40 | - route_for(:controller => "choices", :action => "destroy", :id => "1", :question_id => @q.id.to_s).should == {:path =>"/questions/#{@q.id}/choices/1", :method => :delete} | ||
41 | - end | ||
42 | end | 30 | end |
43 | 31 | ||
44 | describe "route recognition" do | 32 | describe "route recognition" do |
@@ -46,10 +34,6 @@ describe ChoicesController do | @@ -46,10 +34,6 @@ describe ChoicesController do | ||
46 | params_from(:get, "/questions/#{@q.id.to_s}/choices").should == {:controller => "choices", :action => "index", :question_id => @q.id.to_s} | 34 | params_from(:get, "/questions/#{@q.id.to_s}/choices").should == {:controller => "choices", :action => "index", :question_id => @q.id.to_s} |
47 | end | 35 | end |
48 | 36 | ||
49 | - it "generates params for #new" do | ||
50 | - params_from(:get, "/questions/#{@q.id}/choices/new").should == {:controller => "choices", :action => "new", :question_id => @q.id.to_s} | ||
51 | - end | ||
52 | - | ||
53 | it "generates params for #create" do | 37 | it "generates params for #create" do |
54 | params_from(:post, "/questions/#{@q.id}/choices").should == {:controller => "choices", :action => "create", :question_id => @q.id.to_s} | 38 | params_from(:post, "/questions/#{@q.id}/choices").should == {:controller => "choices", :action => "create", :question_id => @q.id.to_s} |
55 | end | 39 | end |
@@ -58,16 +42,8 @@ describe ChoicesController do | @@ -58,16 +42,8 @@ describe ChoicesController do | ||
58 | params_from(:get, "/questions/#{@q.id}/choices/1").should == {:controller => "choices", :action => "show", :id => "1", :question_id => @q.id.to_s} | 42 | params_from(:get, "/questions/#{@q.id}/choices/1").should == {:controller => "choices", :action => "show", :id => "1", :question_id => @q.id.to_s} |
59 | end | 43 | end |
60 | 44 | ||
61 | - it "generates params for #edit" do | ||
62 | - params_from(:get, "/questions/#{@q.id}/choices/1/edit").should == {:controller => "choices", :action => "edit", :id => "1", :question_id => @q.id.to_s} | ||
63 | - end | ||
64 | - | ||
65 | it "generates params for #update" do | 45 | it "generates params for #update" do |
66 | params_from(:put, "/questions/#{@q.id}/choices/1").should == {:controller => "choices", :action => "update", :id => "1", :question_id => @q.id.to_s} | 46 | params_from(:put, "/questions/#{@q.id}/choices/1").should == {:controller => "choices", :action => "update", :id => "1", :question_id => @q.id.to_s} |
67 | end | 47 | end |
68 | - | ||
69 | - it "generates params for #destroy" do | ||
70 | - params_from(:delete, "/questions/#{@q.id}/choices/1").should == {:controller => "choices", :action => "destroy", :id => "1", :question_id => @q.id.to_s} | ||
71 | - end | ||
72 | end | 48 | end |
73 | end | 49 | end |
spec/routing/prompts_routing_spec.rb
@@ -13,62 +13,16 @@ describe PromptsController do | @@ -13,62 +13,16 @@ describe PromptsController do | ||
13 | end | 13 | end |
14 | 14 | ||
15 | describe "route generation" do | 15 | describe "route generation" do |
16 | - it "maps #index" do | ||
17 | - route_for(:controller => "prompts", :action => "index", :question_id => @q.id.to_s).should == "/questions/#{@q.id}/prompts/index" | ||
18 | - end | ||
19 | - | ||
20 | - it "maps #new" do | ||
21 | - route_for(:controller => "prompts", :action => "new", :question_id => @q.id.to_s).should == "/questions/#{@q.id}/prompts/new" | ||
22 | - end | ||
23 | - | ||
24 | it "maps #show" do | 16 | it "maps #show" do |
25 | route_for(:controller => "prompts", :action => "show", :id => "1", :question_id => @q.id.to_s).should == "/questions/#{@q.id}/prompts/1" | 17 | route_for(:controller => "prompts", :action => "show", :id => "1", :question_id => @q.id.to_s).should == "/questions/#{@q.id}/prompts/1" |
26 | end | 18 | end |
27 | 19 | ||
28 | - it "maps #edit" do | ||
29 | - route_for(:controller => "prompts", :action => "edit", :id => "1", :question_id => @q.id.to_s).should == "/questions/#{@q.id}/prompts/1/edit" | ||
30 | - end | ||
31 | - | ||
32 | - it "maps #create" do | ||
33 | - route_for(:controller => "prompts", :action => "create", :question_id => @q.id.to_s).should == {:path => "/questions/#{@q.id}/prompts", :method => :post} | ||
34 | - end | ||
35 | - | ||
36 | - it "maps #update" do | ||
37 | - route_for(:controller => "prompts", :action => "update", :id => "1", :question_id => @q.id.to_s).should == {:path =>"/questions/#{@q.id}/prompts/1", :method => :put} | ||
38 | - end | ||
39 | - | ||
40 | - it "maps #destroy" do | ||
41 | - route_for(:controller => "prompts", :action => "destroy", :id => "1", :question_id => @q.id.to_s).should == {:path =>"/questions/#{@q.id}/prompts/1", :method => :delete} | ||
42 | - end | ||
43 | end | 20 | end |
44 | 21 | ||
45 | describe "route recognition" do | 22 | describe "route recognition" do |
46 | - it "generates params for #index" do | ||
47 | - params_from(:get, "/questions/#{@q.id}/prompts").should == {:controller => "prompts", :action => "index", :question_id => @q.id.to_s} | ||
48 | - end | ||
49 | - | ||
50 | - it "generates params for #new" do | ||
51 | - params_from(:get, "/questions/#{@q.id}/prompts/new").should == {:controller => "prompts", :action => "new", :question_id => @q.id.to_s} | ||
52 | - end | ||
53 | - | ||
54 | - it "generates params for #create" do | ||
55 | - params_from(:post, "/questions/#{@q.id}/prompts").should == {:controller => "prompts", :action => "create", :question_id => @q.id.to_s} | ||
56 | - end | ||
57 | - | ||
58 | it "generates params for #show" do | 23 | it "generates params for #show" do |
59 | params_from(:get, "/questions/#{@q.id}/prompts/1").should == {:controller => "prompts", :action => "show", :id => "1", :question_id => @q.id.to_s} | 24 | params_from(:get, "/questions/#{@q.id}/prompts/1").should == {:controller => "prompts", :action => "show", :id => "1", :question_id => @q.id.to_s} |
60 | end | 25 | end |
61 | - | ||
62 | - it "generates params for #edit" do | ||
63 | - params_from(:get, "/questions/#{@q.id}/prompts/1/edit").should == {:controller => "prompts", :action => "edit", :id => "1", :question_id => @q.id.to_s} | ||
64 | - end | ||
65 | - | ||
66 | - it "generates params for #update" do | ||
67 | - params_from(:put, "/questions/#{@q.id}/prompts/1").should == {:controller => "prompts", :action => "update", :id => "1", :question_id => @q.id.to_s} | ||
68 | - end | ||
69 | - | ||
70 | - it "generates params for #destroy" do | ||
71 | - params_from(:delete, "/questions/#{@q.id}/prompts/1").should == {:controller => "prompts", :action => "destroy", :id => "1", :question_id => @q.id.to_s} | ||
72 | - end | ||
73 | end | 26 | end |
27 | + | ||
74 | end | 28 | end |
spec/routing/questions_routing_spec.rb
@@ -14,10 +14,6 @@ describe QuestionsController do | @@ -14,10 +14,6 @@ describe QuestionsController do | ||
14 | route_for(:controller => "questions", :action => "show", :id => "1").should == "/questions/1" | 14 | route_for(:controller => "questions", :action => "show", :id => "1").should == "/questions/1" |
15 | end | 15 | end |
16 | 16 | ||
17 | - it "maps #edit" do | ||
18 | - route_for(:controller => "questions", :action => "edit", :id => "1").should == "/questions/1/edit" | ||
19 | - end | ||
20 | - | ||
21 | it "maps #create" do | 17 | it "maps #create" do |
22 | route_for(:controller => "questions", :action => "create").should == {:path => "/questions", :method => :post} | 18 | route_for(:controller => "questions", :action => "create").should == {:path => "/questions", :method => :post} |
23 | end | 19 | end |
@@ -26,9 +22,6 @@ describe QuestionsController do | @@ -26,9 +22,6 @@ describe QuestionsController do | ||
26 | route_for(:controller => "questions", :action => "update", :id => "1").should == {:path =>"/questions/1", :method => :put} | 22 | route_for(:controller => "questions", :action => "update", :id => "1").should == {:path =>"/questions/1", :method => :put} |
27 | end | 23 | end |
28 | 24 | ||
29 | - it "maps #destroy" do | ||
30 | - route_for(:controller => "questions", :action => "destroy", :id => "1").should == {:path =>"/questions/1", :method => :delete} | ||
31 | - end | ||
32 | end | 25 | end |
33 | 26 | ||
34 | describe "route recognition" do | 27 | describe "route recognition" do |
@@ -48,16 +41,9 @@ describe QuestionsController do | @@ -48,16 +41,9 @@ describe QuestionsController do | ||
48 | params_from(:get, "/questions/1").should == {:controller => "questions", :action => "show", :id => "1"} | 41 | params_from(:get, "/questions/1").should == {:controller => "questions", :action => "show", :id => "1"} |
49 | end | 42 | end |
50 | 43 | ||
51 | - it "generates params for #edit" do | ||
52 | - params_from(:get, "/questions/1/edit").should == {:controller => "questions", :action => "edit", :id => "1"} | ||
53 | - end | ||
54 | - | ||
55 | it "generates params for #update" do | 44 | it "generates params for #update" do |
56 | params_from(:put, "/questions/1").should == {:controller => "questions", :action => "update", :id => "1"} | 45 | params_from(:put, "/questions/1").should == {:controller => "questions", :action => "update", :id => "1"} |
57 | end | 46 | end |
58 | 47 | ||
59 | - it "generates params for #destroy" do | ||
60 | - params_from(:delete, "/questions/1").should == {:controller => "questions", :action => "destroy", :id => "1"} | ||
61 | - end | ||
62 | end | 48 | end |
63 | end | 49 | end |
spec/routing/visitors_routing_spec.rb
1 | require File.expand_path(File.dirname(__FILE__) + '/../spec_helper') | 1 | require File.expand_path(File.dirname(__FILE__) + '/../spec_helper') |
2 | 2 | ||
3 | describe VisitorsController do | 3 | describe VisitorsController do |
4 | - describe "route generation" do | ||
5 | - it "maps #index" do | ||
6 | - route_for(:controller => "visitors", :action => "index").should == "/visitors" | ||
7 | - end | ||
8 | 4 | ||
9 | - it "maps #new" do | ||
10 | - route_for(:controller => "visitors", :action => "new").should == "/visitors/new" | ||
11 | - end | ||
12 | - | ||
13 | - it "maps #show" do | ||
14 | - route_for(:controller => "visitors", :action => "show", :id => "1").should == "/visitors/1" | ||
15 | - end | ||
16 | - | ||
17 | - it "maps #edit" do | ||
18 | - route_for(:controller => "visitors", :action => "edit", :id => "1").should == "/visitors/1/edit" | ||
19 | - end | ||
20 | - | ||
21 | - it "maps #create" do | ||
22 | - route_for(:controller => "visitors", :action => "create").should == {:path => "/visitors", :method => :post} | ||
23 | - end | ||
24 | - | ||
25 | - it "maps #update" do | ||
26 | - route_for(:controller => "visitors", :action => "update", :id => "1").should == {:path =>"/visitors/1", :method => :put} | ||
27 | - end | ||
28 | - | ||
29 | - it "maps #destroy" do | ||
30 | - route_for(:controller => "visitors", :action => "destroy", :id => "1").should == {:path =>"/visitors/1", :method => :delete} | ||
31 | - end | ||
32 | - end | ||
33 | - | ||
34 | - describe "route recognition" do | ||
35 | - it "generates params for #index" do | ||
36 | - params_from(:get, "/visitors").should == {:controller => "visitors", :action => "index"} | ||
37 | - end | ||
38 | - | ||
39 | - it "generates params for #new" do | ||
40 | - params_from(:get, "/visitors/new").should == {:controller => "visitors", :action => "new"} | ||
41 | - end | ||
42 | - | ||
43 | - it "generates params for #create" do | ||
44 | - params_from(:post, "/visitors").should == {:controller => "visitors", :action => "create"} | ||
45 | - end | ||
46 | - | ||
47 | - it "generates params for #show" do | ||
48 | - params_from(:get, "/visitors/1").should == {:controller => "visitors", :action => "show", :id => "1"} | ||
49 | - end | ||
50 | - | ||
51 | - it "generates params for #edit" do | ||
52 | - params_from(:get, "/visitors/1/edit").should == {:controller => "visitors", :action => "edit", :id => "1"} | ||
53 | - end | ||
54 | - | ||
55 | - it "generates params for #update" do | ||
56 | - params_from(:put, "/visitors/1").should == {:controller => "visitors", :action => "update", :id => "1"} | ||
57 | - end | ||
58 | - | ||
59 | - it "generates params for #destroy" do | ||
60 | - params_from(:delete, "/visitors/1").should == {:controller => "visitors", :action => "destroy", :id => "1"} | ||
61 | - end | ||
62 | - end | ||
63 | end | 5 | end |
spec/views/visitors/edit.html.erb_spec.rb
@@ -1,24 +0,0 @@ | @@ -1,24 +0,0 @@ | ||
1 | -require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper') | ||
2 | - | ||
3 | -describe "/visitors/edit.html.erb" do | ||
4 | - include VisitorsHelper | ||
5 | - | ||
6 | - before(:each) do | ||
7 | - assigns[:visitor] = @visitor = stub_model(Visitor, | ||
8 | - :new_record? => false, | ||
9 | - :site_id => 1, | ||
10 | - :identifier => "value for identifier", | ||
11 | - :tracking => "value for tracking" | ||
12 | - ) | ||
13 | - end | ||
14 | - | ||
15 | - it "renders the edit visitor form" do | ||
16 | - render | ||
17 | - | ||
18 | - response.should have_tag("form[action=#{visitor_path(@visitor)}][method=post]") do | ||
19 | - with_tag('input#visitor_site_id[name=?]', "visitor[site_id]") | ||
20 | - with_tag('input#visitor_identifier[name=?]', "visitor[identifier]") | ||
21 | - with_tag('textarea#visitor_tracking[name=?]', "visitor[tracking]") | ||
22 | - end | ||
23 | - end | ||
24 | -end |
spec/views/visitors/index.html.erb_spec.rb
@@ -1,27 +0,0 @@ | @@ -1,27 +0,0 @@ | ||
1 | -require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper') | ||
2 | - | ||
3 | -describe "/visitors/index.html.erb" do | ||
4 | - include VisitorsHelper | ||
5 | - | ||
6 | - before(:each) do | ||
7 | - assigns[:visitors] = [ | ||
8 | - stub_model(Visitor, | ||
9 | - :site_id => 1, | ||
10 | - :identifier => "value for identifier", | ||
11 | - :tracking => "value for tracking" | ||
12 | - ), | ||
13 | - stub_model(Visitor, | ||
14 | - :site_id => 1, | ||
15 | - :identifier => "value for identifier", | ||
16 | - :tracking => "value for tracking" | ||
17 | - ) | ||
18 | - ] | ||
19 | - end | ||
20 | - | ||
21 | - it "renders a list of visitors" do | ||
22 | - render | ||
23 | - response.should have_tag("tr>td", 1.to_s, 2) | ||
24 | - response.should have_tag("tr>td", "value for identifier".to_s, 2) | ||
25 | - response.should have_tag("tr>td", "value for tracking".to_s, 2) | ||
26 | - end | ||
27 | -end |
spec/views/visitors/new.html.erb_spec.rb
@@ -1,24 +0,0 @@ | @@ -1,24 +0,0 @@ | ||
1 | -require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper') | ||
2 | - | ||
3 | -describe "/visitors/new.html.erb" do | ||
4 | - include VisitorsHelper | ||
5 | - | ||
6 | - before(:each) do | ||
7 | - assigns[:visitor] = stub_model(Visitor, | ||
8 | - :new_record? => true, | ||
9 | - :site_id => 1, | ||
10 | - :identifier => "value for identifier", | ||
11 | - :tracking => "value for tracking" | ||
12 | - ) | ||
13 | - end | ||
14 | - | ||
15 | - it "renders new visitor form" do | ||
16 | - render | ||
17 | - | ||
18 | - response.should have_tag("form[action=?][method=post]", visitors_path) do | ||
19 | - with_tag("input#visitor_site_id[name=?]", "visitor[site_id]") | ||
20 | - with_tag("input#visitor_identifier[name=?]", "visitor[identifier]") | ||
21 | - with_tag("textarea#visitor_tracking[name=?]", "visitor[tracking]") | ||
22 | - end | ||
23 | - end | ||
24 | -end |
spec/views/visitors/show.html.erb_spec.rb
@@ -1,19 +0,0 @@ | @@ -1,19 +0,0 @@ | ||
1 | -require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper') | ||
2 | - | ||
3 | -describe "/visitors/show.html.erb" do | ||
4 | - include VisitorsHelper | ||
5 | - before(:each) do | ||
6 | - assigns[:visitor] = @visitor = stub_model(Visitor, | ||
7 | - :site_id => 1, | ||
8 | - :identifier => "value for identifier", | ||
9 | - :tracking => "value for tracking" | ||
10 | - ) | ||
11 | - end | ||
12 | - | ||
13 | - it "renders attributes in <p>" do | ||
14 | - render | ||
15 | - response.should have_text(/1/) | ||
16 | - response.should have_text(/value\ for\ identifier/) | ||
17 | - response.should have_text(/value\ for\ tracking/) | ||
18 | - end | ||
19 | -end |