<commit_before>require 'spec_helper'

describe 'projects/merge_requests/show.html.haml' do
  include Devise::TestHelpers

  let(:project) { create(:project) }
  let(:fork_project) { create(:project, forked_from_project: project) }

  let(:closed_merge_request) do
    create(:closed_merge_request,
      source_project: fork_project,
      source_branch: 'add-submodule-version-bump',
      target_branch: 'master',
      target_project: project)
  end

  before do
    assign(:project, project)
    assign(:merge_request, closed_merge_request)
    assign(:commits_count, 0)

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

  context 'when the merge request is closed' do
    it 'shows the "Reopen" button' do
      render

      expect(rendered).to have_css('a', visible: true, text: 'Reopen')
      expect(rendered).to have_css('a', visible: false, text: 'Close')
    end

    it 'does not show the "Reopen" button when the source project does not exist' do
      fork_project.destroy

      render

      expect(rendered).to have_css('a', visible: false, text: 'Reopen')
      expect(rendered).to have_css('a', visible: false, text: 'Close')
    end
  end
end<commit_msg>Fix test<commit_after>require 'spec_helper'

describe 'projects/merge_requests/show.html.haml' do
  include Devise::TestHelpers

  let(:user) { create(:user) }
  let(:project) { create(:project) }
  let(:fork_project) { create(:project, forked_from_project: project) }
  let(:unlink_project) { Projects::UnlinkForkService.new(fork_project, user) }

  let(:closed_merge_request) do
    create(:closed_merge_request,
      source_project: fork_project,
      target_project: project,
      author: user)
  end

  before do
    assign(:project, project)
    assign(:merge_request, closed_merge_request)
    assign(:commits_count, 0)

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

  context 'when the merge request is closed' do
    it 'shows the "Reopen" button' do
      render

      expect(rendered).to have_css('a', visible: true, text: 'Reopen')
      expect(rendered).to have_css('a', visible: false, text: 'Close')
    end

    it 'does not show the "Reopen" button when the source project does not exist' do
      unlink_project.execute
      closed_merge_request.reload

      render

      expect(rendered).to have_css('a', visible: false, text: 'Reopen')
      expect(rendered).to have_css('a', visible: false, text: 'Close')
    end
  end
end
{'fraction_non_alphanumeric': 0.11646914589293011, 'fraction_numerical': 0.0008173273395995096, 'mean_word_length': 3.905811623246493, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '528643', 'n_tokens_mistral': 791, 'n_tokens_neox': 756, 'n_words': 196}