Commit cf78c357 authored by Lin Jen-Shin's avatar Lin Jen-Shin

Use shared_example rather than methods, feedback:

https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/5347#note_13173653
parent 709e805d
...@@ -217,14 +217,15 @@ describe API::API, api: true do ...@@ -217,14 +217,15 @@ describe API::API, api: true do
fixture_file_upload(Rails.root + 'spec/fixtures/dk.png', 'image/gif') fixture_file_upload(Rails.root + 'spec/fixtures/dk.png', 'image/gif')
end end
def verify let(:download_headers) do
download_headers =
{ 'Content-Transfer-Encoding' => 'binary', { 'Content-Transfer-Encoding' => 'binary',
'Content-Disposition' => 'Content-Disposition' =>
"attachment; filename=#{build.artifacts_file.filename}" } "attachment; filename=#{build.artifacts_file.filename}" }
end
expect(response).to have_http_status(200) shared_examples 'a valid file' do
expect(response.headers).to include(download_headers) it { expect(response).to have_http_status(200) }
it { expect(response.headers).to include(download_headers) }
end end
context 'with regular branch' do context 'with regular branch' do
...@@ -237,7 +238,7 @@ describe API::API, api: true do ...@@ -237,7 +238,7 @@ describe API::API, api: true do
get path_for_ref('master') get path_for_ref('master')
end end
it('gives the file') { verify } it_behaves_like 'a valid file'
end end
context 'with branch name containing slash' do context 'with branch name containing slash' do
...@@ -250,7 +251,7 @@ describe API::API, api: true do ...@@ -250,7 +251,7 @@ describe API::API, api: true do
get path_for_ref('improve/awesome') get path_for_ref('improve/awesome')
end end
it('gives the file') { verify } it_behaves_like 'a valid file'
end end
context 'with latest pipeline' do context 'with latest pipeline' do
...@@ -269,7 +270,7 @@ describe API::API, api: true do ...@@ -269,7 +270,7 @@ describe API::API, api: true do
get path_for_ref get path_for_ref
end end
it('gives the file') { verify } it_behaves_like 'a valid file'
end end
context 'with success pipeline' do context 'with success pipeline' do
...@@ -285,7 +286,7 @@ describe API::API, api: true do ...@@ -285,7 +286,7 @@ describe API::API, api: true do
get path_for_ref get path_for_ref
end end
it('gives the file') { verify } it_behaves_like 'a valid file'
end end
end end
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