2019-12-26 22:10:19 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
require 'spec_helper'
|
|
|
|
|
2020-06-23 00:09:42 +05:30
|
|
|
RSpec.describe 'Project group variables', :js do
|
2019-12-26 22:10:19 +05:30
|
|
|
let(:user) { create(:user) }
|
|
|
|
let(:group) { create(:group) }
|
|
|
|
let(:subgroup) { create(:group, parent: group) }
|
|
|
|
let(:subgroup_nested) { create(:group, parent: subgroup) }
|
|
|
|
let(:project) { create(:project, group: group) }
|
|
|
|
let(:project2) { create(:project, group: subgroup) }
|
|
|
|
let(:project3) { create(:project, group: subgroup_nested) }
|
|
|
|
let(:key1) { 'test_key' }
|
|
|
|
let(:key2) { 'test_key2' }
|
|
|
|
let(:key3) { 'test_key3' }
|
|
|
|
let!(:ci_variable) { create(:ci_group_variable, group: group, key: key1) }
|
|
|
|
let!(:ci_variable2) { create(:ci_group_variable, group: subgroup, key: key2) }
|
|
|
|
let!(:ci_variable3) { create(:ci_group_variable, group: subgroup_nested, key: key3) }
|
|
|
|
let(:project_path) { project_settings_ci_cd_path(project) }
|
|
|
|
let(:project2_path) { project_settings_ci_cd_path(project2) }
|
|
|
|
let(:project3_path) { project_settings_ci_cd_path(project3) }
|
|
|
|
|
|
|
|
before do
|
|
|
|
sign_in(user)
|
|
|
|
project.add_maintainer(user)
|
|
|
|
group.add_owner(user)
|
2020-04-08 14:13:33 +05:30
|
|
|
stub_feature_flags(new_variables_ui: false)
|
2019-12-26 22:10:19 +05:30
|
|
|
end
|
|
|
|
|
|
|
|
it 'project in group shows inherited vars from ancestor group' do
|
|
|
|
visit project_path
|
|
|
|
expect(page).to have_content(key1)
|
|
|
|
expect(page).to have_content(group.name)
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'project in subgroup shows inherited vars from all ancestor groups' do
|
|
|
|
visit project2_path
|
|
|
|
expect(page).to have_content(key1)
|
|
|
|
expect(page).to have_content(key2)
|
|
|
|
expect(page).to have_content(group.name)
|
|
|
|
expect(page).to have_content(subgroup.name)
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'project in nested subgroup shows inherited vars from all ancestor groups' do
|
|
|
|
visit project3_path
|
|
|
|
expect(page).to have_content(key1)
|
|
|
|
expect(page).to have_content(key2)
|
|
|
|
expect(page).to have_content(key3)
|
|
|
|
expect(page).to have_content(group.name)
|
|
|
|
expect(page).to have_content(subgroup.name)
|
|
|
|
expect(page).to have_content(subgroup_nested.name)
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'project origin keys link to ancestor groups ci_cd settings' do
|
|
|
|
visit project_path
|
|
|
|
find('.group-origin-link').click
|
|
|
|
page.within('.js-ci-variable-list-section .js-row:nth-child(2)') do
|
|
|
|
expect(find('.js-ci-variable-input-key').value).to eq(key1)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|