BigW Consortium Gitlab

variables_spec.rb 1.3 KB
Newer Older
1 2
require 'spec_helper'

3 4 5 6 7 8 9 10 11 12 13 14 15
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

16
  it 'shows list of variables' do
17 18 19 20 21
    page.within('.variables-table') do
      expect(page).to have_content(variable.key)
    end
  end

22
  it 'adds new variable' do
23 24 25 26 27 28 29 30 31
    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

32
  it 'deletes variable' do
33 34 35 36
    page.within('.variables-table') do
      find('.btn-variable-delete').click
    end

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

40
  it 'edits variable' do
41 42
    page.within('.variables-table') do
      find('.btn-variable-edit').click
43 44
    end

Phil Hughes committed
45
    expect(page).to have_content('Update variable')
46 47 48
    fill_in('variable_key', with: 'key')
    fill_in('variable_value', with: 'key value')
    click_button('Save variable')
49

50 51
    page.within('.variables-table') do
      expect(page).to have_content('key')
52 53 54
    end
  end
end