diff options
author | Shinya Maeda <shinya@gitlab.com> | 2019-01-02 09:25:44 +0300 |
---|---|---|
committer | Shinya Maeda <shinya@gitlab.com> | 2019-01-04 16:17:02 +0300 |
commit | 8a14548fc741e8d115d99e8303e36ed83660494d (patch) | |
tree | 224985a3ba901dbfaf2cdd4987aa6a5b535ed6c1 /spec/requests | |
parent | f5f52da885f331b9860c2cc1fe1847fd10ca9385 (diff) |
Add spec for duplicate link name creation
Fix spec for mysql unique validation failure
Diffstat (limited to 'spec/requests')
-rw-r--r-- | spec/requests/api/releases_spec.rb | 55 |
1 files changed, 33 insertions, 22 deletions
diff --git a/spec/requests/api/releases_spec.rb b/spec/requests/api/releases_spec.rb index 43615475a50..8433497863e 100644 --- a/spec/requests/api/releases_spec.rb +++ b/spec/requests/api/releases_spec.rb @@ -153,6 +153,7 @@ describe API::Releases do get api("/projects/#{project.id}/releases/v0.1", maintainer) expect(json_response['assets']['links'].count).to eq(1) + expect(json_response['assets']['links'].first['id']).to eq(link.id) expect(json_response['assets']['links'].first['name']) .to eq('release-18.04.dmg') expect(json_response['assets']['links'].first['url']) @@ -303,19 +304,21 @@ describe API::Releases do end context 'when create assets altogether' do + let(:base_params) do + { + name: 'New release', + tag_name: 'v0.1', + description: 'Super nice release' + } + end + context 'when create one asset' do let(:params) do - { - name: 'New release', - tag_name: 'v0.1', - description: 'Super nice release', + base_params.merge({ links_attributes: [ - { - name: 'beta', - url: 'https://dosuken.example.com/inspection.exe' - } + { name: 'beta', url: 'https://dosuken.example.com/inspection.exe' } ] - } + }) end it 'accepts the request' do @@ -342,21 +345,12 @@ describe API::Releases do context 'when create two assets' do let(:params) do - { - name: 'New release', - tag_name: 'v0.1', - description: 'Super nice release', + base_params.merge({ links_attributes: [ - { - name: 'alpha', - url: 'https://dosuken.example.com/alpha.exe' - }, - { - name: 'beta', - url: 'https://dosuken.example.com/beta.exe' - } + { name: 'alpha', url: 'https://dosuken.example.com/alpha.exe' }, + { name: 'beta', url: 'https://dosuken.example.com/beta.exe' } ] - } + }) end it 'creates two assets with specified parameters' do @@ -369,6 +363,23 @@ describe API::Releases do .to match_array(%w[https://dosuken.example.com/alpha.exe https://dosuken.example.com/beta.exe]) end + + context 'when link names are duplicates' do + let(:params) do + base_params.merge({ + links_attributes: [ + { name: 'alpha', url: 'https://dosuken.example.com/alpha.exe' }, + { name: 'alpha', url: 'https://dosuken.example.com/beta.exe' } + ] + }) + end + + it 'recognizes as a bad request' do + post api("/projects/#{project.id}/releases", maintainer), params: params + + expect(response).to have_gitlab_http_status(:bad_request) + end + end end end end |