闭社主体 forked from https://github.com/tootsuite/mastodon
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

78 lines
1.9 KiB

  1. require 'rails_helper'
  2. RSpec.describe Admin::AccountsController, type: :controller do
  3. render_views
  4. let(:user) { Fabricate(:user, admin: true) }
  5. before do
  6. sign_in user, scope: :user
  7. end
  8. describe 'GET #index' do
  9. around do |example|
  10. default_per_page = Account.default_per_page
  11. Account.paginates_per 1
  12. example.run
  13. Account.paginates_per default_per_page
  14. end
  15. it 'filters with parameters' do
  16. new = AccountFilter.method(:new)
  17. expect(AccountFilter).to receive(:new) do |params|
  18. h = params.to_h
  19. expect(h[:local]).to eq '1'
  20. expect(h[:remote]).to eq '1'
  21. expect(h[:by_domain]).to eq 'domain'
  22. expect(h[:silenced]).to eq '1'
  23. expect(h[:recent]).to eq '1'
  24. expect(h[:suspended]).to eq '1'
  25. expect(h[:username]).to eq 'username'
  26. expect(h[:display_name]).to eq 'display name'
  27. expect(h[:email]).to eq 'local-part@domain'
  28. expect(h[:ip]).to eq '0.0.0.42'
  29. new.call({})
  30. end
  31. get :index, params: {
  32. local: '1',
  33. remote: '1',
  34. by_domain: 'domain',
  35. silenced: '1',
  36. recent: '1',
  37. suspended: '1',
  38. username: 'username',
  39. display_name: 'display name',
  40. email: 'local-part@domain',
  41. ip: '0.0.0.42'
  42. }
  43. end
  44. it 'paginates accounts' do
  45. Fabricate(:account)
  46. get :index, params: { page: 2 }
  47. accounts = assigns(:accounts)
  48. expect(accounts.count).to eq 1
  49. expect(accounts.klass).to be Account
  50. end
  51. it 'returns http success' do
  52. get :index
  53. expect(response).to have_http_status(:success)
  54. end
  55. end
  56. describe 'GET #show' do
  57. let(:account) { Fabricate(:account, username: 'bob') }
  58. it 'returns http success' do
  59. get :show, params: { id: account.id }
  60. expect(response).to have_http_status(:success)
  61. end
  62. end
  63. end