diff --git a/app/controllers/admin/users_controller.rb b/app/controllers/admin/users_controller.rb index 1942709a8..1395d2172 100644 --- a/app/controllers/admin/users_controller.rb +++ b/app/controllers/admin/users_controller.rb @@ -1,14 +1,13 @@ module Admin class UsersController < Admin::ApplicationController - def index - super - @resources = User.peers.page(params[:page]).per(10) - end - def find_resource(param) User.peers.from_slug(param) end + def scoped_resource + User.peers + end + # See https://administrate-prototype.herokuapp.com/customizing_controller_actions # for more information end diff --git a/spec/controllers/admin/users_controller_spec.rb b/spec/controllers/admin/users_controller_spec.rb new file mode 100644 index 000000000..b7ebbb741 --- /dev/null +++ b/spec/controllers/admin/users_controller_spec.rb @@ -0,0 +1,35 @@ +require 'spec_helper' + +describe Admin::UsersController do + render_views + + before { set_subdomain } + + let(:user) { build(:admin_user) } + let!(:event) do + Whitelabel.with_label(Whitelabel.labels.first) do + create(:event_with_participants) + end + end + let!(:other_event) do + Whitelabel.with_label(Whitelabel.labels.last) do + create(:event_with_participants) + end + end + + context 'with logged-in user' do + before do + allow(controller).to receive_messages(current_user: user) + end + + context 'GET :index' do + it 'assign the users and renders the template' do + get :index + + expect(response).to render_template(:index) + expect(response.body).to include(event.participants.first.user.nickname) + expect(response.body).not_to include(other_event.participants.first.user.nickname) + end + end + end +end diff --git a/spec/controllers/super_admin/users_controller_spec.rb b/spec/controllers/super_admin/users_controller_spec.rb new file mode 100644 index 000000000..020a6d6a3 --- /dev/null +++ b/spec/controllers/super_admin/users_controller_spec.rb @@ -0,0 +1,35 @@ +require 'spec_helper' + +describe SuperAdmin::UsersController do + render_views + + before { set_subdomain } + + let(:user) { build(:admin_user) } + let!(:event) do + Whitelabel.with_label(Whitelabel.labels.first) do + create(:event_with_participants) + end + end + let!(:other_event) do + Whitelabel.with_label(Whitelabel.labels.last) do + create(:event_with_participants) + end + end + + context 'with logged-in user' do + before do + allow(controller).to receive_messages(current_user: user) + end + + context 'GET :index' do + it 'assign the users and renders the template' do + get :index + + expect(response).to render_template(:index) + expect(response.body).to include(event.participants.first.user.nickname) + expect(response.body).to include(other_event.participants.first.user.nickname) + end + end + end +end