Add method to Note to create notes about status changes.
This commit is contained in:
parent
00ec81eacb
commit
02924de3e1
2 changed files with 27 additions and 0 deletions
|
@ -42,6 +42,14 @@ class Note < ActiveRecord::Base
|
|||
|
||||
mount_uploader :attachment, AttachmentUploader
|
||||
|
||||
def self.create_status_change_note(noteable, author, status)
|
||||
create({ :noteable => noteable,
|
||||
:project => noteable.project,
|
||||
:author => author,
|
||||
:note => "_Status changed to #{status}_" },
|
||||
:without_protection => true)
|
||||
end
|
||||
|
||||
def notify
|
||||
@notify ||= false
|
||||
end
|
||||
|
|
|
@ -70,6 +70,25 @@ describe Note do
|
|||
end
|
||||
end
|
||||
|
||||
describe '#create_status_change_note' do
|
||||
let(:project) { Factory.create(:project) }
|
||||
let(:thing) { Factory.create(:issue, :project => project) }
|
||||
let(:author) { Factory(:user) }
|
||||
let(:status) { 'new_status' }
|
||||
|
||||
subject { Note.create_status_change_note(thing, author, status) }
|
||||
|
||||
it 'creates and saves a Note' do
|
||||
should be_a Note
|
||||
subject.id.should_not be_nil
|
||||
end
|
||||
|
||||
its(:noteable) { should == thing }
|
||||
its(:project) { should == thing.project }
|
||||
its(:author) { should == author }
|
||||
its(:note) { should =~ /Status changed to #{status}/ }
|
||||
end
|
||||
|
||||
describe :authorization do
|
||||
before do
|
||||
@p1 = project
|
||||
|
|
Loading…
Reference in a new issue