diff options
author | Stan Hu <stanhu@gmail.com> | 2019-02-16 14:26:15 -0800 |
---|---|---|
committer | Stan Hu <stanhu@gmail.com> | 2019-02-19 15:36:05 -0800 |
commit | e87c255d9e76fb3ca691267107e83d48c90bc816 (patch) | |
tree | 9ff03ae5830a34f1269a82f482f967adb213d82a /spec/controllers/admin | |
parent | ab9f8785ebf5483e5d2cd02497b57fa05a47561e (diff) | |
download | gitlab-ce-e87c255d9e76fb3ca691267107e83d48c90bc816.tar.gz |
Make Admin::UsersController work with Ruby 2.6
Ruby 2.6 introduced `Enumerable#filter`, which takes no arguments.
Attempting to call `filter` on an `ActiveRecord::Relation` with a scope
will fail with a `wrong number of arguments (given 1, expected 0)`
message because the `Enumerable#filter` implementation overrides the
delegated `ActiveRecord::Relation#filter` method.
To make Admin::UsersController compatible with Ruby 2.6, rename
`User.filter` to `User.filter_items`.
Diffstat (limited to 'spec/controllers/admin')
-rw-r--r-- | spec/controllers/admin/users_controller_spec.rb | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/spec/controllers/admin/users_controller_spec.rb b/spec/controllers/admin/users_controller_spec.rb index c934db9e237..cb24a6ef142 100644 --- a/spec/controllers/admin/users_controller_spec.rb +++ b/spec/controllers/admin/users_controller_spec.rb @@ -8,6 +8,20 @@ describe Admin::UsersController do sign_in(admin) end + describe 'GET #index' do + it 'retrieves all users' do + get :index + + expect(assigns(:users)).to match_array([user, admin]) + end + + it 'filters by admins' do + get :index, params: { filter: 'admins' } + + expect(assigns(:users)).to eq([admin]) + end + end + describe 'GET :id' do it 'finds a user case-insensitively' do user = create(:user, username: 'CaseSensitive') |