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 !
moved event creation to observers so that caching is not required for 
development mode

git-svn-id: http://svn.techno-weenie.net/projects/mephisto/trunk@1427 
567b1171-46fb-0310-a4c9-b4bef9110e78
technoweenie (author)
Tue Jul 25 21:33:45 -0700 2006
commit  f292f1f2b3eae690ce55653ed597f5a86bdcb442
tree    602ea78a3d4e80cdeafbab0539b1406877c26657
parent  ce6f02b286a97250db595f938819b53365373ba3
...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
 
24
25
26
...
1
2
3
 
 
 
 
 
 
 
 
 
4
5
6
7
8
 
 
 
 
 
9
10
11
12
13
0
@@ -1,26 +1,13 @@
0
 class ArticleSweeper < ActionController::Caching::Sweeper
0
   observe Article
0
 
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
- end
0
- end
0
-
0
   def after_create(record)
0
     expire_assigned_sections!(record) unless controller.nil? || record.status != :published
0
   end
0
 
0
   def after_save(record)
0
- if @event && record.is_a?(Article)
0
- @event.update_attributes :title => record.title, :body => record.body, :article => record, :user => record.updater, :site => record.site
0
- expire_overview_feed!
0
- end
0
-
0
     return if controller.nil?
0
+ expire_overview_feed! if record.is_a?(Article)
0
     pages = CachedPage.find_by_reference(record)
0
     controller.class.benchmark "Expired pages referenced by #{record.class} ##{record.id}" do
0
       pages.each { |p| controller.class.expire_page(p.url) }
...
1
2
3
4
5
6
7
8
9
10
11
...
16
17
18
19
20
21
22
23
24
25
...
1
2
3
 
 
 
 
 
4
5
6
...
11
12
13
 
 
 
 
14
15
16
0
@@ -1,11 +1,6 @@
0
 class CommentSweeper < ArticleSweeper
0
   observe Comment
0
 
0
- def after_save(record)
0
- @event.update_attributes :title => record.article.title, :body => record.body, :site => record.article.site,
0
- :article => record.article, :author => record.author, :comment => record if record.approved?
0
- end
0
-
0
   def after_update(record)
0
     return if controller.nil?
0
     expire_overview_feed!
0
@@ -16,9 +11,5 @@ class CommentSweeper < ArticleSweeper
0
     end if pages.any?
0
   end
0
 
0
- def after_destroy(record)
0
- Event.destroy_all ['comment_id = ?', record.id]
0
- end
0
-
0
   undef :after_create
0
 end
0
\ No newline at end of file
...
1
2
3
4
5
6
...
1
2
3
 
4
5
0
@@ -1,5 +1,4 @@
0
 class SectionSweeper < ArticleSweeper
0
   observe Section
0
   undef :after_create
0
- undef :before_save
0
 end
0
\ No newline at end of file
...
8
9
10
 
11
12
13
...
8
9
10
11
12
13
14
0
@@ -8,6 +8,7 @@ class TemplateSweeper < ActionController::Caching::Sweeper
0
   end
0
 
0
   def after_save(record)
0
+ return if controller.nil?
0
     controller.class.benchmark "Expired all referenced pages" do
0
       CachedPage.find(:all).each { |p| controller.class.expire_page(p.url) }
0
       CachedPage.delete_all
...
1
2
3
4
5
 
6
7
8
 
 
9
10
11
...
40
41
42
43
44
 
45
46
47
...
1
2
3
 
 
4
5
6
 
7
8
9
10
11
...
40
41
42
 
 
43
44
45
46
0
@@ -1,11 +1,11 @@
0
 class Admin::ArticlesController < Admin::BaseController
0
   with_options :only => [:create, :update] do |c|
0
     c.before_filter :set_default_section_ids
0
- c.cache_sweeper :article_sweeper
0
- c.cache_sweeper :section_sweeper
0
+ c.cache_sweeper :article_sweeper, :section_sweeper
0
     cache_sweeper :comment_sweeper, :only => [:approve, :unapprove, :destroy_comment]
0
   end
0
-
0
+
0
+ observer :article_observer, :comment_observer
0
   before_filter :check_for_new_draft, :only => [:create, :update]
0
   before_filter :convert_times_to_utc, :only => [:create, :update]
0
   
0
@@ -40,8 +40,7 @@ class Admin::ArticlesController < Admin::BaseController
0
   end
0
 
0
   def create
0
- @article = current_user.articles.create params[:article].merge(
0
- :updater => current_user, :site => site)
0
+ @article = current_user.articles.create params[:article].merge(:updater => current_user, :site => site)
0
       
0
     if @article.new_record?
0
       load_sections
...
3
4
5
6
 
7
8
9
...
13
14
15
16
 
17
18
19
...
3
4
5
 
6
7
8
9
...
13
14
15
 
16
17
18
19
0
@@ -3,7 +3,7 @@
0
 # In the development environment your application's code is reloaded on
0
 # every request. This slows down response time but is perfect for development
0
 # since you don't have to restart the webserver when you make code changes.
0
-config.cache_classes = false
0
+config.cache_classes = true
0
 
0
 # Log error messages when you accidentally call methods on nil.
0
 config.whiny_nils = true
