4 class UsersControllerTest < ActionDispatch::IntegrationTest
6 # test all routes which lead to this controller
9 { :path => "/api/0.6/user/1", :method => :get },
10 { :controller => "api/users", :action => "show", :id => "1" }
13 { :path => "/api/0.6/user/1.json", :method => :get },
14 { :controller => "api/users", :action => "show", :id => "1", :format => "json" }
17 { :path => "/api/0.6/user/details", :method => :get },
18 { :controller => "api/users", :action => "details" }
21 { :path => "/api/0.6/user/details.json", :method => :get },
22 { :controller => "api/users", :action => "details", :format => "json" }
25 { :path => "/api/0.6/user/gpx_files", :method => :get },
26 { :controller => "api/users", :action => "gpx_files" }
29 { :path => "/api/0.6/users", :method => :get },
30 { :controller => "api/users", :action => "index" }
33 { :path => "/api/0.6/users.json", :method => :get },
34 { :controller => "api/users", :action => "index", :format => "json" }
40 :description => "test",
41 :terms_agreed => Date.yesterday,
42 :home_lat => 12.1, :home_lon => 23.4,
45 # check that a visible user is returned properly
46 get api_user_path(:id => user.id)
47 assert_response :success
48 assert_equal "application/xml", response.media_type
50 # check the data that is returned
51 check_xml_details(user, false, false)
53 # check that a suspended user is not returned
54 get api_user_path(:id => create(:user, :suspended).id)
57 # check that a deleted user is not returned
58 get api_user_path(:id => create(:user, :deleted).id)
61 # check that a non-existent user is not returned
62 get api_user_path(:id => 0)
63 assert_response :not_found
65 # check that a visible user is returned properly in json
66 get api_user_path(:id => user.id, :format => "json")
67 assert_response :success
68 assert_equal "application/json", response.media_type
71 js = ActiveSupport::JSON.decode(@response.body)
74 # check the data that is returned
75 check_json_details(js, user, false, false)
80 :home_lat => 12.1, :home_lon => 23.4,
82 good_token = create(:access_token,
84 :allow_read_prefs => true)
85 bad_token = create(:access_token,
87 other_user = create(:user,
88 :home_lat => 12.1, :home_lon => 23.4,
91 # check that we can fetch our own details as XML with read_prefs
92 signed_get api_user_path(:id => user.id), :oauth => { :token => good_token }
93 assert_response :success
94 assert_equal "application/xml", response.media_type
96 # check the data that is returned
97 check_xml_details(user, true, false)
99 # check that we can fetch a different user's details as XML with read_prefs
100 signed_get api_user_path(:id => other_user.id), :oauth => { :token => good_token }
101 assert_response :success
102 assert_equal "application/xml", response.media_type
104 # check the data that is returned
105 check_xml_details(other_user, false, false)
107 # check that we can fetch our own details as XML without read_prefs
108 signed_get api_user_path(:id => user.id), :oauth => { :token => bad_token }
109 assert_response :success
110 assert_equal "application/xml", response.media_type
112 # check the data that is returned
113 check_xml_details(user, false, false)
115 # check that we can fetch our own details as JSON with read_prefs
116 signed_get api_user_path(:id => user.id, :format => "json"), :oauth => { :token => good_token }
117 assert_response :success
118 assert_equal "application/json", response.media_type
121 js = ActiveSupport::JSON.decode(@response.body)
124 # check the data that is returned
125 check_json_details(js, user, true, false)
127 # check that we can fetch a different user's details as JSON with read_prefs
128 signed_get api_user_path(:id => other_user.id, :format => "json"), :oauth => { :token => good_token }
129 assert_response :success
130 assert_equal "application/json", response.media_type
133 js = ActiveSupport::JSON.decode(@response.body)
136 # check the data that is returned
137 check_json_details(js, other_user, false, false)
139 # check that we can fetch our own details as JSON without read_prefs
140 signed_get api_user_path(:id => other_user.id, :format => "json"), :oauth => { :token => bad_token }
141 assert_response :success
142 assert_equal "application/json", response.media_type
145 js = ActiveSupport::JSON.decode(@response.body)
148 # check the data that is returned
149 check_json_details(js, other_user, false, false)
154 :home_lat => 12.1, :home_lon => 23.4,
155 :languages => ["en"])
156 good_token = create(:oauth_access_token,
157 :resource_owner_id => user.id,
158 :scopes => %w[read_prefs])
159 bad_token = create(:oauth_access_token,
160 :resource_owner_id => user.id,
162 other_user = create(:user,
163 :home_lat => 12.1, :home_lon => 23.4,
164 :languages => ["en"])
166 # check that we can fetch our own details as XML with read_prefs
167 get api_user_path(:id => user.id), :headers => bearer_authorization_header(good_token.token)
168 assert_response :success
169 assert_equal "application/xml", response.media_type
171 # check the data that is returned
172 check_xml_details(user, true, false)
174 # check that we can fetch a different user's details as XML with read_prefs
175 get api_user_path(:id => other_user.id), :headers => bearer_authorization_header(good_token.token)
176 assert_response :success
177 assert_equal "application/xml", response.media_type
179 # check the data that is returned
180 check_xml_details(other_user, false, false)
182 # check that we can fetch our own details as XML without read_prefs
183 get api_user_path(:id => user.id), :headers => bearer_authorization_header(bad_token.token)
184 assert_response :success
185 assert_equal "application/xml", response.media_type
187 # check the data that is returned
188 check_xml_details(user, false, false)
190 # check that we can fetch our own details as JSON with read_prefs
191 get api_user_path(:id => user.id, :format => "json"), :headers => bearer_authorization_header(good_token.token)
192 assert_response :success
193 assert_equal "application/json", response.media_type
196 js = ActiveSupport::JSON.decode(@response.body)
199 # check the data that is returned
200 check_json_details(js, user, true, false)
202 # check that we can fetch a different user's details as JSON with read_prefs
203 get api_user_path(:id => other_user.id, :format => "json"), :headers => bearer_authorization_header(good_token.token)
204 assert_response :success
205 assert_equal "application/json", response.media_type
208 js = ActiveSupport::JSON.decode(@response.body)
211 # check the data that is returned
212 check_json_details(js, other_user, false, false)
214 # check that we can fetch our own details as JSON without read_prefs
215 get api_user_path(:id => user.id, :format => "json"), :headers => bearer_authorization_header(bad_token.token)
216 assert_response :success
217 assert_equal "application/json", response.media_type
220 js = ActiveSupport::JSON.decode(@response.body)
223 # check the data that is returned
224 check_json_details(js, user, false, false)
229 :description => "test",
230 :terms_agreed => Date.yesterday,
231 :home_lat => 12.1, :home_lon => 23.4,
232 :languages => ["en"])
233 create(:message, :read, :recipient => user)
234 create(:message, :sender => user)
236 # check that nothing is returned when not logged in
237 get user_details_path
238 assert_response :unauthorized
240 # check that we get a response when logged in
241 auth_header = basic_authorization_header user.email, "test"
242 get user_details_path, :headers => auth_header
243 assert_response :success
244 assert_equal "application/xml", response.media_type
246 # check the data that is returned
247 check_xml_details(user, true, false)
249 # check that data is returned properly in json
250 auth_header = basic_authorization_header user.email, "test"
251 get user_details_path(:format => "json"), :headers => auth_header
252 assert_response :success
253 assert_equal "application/json", response.media_type
256 js = ActiveSupport::JSON.decode(@response.body)
259 # check the data that is returned
260 check_json_details(js, user, true, false)
263 def test_details_oauth1
265 :home_lat => 12.1, :home_lon => 23.4,
266 :languages => ["en"])
267 good_token = create(:access_token,
269 :allow_read_prefs => true)
270 bad_token = create(:access_token,
273 # check that we can't fetch details as XML without read_prefs
274 signed_get user_details_path, :oauth => { :token => bad_token }
275 assert_response :forbidden
277 # check that we can fetch details as XML
278 signed_get user_details_path, :oauth => { :token => good_token }
279 assert_response :success
280 assert_equal "application/xml", response.media_type
282 # check the data that is returned
283 check_xml_details(user, true, false)
285 # check that we can't fetch details as JSON without read_prefs
286 signed_get user_details_path(:format => "json"), :oauth => { :token => bad_token }
287 assert_response :forbidden
289 # check that we can fetch details as JSON
290 signed_get user_details_path(:format => "json"), :oauth => { :token => good_token }
291 assert_response :success
292 assert_equal "application/json", response.media_type
295 js = ActiveSupport::JSON.decode(@response.body)
298 # check the data that is returned
299 check_json_details(js, user, true, false)
302 def test_details_oauth2
304 :home_lat => 12.1, :home_lon => 23.4,
305 :languages => ["en"])
306 good_token = create(:oauth_access_token,
307 :resource_owner_id => user.id,
308 :scopes => %w[read_prefs])
309 bad_token = create(:oauth_access_token,
310 :resource_owner_id => user.id)
311 email_token = create(:oauth_access_token,
312 :resource_owner_id => user.id,
313 :scopes => %w[read_prefs read_email])
315 # check that we can't fetch details as XML without read_prefs
316 get user_details_path, :headers => bearer_authorization_header(bad_token.token)
317 assert_response :forbidden
319 # check that we can fetch details as XML without read_email
320 get user_details_path, :headers => bearer_authorization_header(good_token.token)
321 assert_response :success
322 assert_equal "application/xml", response.media_type
324 # check the data that is returned
325 check_xml_details(user, true, false)
327 # check that we can fetch details as XML with read_email
328 get user_details_path, :headers => bearer_authorization_header(email_token.token)
329 assert_response :success
330 assert_equal "application/xml", response.media_type
332 # check the data that is returned
333 check_xml_details(user, true, true)
335 # check that we can't fetch details as JSON without read_prefs
336 get user_details_path(:format => "json"), :headers => bearer_authorization_header(bad_token.token)
337 assert_response :forbidden
339 # check that we can fetch details as JSON without read_email
340 get user_details_path(:format => "json"), :headers => bearer_authorization_header(good_token.token)
341 assert_response :success
342 assert_equal "application/json", response.media_type
345 js = ActiveSupport::JSON.decode(@response.body)
348 # check the data that is returned
349 check_json_details(js, user, true, false)
351 # check that we can fetch details as JSON with read_email
352 get user_details_path(:format => "json"), :headers => bearer_authorization_header(email_token.token)
353 assert_response :success
354 assert_equal "application/json", response.media_type
357 js = ActiveSupport::JSON.decode(@response.body)
360 # check the data that is returned
361 check_json_details(js, user, true, true)
365 user1 = create(:user, :description => "test1", :terms_agreed => Date.yesterday)
366 user2 = create(:user, :description => "test2", :terms_agreed => Date.yesterday)
367 user3 = create(:user, :description => "test3", :terms_agreed => Date.yesterday)
369 get api_users_path, :params => { :users => user1.id }
370 assert_response :success
371 assert_equal "application/xml", response.media_type
372 assert_select "user", :count => 1 do
373 check_xml_details(user1, false, false)
374 assert_select "user[id='#{user2.id}']", :count => 0
375 assert_select "user[id='#{user3.id}']", :count => 0
378 get api_users_path, :params => { :users => user2.id }
379 assert_response :success
380 assert_equal "application/xml", response.media_type
381 assert_select "user", :count => 1 do
382 assert_select "user[id='#{user1.id}']", :count => 0
383 check_xml_details(user2, false, false)
384 assert_select "user[id='#{user3.id}']", :count => 0
387 get api_users_path, :params => { :users => "#{user1.id},#{user3.id}" }
388 assert_response :success
389 assert_equal "application/xml", response.media_type
390 assert_select "user", :count => 2 do
391 check_xml_details(user1, false, false)
392 assert_select "user[id='#{user2.id}']", :count => 0
393 check_xml_details(user3, false, false)
396 get api_users_path, :params => { :users => user1.id, :format => "json" }
397 assert_response :success
398 assert_equal "application/json", response.media_type
399 js = ActiveSupport::JSON.decode(@response.body)
401 assert_equal 1, js["users"].count
402 check_json_details(js["users"][0], user1, false, false)
404 get api_users_path, :params => { :users => user2.id, :format => "json" }
405 assert_response :success
406 assert_equal "application/json", response.media_type
407 js = ActiveSupport::JSON.decode(@response.body)
409 assert_equal 1, js["users"].count
410 check_json_details(js["users"][0], user2, false, false)
412 get api_users_path, :params => { :users => "#{user1.id},#{user3.id}", :format => "json" }
413 assert_response :success
414 assert_equal "application/json", response.media_type
415 js = ActiveSupport::JSON.decode(@response.body)
417 assert_equal 2, js["users"].count
418 check_json_details(js["users"][0], user1, false, false)
419 check_json_details(js["users"][1], user3, false, false)
421 get api_users_path, :params => { :users => create(:user, :suspended).id }
422 assert_response :success
423 assert_equal "application/xml", response.media_type
424 assert_select "user", :count => 0
426 get api_users_path, :params => { :users => create(:user, :deleted).id }
427 assert_response :success
428 assert_equal "application/xml", response.media_type
429 assert_select "user", :count => 0
431 get api_users_path, :params => { :users => 0 }
432 assert_response :success
433 assert_equal "application/xml", response.media_type
434 assert_select "user", :count => 0
437 def test_index_oauth1
438 user1 = create(:user, :description => "test1", :terms_agreed => Date.yesterday)
439 user2 = create(:user, :description => "test2", :terms_agreed => Date.yesterday)
440 user3 = create(:user, :description => "test3", :terms_agreed => Date.yesterday)
441 good_token = create(:access_token, :user => user1, :allow_read_prefs => true)
442 bad_token = create(:access_token, :user => user1)
444 signed_get api_users_path, :params => { :users => user1.id }, :oauth => { :token => good_token }
445 assert_response :success
446 assert_equal "application/xml", response.media_type
447 assert_select "user", :count => 1 do
448 check_xml_details(user1, true, false)
449 assert_select "user[id='#{user2.id}']", :count => 0
450 assert_select "user[id='#{user3.id}']", :count => 0
453 signed_get api_users_path, :params => { :users => user2.id }, :oauth => { :token => good_token }
454 assert_response :success
455 assert_equal "application/xml", response.media_type
456 assert_select "user", :count => 1 do
457 assert_select "user[id='#{user1.id}']", :count => 0
458 check_xml_details(user2, false, false)
459 assert_select "user[id='#{user3.id}']", :count => 0
462 signed_get api_users_path, :params => { :users => "#{user1.id},#{user3.id}" }, :oauth => { :token => good_token }
463 assert_response :success
464 assert_equal "application/xml", response.media_type
465 assert_select "user", :count => 2 do
466 check_xml_details(user1, true, false)
467 assert_select "user[id='#{user2.id}']", :count => 0
468 check_xml_details(user3, false, false)
471 signed_get api_users_path, :params => { :users => "#{user1.id},#{user3.id}" }, :oauth => { :token => bad_token }
472 assert_response :success
473 assert_equal "application/xml", response.media_type
474 assert_select "user", :count => 2 do
475 check_xml_details(user1, false, false)
476 assert_select "user[id='#{user2.id}']", :count => 0
477 check_xml_details(user3, false, false)
480 signed_get api_users_path, :params => { :users => user1.id, :format => "json" }, :oauth => { :token => good_token }
481 assert_response :success
482 assert_equal "application/json", response.media_type
483 js = ActiveSupport::JSON.decode(@response.body)
485 assert_equal 1, js["users"].count
486 check_json_details(js["users"][0], user1, true, false)
488 signed_get api_users_path, :params => { :users => user2.id, :format => "json" }, :oauth => { :token => good_token }
489 assert_response :success
490 assert_equal "application/json", response.media_type
491 js = ActiveSupport::JSON.decode(@response.body)
493 assert_equal 1, js["users"].count
494 check_json_details(js["users"][0], user2, false, false)
496 signed_get api_users_path, :params => { :users => "#{user1.id},#{user3.id}", :format => "json" }, :oauth => { :token => good_token }
497 assert_response :success
498 assert_equal "application/json", response.media_type
499 js = ActiveSupport::JSON.decode(@response.body)
501 assert_equal 2, js["users"].count
502 check_json_details(js["users"][0], user1, true, false)
503 check_json_details(js["users"][1], user3, false, false)
505 signed_get api_users_path, :params => { :users => "#{user1.id},#{user3.id}", :format => "json" }, :oauth => { :token => bad_token }
506 assert_response :success
507 assert_equal "application/json", response.media_type
508 js = ActiveSupport::JSON.decode(@response.body)
510 assert_equal 2, js["users"].count
511 check_json_details(js["users"][0], user1, false, false)
512 check_json_details(js["users"][1], user3, false, false)
514 signed_get api_users_path, :params => { :users => create(:user, :suspended).id }, :oauth => { :token => good_token }
515 assert_response :success
516 assert_equal "application/xml", response.media_type
517 assert_select "user", :count => 0
519 signed_get api_users_path, :params => { :users => create(:user, :deleted).id }, :oauth => { :token => good_token }
520 assert_response :success
521 assert_equal "application/xml", response.media_type
522 assert_select "user", :count => 0
524 signed_get api_users_path, :params => { :users => 0 }, :oauth => { :token => good_token }
525 assert_response :success
526 assert_equal "application/xml", response.media_type
527 assert_select "user", :count => 0
530 def test_index_oauth2
531 user1 = create(:user, :description => "test1", :terms_agreed => Date.yesterday)
532 user2 = create(:user, :description => "test2", :terms_agreed => Date.yesterday)
533 user3 = create(:user, :description => "test3", :terms_agreed => Date.yesterday)
534 good_token = create(:oauth_access_token, :resource_owner_id => user1.id, :scopes => %w[read_prefs])
535 bad_token = create(:oauth_access_token, :resource_owner_id => user1.id, :scopes => %w[])
537 get api_users_path, :params => { :users => user1.id }, :headers => bearer_authorization_header(good_token.token)
538 assert_response :success
539 assert_equal "application/xml", response.media_type
540 assert_select "user", :count => 1 do
541 check_xml_details(user1, true, false)
542 assert_select "user[id='#{user2.id}']", :count => 0
543 assert_select "user[id='#{user3.id}']", :count => 0
546 get api_users_path, :params => { :users => user2.id }, :headers => bearer_authorization_header(good_token.token)
547 assert_response :success
548 assert_equal "application/xml", response.media_type
549 assert_select "user", :count => 1 do
550 assert_select "user[id='#{user1.id}']", :count => 0
551 check_xml_details(user2, false, false)
552 assert_select "user[id='#{user3.id}']", :count => 0
555 get api_users_path, :params => { :users => "#{user1.id},#{user3.id}" }, :headers => bearer_authorization_header(good_token.token)
556 assert_response :success
557 assert_equal "application/xml", response.media_type
558 assert_select "user", :count => 2 do
559 check_xml_details(user1, true, false)
560 assert_select "user[id='#{user2.id}']", :count => 0
561 check_xml_details(user3, false, false)
564 get api_users_path, :params => { :users => "#{user1.id},#{user3.id}" }, :headers => bearer_authorization_header(bad_token.token)
565 assert_response :success
566 assert_equal "application/xml", response.media_type
567 assert_select "user", :count => 2 do
568 check_xml_details(user1, false, false)
569 assert_select "user[id='#{user2.id}']", :count => 0
570 check_xml_details(user3, false, false)
573 get api_users_path, :params => { :users => user1.id, :format => "json" }, :headers => bearer_authorization_header(good_token.token)
574 assert_response :success
575 assert_equal "application/json", response.media_type
576 js = ActiveSupport::JSON.decode(@response.body)
578 assert_equal 1, js["users"].count
579 check_json_details(js["users"][0], user1, true, false)
581 get api_users_path, :params => { :users => user2.id, :format => "json" }, :headers => bearer_authorization_header(good_token.token)
582 assert_response :success
583 assert_equal "application/json", response.media_type
584 js = ActiveSupport::JSON.decode(@response.body)
586 assert_equal 1, js["users"].count
587 check_json_details(js["users"][0], user2, false, false)
589 get api_users_path, :params => { :users => "#{user1.id},#{user3.id}", :format => "json" }, :headers => bearer_authorization_header(good_token.token)
590 assert_response :success
591 assert_equal "application/json", response.media_type
592 js = ActiveSupport::JSON.decode(@response.body)
594 assert_equal 2, js["users"].count
595 check_json_details(js["users"][0], user1, true, false)
596 check_json_details(js["users"][1], user3, false, false)
598 get api_users_path, :params => { :users => "#{user1.id},#{user3.id}", :format => "json" }, :headers => bearer_authorization_header(bad_token.token)
599 assert_response :success
600 assert_equal "application/json", response.media_type
601 js = ActiveSupport::JSON.decode(@response.body)
603 assert_equal 2, js["users"].count
604 check_json_details(js["users"][0], user1, false, false)
605 check_json_details(js["users"][1], user3, false, false)
607 get api_users_path, :params => { :users => create(:user, :suspended).id }, :headers => bearer_authorization_header(good_token.token)
608 assert_response :success
609 assert_equal "application/xml", response.media_type
610 assert_select "user", :count => 0
612 get api_users_path, :params => { :users => create(:user, :deleted).id }, :headers => bearer_authorization_header(good_token.token)
613 assert_response :success
614 assert_equal "application/xml", response.media_type
615 assert_select "user", :count => 0
617 get api_users_path, :params => { :users => 0 }, :headers => bearer_authorization_header(good_token.token)
618 assert_response :success
619 assert_equal "application/xml", response.media_type
620 assert_select "user", :count => 0
625 trace1 = create(:trace, :user => user) do |trace|
626 create(:tracetag, :trace => trace, :tag => "London")
628 trace2 = create(:trace, :user => user) do |trace|
629 create(:tracetag, :trace => trace, :tag => "Birmingham")
631 # check that nothing is returned when not logged in
632 get user_gpx_files_path
633 assert_response :unauthorized
635 # check that we get a response when logged in
636 auth_header = basic_authorization_header user.email, "test"
637 get user_gpx_files_path, :headers => auth_header
638 assert_response :success
639 assert_equal "application/xml", response.media_type
641 # check the data that is returned
642 assert_select "gpx_file[id='#{trace1.id}']", 1 do
643 assert_select "tag", "London"
645 assert_select "gpx_file[id='#{trace2.id}']", 1 do
646 assert_select "tag", "Birmingham"
652 def check_xml_details(user, include_private, include_email)
653 assert_select "user[id='#{user.id}']", :count => 1 do
654 assert_select "description", :count => 1, :text => user.description
656 assert_select "contributor-terms", :count => 1 do
657 if user.terms_agreed.present?
658 assert_select "[agreed='true']", :count => 1
660 assert_select "[agreed='false']", :count => 1
664 assert_select "[pd='false']", :count => 1
666 assert_select "[pd]", :count => 0
670 assert_select "img", :count => 0
672 assert_select "roles", :count => 1 do
673 assert_select "role", :count => 0
676 assert_select "changesets", :count => 1 do
677 assert_select "[count='0']", :count => 1
680 assert_select "traces", :count => 1 do
681 assert_select "[count='0']", :count => 1
684 assert_select "blocks", :count => 1 do
685 assert_select "received", :count => 1 do
686 assert_select "[count='0'][active='0']", :count => 1
689 assert_select "issued", :count => 0
692 if include_private && user.home_lat.present? && user.home_lon.present?
693 assert_select "home", :count => 1 do
694 assert_select "[lat='12.1'][lon='23.4'][zoom='3']", :count => 1
697 assert_select "home", :count => 0
701 assert_select "languages", :count => 1 do
702 assert_select "lang", :count => user.languages.count
704 user.languages.each do |language|
705 assert_select "lang", :count => 1, :text => language
709 assert_select "messages", :count => 1 do
710 assert_select "received", :count => 1 do
711 assert_select "[count='#{user.messages.count}'][unread='0']", :count => 1
714 assert_select "sent", :count => 1 do
715 assert_select "[count='#{user.sent_messages.count}']", :count => 1
719 assert_select "languages", :count => 0
720 assert_select "messages", :count => 0
724 assert_select "email", :count => 1, :text => user.email
726 assert_select "email", :count => 0
731 def check_json_details(js, user, include_private, include_email)
732 assert_equal user.id, js["user"]["id"]
733 assert_equal user.description, js["user"]["description"]
734 assert_operator js["user"]["contributor_terms"], :[], "agreed"
737 assert_not js["user"]["contributor_terms"]["pd"]
739 assert_nil js["user"]["contributor_terms"]["pd"]
742 assert_nil js["user"]["img"]
743 assert_empty js["user"]["roles"]
744 assert_equal 0, js["user"]["changesets"]["count"]
745 assert_equal 0, js["user"]["traces"]["count"]
746 assert_equal 0, js["user"]["blocks"]["received"]["count"]
747 assert_equal 0, js["user"]["blocks"]["received"]["active"]
748 assert_nil js["user"]["blocks"]["issued"]
750 if include_private && user.home_lat.present? && user.home_lon.present?
751 assert_in_delta 12.1, js["user"]["home"]["lat"]
752 assert_in_delta 23.4, js["user"]["home"]["lon"]
753 assert_equal 3, js["user"]["home"]["zoom"]
755 assert_nil js["user"]["home"]
758 if include_private && user.languages.present?
759 assert_equal user.languages, js["user"]["languages"]
761 assert_nil js["user"]["languages"]
765 assert_equal user.messages.count, js["user"]["messages"]["received"]["count"]
766 assert_equal 0, js["user"]["messages"]["received"]["unread"]
767 assert_equal user.sent_messages.count, js["user"]["messages"]["sent"]["count"]
769 assert_nil js["user"]["messages"]
773 assert_equal user.email, js["user"]["email"]
775 assert_nil js["user"]["email"]