diff --git a/app/models/article.rb b/app/models/article.rb index 91e4bae..d60bb0f 100644 --- a/app/models/article.rb +++ b/app/models/article.rb @@ -5,6 +5,8 @@ class Article < ActiveRecord::Base validates_uniqueness_of :slug, :scope => ['profile_id', 'parent_id'], :message => _('%{fn} (the code generated from the article name) is already being used by another article.') + belongs_to :last_changed_by, :class_name => Person.name, :foreign_key => 'last_changed_by_id' + acts_as_taggable acts_as_filesystem diff --git a/test/unit/article_test.rb b/test/unit/article_test.rb index e60002c..8f7fde1 100644 --- a/test/unit/article_test.rb +++ b/test/unit/article_test.rb @@ -117,4 +117,18 @@ class ArticleTest < Test::Unit::TestCase assert_equal "/#{profile.identifier}/aaa/bbb", b.public_path end + should 'record who did the last change' do + a = profile.articles.build(:name => 'test') + + # must be a person + assert_raise ActiveRecord::AssociationTypeMismatch do + a.last_changed_by = Profile.new + end + assert_nothing_raised do + a.last_changed_by = Person.new + a.save! + end + + end + end -- libgit2 0.21.2