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
424 get api_users_path, :params => { :users => create(:user, :deleted).id }
425 assert_response :success
427 get api_users_path, :params => { :users => 0 }
428 assert_response :success
429 assert_equal "application/xml", response.media_type
430 assert_select "user", :count => 0
433 def test_index_oauth1
434 user1 = create(:user, :description => "test1", :terms_agreed => Date.yesterday)
435 user2 = create(:user, :description => "test2", :terms_agreed => Date.yesterday)
436 user3 = create(:user, :description => "test3", :terms_agreed => Date.yesterday)
437 good_token = create(:access_token, :user => user1, :allow_read_prefs => true)
438 bad_token = create(:access_token, :user => user1)
440 signed_get api_users_path, :params => { :users => user1.id }, :oauth => { :token => good_token }
441 assert_response :success
442 assert_equal "application/xml", response.media_type
443 assert_select "user", :count => 1 do
444 check_xml_details(user1, true, false)
445 assert_select "user[id='#{user2.id}']", :count => 0
446 assert_select "user[id='#{user3.id}']", :count => 0
449 signed_get api_users_path, :params => { :users => user2.id }, :oauth => { :token => good_token }
450 assert_response :success
451 assert_equal "application/xml", response.media_type
452 assert_select "user", :count => 1 do
453 assert_select "user[id='#{user1.id}']", :count => 0
454 check_xml_details(user2, false, false)
455 assert_select "user[id='#{user3.id}']", :count => 0
458 signed_get api_users_path, :params => { :users => "#{user1.id},#{user3.id}" }, :oauth => { :token => good_token }
459 assert_response :success
460 assert_equal "application/xml", response.media_type
461 assert_select "user", :count => 2 do
462 check_xml_details(user1, true, false)
463 assert_select "user[id='#{user2.id}']", :count => 0
464 check_xml_details(user3, false, false)
467 signed_get api_users_path, :params => { :users => "#{user1.id},#{user3.id}" }, :oauth => { :token => bad_token }
468 assert_response :success
469 assert_equal "application/xml", response.media_type
470 assert_select "user", :count => 2 do
471 check_xml_details(user1, false, false)
472 assert_select "user[id='#{user2.id}']", :count => 0
473 check_xml_details(user3, false, false)
476 signed_get api_users_path, :params => { :users => user1.id, :format => "json" }, :oauth => { :token => good_token }
477 assert_response :success
478 assert_equal "application/json", response.media_type
479 js = ActiveSupport::JSON.decode(@response.body)
481 assert_equal 1, js["users"].count
482 check_json_details(js["users"][0], user1, true, false)
484 signed_get api_users_path, :params => { :users => user2.id, :format => "json" }, :oauth => { :token => good_token }
485 assert_response :success
486 assert_equal "application/json", response.media_type
487 js = ActiveSupport::JSON.decode(@response.body)
489 assert_equal 1, js["users"].count
490 check_json_details(js["users"][0], user2, false, false)
492 signed_get api_users_path, :params => { :users => "#{user1.id},#{user3.id}", :format => "json" }, :oauth => { :token => good_token }
493 assert_response :success
494 assert_equal "application/json", response.media_type
495 js = ActiveSupport::JSON.decode(@response.body)
497 assert_equal 2, js["users"].count
498 check_json_details(js["users"][0], user1, true, false)
499 check_json_details(js["users"][1], user3, false, false)
501 signed_get api_users_path, :params => { :users => "#{user1.id},#{user3.id}", :format => "json" }, :oauth => { :token => bad_token }
502 assert_response :success
503 assert_equal "application/json", response.media_type
504 js = ActiveSupport::JSON.decode(@response.body)
506 assert_equal 2, js["users"].count
507 check_json_details(js["users"][0], user1, false, false)
508 check_json_details(js["users"][1], user3, false, false)
510 signed_get api_users_path, :params => { :users => create(:user, :suspended).id }, :oauth => { :token => good_token }
511 assert_response :success
513 signed_get api_users_path, :params => { :users => create(:user, :deleted).id }, :oauth => { :token => good_token }
514 assert_response :success
516 signed_get api_users_path, :params => { :users => 0 }, :oauth => { :token => good_token }
517 assert_response :success
518 assert_equal "application/xml", response.media_type
519 assert_select "user", :count => 0
522 def test_index_oauth2
523 user1 = create(:user, :description => "test1", :terms_agreed => Date.yesterday)
524 user2 = create(:user, :description => "test2", :terms_agreed => Date.yesterday)
525 user3 = create(:user, :description => "test3", :terms_agreed => Date.yesterday)
526 good_token = create(:oauth_access_token, :resource_owner_id => user1.id, :scopes => %w[read_prefs])
527 bad_token = create(:oauth_access_token, :resource_owner_id => user1.id, :scopes => %w[])
529 get api_users_path, :params => { :users => user1.id }, :headers => bearer_authorization_header(good_token.token)
530 assert_response :success
531 assert_equal "application/xml", response.media_type
532 assert_select "user", :count => 1 do
533 check_xml_details(user1, true, false)
534 assert_select "user[id='#{user2.id}']", :count => 0
535 assert_select "user[id='#{user3.id}']", :count => 0
538 get api_users_path, :params => { :users => user2.id }, :headers => bearer_authorization_header(good_token.token)
539 assert_response :success
540 assert_equal "application/xml", response.media_type
541 assert_select "user", :count => 1 do
542 assert_select "user[id='#{user1.id}']", :count => 0
543 check_xml_details(user2, false, false)
544 assert_select "user[id='#{user3.id}']", :count => 0
547 get api_users_path, :params => { :users => "#{user1.id},#{user3.id}" }, :headers => bearer_authorization_header(good_token.token)
548 assert_response :success
549 assert_equal "application/xml", response.media_type
550 assert_select "user", :count => 2 do
551 check_xml_details(user1, true, false)
552 assert_select "user[id='#{user2.id}']", :count => 0
553 check_xml_details(user3, false, false)
556 get api_users_path, :params => { :users => "#{user1.id},#{user3.id}" }, :headers => bearer_authorization_header(bad_token.token)
557 assert_response :success
558 assert_equal "application/xml", response.media_type
559 assert_select "user", :count => 2 do
560 check_xml_details(user1, false, false)
561 assert_select "user[id='#{user2.id}']", :count => 0
562 check_xml_details(user3, false, false)
565 get api_users_path, :params => { :users => user1.id, :format => "json" }, :headers => bearer_authorization_header(good_token.token)
566 assert_response :success
567 assert_equal "application/json", response.media_type
568 js = ActiveSupport::JSON.decode(@response.body)
570 assert_equal 1, js["users"].count
571 check_json_details(js["users"][0], user1, true, false)
573 get api_users_path, :params => { :users => user2.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], user2, false, false)
581 get api_users_path, :params => { :users => "#{user1.id},#{user3.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 2, js["users"].count
587 check_json_details(js["users"][0], user1, true, false)
588 check_json_details(js["users"][1], user3, false, false)
590 get api_users_path, :params => { :users => "#{user1.id},#{user3.id}", :format => "json" }, :headers => bearer_authorization_header(bad_token.token)
591 assert_response :success
592 assert_equal "application/json", response.media_type
593 js = ActiveSupport::JSON.decode(@response.body)
595 assert_equal 2, js["users"].count
596 check_json_details(js["users"][0], user1, false, false)
597 check_json_details(js["users"][1], user3, false, false)
599 get api_users_path, :params => { :users => create(:user, :suspended).id }, :headers => bearer_authorization_header(good_token.token)
600 assert_response :success
602 get api_users_path, :params => { :users => create(:user, :deleted).id }, :headers => bearer_authorization_header(good_token.token)
603 assert_response :success
605 get api_users_path, :params => { :users => 0 }, :headers => bearer_authorization_header(good_token.token)
606 assert_response :success
607 assert_equal "application/xml", response.media_type
608 assert_select "user", :count => 0
613 trace1 = create(:trace, :user => user) do |trace|
614 create(:tracetag, :trace => trace, :tag => "London")
616 trace2 = create(:trace, :user => user) do |trace|
617 create(:tracetag, :trace => trace, :tag => "Birmingham")
619 # check that nothing is returned when not logged in
620 get user_gpx_files_path
621 assert_response :unauthorized
623 # check that we get a response when logged in
624 auth_header = basic_authorization_header user.email, "test"
625 get user_gpx_files_path, :headers => auth_header
626 assert_response :success
627 assert_equal "application/xml", response.media_type
629 # check the data that is returned
630 assert_select "gpx_file[id='#{trace1.id}']", 1 do
631 assert_select "tag", "London"
633 assert_select "gpx_file[id='#{trace2.id}']", 1 do
634 assert_select "tag", "Birmingham"
640 def check_xml_details(user, include_private, include_email)
641 assert_select "user[id='#{user.id}']", :count => 1 do
642 assert_select "description", :count => 1, :text => user.description
644 assert_select "contributor-terms", :count => 1 do
645 if user.terms_agreed.present?
646 assert_select "[agreed='true']", :count => 1
648 assert_select "[agreed='false']", :count => 1
652 assert_select "[pd='false']", :count => 1
654 assert_select "[pd]", :count => 0
658 assert_select "img", :count => 0
660 assert_select "roles", :count => 1 do
661 assert_select "role", :count => 0
664 assert_select "changesets", :count => 1 do
665 assert_select "[count='0']", :count => 1
668 assert_select "traces", :count => 1 do
669 assert_select "[count='0']", :count => 1
672 assert_select "blocks", :count => 1 do
673 assert_select "received", :count => 1 do
674 assert_select "[count='0'][active='0']", :count => 1
677 assert_select "issued", :count => 0
680 if include_private && user.home_lat.present? && user.home_lon.present?
681 assert_select "home", :count => 1 do
682 assert_select "[lat='12.1'][lon='23.4'][zoom='3']", :count => 1
685 assert_select "home", :count => 0
689 assert_select "languages", :count => 1 do
690 assert_select "lang", :count => user.languages.count
692 user.languages.each do |language|
693 assert_select "lang", :count => 1, :text => language
697 assert_select "messages", :count => 1 do
698 assert_select "received", :count => 1 do
699 assert_select "[count='#{user.messages.count}'][unread='0']", :count => 1
702 assert_select "sent", :count => 1 do
703 assert_select "[count='#{user.sent_messages.count}']", :count => 1
707 assert_select "languages", :count => 0
708 assert_select "messages", :count => 0
712 assert_select "email", :count => 1, :text => user.email
714 assert_select "email", :count => 0
719 def check_json_details(js, user, include_private, include_email)
720 assert_equal user.id, js["user"]["id"]
721 assert_equal user.description, js["user"]["description"]
722 assert js["user"]["contributor_terms"]["agreed"]
725 assert_not js["user"]["contributor_terms"]["pd"]
727 assert_nil js["user"]["contributor_terms"]["pd"]
730 assert_nil js["user"]["img"]
731 assert_empty js["user"]["roles"]
732 assert_equal 0, js["user"]["changesets"]["count"]
733 assert_equal 0, js["user"]["traces"]["count"]
734 assert_equal 0, js["user"]["blocks"]["received"]["count"]
735 assert_equal 0, js["user"]["blocks"]["received"]["active"]
736 assert_nil js["user"]["blocks"]["issued"]
738 if include_private && user.home_lat.present? && user.home_lon.present?
739 assert_in_delta 12.1, js["user"]["home"]["lat"]
740 assert_in_delta 23.4, js["user"]["home"]["lon"]
741 assert_equal 3, js["user"]["home"]["zoom"]
743 assert_nil js["user"]["home"]
746 if include_private && user.languages.present?
747 assert_equal user.languages, js["user"]["languages"]
749 assert_nil js["user"]["languages"]
753 assert_equal user.messages.count, js["user"]["messages"]["received"]["count"]
754 assert_equal 0, js["user"]["messages"]["received"]["unread"]
755 assert_equal user.sent_messages.count, js["user"]["messages"]["sent"]["count"]
757 assert_nil js["user"]["messages"]
761 assert_equal user.email, js["user"]["email"]
763 assert_nil js["user"]["email"]