Spec coverage on Settings/ controllers specs (#24221)

This commit is contained in:
Matt Jankowski 2023-04-11 11:35:39 +02:00 committed by GitHub
parent a2a66300d9
commit 36eeb70d53
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 205 additions and 20 deletions

View file

@ -18,5 +18,35 @@ describe Settings::PicturesController do
expect(response).to have_http_status(400)
end
end
context 'with valid picture id' do
context 'when account updates correctly' do
let(:service) { instance_double(UpdateAccountService, call: true) }
before do
allow(UpdateAccountService).to receive(:new).and_return(service)
end
it 'updates the account' do
delete :destroy, params: { id: 'avatar' }
expect(response).to redirect_to(settings_profile_path)
expect(response).to have_http_status(303)
expect(service).to have_received(:call).with(user.account, { 'avatar' => nil, 'avatar_remote_url' => '' })
end
end
context 'when account cannot update' do
let(:service) { instance_double(UpdateAccountService, call: false) }
before do
allow(UpdateAccountService).to receive(:new).and_return(service)
end
it 'redirects to profile' do
delete :destroy, params: { id: 'avatar' }
expect(response).to redirect_to(settings_profile_path)
end
end
end
end
end