about summary refs log tree commit diff
path: root/spec/controllers/settings/pictures_controller_spec.rb
diff options
context:
space:
mode:
authorMatt Jankowski <matt@jankowski.online>2023-04-11 11:35:39 +0200
committerGitHub <noreply@github.com>2023-04-11 11:35:39 +0200
commit36eeb70d5315be045a638d77f8ff0a71dce61076 (patch)
tree923f26358c714c41fa0b525bba6c5a4036480473 /spec/controllers/settings/pictures_controller_spec.rb
parenta2a66300d99ed53d63a7f065ffbed53d2ce074e3 (diff)
Spec coverage on Settings/ controllers specs (#24221)
Diffstat (limited to 'spec/controllers/settings/pictures_controller_spec.rb')
-rw-r--r--spec/controllers/settings/pictures_controller_spec.rb30
1 files changed, 30 insertions, 0 deletions
diff --git a/spec/controllers/settings/pictures_controller_spec.rb b/spec/controllers/settings/pictures_controller_spec.rb
index 2368dc55d..705878f03 100644
--- a/spec/controllers/settings/pictures_controller_spec.rb
+++ b/spec/controllers/settings/pictures_controller_spec.rb
@@ -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