From 3f2c283c269d68bfa0aa9ea9795a2056280ce34f Mon Sep 17 00:00:00 2001 From: AntonioTerceiro Date: Fri, 30 Nov 2007 15:18:47 +0000 Subject: [PATCH] ActionItem21: recording who did the last change to an article --- app/models/article.rb | 2 ++ test/unit/article_test.rb | 14 ++++++++++++++ 2 files changed, 16 insertions(+), 0 deletions(-) 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