summaryrefslogtreecommitdiff
path: root/spec/controllers/groups
diff options
context:
space:
mode:
authorMatija Čupić <matteeyah@gmail.com>2018-02-02 18:54:13 +0100
committerMatija Čupić <matteeyah@gmail.com>2018-02-05 18:58:21 +0100
commit45a14b4f584dd1102bd81c560e4d2e7c4b34aea5 (patch)
tree3fd98420ce8a29313dd20f321d9e1a22dddd62e0 /spec/controllers/groups
parent18232d7efb53381dea8727c36fc7a36dd2fd9d5e (diff)
downloadgitlab-ce-45a14b4f584dd1102bd81c560e4d2e7c4b34aea5.tar.gz
Refactor Variable controllers specs
Diffstat (limited to 'spec/controllers/groups')
-rw-r--r--spec/controllers/groups/variables_controller_spec.rb43
1 files changed, 23 insertions, 20 deletions
diff --git a/spec/controllers/groups/variables_controller_spec.rb b/spec/controllers/groups/variables_controller_spec.rb
index 80b6be39291..8abdc1cb5b1 100644
--- a/spec/controllers/groups/variables_controller_spec.rb
+++ b/spec/controllers/groups/variables_controller_spec.rb
@@ -25,23 +25,32 @@ describe Groups::VariablesController do
describe 'POST #update' do
let!(:variable) { create(:ci_group_variable, group: group) }
+
+ subject do
+ patch :update,
+ group_id: group,
+ variables_attributes: variables_attributes,
+ format: :json
+ end
+
let(:variable_attributes) do
- { id: variable.id, key: variable.key,
+ { id: variable.id,
+ key: variable.key,
value: variable.value,
protected: variable.protected?.to_s }
end
let(:new_variable_attributes) do
- { key: 'new_key', value: 'dummy_value',
+ { key: 'new_key',
+ value: 'dummy_value',
protected: 'false' }
end
context 'with invalid new variable parameters' do
- subject do
- patch :update,
- group_id: group,
- variables_attributes: [variable_attributes.merge(value: 'other_value'),
- new_variable_attributes.merge(key: '..?')],
- format: :json
+ let(:variables_attributes) do
+ [
+ variable_attributes.merge(value: 'other_value'),
+ new_variable_attributes.merge(key: '...?')
+ ]
end
it 'does not update the existing variable' do
@@ -60,12 +69,11 @@ describe Groups::VariablesController do
end
context 'with valid new variable parameters' do
- subject do
- patch :update,
- group_id: group,
- variables_attributes: [variable_attributes.merge(value: 'other_value'),
- new_variable_attributes],
- format: :json
+ let(:variables_attributes) do
+ [
+ variable_attributes.merge(value: 'other_value'),
+ new_variable_attributes
+ ]
end
it 'updates the existing variable' do
@@ -90,12 +98,7 @@ describe Groups::VariablesController do
end
context 'with a deleted variable' do
- subject do
- patch :update,
- group_id: group,
- variables_attributes: [variable_attributes.merge(_destroy: 'true')],
- format: :json
- end
+ let(:variables_attributes) { [variable_attributes.merge(_destroy: 'true')] }
it 'destroys the variable' do
expect { subject }.to change { group.variables.count }.by(-1)