Commit 296cbdb4fcf71c81c4a4bb1a0e8443a0726fb340

Authored by Victor Costa
1 parent a5c0c0f3

Limit creation of article versions

(ActionItem3124)
app/models/article.rb
... ... @@ -203,6 +203,10 @@ class Article < ActiveRecord::Base
203 203 acts_as_versioned
204 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 210 def comment_data
207 211 comments.map {|item| [item.title, item.body].join(' ') }.join(' ')
208 212 end
... ...
test/unit/article_test.rb
... ... @@ -1825,4 +1825,10 @@ class ArticleTest &lt; ActiveSupport::TestCase
1825 1825 assert_equivalent [c3], Article.with_types(['Event'])
1826 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 1834 end
... ...