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

Share more stuffs

parent 8735d95a
......@@ -4,18 +4,9 @@ require_relative '../shared/artifacts_context'
describe API::API, api: true do
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
include_context 'artifacts from ref and build name'
def path_from_ref(ref = pipeline.sha, build_name = build.name, _ = '')
api("/projects/#{project.id}/artifacts/#{ref}/#{build_name}", user)
end
......
......@@ -2,19 +2,13 @@ require 'spec_helper'
require_relative '../shared/artifacts_context'
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) }
describe 'GET /:project/artifacts/:ref/:build_name/browse' do
include_context 'artifacts from ref and build name'
before do
login_as(user)
project.team << [user, :developer]
end
describe 'GET /:project/artifacts/:ref/:build_name/browse' do
def path_from_ref(ref = pipeline.sha, build_name = build.name,
path = 'browse')
search_namespace_project_artifacts_path(
......
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
before do
get path_from_ref('TAIL', build.name)
......@@ -16,7 +29,7 @@ shared_context 'artifacts from ref with 404' do
end
end
shared_context 'artifacts from ref with 302' do
shared_examples 'artifacts from ref with 302' do
context 'with sha' do
before do
get path_from_ref
......
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