Add new utility method for an issue to know whether it is being reassigned
This commit is contained in:
parent
f6035552e5
commit
2416e3cb19
2 changed files with 25 additions and 5 deletions
|
@ -27,7 +27,7 @@ class Issue < ActiveRecord::Base
|
||||||
validates :title,
|
validates :title,
|
||||||
:presence => true,
|
:presence => true,
|
||||||
:length => { :within => 0..255 }
|
:length => { :within => 0..255 }
|
||||||
|
|
||||||
validates :description,
|
validates :description,
|
||||||
:length => { :within => 0..2000 }
|
:length => { :within => 0..2000 }
|
||||||
|
|
||||||
|
@ -55,6 +55,15 @@ class Issue < ActiveRecord::Base
|
||||||
def new?
|
def new?
|
||||||
today? && created_at == updated_at
|
today? && created_at == updated_at
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Return the number of +1 comments (upvotes)
|
||||||
|
def upvotes
|
||||||
|
notes.select(&:upvote?).size
|
||||||
|
end
|
||||||
|
|
||||||
|
def is_being_reassigned?
|
||||||
|
assignee_id_changed?
|
||||||
|
end
|
||||||
end
|
end
|
||||||
# == Schema Information
|
# == Schema Information
|
||||||
#
|
#
|
||||||
|
|
|
@ -20,10 +20,21 @@ describe Issue do
|
||||||
it { Issue.should respond_to :opened }
|
it { Issue.should respond_to :opened }
|
||||||
end
|
end
|
||||||
|
|
||||||
it { Factory.create(:issue,
|
subject { Factory.create(:issue,
|
||||||
:author => Factory(:user),
|
:author => Factory(:user),
|
||||||
:assignee => Factory(:user),
|
:assignee => Factory(:user),
|
||||||
:project => Factory.create(:project)).should be_valid }
|
:project => Factory.create(:project)) }
|
||||||
|
it { should be_valid }
|
||||||
|
|
||||||
|
describe '#is_being_reassigned?' do
|
||||||
|
it 'returns true if the issue assignee has changed' do
|
||||||
|
subject.assignee = Factory(:user)
|
||||||
|
subject.is_being_reassigned?.should be_true
|
||||||
|
end
|
||||||
|
it 'returns false if the issue assignee has not changed' do
|
||||||
|
subject.is_being_reassigned?.should be_false
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
describe "plus 1" do
|
describe "plus 1" do
|
||||||
let(:project) { Factory(:project) }
|
let(:project) { Factory(:project) }
|
||||||
|
|
Loading…
Reference in a new issue