Welcome to mirror list, hosted at ThFree Co, Russian Federation.

_form.html.haml_spec.rb « keys « profiles « views « spec - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 3c61afb21c5c879a894c52c8ad2157e6068648c2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# frozen_string_literal: true

require 'spec_helper'

RSpec.describe 'profiles/keys/_form.html.haml' do
  include SshKeysHelper

  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
      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 })
    end

    it 'has the title field', :aggregate_failures do
      expect(rendered).to have_field('Title', type: 'text', placeholder: 'Example: MacBook key')
      expect(rendered).to have_text('Key titles are publicly visible.')
    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"))
      expect(rendered).to have_text( s_('Profiles|Optional but recommended. If set, key becomes invalid on the specified date.'))
    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