developer_spec.rb 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. require 'rails_helper'
  2. require 'lib/auth/backend_examples'
  3. RSpec.describe Auth::Developer do
  4. let(:user) { create(:user) }
  5. let(:instance) { described_class.new({ adapter: described_class.name }) }
  6. describe '#valid?' do
  7. it_behaves_like 'Auth backend'
  8. it "authenticates users with password 'test'" do
  9. allow(Setting).to receive(:get)
  10. allow(Setting).to receive(:get).with('developer_mode').and_return(true)
  11. result = instance.valid?(user, 'test')
  12. expect(result).to be true
  13. end
  14. context 'invalid' do
  15. let(:password) { 'zammad' }
  16. it "doesn't authenticate if developer mode is off" do
  17. allow(Setting).to receive(:get)
  18. allow(Setting).to receive(:get).with('developer_mode').and_return(false)
  19. result = instance.valid?(user, password)
  20. expect(result).to be false
  21. end
  22. it "doesn't authenticate with correct password" do
  23. allow(Setting).to receive(:get)
  24. allow(Setting).to receive(:get).with('developer_mode').and_return(true)
  25. result = instance.valid?(user, password)
  26. expect(result).to be false
  27. end
  28. end
  29. end
  30. end