diff options
author | Lin Jen-Shin <godfat@godfat.org> | 2016-08-19 12:41:53 +0300 |
---|---|---|
committer | Lin Jen-Shin <godfat@godfat.org> | 2016-08-19 12:41:53 +0300 |
commit | 9c9259cc6a08d8b2f8f827598aba06baae7b31f6 (patch) | |
tree | 65e103ef2126a46e0ed693f91d5e40a371d9c2ca /spec/models/merge_request_spec.rb | |
parent | 62127dc95a28d6e7018a72c1a643dbf828a806d4 (diff) | |
parent | 12fe6a6fd733110acc72aa0f5bdaec2b1fa1f358 (diff) |
Merge remote-tracking branch 'upstream/master' into artifacts-from-ref-and-build-name
* upstream/master: (195 commits)
Fix expansion of discussions in diff
Improve performance of MR show page
Fix jumping between discussions on changes tab
Update doorkeeper to 4.2.0
Fix MR note discussion ID
Handle legacy sort order values
Refactor `find_for_git_client` and its related methods.
Remove right margin on Jump button icon
Fix bug causing “Jump to discussion” button not to show
Small refactor and syntax fixes.
Removed unnecessary service for user retrieval and improved API error message.
Added documentation and CHANGELOG item
Added checks for 2FA to the API `/sessions` endpoint and the Resource Owner Password Credentials flow.
Fix behavior around commands with optional arguments
Fix behavior of label_ids and add/remove_label_ids
Remove unneeded aliases
Do not expose projects on deployments
Incorporate feedback
Docs for API endpoints
Expose project for environments
...
Diffstat (limited to 'spec/models/merge_request_spec.rb')
-rw-r--r-- | spec/models/merge_request_spec.rb | 92 |
1 files changed, 92 insertions, 0 deletions
diff --git a/spec/models/merge_request_spec.rb b/spec/models/merge_request_spec.rb index c57d754d5d0..b6697d0087e 100644 --- a/spec/models/merge_request_spec.rb +++ b/spec/models/merge_request_spec.rb @@ -784,6 +784,98 @@ describe MergeRequest, models: true do end end + context "discussion status" do + let(:first_discussion) { Discussion.new([create(:diff_note_on_merge_request)]) } + let(:second_discussion) { Discussion.new([create(:diff_note_on_merge_request)]) } + let(:third_discussion) { Discussion.new([create(:diff_note_on_merge_request)]) } + + before do + allow(subject).to receive(:diff_discussions).and_return([first_discussion, second_discussion, third_discussion]) + end + + describe "#discussions_resolvable?" do + context "when all discussions are unresolvable" do + before do + allow(first_discussion).to receive(:resolvable?).and_return(false) + allow(second_discussion).to receive(:resolvable?).and_return(false) + allow(third_discussion).to receive(:resolvable?).and_return(false) + end + + it "returns false" do + expect(subject.discussions_resolvable?).to be false + end + end + + context "when some discussions are unresolvable and some discussions are resolvable" do + before do + allow(first_discussion).to receive(:resolvable?).and_return(true) + allow(second_discussion).to receive(:resolvable?).and_return(false) + allow(third_discussion).to receive(:resolvable?).and_return(true) + end + + it "returns true" do + expect(subject.discussions_resolvable?).to be true + end + end + + context "when all discussions are resolvable" do + before do + allow(first_discussion).to receive(:resolvable?).and_return(true) + allow(second_discussion).to receive(:resolvable?).and_return(true) + allow(third_discussion).to receive(:resolvable?).and_return(true) + end + + it "returns true" do + expect(subject.discussions_resolvable?).to be true + end + end + end + + describe "#discussions_resolved?" do + context "when discussions are not resolvable" do + before do + allow(subject).to receive(:discussions_resolvable?).and_return(false) + end + + it "returns false" do + expect(subject.discussions_resolved?).to be false + end + end + + context "when discussions are resolvable" do + before do + allow(subject).to receive(:discussions_resolvable?).and_return(true) + + allow(first_discussion).to receive(:resolvable?).and_return(true) + allow(second_discussion).to receive(:resolvable?).and_return(false) + allow(third_discussion).to receive(:resolvable?).and_return(true) + end + + context "when all resolvable discussions are resolved" do + before do + allow(first_discussion).to receive(:resolved?).and_return(true) + allow(third_discussion).to receive(:resolved?).and_return(true) + end + + it "returns true" do + expect(subject.discussions_resolved?).to be true + end + end + + context "when some resolvable discussions are not resolved" do + before do + allow(first_discussion).to receive(:resolved?).and_return(true) + allow(third_discussion).to receive(:resolved?).and_return(false) + end + + it "returns false" do + expect(subject.discussions_resolved?).to be false + end + end + end + end + end + describe '#conflicts_can_be_resolved_in_ui?' do def create_merge_request(source_branch) create(:merge_request, source_branch: source_branch, target_branch: 'conflict-start') do |mr| |