Browse files

fixing api screen bug caused by "new" html wrapper

  • Loading branch information...
1 parent 904dc47 commit 5df78c798641be3a20ea6914100d037a06c7740c lizconlan committed Jun 30, 2011
Showing with 5 additions and 4 deletions.
  1. +1 −0 app/controllers/api_controller.rb
  2. +2 −2 app/views/api/index.haml
  3. +2 −2 spec/controllers/api_controller_spec.rb
View
1 app/controllers/api_controller.rb
@@ -8,6 +8,7 @@ def index
end
def search
+ params[:search_term] = params[:q1] unless params[:q1].blank?
params[:search_term] = params[:q] unless params[:q].blank?
search_term = params[:search_term]
View
4 app/views/api/index.haml
@@ -21,12 +21,12 @@
= label_tag 'f_csv', 'CSV'
= radio_button_tag 'f', 'csv'
%p
- = text_field_tag 'q', '', :size => 24
+ = text_field_tag 'q1', '', :size => 24
= submit_tag 'Find MP'
= observe_field :f_xml, :frequency => 0.5, :function => 'if($("f_xml").checked) { $("format").innerHTML = $("f_xml").value }'
= observe_field :f_js, :frequency => 0.5, :function => 'if($("f_js").checked) { $("format").innerHTML = $("f_js").value }'
= observe_field :f_csv, :frequency => 0.5, :function => 'if($("f_csv").checked) { $("format").innerHTML = $("f_csv").value }'
-= observe_field :q, :frequency => 0.5, :function => '$("query").innerHTML = escape($("q").value)'
+= observe_field :q1, :frequency => 0.5, :function => '$("query").innerHTML = escape($("q1").value)'
%p
URL:
%p
View
4 spec/controllers/api_controller_spec.rb
@@ -69,12 +69,12 @@ def do_get format=nil
it 'should render js correctly' do
do_get 'js'
- response.body.should == %Q|{"results": { "constituencies": {json version of data}, "members": {} }} |
+ response.body.should == %Q|{"results": { "constituencies": [json version of data], "members": [] }} |
end
it 'should render js with callback correctly' do
get :search, :q => @postcode_no_space, :format => 'js', :callback => 'callback_function'
- response.body.should == %Q|callback_function({"results": { "constituencies": {json version of data}, "members": {} }} )|
+ response.body.should == %Q|callback_function({"results": { "constituencies": [json version of data], "members": [] }} )|
end
end

0 comments on commit 5df78c7

Please sign in to comment.