Add tests for the ICS and XML views and fix them up

This commit is contained in:
Matt Rogers 2013-04-30 20:38:10 -05:00
parent ebd182695d
commit 98b188d1df
2 changed files with 21 additions and 1 deletions

View file

@ -14,11 +14,19 @@ class CalendarController < ApplicationController
respond_to do |format|
format.html
format.ics {
render :action => 'calendar', :layout => false, :content_type => Mime::ICS
render :action => 'show', :layout => false, :content_type => Mime::ICS
}
format.xml {
render :xml => @due_all.to_xml( *to_xml_params )
}
end
end
def to_xml_params
if params[:limit_fields] == 'index'
return [:only => [:id, :created_at, :updated_at, :completed_at] ]
else
return [:except => :user_id, :include => [:tags, :predecessors, :successors] ]
end
end
end

View file

@ -27,4 +27,16 @@ class CalendarControllerTest < ActionController::TestCase
assert_equal [], assigns['calendar'].due_after_this_month
assert_equal 8, assigns['count']
end
def test_show_ics
login_as(:admin_user)
get :show, :format => 'ics'
assert_equal 8, assigns['due_all'].count
end
def test_show_xml
login_as(:admin_user)
get :show, :format => 'xml'
assert_equal 8, assigns['due_all'].count
end
end