2017-06-10 07:39:26 +00:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
require 'rails_helper'
|
|
|
|
|
2024-09-04 05:12:25 +00:00
|
|
|
RSpec.describe 'API V1 Statuses Mutes' do
|
2022-01-27 23:46:42 +00:00
|
|
|
let(:user) { Fabricate(:user) }
|
2024-01-26 17:45:54 +00:00
|
|
|
let(:token) { Fabricate(:accessible_access_token, resource_owner_id: user.id, scopes: scopes) }
|
|
|
|
let(:scopes) { 'write:mutes' }
|
|
|
|
let(:headers) { { 'Authorization' => "Bearer #{token.token}" } }
|
2017-06-10 07:39:26 +00:00
|
|
|
|
|
|
|
context 'with an oauth token' do
|
2024-01-26 17:45:54 +00:00
|
|
|
describe 'POST /api/v1/statuses/:status_id/mute' do
|
2017-06-10 07:39:26 +00:00
|
|
|
let(:status) { Fabricate(:status, account: user.account) }
|
|
|
|
|
|
|
|
before do
|
2024-01-26 17:45:54 +00:00
|
|
|
post "/api/v1/statuses/#{status.id}/mute", headers: headers
|
2017-06-10 07:39:26 +00:00
|
|
|
end
|
|
|
|
|
2023-10-13 12:42:09 +00:00
|
|
|
it 'creates a conversation mute', :aggregate_failures do
|
2018-04-21 19:35:07 +00:00
|
|
|
expect(response).to have_http_status(200)
|
2024-09-20 13:13:04 +00:00
|
|
|
expect(response.content_type)
|
|
|
|
.to start_with('application/json')
|
2017-06-10 07:39:26 +00:00
|
|
|
expect(ConversationMute.find_by(account: user.account, conversation_id: status.conversation_id)).to_not be_nil
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2024-01-26 17:45:54 +00:00
|
|
|
describe 'POST /api/v1/statuses/:status_id/unmute' do
|
2017-06-10 07:39:26 +00:00
|
|
|
let(:status) { Fabricate(:status, account: user.account) }
|
|
|
|
|
|
|
|
before do
|
|
|
|
user.account.mute_conversation!(status.conversation)
|
2024-01-26 17:45:54 +00:00
|
|
|
post "/api/v1/statuses/#{status.id}/unmute", headers: headers
|
2017-06-10 07:39:26 +00:00
|
|
|
end
|
|
|
|
|
2023-10-13 12:42:09 +00:00
|
|
|
it 'destroys the conversation mute', :aggregate_failures do
|
2018-04-21 19:35:07 +00:00
|
|
|
expect(response).to have_http_status(200)
|
2024-09-20 13:13:04 +00:00
|
|
|
expect(response.content_type)
|
|
|
|
.to start_with('application/json')
|
2017-06-10 07:39:26 +00:00
|
|
|
expect(ConversationMute.find_by(account: user.account, conversation_id: status.conversation_id)).to be_nil
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|