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.

50 lines
1.5 KiB

  1. # frozen_string_literal: true
  2. require 'rails_helper'
  3. describe Api::V1::Statuses::MutesController do
  4. render_views
  5. let(:user) { Fabricate(:user, account: Fabricate(:account, username: 'alice')) }
  6. let(:app) { Fabricate(:application, name: 'Test app', website: 'http://testapp.com') }
  7. let(:token) { double acceptable?: true, resource_owner_id: user.id, application: app }
  8. context 'with an oauth token' do
  9. before do
  10. allow(controller).to receive(:doorkeeper_token) { token }
  11. end
  12. describe 'POST #create' do
  13. let(:status) { Fabricate(:status, account: user.account) }
  14. before do
  15. post :create, params: { status_id: status.id }
  16. end
  17. it 'returns http success' do
  18. expect(response).to have_http_status(:success)
  19. end
  20. it 'creates a conversation mute' do
  21. expect(ConversationMute.find_by(account: user.account, conversation_id: status.conversation_id)).to_not be_nil
  22. end
  23. end
  24. describe 'POST #destroy' do
  25. let(:status) { Fabricate(:status, account: user.account) }
  26. before do
  27. user.account.mute_conversation!(status.conversation)
  28. post :destroy, params: { status_id: status.id }
  29. end
  30. it 'returns http success' do
  31. expect(response).to have_http_status(:success)
  32. end
  33. it 'destroys the conversation mute' do
  34. expect(ConversationMute.find_by(account: user.account, conversation_id: status.conversation_id)).to be_nil
  35. end
  36. end
  37. end
  38. end