mutes_spec.rb 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. # frozen_string_literal: true
  2. require 'rails_helper'
  3. RSpec.describe 'API V1 Statuses Mutes' do
  4. let(:user) { Fabricate(:user) }
  5. let(:token) { Fabricate(:accessible_access_token, resource_owner_id: user.id, scopes: scopes) }
  6. let(:scopes) { 'write:mutes' }
  7. let(:headers) { { 'Authorization' => "Bearer #{token.token}" } }
  8. context 'with an oauth token' do
  9. describe 'POST /api/v1/statuses/:status_id/mute' do
  10. let(:status) { Fabricate(:status, account: user.account) }
  11. before do
  12. post "/api/v1/statuses/#{status.id}/mute", headers: headers
  13. end
  14. it 'creates a conversation mute', :aggregate_failures do
  15. expect(response).to have_http_status(200)
  16. expect(response.content_type)
  17. .to start_with('application/json')
  18. expect(ConversationMute.find_by(account: user.account, conversation_id: status.conversation_id)).to_not be_nil
  19. end
  20. end
  21. describe 'POST /api/v1/statuses/:status_id/unmute' do
  22. let(:status) { Fabricate(:status, account: user.account) }
  23. before do
  24. user.account.mute_conversation!(status.conversation)
  25. post "/api/v1/statuses/#{status.id}/unmute", headers: headers
  26. end
  27. it 'destroys the conversation mute', :aggregate_failures do
  28. expect(response).to have_http_status(200)
  29. expect(response.content_type)
  30. .to start_with('application/json')
  31. expect(ConversationMute.find_by(account: user.account, conversation_id: status.conversation_id)).to be_nil
  32. end
  33. end
  34. end
  35. end