2016-11-30 16:32:26 +02:00
|
|
|
require 'rails_helper'
|
|
|
|
|
|
|
|
RSpec.describe Admin::AccountsController, type: :controller do
|
2017-04-28 16:12:37 +03:00
|
|
|
render_views
|
|
|
|
|
2017-06-29 02:43:10 +03:00
|
|
|
let(:user) { Fabricate(:user, admin: true) }
|
|
|
|
|
2016-11-30 16:32:26 +02:00
|
|
|
before do
|
2017-06-29 02:43:10 +03:00
|
|
|
sign_in user, scope: :user
|
2016-11-30 16:32:26 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
describe 'GET #index' do
|
2017-06-29 02:43:10 +03:00
|
|
|
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
|
|
|
|
|
2016-11-30 16:32:26 +02:00
|
|
|
it 'returns http success' do
|
|
|
|
get :index
|
2018-04-21 22:35:07 +03:00
|
|
|
expect(response).to have_http_status(200)
|
2016-11-30 16:32:26 +02:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
describe 'GET #show' do
|
2016-12-03 21:04:19 +02:00
|
|
|
let(:account) { Fabricate(:account, username: 'bob') }
|
|
|
|
|
2016-11-30 16:32:26 +02:00
|
|
|
it 'returns http success' do
|
2016-12-03 21:04:19 +02:00
|
|
|
get :show, params: { id: account.id }
|
2018-04-21 22:35:07 +03:00
|
|
|
expect(response).to have_http_status(200)
|
2016-11-30 16:32:26 +02:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|