mirror of
https://github.com/TracksApp/tracks.git
synced 2025-12-17 15:50:13 +01:00
Add tests for the ICS and XML views and fix them up
This commit is contained in:
parent
ebd182695d
commit
98b188d1df
2 changed files with 21 additions and 1 deletions
|
|
@ -14,11 +14,19 @@ class CalendarController < ApplicationController
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
format.html
|
format.html
|
||||||
format.ics {
|
format.ics {
|
||||||
render :action => 'calendar', :layout => false, :content_type => Mime::ICS
|
render :action => 'show', :layout => false, :content_type => Mime::ICS
|
||||||
}
|
}
|
||||||
format.xml {
|
format.xml {
|
||||||
render :xml => @due_all.to_xml( *to_xml_params )
|
render :xml => @due_all.to_xml( *to_xml_params )
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
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
|
end
|
||||||
|
|
|
||||||
|
|
@ -27,4 +27,16 @@ class CalendarControllerTest < ActionController::TestCase
|
||||||
assert_equal [], assigns['calendar'].due_after_this_month
|
assert_equal [], assigns['calendar'].due_after_this_month
|
||||||
assert_equal 8, assigns['count']
|
assert_equal 8, assigns['count']
|
||||||
end
|
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
|
end
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue