Share more stuffs
This commit is contained in:
parent
8735d95af1
commit
b043729d49
|
@ -4,18 +4,9 @@ require_relative '../shared/artifacts_context'
|
||||||
describe API::API, api: true do
|
describe API::API, api: true do
|
||||||
include ApiHelpers
|
include ApiHelpers
|
||||||
|
|
||||||
let(:user) { create(:user) }
|
|
||||||
let(:project) { create(:project) }
|
|
||||||
let(:pipeline) do
|
|
||||||
create(:ci_pipeline, project: project, sha: project.commit('fix').sha)
|
|
||||||
end
|
|
||||||
let(:build) { create(:ci_build, :success, :artifacts, pipeline: pipeline) }
|
|
||||||
|
|
||||||
before do
|
|
||||||
project.team << [user, :developer]
|
|
||||||
end
|
|
||||||
|
|
||||||
describe 'GET /projects/:id/artifacts/:ref_name/:build_name' do
|
describe 'GET /projects/:id/artifacts/:ref_name/:build_name' do
|
||||||
|
include_context 'artifacts from ref and build name'
|
||||||
|
|
||||||
def path_from_ref(ref = pipeline.sha, build_name = build.name, _ = '')
|
def path_from_ref(ref = pipeline.sha, build_name = build.name, _ = '')
|
||||||
api("/projects/#{project.id}/artifacts/#{ref}/#{build_name}", user)
|
api("/projects/#{project.id}/artifacts/#{ref}/#{build_name}", user)
|
||||||
end
|
end
|
||||||
|
|
|
@ -2,19 +2,13 @@ require 'spec_helper'
|
||||||
require_relative '../shared/artifacts_context'
|
require_relative '../shared/artifacts_context'
|
||||||
|
|
||||||
describe Projects::ArtifactsController do
|
describe Projects::ArtifactsController do
|
||||||
let(:user) { create(:user) }
|
|
||||||
let(:project) { create(:project) }
|
|
||||||
let(:pipeline) do
|
|
||||||
create(:ci_pipeline, project: project, sha: project.commit('fix').sha)
|
|
||||||
end
|
|
||||||
let(:build) { create(:ci_build, :success, :artifacts, pipeline: pipeline) }
|
|
||||||
|
|
||||||
before do
|
|
||||||
login_as(user)
|
|
||||||
project.team << [user, :developer]
|
|
||||||
end
|
|
||||||
|
|
||||||
describe 'GET /:project/artifacts/:ref/:build_name/browse' do
|
describe 'GET /:project/artifacts/:ref/:build_name/browse' do
|
||||||
|
include_context 'artifacts from ref and build name'
|
||||||
|
|
||||||
|
before do
|
||||||
|
login_as(user)
|
||||||
|
end
|
||||||
|
|
||||||
def path_from_ref(ref = pipeline.sha, build_name = build.name,
|
def path_from_ref(ref = pipeline.sha, build_name = build.name,
|
||||||
path = 'browse')
|
path = 'browse')
|
||||||
search_namespace_project_artifacts_path(
|
search_namespace_project_artifacts_path(
|
||||||
|
|
|
@ -1,4 +1,17 @@
|
||||||
shared_context 'artifacts from ref with 404' do
|
shared_context 'artifacts from ref and build name' do
|
||||||
|
let(:user) { create(:user) }
|
||||||
|
let(:project) { create(:project) }
|
||||||
|
let(:pipeline) do
|
||||||
|
create(:ci_pipeline, project: project, sha: project.commit('fix').sha)
|
||||||
|
end
|
||||||
|
let(:build) { create(:ci_build, :success, :artifacts, pipeline: pipeline) }
|
||||||
|
|
||||||
|
before do
|
||||||
|
project.team << [user, :developer]
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
shared_examples 'artifacts from ref with 404' do
|
||||||
context 'has no such ref' do
|
context 'has no such ref' do
|
||||||
before do
|
before do
|
||||||
get path_from_ref('TAIL', build.name)
|
get path_from_ref('TAIL', build.name)
|
||||||
|
@ -16,7 +29,7 @@ shared_context 'artifacts from ref with 404' do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
shared_context 'artifacts from ref with 302' do
|
shared_examples 'artifacts from ref with 302' do
|
||||||
context 'with sha' do
|
context 'with sha' do
|
||||||
before do
|
before do
|
||||||
get path_from_ref
|
get path_from_ref
|
||||||
|
|
Loading…
Reference in New Issue