summaryrefslogtreecommitdiff
path: root/spec/features/variables_spec.rb
blob: a2b8f7b6931ffb5c9786a48b37aecc633b4ed09e (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
51
52
53
require 'spec_helper'

describe 'Project variables', js: true do
  let(:user)     { create(:user) }
  let(:project)  { create(:project) }
  let(:variable) { create(:ci_variable, key: 'test') }

  before do
    login_as(user)
    project.team << [user, :master]
    project.variables << variable

    visit namespace_project_variables_path(project.namespace, project)
  end

  it 'should show list of variables' do
    page.within('.variables-table') do
      expect(page).to have_content(variable.key)
    end
  end

  it 'should add new variable' do
    fill_in('variable_key', with: 'key')
    fill_in('variable_value', with: 'key value')
    click_button('Add new variable')

    page.within('.variables-table') do
      expect(page).to have_content('key')
    end
  end

  it 'should delete variable' do
    page.within('.variables-table') do
      find('.btn-variable-delete').click
    end

    expect(page).not_to have_selector('variables-table')
  end

  it 'should edit variable' do
    page.within('.variables-table') do
      find('.btn-variable-edit').click
    end

    fill_in('variable_key', with: 'key')
    fill_in('variable_value', with: 'key value')
    click_button('Save variable')

    page.within('.variables-table') do
      expect(page).to have_content('key')
    end
  end
end