diff --git a/app/models/merge_request.rb b/app/models/merge_request.rb index f752a4fd1ccbc1f0471e10b742c178e2d9fb3c9e..5986a464bbc5db670230988f36fcb2267dd9715b 100644 --- a/app/models/merge_request.rb +++ b/app/models/merge_request.rb @@ -327,6 +327,13 @@ class MergeRequest < ActiveRecord::Base !source_project.forked_from?(target_project) end + def can_reopen? + return false if closed_without_fork? || closed_without_source_project? + return true if closed? + + # false + end + def ensure_merge_request_diff merge_request_diff || create_merge_request_diff end diff --git a/spec/models/merge_request_spec.rb b/spec/models/merge_request_spec.rb index e223d51aa6a800f865decffbfc6a941b4c3dbd11..4780d9fb3fe9b231ae6fccfd4870eeab4385f138 100644 --- a/spec/models/merge_request_spec.rb +++ b/spec/models/merge_request_spec.rb @@ -1076,4 +1076,17 @@ describe MergeRequest, models: true do end end end + + describe '#can_reopen?' do + it "returns true" do + subject.close + binding.pry + + expect(subject.can_reopen?).to be_truthy + end + + it "returns false" do + expect(subject.can_reopen?).to be_falsey + end + end end