public
Fork of halorgium/mephisto
Description: A mirror of the mephisto code-base
Homepage: http://mephistoblog.com/
Clone URL: git://github.com/technoweenie/mephisto.git
Click here to lend your support to: mephisto and make a donation at www.pledgie.com !
Don't generate an article event for unversioned changes. [Marcus Brito]

git-svn-id: http://svn.techno-weenie.net/projects/mephisto/trunk@2903 
567b1171-46fb-0310-a4c9-b4bef9110e78
technoweenie (author)
Thu Jun 14 08:13:28 -0700 2007
commit  84bd69e4469e500cb2cba14071a1cc28e9dda8f6
tree    4d461ae4a956d2958fcb7876adacb2571ddc364d
parent  ac57a508d1ccbd05cdd1737eeab79148f05136a3
...
1
2
 
 
3
4
5
...
1
2
3
4
5
6
7
0
@@ -1,5 +1,7 @@
0
 * SVN *
0
 
0
+* Don't generate an article event for unversioned changes. [Marcus Brito]
0
+
0
 * Switch to will_paginate plugin [Mislav]
0
 
0
 * unit test fixes for those not using mysql or psql [Mislav]
...
1
2
3
4
5
6
7
 
 
 
 
 
 
 
8
9
10
...
15
16
17
18
19
 
...
1
2
 
 
 
 
 
3
4
5
6
7
8
9
10
11
12
...
17
18
19
 
20
21
0
@@ -1,10 +1,12 @@
0
 class ArticleObserver < ActiveRecord::Observer
0
   def before_save(record)
0
- @event = Event.new
0
- @event.mode = case
0
- when record.is_a?(Comment) then 'comment'
0
- when record.new_record? then 'publish'
0
- else 'edit'
0
+ if (record.is_a?(Article) && record.save_version?) || record.is_a?(Comment)
0
+ @event = Event.new
0
+ @event.mode = case
0
+ when record.is_a?(Comment) then 'comment'
0
+ when record.new_record? then 'publish'
0
+ else 'edit'
0
+ end
0
     end
0
   end
0
 
0
@@ -15,4 +17,4 @@ class ArticleObserver < ActiveRecord::Observer
0
   end
0
 
0
   alias after_destroy after_save
0
-end
0
\ No newline at end of file
0
+end
...
28
29
30
 
 
 
 
 
 
 
 
31
32
33
...
28
29
30
31
32
33
34
35
36
37
38
39
40
41
0
@@ -28,6 +28,14 @@ class EventTest < Test::Unit::TestCase
0
     end
0
   end
0
 
0
+ def test_should_not_create_article_event_for_save_without_revision
0
+ assert_no_event_created do
0
+ article = contents(:welcome)
0
+ article.body = 'bar.'
0
+ article.save_without_revision!
0
+ end
0
+ end
0
+
0
   def test_should_not_create_comment_article_event_for_unnaproved
0
     assert_no_event_created do
0
       contents(:welcome).comments.create :body => 'test comment', :author => 'bob', :author_ip => '127.0.0.1'

Comments

    No one has commented yet.