Add method

This commit is contained in:
Katarzyna Kobierska 2016-09-06 16:48:59 +02:00
parent 81da7f1378
commit 554baec9e8
2 changed files with 20 additions and 0 deletions

View file

@ -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

View file

@ -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