Skip to content
This repository has been archived by the owner on Apr 28, 2020. It is now read-only.

Commit

Permalink
fixing api screen bug caused by "new" html wrapper
Browse files Browse the repository at this point in the history
  • Loading branch information
lizconlan authored and lizconlan committed Jun 30, 2011
1 parent 904dc47 commit 5df78c7
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 4 deletions.
1 change: 1 addition & 0 deletions app/controllers/api_controller.rb
Expand Up @@ -8,6 +8,7 @@ def index
end end


def search def search
params[:search_term] = params[:q1] unless params[:q1].blank?
params[:search_term] = params[:q] unless params[:q].blank? params[:search_term] = params[:q] unless params[:q].blank?
search_term = params[:search_term] search_term = params[:search_term]


Expand Down
4 changes: 2 additions & 2 deletions app/views/api/index.haml
Expand Up @@ -21,12 +21,12 @@
= label_tag 'f_csv', 'CSV' = label_tag 'f_csv', 'CSV'
= radio_button_tag 'f', 'csv' = radio_button_tag 'f', 'csv'
%p %p
= text_field_tag 'q', '', :size => 24 = text_field_tag 'q1', '', :size => 24
= submit_tag 'Find MP' = submit_tag 'Find MP'
= observe_field :f_xml, :frequency => 0.5, :function => 'if($("f_xml").checked) { $("format").innerHTML = $("f_xml").value }' = 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_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 :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 %p
URL: URL:
%p %p
Expand Down
4 changes: 2 additions & 2 deletions spec/controllers/api_controller_spec.rb
Expand Up @@ -69,12 +69,12 @@ def do_get format=nil


it 'should render js correctly' do it 'should render js correctly' do
do_get 'js' 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 end


it 'should render js with callback correctly' do it 'should render js with callback correctly' do
get :search, :q => @postcode_no_space, :format => 'js', :callback => 'callback_function' 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
end end


Expand Down

0 comments on commit 5df78c7

Please sign in to comment.