BigW Consortium Gitlab

builds.rb 2.3 KB
Newer Older
1 2 3
module SharedBuilds
  include Spinach::DSL

4
  step 'project has CI enabled' do
5 6 7
    @project.enable_ci
  end

8 9 10 11
  step 'project has coverage enabled' do
    @project.update_attribute(:build_coverage_regex, /Coverage (\d+)%/)
  end

12
  step 'project has a recent build' do
13
    @pipeline = create(:ci_empty_pipeline, project: @project, sha: @project.commit.sha, ref: 'master')
14
    @build = create(:ci_build_with_coverage, pipeline: @pipeline)
15 16
  end

17
  step 'recent build is successful' do
18
    @build.success
19 20 21
  end

  step 'recent build failed' do
22
    @build.drop
23 24
  end

25
  step 'project has another build that is running' do
26
    create(:ci_build, pipeline: @pipeline, name: 'second build', status_event: 'run')
27 28
  end

29
  step 'I visit recent build details page' do
30 31
    visit namespace_project_build_path(@project.namespace, @project, @build)
  end
32

33 34 35 36
  step 'I visit project builds page' do
    visit namespace_project_builds_path(@project.namespace, @project)
  end

37 38 39 40 41 42 43 44 45 46 47
  step 'recent build has artifacts available' do
    artifacts = Rails.root + 'spec/fixtures/ci_build_artifacts.zip'
    archive = fixture_file_upload(artifacts, 'application/zip')
    @build.update_attributes(artifacts_file: archive)
  end

  step 'recent build has artifacts metadata available' do
    metadata = Rails.root + 'spec/fixtures/ci_build_artifacts_metadata.gz'
    gzip = fixture_file_upload(metadata, 'application/x-gzip')
    @build.update_attributes(artifacts_metadata: gzip)
  end
48

49 50 51 52
  step 'recent build has a build trace' do
    @build.trace = 'build trace'
  end

53 54 55 56 57 58 59 60
  step 'download of build artifacts archive starts' do
    expect(page.response_headers['Content-Type']).to eq 'application/zip'
    expect(page.response_headers['Content-Transfer-Encoding']).to eq 'binary'
  end

  step 'I access artifacts download page' do
    visit download_namespace_project_build_artifacts_path(@project.namespace, @project, @build)
  end
61 62 63 64 65 66 67 68 69 70

  step 'I see details of a build' do
    expect(page).to have_content "Build ##{@build.id}"
  end

  step 'I see build trace' do
    expect(page).to have_css '#build-trace'
  end

  step 'I see the build' do
71
    page.within('.build') do
72 73 74 75 76 77
      expect(page).to have_content "##{@build.id}"
      expect(page).to have_content @build.sha[0..7]
      expect(page).to have_content @build.ref
      expect(page).to have_content @build.name
    end
  end
78
end