Commit 55805701 authored by Matija Čupić's avatar Matija Čupić

Extract variable parameters in VariablesController specs

parent c95c3ffc
...@@ -25,16 +25,22 @@ describe Groups::VariablesController do ...@@ -25,16 +25,22 @@ describe Groups::VariablesController do
describe 'POST #update' do describe 'POST #update' do
let!(:variable) { create(:ci_group_variable, group: group) } let!(:variable) { create(:ci_group_variable, group: group) }
let(:variable_attributes) do
{ 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',
protected: 'false' }
end
context 'with invalid new variable parameters' do context 'with invalid new variable parameters' do
subject do subject do
patch :update, patch :update,
group_id: group, group_id: group,
variables_attributes: [{ id: variable.id, key: variable.key, variables_attributes: [variable_attributes.merge(value: 'other_value'),
value: 'other_value', new_variable_attributes.merge(key: '..?')],
protected: variable.protected?.to_s },
{ key: '..?', value: 'dummy_value',
protected: 'false' }],
format: :json format: :json
end end
...@@ -57,11 +63,8 @@ describe Groups::VariablesController do ...@@ -57,11 +63,8 @@ describe Groups::VariablesController do
subject do subject do
patch :update, patch :update,
group_id: group, group_id: group,
variables_attributes: [{ id: variable.id, key: variable.key, variables_attributes: [variable_attributes.merge(value: 'other_value'),
value: 'other_value', new_variable_attributes],
protected: variable.protected?.to_s },
{ key: 'new_key', value: 'dummy_value',
protected: 'false' }],
format: :json format: :json
end end
...@@ -90,10 +93,7 @@ describe Groups::VariablesController do ...@@ -90,10 +93,7 @@ describe Groups::VariablesController do
subject do subject do
patch :update, patch :update,
group_id: group, group_id: group,
variables_attributes: [{ id: variable.id, key: variable.key, variables_attributes: [variable_attributes.merge(_destroy: 'true')],
value: variable.value,
protected: variable.protected?.to_s,
_destroy: 'true' }],
format: :json format: :json
end end
......
...@@ -30,6 +30,15 @@ describe Projects::VariablesController do ...@@ -30,6 +30,15 @@ describe Projects::VariablesController do
describe 'POST #update' do describe 'POST #update' do
let(:variable) { create(:ci_variable) } let(:variable) { create(:ci_variable) }
let(:variable_attributes) do
{ 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',
protected: 'false' }
end
before do before do
project.variables << variable project.variables << variable
...@@ -39,11 +48,8 @@ describe Projects::VariablesController do ...@@ -39,11 +48,8 @@ describe Projects::VariablesController do
subject do subject do
patch :update, patch :update,
namespace_id: project.namespace.to_param, project_id: project, namespace_id: project.namespace.to_param, project_id: project,
variables_attributes: [{ id: variable.id, key: variable.key, variables_attributes: [variable_attributes.merge(value: 'other_value'),
value: 'other_value', new_variable_attributes.merge(key: '..?')],
protected: variable.protected?.to_s },
{ key: '..?', value: 'dummy_value',
protected: 'false' }],
format: :json format: :json
end end
...@@ -66,11 +72,8 @@ describe Projects::VariablesController do ...@@ -66,11 +72,8 @@ describe Projects::VariablesController do
subject do subject do
patch :update, patch :update,
namespace_id: project.namespace.to_param, project_id: project, namespace_id: project.namespace.to_param, project_id: project,
variables_attributes: [{ id: variable.id, key: variable.key, variables_attributes: [variable_attributes.merge(value: 'other_value'),
value: 'other_value', new_variable_attributes],
protected: variable.protected?.to_s },
{ key: 'new_key', value: 'dummy_value',
protected: 'false' }],
format: :json format: :json
end end
...@@ -99,10 +102,7 @@ describe Projects::VariablesController do ...@@ -99,10 +102,7 @@ describe Projects::VariablesController do
subject do subject do
patch :update, patch :update,
namespace_id: project.namespace.to_param, project_id: project, namespace_id: project.namespace.to_param, project_id: project,
variables_attributes: [{ id: variable.id, key: variable.key, variables_attributes: [variable_attributes.merge(_destroy: 'true')],
value: variable.value,
protected: variable.protected?.to_s,
_destroy: 'true' }],
format: :json format: :json
end end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment