From 1fa55069745163e70f01349f71798e2a214ae28e Mon Sep 17 00:00:00 2001 From: Stan Hu Date: Thu, 24 Nov 2016 02:24:52 -0800 Subject: Add spec for hiding variables and remove the need for ES6 Symbol --- app/assets/javascripts/project_variables.js.es6 | 6 +++--- spec/features/variables_spec.rb | 25 +++++++++++++++++++++++++ 2 files changed, 28 insertions(+), 3 deletions(-) diff --git a/app/assets/javascripts/project_variables.js.es6 b/app/assets/javascripts/project_variables.js.es6 index 51ee55946e4..6c905f58c85 100644 --- a/app/assets/javascripts/project_variables.js.es6 +++ b/app/assets/javascripts/project_variables.js.es6 @@ -23,9 +23,9 @@ $btn.attr('data-status', newStatus); - $variables = $('.variable-value'); + let $variables = $('.variable-value'); - for (let variable of $variables) { + $variables.each(function (_, variable) { let $variable = $(variable); let newText = HIDDEN_VALUE_TEXT; @@ -34,7 +34,7 @@ } $variable.text(newText); - } + }); $btn.text(newAction); } diff --git a/spec/features/variables_spec.rb b/spec/features/variables_spec.rb index d7880d5778f..ff30ffd7820 100644 --- a/spec/features/variables_spec.rb +++ b/spec/features/variables_spec.rb @@ -29,6 +29,31 @@ describe 'Project variables', js: true do end end + it 'reveals and hides 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') + expect(page).to have_content('******') + end + + click_button('Reveal Values') + + page.within('.variables-table') do + expect(page).to have_content('key') + expect(page).to have_content('key value') + end + + click_button('Hide Values') + + page.within('.variables-table') do + expect(page).to have_content('key') + expect(page).to have_content('******') + end + end + it 'deletes variable' do page.within('.variables-table') do find('.btn-variable-delete').click -- cgit v1.2.1