summaryrefslogtreecommitdiff
path: root/spec/models/discussion_spec.rb
diff options
context:
space:
mode:
authorDouwe Maan <douwe@selenight.nl>2017-03-09 19:29:11 -0600
committerLuke "Jared" Bennett <lbennett@gitlab.com>2017-04-05 17:44:14 +0100
commit08bbb9fce66cb46d3262e6cd4c4379b59f065be0 (patch)
tree159eeb7ca43419f29926d6e77637db18bddd20a9 /spec/models/discussion_spec.rb
parent8bdfee8ba5fb0a8f48501e63274c8f9ce5708007 (diff)
downloadgitlab-ce-08bbb9fce66cb46d3262e6cd4c4379b59f065be0.tar.gz
Add option to start a new discussion on an MR
Diffstat (limited to 'spec/models/discussion_spec.rb')
-rw-r--r--spec/models/discussion_spec.rb97
1 files changed, 57 insertions, 40 deletions
diff --git a/spec/models/discussion_spec.rb b/spec/models/discussion_spec.rb
index bc32fadd391..f48450589d0 100644
--- a/spec/models/discussion_spec.rb
+++ b/spec/models/discussion_spec.rb
@@ -3,14 +3,34 @@ require 'spec_helper'
describe Discussion, model: true do
subject { described_class.new([first_note, second_note, third_note]) }
- let(:first_note) { create(:diff_note_on_merge_request) }
- let(:second_note) { create(:diff_note_on_merge_request) }
- let(:third_note) { create(:diff_note_on_merge_request) }
+ let(:first_note) { create(:discussion_note_on_merge_request) }
+ let(:second_note) { create(:discussion_note_on_merge_request) }
+ let(:third_note) { create(:discussion_note_on_merge_request) }
+
+ describe '.build' do
+ # TODO: Test
+ end
+
+ describe '.build_collection' do
+ # TODO: Test
+ end
+
+ describe '#id' do
+ # TODO: Test
+ end
+
+ describe '#original_id' do
+ # TODO: Test
+ end
+
+ describe '#potentially_resolvable?' do
+ # TODO: Test
+ end
describe "#resolvable?" do
- context "when a diff discussion" do
+ context "when potentially resolvable" do
before do
- allow(subject).to receive(:diff_discussion?).and_return(true)
+ allow(subject).to receive(:discussion_resolvable?).and_return(true)
end
context "when all notes are unresolvable" do
@@ -50,9 +70,9 @@ describe Discussion, model: true do
end
end
- context "when not a diff discussion" do
+ context "when not potentially resolvable" do
before do
- allow(subject).to receive(:diff_discussion?).and_return(false)
+ allow(subject).to receive(:discussion_resolvable?).and_return(false)
end
it "returns false" do
@@ -530,10 +550,14 @@ describe Discussion, model: true do
end
end
+ describe "#last_resolved_note" do
+ # TODO: Test
+ end
+
describe "#collapsed?" do
- context "when a diff discussion" do
+ context "when potentially resolvable" do
before do
- allow(subject).to receive(:diff_discussion?).and_return(true)
+ allow(subject).to receive(:discussion_resolvable?).and_return(true)
end
context "when resolvable" do
@@ -567,31 +591,43 @@ describe Discussion, model: true do
allow(subject).to receive(:resolvable?).and_return(false)
end
- context "when active" do
+ context "when a diff discussion" do
before do
- allow(subject).to receive(:active?).and_return(true)
+ allow(subject).to receive(:diff_discussion?).and_return(true)
end
- it "returns false" do
- expect(subject.collapsed?).to be false
+ context "when active" do
+ before do
+ allow(subject).to receive(:active?).and_return(true)
+ end
+
+ it "returns false" do
+ expect(subject.collapsed?).to be false
+ end
end
- end
- context "when outdated" do
- before do
- allow(subject).to receive(:active?).and_return(false)
+ context "when outdated" do
+ before do
+ allow(subject).to receive(:active?).and_return(false)
+ end
+
+ it "returns true" do
+ expect(subject.collapsed?).to be true
+ end
end
+ end
- it "returns true" do
- expect(subject.collapsed?).to be true
+ context "when not a diff discussion" do
+ it "returns false" do
+ expect(subject.collapsed?).to be false
end
end
end
end
- context "when not a diff discussion" do
+ context "when not potentially resolvable" do
before do
- allow(subject).to receive(:diff_discussion?).and_return(false)
+ allow(subject).to receive(:discussion_resolvable?).and_return(false)
end
it "returns false" do
@@ -599,23 +635,4 @@ describe Discussion, model: true do
end
end
end
-
- 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
- expect(subject.diff_lines.count).to be > described_class::NUMBER_OF_TRUNCATED_DIFF_LINES
-
- expect(truncated_lines.count).to be <= described_class::NUMBER_OF_TRUNCATED_DIFF_LINES
- 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