logo

mastofe

My custom branche(s) on git.pleroma.social/pleroma/mastofe git clone https://hacktivis.me/git/mastofe.git

accounts_controller_spec.rb (1443B)


  1. require 'rails_helper'
  2. describe Api::V1::Lists::AccountsController do
  3. render_views
  4. let(:user) { Fabricate(:user, account: Fabricate(:account, username: 'alice')) }
  5. let(:token) { Fabricate(:accessible_access_token, resource_owner_id: user.id, scopes: 'read write') }
  6. let(:list) { Fabricate(:list, account: user.account) }
  7. before do
  8. follow = Fabricate(:follow, account: user.account)
  9. list.accounts << follow.target_account
  10. allow(controller).to receive(:doorkeeper_token) { token }
  11. end
  12. describe 'GET #index' do
  13. it 'returns http success' do
  14. get :show, params: { list_id: list.id }
  15. expect(response).to have_http_status(:success)
  16. end
  17. end
  18. describe 'POST #create' do
  19. let(:bob) { Fabricate(:account, username: 'bob') }
  20. before do
  21. user.account.follow!(bob)
  22. post :create, params: { list_id: list.id, account_ids: [bob.id] }
  23. end
  24. it 'returns http success' do
  25. expect(response).to have_http_status(:success)
  26. end
  27. it 'adds account to the list' do
  28. expect(list.accounts.include?(bob)).to be true
  29. end
  30. end
  31. describe 'DELETE #destroy' do
  32. before do
  33. delete :destroy, params: { list_id: list.id, account_ids: [list.accounts.first.id] }
  34. end
  35. it 'returns http success' do
  36. expect(response).to have_http_status(:success)
  37. end
  38. it 'removes account from the list' do
  39. expect(list.accounts.count).to eq 0
  40. end
  41. end
  42. end