Commit 3f2c283c269d68bfa0aa9ea9795a2056280ce34f
1 parent
5905980f
Exists in
master
and in
22 other branches
ActionItem21: recording who did the last change to an article
git-svn-id: https://svn.colivre.coop.br/svn/noosfero/trunk@982 3f533792-8f58-4932-b0fe-aaf55b0a4547
Showing
2 changed files
with
16 additions
and
0 deletions
Show diff stats
app/models/article.rb
| ... | ... | @@ -5,6 +5,8 @@ class Article < ActiveRecord::Base |
| 5 | 5 | |
| 6 | 6 | 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.') |
| 7 | 7 | |
| 8 | + belongs_to :last_changed_by, :class_name => Person.name, :foreign_key => 'last_changed_by_id' | |
| 9 | + | |
| 8 | 10 | acts_as_taggable |
| 9 | 11 | |
| 10 | 12 | acts_as_filesystem | ... | ... |
test/unit/article_test.rb
| ... | ... | @@ -117,4 +117,18 @@ class ArticleTest < Test::Unit::TestCase |
| 117 | 117 | assert_equal "/#{profile.identifier}/aaa/bbb", b.public_path |
| 118 | 118 | end |
| 119 | 119 | |
| 120 | + should 'record who did the last change' do | |
| 121 | + a = profile.articles.build(:name => 'test') | |
| 122 | + | |
| 123 | + # must be a person | |
| 124 | + assert_raise ActiveRecord::AssociationTypeMismatch do | |
| 125 | + a.last_changed_by = Profile.new | |
| 126 | + end | |
| 127 | + assert_nothing_raised do | |
| 128 | + a.last_changed_by = Person.new | |
| 129 | + a.save! | |
| 130 | + end | |
| 131 | + | |
| 132 | + end | |
| 133 | + | |
| 120 | 134 | end | ... | ... |