4 class SwfControllerTest < ActionController::TestCase
6 # test all routes which lead to this controller
9 { :path => "/api/0.6/swf/trackpoints", :method => :get },
10 { :controller => "api/swf", :action => "trackpoints" }
15 # basic test that trackpoints at least returns some sort of flash movie
18 other_user = create(:user)
19 create(:trace, :visibility => "trackable", :latitude => 51.51, :longitude => -0.14, :user => user) do |trace|
20 create(:tracepoint, :trace => trace, :trackid => 1, :latitude => (51.510 * GeoRecord::SCALE).to_i, :longitude => (-0.140 * GeoRecord::SCALE).to_i)
21 create(:tracepoint, :trace => trace, :trackid => 2, :latitude => (51.511 * GeoRecord::SCALE).to_i, :longitude => (-0.141 * GeoRecord::SCALE).to_i)
23 create(:trace, :visibility => "identifiable", :latitude => 51.512, :longitude => 0.142) do |trace|
24 create(:tracepoint, :trace => trace, :latitude => (51.512 * GeoRecord::SCALE).to_i, :longitude => (0.142 * GeoRecord::SCALE).to_i)
27 get :trackpoints, :params => { :xmin => -1, :xmax => 1, :ymin => 51, :ymax => 52, :baselong => 0, :basey => 0, :masterscale => 1 }
28 assert_response :success
29 assert_equal "application/x-shockwave-flash", response.content_type
30 assert_match(/^FWS/, response.body)
31 assert_equal 80, response.body.length
33 get :trackpoints, :params => { :xmin => -1, :xmax => 1, :ymin => 51, :ymax => 52, :baselong => 0, :basey => 0, :masterscale => 1, :token => other_user.tokens.create.token }
34 assert_response :success
35 assert_equal "application/x-shockwave-flash", response.content_type
36 assert_match(/^FWS/, response.body)
37 assert_equal 67, response.body.length
39 get :trackpoints, :params => { :xmin => -1, :xmax => 1, :ymin => 51, :ymax => 52, :baselong => 0, :basey => 0, :masterscale => 1, :token => user.tokens.create.token }
40 assert_response :success
41 assert_equal "application/x-shockwave-flash", response.content_type
42 assert_match(/^FWS/, response.body)
43 assert_equal 74, response.body.length