Project

General

Profile

Feature #33592 » 0002-Add_assertions_to_users_api_integration_test.patch

vzvu 3k6k, 2020-06-25 23:57

View differences:

test/integration/api_test/users_test.rb
28 28
    assert_response :success
29 29
    assert_equal 'application/xml', response.media_type
30 30
    assert_select 'users' do
31
      assert_select 'user', User.active.count
31
      users = User.active.order('login')
32
      assert_select 'user', :count => users.size do |nodeset|
33
        nodeset.zip(users) do |user_element, user|
34
          assert_select user_element, 'id', :text => user.id.to_s
35
          assert_select user_element, 'updated_on', :text => user.updated_on.iso8601
36

  
37
          # No one has changed password.
38
          assert_select user_element, 'passwd_changed_on', :text => ''
39
        end
40
      end
32 41
    end
33 42
  end
34 43

  
......
39 48
    assert_equal 'application/json', response.media_type
40 49
    json = ActiveSupport::JSON.decode(response.body)
41 50
    assert json.key?('users')
42
    assert_equal User.active.count, json['users'].size
51

  
52
    users = User.active.order('login')
53
    assert_equal users.size, json['users'].size
54

  
55
    json['users'].zip(users) do |user_json, user|
56
      assert_equal user.id, user_json['id']
57
      assert_equal user.updated_on.iso8601, user_json['updated_on']
58

  
59
      # No one has changed password.
60
      assert_nil user_json['passwd_changed_on']
61
    end
43 62
  end
44 63

  
45 64
  test "GET /users/:id.xml should return the user" do
......
47 66

  
48 67
    assert_response :success
49 68
    assert_select 'user id', :text => '2'
69
    assert_select 'user updated_on', :text => '2006-07-19T20:42:15Z'
70
    assert_select 'user passwd_changed_on', :text => ''
50 71
  end
51 72

  
52 73
  test "GET /users/:id.json should return the user" do
......
57 78
    assert_kind_of Hash, json
58 79
    assert_kind_of Hash, json['user']
59 80
    assert_equal 2, json['user']['id']
81
    assert_equal '2006-07-19T20:42:15Z', json['user']['updated_on']
82
    assert_nil json['user']['passwd_changed_on']
60 83
  end
61 84

  
62 85
  test "GET /users/:id.xml with include=memberships should include memberships" do
(2-2/2)