summaryrefslogtreecommitdiff
path: root/features/steps/shared/builds.rb
blob: f5950145348fccd7d04c59037b67ba6bff8aa387 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
module SharedBuilds
  include Spinach::DSL

  step 'project has CI enabled' do
    @project.enable_ci
  end

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

  step 'project has a recent build' do
    @pipeline = create(:ci_empty_pipeline, project: @project, sha: @project.commit.sha, ref: 'master')
    @build = create(:ci_build, :running, :coverage, :trace_artifact, pipeline: @pipeline)
  end

  step 'recent build is successful' do
    @build.success
  end

  step 'recent build failed' do
    @build.drop
  end

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

  step 'I visit recent build details page' do
    visit project_job_path(@project, @build)
  end

  step 'I visit project builds page' do
    visit project_jobs_path(@project)
  end

  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(legacy_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(legacy_artifacts_metadata: gzip)
  end

  step 'recent build has a build trace' do
    @build.trace.set('job trace')
  end

  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_project_job_artifacts_path(@project, @build)
  end

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

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

  step 'I see the build' do
    page.within('.build') do
      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
end