From 7b92950f1c43ad009d169ce1792c9afed109b417 Mon Sep 17 00:00:00 2001 From: Akihiko Odaki Date: Tue, 30 May 2017 01:12:17 +0900 Subject: [PATCH] Cover InstancesController more (#3342) --- .../admin/instances_controller_spec.rb | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/spec/controllers/admin/instances_controller_spec.rb b/spec/controllers/admin/instances_controller_spec.rb index 37fa8dd9a..f57e3fa97 100644 --- a/spec/controllers/admin/instances_controller_spec.rb +++ b/spec/controllers/admin/instances_controller_spec.rb @@ -8,8 +8,23 @@ RSpec.describe Admin::InstancesController, type: :controller do end describe 'GET #index' do - it 'returns http success' do - get :index + around do |example| + default_per_page = Account.default_per_page + Account.paginates_per 1 + example.run + Account.paginates_per default_per_page + end + + it 'renders instances' do + Fabricate(:account, domain: 'popular') + Fabricate(:account, domain: 'popular') + Fabricate(:account, domain: 'less.popular') + + get :index, params: { page: 2 } + + instances = assigns(:instances).to_a + expect(instances.size).to eq 1 + expect(instances[0].domain).to eq 'less.popular' expect(response).to have_http_status(:success) end