Share more stuffs

This commit is contained in:
Lin Jen-Shin 2016-07-13 23:23:05 +08:00
parent 8735d95af1
commit b043729d49
3 changed files with 23 additions and 25 deletions

View File

@ -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

View File

@ -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) }
before do
login_as(user)
project.team << [user, :developer]
end
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,
path = 'browse')
search_namespace_project_artifacts_path(

View File

@ -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
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