API support for muting notifications (and specs)
parent
6f7d00bfdd
commit
eaaf2170fe
|
@ -33,7 +33,7 @@ class Api::V1::AccountsController < Api::BaseController
|
||||||
end
|
end
|
||||||
|
|
||||||
def mute
|
def mute
|
||||||
MuteService.new.call(current_user.account, @account)
|
MuteService.new.call(current_user.account, @account, notifications: params[:notifications])
|
||||||
render json: @account, serializer: REST::RelationshipSerializer, relationships: relationships
|
render json: @account, serializer: REST::RelationshipSerializer, relationships: relationships
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -114,6 +114,35 @@ RSpec.describe Api::V1::AccountsController, type: :controller do
|
||||||
it 'creates a muting relation' do
|
it 'creates a muting relation' do
|
||||||
expect(user.account.muting?(other_account)).to be true
|
expect(user.account.muting?(other_account)).to be true
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it 'mutes notifications' do
|
||||||
|
expect(user.account.muting_notifications?(other_account)).to be true
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
describe 'POST #mute with notifications set to false' do
|
||||||
|
let(:other_account) { Fabricate(:user, email: 'bob@example.com', account: Fabricate(:account, username: 'bob')).account }
|
||||||
|
|
||||||
|
before do
|
||||||
|
user.account.follow!(other_account)
|
||||||
|
post :mute, params: {id: other_account.id, notifications: false }
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'returns http success' do
|
||||||
|
expect(response).to have_http_status(:success)
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'does not remove the following relation between user and target user' do
|
||||||
|
expect(user.account.following?(other_account)).to be true
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'creates a muting relation' do
|
||||||
|
expect(user.account.muting?(other_account)).to be true
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'does not mute notifications' do
|
||||||
|
expect(user.account.muting_notifications?(other_account)).to be false
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe 'POST #unmute' do
|
describe 'POST #unmute' do
|
||||||
|
|
Loading…
Reference in New Issue