logo

mastofe

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

domain_blocks_controller_spec.rb (1359B)


  1. require 'rails_helper'
  2. RSpec.describe Api::V1::DomainBlocksController, type: :controller 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: 'follow') }
  6. before do
  7. user.account.block_domain!('example.com')
  8. allow(controller).to receive(:doorkeeper_token) { token }
  9. end
  10. describe 'GET #show' do
  11. before do
  12. get :show, params: { limit: 1 }
  13. end
  14. it 'returns http success' do
  15. expect(response).to have_http_status(:success)
  16. end
  17. it 'returns blocked domains' do
  18. expect(body_as_json.first).to eq 'example.com'
  19. end
  20. end
  21. describe 'POST #create' do
  22. before do
  23. post :create, params: { domain: 'example.org' }
  24. end
  25. it 'returns http success' do
  26. expect(response).to have_http_status(:success)
  27. end
  28. it 'creates a domain block' do
  29. expect(user.account.domain_blocking?('example.org')).to be true
  30. end
  31. end
  32. describe 'DELETE #destroy' do
  33. before do
  34. delete :destroy, params: { domain: 'example.com' }
  35. end
  36. it 'returns http success' do
  37. expect(response).to have_http_status(:success)
  38. end
  39. it 'deletes a domain block' do
  40. expect(user.account.domain_blocking?('example.com')).to be false
  41. end
  42. end
  43. end