password_check_spec.rb 714 B

123456789101112131415161718192021222324252627282930313233
  1. # Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/
  2. require 'rails_helper'
  3. RSpec.describe Service::User::PasswordCheck do
  4. subject(:service) { described_class.new(user:, password:) }
  5. let(:user) { create(:agent, password: 'lorem') }
  6. context 'with empty password' do
  7. let(:password) { nil }
  8. it 'returns false' do
  9. expect(service.execute).to be_falsey
  10. end
  11. end
  12. context 'with wrong password' do
  13. let(:password) { 'nah' }
  14. it 'returns false' do
  15. expect(service.execute).to be_falsey
  16. end
  17. end
  18. context 'with correct password' do
  19. let(:password) { 'lorem' }
  20. it 'returns true' do
  21. expect(service.execute).to be_truthy
  22. end
  23. end
  24. end