Commit 1852c796 authored by Igor Drozdov's avatar Igor Drozdov

Merge branch 'sh-add-api-nil-specs' into 'master'

Add tests for passing nil values in epics and packages

See merge request gitlab-org/gitlab!30949
parents 4d92f6bd 70558e89
......@@ -38,6 +38,17 @@ describe API::Dependencies do
expect(vulnerability['severity']).to eq('unknown')
end
context 'with nil package_manager' do
let(:params) { { package_manager: nil } }
it 'returns no dependencies' do
expect(response).to have_gitlab_http_status(:ok)
expect(response).to match_response_schema('public_api/v4/dependencies', dir: 'ee')
expect(json_response).to eq([])
end
end
context 'with filter options' do
let(:params) { { package_manager: 'yarn' } }
......
......@@ -618,6 +618,17 @@ describe API::Epics do
expect(json_response['labels']).to include '&'
expect(json_response['labels']).to include '?'
end
it 'creates a new epic with no labels' do
params[:labels] = nil
post api(url, user), params: params
expect(response).to have_gitlab_http_status(:created)
expect(json_response['title']).to include 'new epic'
expect(json_response['description']).to include 'epic description'
expect(json_response['labels']).to be_empty
end
end
end
......@@ -705,6 +716,25 @@ describe API::Epics do
end
end
it 'clears labels when labels param is nil' do
params[:labels] = 'label1'
put api(url, user), params: params
expect(response).to have_gitlab_http_status(:ok)
expect(json_response['title']).to include 'new title'
expect(json_response['description']).to include 'new description'
expect(json_response['labels']).to contain_exactly('label1')
params[:labels] = nil
put api(url, user), params: params
expect(response).to have_gitlab_http_status(:ok)
json_response = Gitlab::Json.parse(response.body)
expect(json_response['title']).to include 'new title'
expect(json_response['description']).to include 'new description'
expect(json_response['labels']).to be_empty
end
it 'updates the epic with labels param as array' do
stub_const("Gitlab::QueryLimiting::Transaction::THRESHOLD", 110)
......
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