0
@@ -13,7 +13,7 @@ config.breakpoint_server = true
0
 
0
 # Show full error reports and disable caching
0
 config.action_controller.consider_all_requests_local = true
0
-config.action_controller.perform_caching = true
0
+config.action_controller.perform_caching = false
0
 
0
 # Don't care if the mailer can't send
0
 config.action_mailer.raise_delivery_errors = false
...
28
29
30
31
 
32
33
34
35
 
36
37
38
39
 
40
41
42
43
 
44
45
46
47
 
48
49
50
51
52
53
54
55
56
57
58
59
60
61
...
63
64
65
66
67
 
 
68
69
70
71
 
72
73
74
 
75
76
77
78
79
80
 
81
82
83
...
28
29
30
 
31
32
33
34
 
35
36
37
38
 
39
40
41
42
 
43
44
45
46
 
47
48
49
50
51
 
52
53
54
55
56
 
57
58
59
...
61
62
63
 
 
64
65
66
67
68
 
69
70
71
 
72
73
74
75
76
77
 
78
79
80
81
0
@@ -28,34 +28,32 @@ class Admin::UsersControllerTest < Test::Unit::TestCase
0
   end
0
 
0
   def test_should_update_email_and_password
0
- post :update, :id => users(:quentin).login, :user => { :email => 'foo', :password => 'testy', :password_confirmation => 'testy' }
0
+ post :update, :id => users(:quentin).id, :user => { :email => 'foo', :password => 'testy', :password_confirmation => 'testy' }
0
     users(:quentin).reload
0
     assert_equal 'foo', users(:quentin).email
0
     assert_equal users(:quentin), User.authenticate('quentin', 'testy')
0
- assert_redirected_to :action => 'show', :id => users(:quentin).login
0
+ assert_response :success
0
   end
0
 
0
   def test_should_leave_password_alone
0
- post :update, :id => users(:quentin).login, :user => { :email => 'foo', :password => '', :password_confirmation => '' }
0
+ post :update, :id => users(:quentin).id, :user => { :email => 'foo', :password => '', :password_confirmation => '' }
0
     users(:quentin).reload
0
     assert_equal 'foo', users(:quentin).email
0
     assert_equal users(:quentin), User.authenticate('quentin', 'quentin')
0
- assert_redirected_to :action => 'show', :id => users(:quentin).login
0
+ assert_response :success
0
   end
0
 
0
   def test_should_show_error_while_updating
0
- post :update, :id => users(:quentin).login, :user => { :email => 'foo', :password => 'tea', :password_confirmation => '' }
0
+ post :update, :id => users(:quentin).id, :user => { :email => 'foo', :password => 'tea', :password_confirmation => '' }
0
     users(:quentin).reload
0
     assert_equal 'quentin@example.com', users(:quentin).email
0
     assert_equal users(:quentin), User.authenticate('quentin', 'quentin')
0
     assert_response :success
0
- assert_template 'show'
0
   end
0
 
0
   def test_should_show_error_while_creating
0
     post :create, :user => { :email => 'foo', :password => 'tea', :password_confirmation => '' }
0
     assert_response :success
0
- assert_template 'new'
0
   end
0
 
0
   def test_should_not_upload_nonexistent_file
0
@@ -63,21 +61,21 @@ class Admin::UsersControllerTest < Test::Unit::TestCase
0
   end
0
 
0
   def test_should_show_correct_form_action
0
- get :show, :id => 'quentin'
0
- assert_tag :tag => 'form', :attributes => { :action => '/admin/users/update/quentin' }
0
+ get :show, :id => users(:quentin).id
0
+ assert_tag :tag => 'form', :attributes => { :action => '/admin/users/update/1' }
0
   end
0
 
0
   def test_should_highlight_correct_filter
0
- get :show, :id => 'quentin'
0
+ get :show, :id => users(:quentin).id
0
     assert_tag :tag => 'select', :attributes => { :id => 'user_filters' },
0
       :descendant => { :tag => 'option', :attributes => { :selected => 'selected', :value => 'textile_filter' } }
0
- get :show, :id => 'arthur'
0
+ get :show, :id => users(:arthur).id
0
     assert_tag :tag => 'select', :attributes => { :id => 'user_filters' },
0
       :descendant => { :tag => 'option', :attributes => { :selected => 'selected', :value => 'markdown_filter' } }
0
   end
0
 
0
   def test_should_save_new_filter
0
- post :update, :id => 'quentin', :user => { :filters => ['markdown_filter'] }
0
+ post :update, :id => '1', :user => { :filters => ['markdown_filter'] }
0
     users(:quentin).reload
0
     assert_equal :markdown_filter, users(:quentin).filters.first
0
   end
...
4
5
6
7
8
 
9
10
11
...
4
5
6
 
 
7
8
9
10
0
@@ -4,8 +4,7 @@ class EventTest < Test::Unit::TestCase
0
   fixtures :events, :contents, :users, :sites
0
 
0
   def setup
0
- ArticleSweeper.instance
0
- CommentSweeper.instance
0
+ [ArticleObserver, CommentObserver, ArticleSweeper, CommentSweeper].each &:instance
0
   end
0
 
0
   def test_should_create_new_article_event

Comments

    No one has commented yet.