show.html.haml_spec.rb 2.12 KB
Newer Older
1 2 3
require 'spec_helper'

describe 'projects/pipelines/show' do
4
  include Devise::Test::ControllerHelpers
5

6
  let(:user) { create(:user) }
7
  let(:project) { create(:project, :repository) }
8 9 10 11 12 13 14

  let(:pipeline) do
    create(:ci_empty_pipeline,
           project: project,
           sha: project.commit.id,
           user: user)
  end
15 16

  before do
Kamil Trzcinski's avatar
Kamil Trzcinski committed
17 18
    controller.prepend_view_path('app/views/projects')

19 20 21 22 23 24 25
    create_build('build', 0, 'build', :success)
    create_build('test', 1, 'rspec 0:2', :pending)
    create_build('test', 1, 'rspec 1:2', :running)
    create_build('test', 1, 'spinach 0:2', :created)
    create_build('test', 1, 'spinach 1:2', :created)
    create_build('test', 1, 'audit', :created)
    create_build('deploy', 2, 'production', :created)
26 27 28 29

    create(:generic_commit_status, pipeline: pipeline, stage: 'external', name: 'jenkins', stage_idx: 3)

    assign(:project, project)
30
    assign(:pipeline, pipeline.present(current_user: user))
31
    assign(:commit, project.commit)
32 33 34 35 36 37 38

    allow(view).to receive(:can?).and_return(true)
  end

  it 'shows a graph with grouped stages' do
    render

Filipa Lacerda's avatar
Filipa Lacerda committed
39
    expect(rendered).to have_css('.js-pipeline-graph')
40
    expect(rendered).to have_css('.js-grouped-pipeline-dropdown')
41

42 43 44 45 46 47
    # header
    expect(rendered).to have_text("##{pipeline.id}")
    expect(rendered).to have_css('time', text: pipeline.created_at.strftime("%b %d, %Y"))
    expect(rendered).to have_selector(%Q(img[alt$="#{pipeline.user.name}'s avatar"]))
    expect(rendered).to have_link(pipeline.user.name, href: user_path(pipeline.user))

48 49 50 51 52 53 54 55
    # stages
    expect(rendered).to have_text('Build')
    expect(rendered).to have_text('Test')
    expect(rendered).to have_text('Deploy')
    expect(rendered).to have_text('External')

    # builds
    expect(rendered).to have_text('rspec')
56
    expect(rendered).to have_text('spinach')
Kamil Trzcinski's avatar
Kamil Trzcinski committed
57
    expect(rendered).to have_text('rspec 0:2')
58 59 60 61 62 63
    expect(rendered).to have_text('production')
    expect(rendered).to have_text('jenkins')
  end

  private

64 65
  def create_build(stage, stage_idx, name, status)
    create(:ci_build, pipeline: pipeline, stage: stage, stage_idx: stage_idx, name: name, status: status)
66 67
  end
end