diff options
author | Akihiko Odaki (@fn_aki@pawoo.net) <akihiko.odaki.4i@stu.hosei.ac.jp> | 2017-06-29 08:43:10 +0900 |
---|---|---|
committer | Eugen Rochko <eugen@zeonfederated.com> | 2017-06-29 01:43:10 +0200 |
commit | 0a53ca444a4bd4b28eddf2064133c38a65d41f2c (patch) | |
tree | a2838b1b87f969430981783784d1d08f888f5eec /spec/controllers | |
parent | f79c10162e51689f6759dfa39251c8ba8e7e11e8 (diff) |
Cover Admin::AccountsController more (#3327)
Diffstat (limited to 'spec/controllers')
-rw-r--r-- | spec/controllers/admin/accounts_controller_spec.rb | 55 |
1 files changed, 54 insertions, 1 deletions
diff --git a/spec/controllers/admin/accounts_controller_spec.rb b/spec/controllers/admin/accounts_controller_spec.rb index 305260475..8be27d866 100644 --- a/spec/controllers/admin/accounts_controller_spec.rb +++ b/spec/controllers/admin/accounts_controller_spec.rb @@ -3,11 +3,64 @@ require 'rails_helper' RSpec.describe Admin::AccountsController, type: :controller do render_views + let(:user) { Fabricate(:user, admin: true) } + before do - sign_in Fabricate(:user, admin: true), scope: :user + sign_in user, scope: :user end describe 'GET #index' do + around do |example| + default_per_page = Account.default_per_page + Account.paginates_per 1 + example.run + Account.paginates_per default_per_page + end + + it 'filters with parameters' do + new = AccountFilter.method(:new) + + expect(AccountFilter).to receive(:new) do |params| + h = params.to_h + + expect(h[:local]).to eq '1' + expect(h[:remote]).to eq '1' + expect(h[:by_domain]).to eq 'domain' + expect(h[:silenced]).to eq '1' + expect(h[:recent]).to eq '1' + expect(h[:suspended]).to eq '1' + expect(h[:username]).to eq 'username' + expect(h[:display_name]).to eq 'display name' + expect(h[:email]).to eq 'local-part@domain' + expect(h[:ip]).to eq '0.0.0.42' + + new.call({}) + end + + get :index, params: { + local: '1', + remote: '1', + by_domain: 'domain', + silenced: '1', + recent: '1', + suspended: '1', + username: 'username', + display_name: 'display name', + email: 'local-part@domain', + ip: '0.0.0.42' + } + end + + it 'paginates accounts' do + Fabricate(:account) + + get :index, params: { page: 2 } + + accounts = assigns(:accounts) + expect(accounts.count).to eq 1 + expect(accounts.klass).to be Account + end + it 'returns http success' do get :index expect(response).to have_http_status(:success) |