BigW Consortium Gitlab

merge_requests.rb 1.71 KB
Newer Older
1 2 3 4 5 6 7 8
require 'spec_helper'

describe Projects::MergeRequestsController, '(JavaScript fixtures)', type: :controller do
  include JavaScriptFixturesHelpers

  let(:admin) { create(:admin) }
  let(:namespace) { create(:namespace, name: 'frontend-fixtures' )}
  let(:project) { create(:project, namespace: namespace, path: 'merge-requests-project') }
9
  let(:merge_request) { create(:merge_request, :with_diffs, source_project: project, target_project: project, description: '- [ ] Task List Item') }
10
  let(:merged_merge_request) { create(:merge_request, :merged, source_project: project, target_project: project) }
11 12 13 14 15 16 17 18
  let(:pipeline) do
    create(
      :ci_pipeline,
      project: merge_request.source_project,
      ref: merge_request.source_branch,
      sha: merge_request.diff_head_sha
    )
  end
19 20 21 22 23 24 25 26 27 28 29 30

  render_views

  before(:all) do
    clean_frontend_fixtures('merge_requests/')
  end

  before(:each) do
    sign_in(admin)
  end

  it 'merge_requests/merge_request_with_task_list.html.raw' do |example|
31 32
    create(:ci_build, :pending, pipeline: pipeline)

33 34 35
    render_merge_request(example.description, merge_request)
  end

36 37 38 39 40 41
  it 'merge_requests/merged_merge_request.html.raw' do |example|
    allow_any_instance_of(MergeRequest).to receive(:source_branch_exists?).and_return(true)
    allow_any_instance_of(MergeRequest).to receive(:can_remove_source_branch?).and_return(true)
    render_merge_request(example.description, merged_merge_request)
  end

42 43 44 45 46
  private

  def render_merge_request(fixture_file_name, merge_request)
    get :show,
      namespace_id: project.namespace.to_param,
47
      project_id: project,
48 49 50 51 52 53
      id: merge_request.to_param

    expect(response).to be_success
    store_frontend_fixture(response, fixture_file_name)
  end
end