BigW Consortium Gitlab

discussion_on_diff_spec.rb 779 Bytes
Newer Older
Douwe Maan committed
1 2
require 'spec_helper'

3
describe DiscussionOnDiff, model: true do
Douwe Maan committed
4 5 6 7 8 9 10
  subject { create(:diff_note_on_merge_request).to_discussion }

  describe "#truncated_diff_lines" do
    let(:truncated_lines) { subject.truncated_diff_lines }

    context "when diff is greater than allowed number of truncated diff lines " do
      it "returns fewer lines"  do
11
        expect(subject.diff_lines.count).to be > DiffDiscussion::NUMBER_OF_TRUNCATED_DIFF_LINES
Douwe Maan committed
12

13
        expect(truncated_lines.count).to be <= DiffDiscussion::NUMBER_OF_TRUNCATED_DIFF_LINES
Douwe Maan committed
14 15 16 17 18 19 20 21 22 23 24
      end
    end

    context "when some diff lines are meta" do
      it "returns no meta lines"  do
        expect(subject.diff_lines).to include(be_meta)
        expect(truncated_lines).not_to include(be_meta)
      end
    end
  end
end