Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Create a story changeset on note save

  • Loading branch information...
commit 62044e90efece20b9f0c84cb33ad4c7a43d60e91 1 parent 2a60292
@malclocke malclocke authored
Showing with 13 additions and 1 deletion.
  1. +6 −0 app/models/note.rb
  2. +7 −1 test/unit/note_test.rb
View
6 app/models/note.rb
@@ -1,4 +1,10 @@
class Note < ActiveRecord::Base
belongs_to :user
belongs_to :story
+
+ after_save :create_changeset
+
+ def create_changeset
+ story.changesets.create! if story
+ end
end
View
8 test/unit/note_test.rb
@@ -6,6 +6,12 @@ def setup
@project = Factory.create(:project, :users => [@user])
@story = Factory.create(:story, :project => @project,
:requested_by => @user)
- @note = Factory.create(:note, :story => @story, :author => @user)
+ @note = Factory.create(:note, :story => @story, :user => @user)
+ end
+
+ test "creating a note creates a changeset" do
+ assert_difference ['Changeset.count', '@story.changesets.count'] do
+ Factory.create(:note, :story => @story, :user => @user)
+ end
end
end
Please sign in to comment.
Something went wrong with that request. Please try again.