Commit bac804f308e05ba3b2541c43c7f0a567db5c160a
1 parent
9bf5aba9
Exists in
master
and in
1 other branch
Added spec for choices#vote
Showing
1 changed file
with
15 additions
and
0 deletions
Show diff stats
spec/controllers/choices_controller_spec.rb
@@ -35,6 +35,10 @@ describe ChoicesController do | @@ -35,6 +35,10 @@ describe ChoicesController do | ||
35 | @mock_flag ||= mock_model(Flag, stubs) | 35 | @mock_flag ||= mock_model(Flag, stubs) |
36 | end | 36 | end |
37 | 37 | ||
38 | + def mock_vote(stubs={}) | ||
39 | + @mock_vote || mock_model(Vote, stubs) | ||
40 | + end | ||
41 | + | ||
38 | describe "PUT flag" do | 42 | describe "PUT flag" do |
39 | before(:each) do | 43 | before(:each) do |
40 | question_list = [mock_question] | 44 | question_list = [mock_question] |
@@ -109,5 +113,16 @@ describe ChoicesController do | @@ -109,5 +113,16 @@ describe ChoicesController do | ||
109 | assigns[:choice].should be_active | 113 | assigns[:choice].should be_active |
110 | end | 114 | end |
111 | end | 115 | end |
116 | + | ||
117 | + describe "GET votes" do | ||
118 | + it "returns a choice's votes" do | ||
119 | + Choice.should_receive(:find).and_return(mock_choice) | ||
120 | + votes_array = [mock_vote] | ||
121 | + votes_array.should_receive(:to_xml) | ||
122 | + mock_choice.should_receive(:votes).and_return(votes_array) | ||
123 | + | ||
124 | + get :votes, :id => mock_choice.id, :question_id => mock_question.id | ||
125 | + end | ||
126 | + end | ||
112 | 127 | ||
113 | end | 128 | end |