BigW Consortium Gitlab

_generic_commit_status.html.haml_spec.rb 1.17 KB
Newer Older
1 2 3 4 5
require 'spec_helper'

describe 'projects/generic_commit_statuses/_generic_commit_status.html.haml' do
  include Devise::Test::ControllerHelpers

6
  let(:project) { create(:project, :repository) }
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
  let(:pipeline) { create(:ci_empty_pipeline, id: 1337, project: project, sha: project.commit.id) }
  let(:generic_commit_status) { create(:generic_commit_status, pipeline: pipeline, stage: 'external', name: 'jenkins', stage_idx: 3) }

  before do
    controller.prepend_view_path('app/views/projects')
    allow(view).to receive(:can?).and_return(true)
  end

  it 'won\'t include a column with a link to its pipeline by default' do
    render partial: 'projects/generic_commit_statuses/generic_commit_status', locals: { generic_commit_status: generic_commit_status }

    expect(rendered).not_to have_link('#1337')
    expect(rendered).not_to have_text('#1337 by API')
  end

  it 'can include a column with a link to its pipeline' do
    render partial: 'projects/generic_commit_statuses/generic_commit_status', locals: { generic_commit_status: generic_commit_status, pipeline_link: true }

    expect(rendered).to have_link('#1337')
    expect(rendered).to have_text('#1337 by API')
  end
end