debian-mirror-gitlab/spec/views/profiles/keys/_form.html.haml_spec.rb

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

56 lines
1.9 KiB
Ruby
Raw Normal View History

2021-04-29 21:17:54 +05:30
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe 'profiles/keys/_form.html.haml' do
2022-03-02 08:16:31 +05:30
include SshKeysHelper
2021-04-29 21:17:54 +05:30
let_it_be(:key) { Key.new }
let(:page) { Capybara::Node::Simple.new(rendered) }
before do
assign(:key, key)
end
context 'when the form partial is used' do
before do
render
end
it 'renders the form with the correct action' do
expect(page.find('form')['action']).to eq('/-/profile/keys')
end
it 'has the key field', :aggregate_failures do
2022-03-02 08:16:31 +05:30
expect(rendered).to have_field('Key', type: 'textarea')
expect(rendered).to have_text(s_('Profiles|Begins with %{ssh_key_algorithms}.') % { ssh_key_algorithms: ssh_key_allowed_algorithms })
2021-04-29 21:17:54 +05:30
end
it 'has the title field', :aggregate_failures do
2022-06-21 17:19:12 +05:30
expect(rendered).to have_field('Title', type: 'text', placeholder: 'Example: MacBook key')
expect(rendered).to have_text('Key titles are publicly visible.')
2021-04-29 21:17:54 +05:30
end
2023-03-04 22:38:38 +05:30
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
2021-04-29 21:17:54 +05:30
it 'has the expires at field', :aggregate_failures do
2022-10-11 01:57:18 +05:30
expect(rendered).to have_field('Expiration date', type: 'text')
2022-01-26 12:08:38 +05:30
expect(page.find_field('Expiration date')['min']).to eq(l(1.day.from_now, format: "%Y-%m-%d"))
2022-10-11 01:57:18 +05:30
expect(rendered).to have_text( s_('Profiles|Optional but recommended. If set, key becomes invalid on the specified date.'))
2021-04-29 21:17:54 +05:30
end
it 'has the validation warning', :aggregate_failures do
expect(rendered).to have_text("Oops, are you sure? Publicly visible private SSH keys can compromise your system.")
expect(rendered).to have_button('Yes, add it')
end
it 'has the submit button' do
expect(rendered).to have_button('Add key')
end
end
end