test/dummy/app/controllers/application_controller.rb in api_docs-1.0.4 vs test/dummy/app/controllers/application_controller.rb in api_docs-1.0.5

- old
+ new

@@ -1,14 +1,25 @@ class ApplicationController < ActionController::Base protect_from_forgery def index - render :text => [{ - :id => 1, - :name => 'Test User', - :created_at => 1.day.ago - }].to_json + respond_to do |format| + format.json { + render :text => [{ + :id => 1, + :name => 'Test User', + :created_at => 1.day.ago + }].to_json + } + format.xml { + render :text => [{ + :id => 1, + :name => 'Test User', + :created_at => 1.day.ago + }].to_xml(:root => 'users') + } + end end def show status = :ok @@ -18,8 +29,16 @@ response = {:message => 'User not found'} status = :not_found end response.merge!(:created_at => rand.days.ago) if params[:random] - render :text => response.to_json, :status => status + + respond_to do |format| + format.json do + render :text => response.to_json, :status => status + end + format.xml do + render :text => response.to_xml(:root => 'user'), :status => status + end + end end end