diff options
Diffstat (limited to 'spec/views/profiles')
-rw-r--r-- | spec/views/profiles/keys/_form.html.haml_spec.rb | 5 | ||||
-rw-r--r-- | spec/views/profiles/keys/_key.html.haml_spec.rb | 20 | ||||
-rw-r--r-- | spec/views/profiles/keys/_key_details.html.haml_spec.rb | 32 |
3 files changed, 57 insertions, 0 deletions
diff --git a/spec/views/profiles/keys/_form.html.haml_spec.rb b/spec/views/profiles/keys/_form.html.haml_spec.rb index 3c61afb21c5..dd8af14100a 100644 --- a/spec/views/profiles/keys/_form.html.haml_spec.rb +++ b/spec/views/profiles/keys/_form.html.haml_spec.rb @@ -32,6 +32,11 @@ RSpec.describe 'profiles/keys/_form.html.haml' do expect(rendered).to have_text('Key titles are publicly visible.') end + it 'has the usage type field', :aggregate_failures do + expect(page).to have_select _('Usage type'), + selected: 'Authentication & Signing', options: ['Authentication & Signing', 'Authentication', 'Signing'] + end + it 'has the expires at field', :aggregate_failures do expect(rendered).to have_field('Expiration date', type: 'text') expect(page.find_field('Expiration date')['min']).to eq(l(1.day.from_now, format: "%Y-%m-%d")) diff --git a/spec/views/profiles/keys/_key.html.haml_spec.rb b/spec/views/profiles/keys/_key.html.haml_spec.rb index 1040541332d..d2e27bd2ee0 100644 --- a/spec/views/profiles/keys/_key.html.haml_spec.rb +++ b/spec/views/profiles/keys/_key.html.haml_spec.rb @@ -30,6 +30,26 @@ RSpec.describe 'profiles/keys/_key.html.haml' do expect(response).to render_template(partial: 'shared/ssh_keys/_key_delete') end + context 'displays the usage type' do + where(:usage_type, :usage_type_text) do + [ + [:auth, 'Authentication'], + [:auth_and_signing, 'Authentication & Signing'], + [:signing, 'Signing'] + ] + end + + with_them do + let(:key) { create(:key, user: user, usage_type: usage_type) } + + it 'renders usage type text' do + render + + expect(rendered).to have_text(usage_type_text) + end + end + end + context 'when the key has not been used' do let_it_be(:key) do create(:personal_key, diff --git a/spec/views/profiles/keys/_key_details.html.haml_spec.rb b/spec/views/profiles/keys/_key_details.html.haml_spec.rb new file mode 100644 index 00000000000..c223d6702c5 --- /dev/null +++ b/spec/views/profiles/keys/_key_details.html.haml_spec.rb @@ -0,0 +1,32 @@ +# frozen_string_literal: true + +require 'spec_helper' + +RSpec.describe 'profiles/keys/_key_details.html.haml' do + let_it_be(:user) { create(:user) } + + before do + assign(:key, key) + allow(view).to receive(:is_admin).and_return(false) + end + + describe 'displays the usage type' do + where(:usage_type, :usage_type_text) do + [ + [:auth, 'Authentication'], + [:auth_and_signing, 'Authentication & Signing'], + [:signing, 'Signing'] + ] + end + + with_them do + let(:key) { create(:key, user: user, usage_type: usage_type) } + + it 'renders usage type text' do + render + + expect(rendered).to have_text(usage_type_text) + end + end + end +end |