diff options
Diffstat (limited to 'spec/presenters/key_presenter_spec.rb')
-rw-r--r-- | spec/presenters/key_presenter_spec.rb | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/spec/presenters/key_presenter_spec.rb b/spec/presenters/key_presenter_spec.rb new file mode 100644 index 00000000000..d5aa39d5933 --- /dev/null +++ b/spec/presenters/key_presenter_spec.rb @@ -0,0 +1,32 @@ +# frozen_string_literal: true + +require 'spec_helper' + +RSpec.describe KeyPresenter do + let(:presenter) { described_class.new(key) } + + describe '#humanized_error_message' do + subject { presenter.humanized_error_message } + + before do + key.valid? + end + + context 'when public key is unsupported' do + let(:key) { build(:key, key: 'a') } + + it 'returns the custom error message' do + expect(subject).to eq('Key must be a <a target="_blank" rel="noopener noreferrer" ' \ + 'href="/help/user/ssh#supported-ssh-key-types">supported SSH public key.</a>') + end + end + + context 'when key is expired' do + let(:key) { build(:key, :expired) } + + it 'returns Active Record error message' do + expect(subject).to eq('Key has expired') + end + end + end +end |