|
28 | 28 | end |
29 | 29 |
|
30 | 30 | describe '#verified_users' do |
31 | | - it 'returns the list of active users' do |
32 | | - users = create_list(:user, 3, status: 'active') + [user, user_with_manage_users_permission] |
| 31 | + it 'returns the list of verified users' do |
| 32 | + users = create_list(:user, 3, verified: true) + [user, user_with_manage_users_permission] |
33 | 33 | get :verified |
34 | 34 | expect(response).to have_http_status(:ok) |
35 | 35 | response_user_ids = response.parsed_body['data'].pluck('id') |
|
47 | 47 | end |
48 | 48 | end |
49 | 49 |
|
| 50 | + describe '#unverified_users' do |
| 51 | + it 'returns the list of unverified users' do |
| 52 | + users = create_list(:user, 3, verified: false) |
| 53 | + get :unverified |
| 54 | + expect(response).to have_http_status(:ok) |
| 55 | + response_user_ids = response.parsed_body['data'].pluck('id') |
| 56 | + expect(response_user_ids).to match_array(users.pluck(:id)) |
| 57 | + end |
| 58 | + |
| 59 | + it 'excludes users with a different provider' do |
| 60 | + greenlight_users = create_list(:user, 3, provider: 'greenlight', verified: false) |
| 61 | + role_with_provider_test = create(:role, provider: 'test') |
| 62 | + create(:user, provider: 'test', role: role_with_provider_test, verified: false) |
| 63 | + get :unverified |
| 64 | + expect(response.parsed_body['data'].pluck('id')).to match_array(greenlight_users.pluck(:id)) |
| 65 | + end |
| 66 | + end |
| 67 | + |
50 | 68 | describe '#pending' do |
51 | 69 | it 'returns a list of pending users' do |
52 | 70 | users = create_list(:user, 3, status: 'pending') |
|
97 | 115 | sign_in_user(super_admin) |
98 | 116 | end |
99 | 117 |
|
100 | | - it 'returns the list of active users' do |
101 | | - users = create_list(:user, 3, status: 'active') + [user, user_with_manage_users_permission] |
| 118 | + it 'returns the list of verified users' do |
| 119 | + users = create_list(:user, 3, verified: true) + [user, user_with_manage_users_permission] |
102 | 120 | get :verified |
103 | 121 | expect(response).to have_http_status(:ok) |
104 | 122 | response_user_ids = response.parsed_body['data'].pluck('id') |
105 | 123 | expect(response_user_ids).to match_array(users.pluck(:id)) |
106 | 124 | end |
107 | 125 |
|
| 126 | + it 'returns the list of unverified users' do |
| 127 | + users = create_list(:user, 3, verified: false) |
| 128 | + get :unverified |
| 129 | + expect(response).to have_http_status(:ok) |
| 130 | + response_user_ids = response.parsed_body['data'].pluck('id') |
| 131 | + expect(response_user_ids).to match_array(users.pluck(:id)) |
| 132 | + end |
| 133 | + |
108 | 134 | it 'returns the list of pending users' do |
109 | 135 | users = create_list(:user, 3, status: 'pending') |
110 | 136 | get :pending |
|
130 | 156 | expect(user.reload.status).to eq('banned') |
131 | 157 | end |
132 | 158 |
|
| 159 | + it 'verifies an unverified user' do |
| 160 | + unverified_user = create(:user, verified: false) |
| 161 | + post :update, params: { id: unverified_user.id, user: { verified: true } } |
| 162 | + unverified_user.reload |
| 163 | + expect(response).to have_http_status(:ok) |
| 164 | + expect(unverified_user.verified).to be(true) |
| 165 | + end |
| 166 | + |
133 | 167 | context 'user without ManageUsers permission' do |
134 | 168 | before do |
135 | 169 | sign_in_user(user) |
|
0 commit comments