From efebdba21db9e11b876ecb54db48358e13b08ad3 Mon Sep 17 00:00:00 2001 From: Lin Jen-Shin Date: Thu, 25 May 2017 19:31:21 +0800 Subject: Frontend implementation, tests, and changelog --- spec/features/variables_spec.rb | 44 ++++++++++++++++++++++++++++++++++++++++- 1 file changed, 43 insertions(+), 1 deletion(-) (limited to 'spec/features/variables_spec.rb') diff --git a/spec/features/variables_spec.rb b/spec/features/variables_spec.rb index b83a230c1f8..08a2df63a40 100644 --- a/spec/features/variables_spec.rb +++ b/spec/features/variables_spec.rb @@ -19,7 +19,7 @@ describe 'Project variables', js: true do end end - it 'adds new variable' do + it 'adds new secret variable' do fill_in('variable_key', with: 'key') fill_in('variable_value', with: 'key value') click_button('Add new variable') @@ -27,6 +27,7 @@ describe 'Project variables', js: true do expect(page).to have_content('Variables were successfully updated.') page.within('.variables-table') do expect(page).to have_content('key') + expect(page).to have_content('No') end end @@ -41,6 +42,19 @@ describe 'Project variables', js: true do end end + it 'adds new protected variable' do + fill_in('variable_key', with: 'key') + fill_in('variable_value', with: 'value') + check('Protected') + click_button('Add new variable') + + expect(page).to have_content('Variables were successfully updated.') + page.within('.variables-table') do + expect(page).to have_content('key') + expect(page).to have_content('Yes') + end + end + it 'reveals and hides new variable' do fill_in('variable_key', with: 'key') fill_in('variable_value', with: 'key value') @@ -100,4 +114,32 @@ describe 'Project variables', js: true do expect(page).to have_content('Variable was successfully updated.') expect(project.variables.first.value).to eq('') end + + it 'edits variable to be protected' do + page.within('.variables-table') do + find('.btn-variable-edit').click + end + + expect(page).to have_content('Update variable') + check('Protected') + click_button('Save variable') + + expect(page).to have_content('Variable was successfully updated.') + expect(project.variables.first).to be_protected + end + + it 'edits variable to be unprotected' do + project.variables.first.update(protected: true) + + page.within('.variables-table') do + find('.btn-variable-edit').click + end + + expect(page).to have_content('Update variable') + check('Protected') + click_button('Save variable') + + expect(page).to have_content('Variable was successfully updated.') + expect(project.variables.first).not_to be_protected + end end -- cgit v1.2.1 From 7f0116768188118d9291de3dc2f62af2d40795b9 Mon Sep 17 00:00:00 2001 From: Lin Jen-Shin Date: Thu, 25 May 2017 20:53:03 +0800 Subject: Fix tests and rubocop offense --- spec/features/variables_spec.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'spec/features/variables_spec.rb') diff --git a/spec/features/variables_spec.rb b/spec/features/variables_spec.rb index 08a2df63a40..5a5922d5f02 100644 --- a/spec/features/variables_spec.rb +++ b/spec/features/variables_spec.rb @@ -136,10 +136,10 @@ describe 'Project variables', js: true do end expect(page).to have_content('Update variable') - check('Protected') + uncheck('Protected') click_button('Save variable') expect(page).to have_content('Variable was successfully updated.') - expect(project.variables.first).not_to be_protected + expect(project.reload.variables.first).not_to be_protected end end -- cgit v1.2.1 From 8a1a73a75a4410115b3cc5a85bf5fd85cb634182 Mon Sep 17 00:00:00 2001 From: Lin Jen-Shin Date: Thu, 1 Jun 2017 00:37:44 +0800 Subject: Make sure we're loading the fresh variables Feedback: https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/11688#note_31186872 --- spec/features/variables_spec.rb | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'spec/features/variables_spec.rb') diff --git a/spec/features/variables_spec.rb b/spec/features/variables_spec.rb index 5a5922d5f02..d0c982919db 100644 --- a/spec/features/variables_spec.rb +++ b/spec/features/variables_spec.rb @@ -99,7 +99,7 @@ describe 'Project variables', js: true do click_button('Save variable') expect(page).to have_content('Variable was successfully updated.') - expect(project.variables.first.value).to eq('key value') + expect(project.variables(true).first.value).to eq('key value') end it 'edits variable with empty value' do @@ -112,7 +112,7 @@ describe 'Project variables', js: true do click_button('Save variable') expect(page).to have_content('Variable was successfully updated.') - expect(project.variables.first.value).to eq('') + expect(project.variables(true).first.value).to eq('') end it 'edits variable to be protected' do @@ -125,7 +125,7 @@ describe 'Project variables', js: true do click_button('Save variable') expect(page).to have_content('Variable was successfully updated.') - expect(project.variables.first).to be_protected + expect(project.variables(true).first).to be_protected end it 'edits variable to be unprotected' do @@ -140,6 +140,6 @@ describe 'Project variables', js: true do click_button('Save variable') expect(page).to have_content('Variable was successfully updated.') - expect(project.reload.variables.first).not_to be_protected + expect(project.variables(true).first).not_to be_protected end end -- cgit v1.2.1