BigW Consortium Gitlab

user_resolves_outdated_diff_discussions_spec.rb 2.26 KB
Newer Older
1 2
require 'spec_helper'

3
feature 'Merge request > User resolves outdated diff discussions', :js do
4
  let(:project) { create(:project, :repository, :public) }
5

6 7 8 9 10 11
  let(:merge_request) do
    create(:merge_request, source_project: project, source_branch: 'csv', target_branch: 'master')
  end

  let(:outdated_diff_refs) { project.commit('926c6595b263b2a40da6b17f3e3b7ea08344fad6').diff_refs }
  let(:current_diff_refs) { merge_request.diff_refs }
12 13 14

  let(:outdated_position) do
    Gitlab::Diff::Position.new(
15 16
      old_path: 'files/csv/Book1.csv',
      new_path: 'files/csv/Book1.csv',
17 18 19 20 21 22
      old_line: nil,
      new_line: 9,
      diff_refs: outdated_diff_refs
    )
  end

23 24 25 26 27 28 29 30
  let(:current_position) do
    Gitlab::Diff::Position.new(
      old_path: 'files/csv/Book1.csv',
      new_path: 'files/csv/Book1.csv',
      old_line: nil,
      new_line: 1,
      diff_refs: current_diff_refs
    )
31 32
  end

33 34 35 36 37 38
  let!(:outdated_discussion) do
    create(:diff_note_on_merge_request,
           project: project,
           noteable: merge_request,
           position: outdated_position).to_discussion
  end
39

40 41 42 43 44 45
  let!(:current_discussion) do
    create(:diff_note_on_merge_request,
           noteable: merge_request,
           project: project,
           position: current_position).to_discussion
  end
46

47 48
  before do
    sign_in(merge_request.author)
49 50
  end

51
  context 'when a discussion was resolved by a push' do
52
    before do
53 54 55 56 57 58 59 60 61
      project.update!(resolve_outdated_diff_discussions: true)

      merge_request.update_diff_discussion_positions(
        old_diff_refs: outdated_diff_refs,
        new_diff_refs: current_diff_refs,
        current_user: merge_request.author
      )

      visit project_merge_request_path(project, merge_request)
62 63
    end

64 65 66 67
    it 'shows that as automatically resolved' do
      within(".discussion[data-discussion-id='#{outdated_discussion.id}']") do
        expect(page).to have_css('.discussion-body', visible: false)
        expect(page).to have_content('Automatically resolved')
68 69 70
      end
    end

71 72 73 74
    it 'does not show that for active discussions' do
      within(".discussion[data-discussion-id='#{current_discussion.id}']") do
        expect(page).to have_css('.discussion-body', visible: true)
        expect(page).not_to have_content('Automatically resolved')
75 76 77 78
      end
    end
  end
end