Commit 296cbdb4fcf71c81c4a4bb1a0e8443a0726fb340
1 parent
a5c0c0f3
Exists in
master
and in
27 other branches
Limit creation of article versions
(ActionItem3124)
Showing
2 changed files
with
10 additions
and
0 deletions
Show diff stats
app/models/article.rb
@@ -203,6 +203,10 @@ class Article < ActiveRecord::Base | @@ -203,6 +203,10 @@ class Article < ActiveRecord::Base | ||
203 | acts_as_versioned | 203 | acts_as_versioned |
204 | self.non_versioned_columns << 'setting' | 204 | self.non_versioned_columns << 'setting' |
205 | 205 | ||
206 | + def version_condition_met? | ||
207 | + (['name', 'body', 'abstract', 'filename', 'start_date', 'end_date', 'image_id', 'license_id'] & changed).length > 0 | ||
208 | + end | ||
209 | + | ||
206 | def comment_data | 210 | def comment_data |
207 | comments.map {|item| [item.title, item.body].join(' ') }.join(' ') | 211 | comments.map {|item| [item.title, item.body].join(' ') }.join(' ') |
208 | end | 212 | end |
test/unit/article_test.rb
@@ -1825,4 +1825,10 @@ class ArticleTest < ActiveSupport::TestCase | @@ -1825,4 +1825,10 @@ class ArticleTest < ActiveSupport::TestCase | ||
1825 | assert_equivalent [c3], Article.with_types(['Event']) | 1825 | assert_equivalent [c3], Article.with_types(['Event']) |
1826 | end | 1826 | end |
1827 | 1827 | ||
1828 | + should 'not create version when receive a comment' do | ||
1829 | + a = Article.create!(:name => 'my article', :body => 'my text', :profile_id => profile.id) | ||
1830 | + Comment.create!(:title => 'test', :body => 'asdsad', :author => profile, :source => a) | ||
1831 | + assert_equal 1, a.versions.count | ||
1832 | + end | ||
1833 | + | ||
1828 | end | 1834 | end |