remove_linked_account_spec.rb 847 B

12345678910111213141516171819202122232425262728
  1. # Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/
  2. require 'rails_helper'
  3. RSpec.describe Service::User::RemoveLinkedAccount do
  4. subject(:service) { described_class.new(provider:, uid:, current_user: user) }
  5. let(:user) { create(:agent) }
  6. let(:authorization) { create(:twitter_authorization, user: user) }
  7. let(:provider) { authorization.provider }
  8. let(:uid) { authorization.uid }
  9. context 'with a valid authorization' do
  10. it 'removes the linked account' do
  11. service.execute
  12. expect { authorization.reload }.to raise_error(ActiveRecord::RecordNotFound)
  13. end
  14. end
  15. context 'without a valid authorization' do
  16. let(:uid) { 'invalid-uid' }
  17. it 'raises an error' do
  18. expect { service.execute }.to raise_error(Exceptions::UnprocessableEntity)
  19. end
  20. end
  21. end