GitHub Sale: sign up for any paid plan this week and pay nothing until January 1, 2009!  [ hide ]

public
Fork of halorgium/mephisto
Description: A mirror of the mephisto code-base
Homepage: http://mephistoblog.com/
Clone URL: git://github.com/zmack/mephisto.git
refactor so that admin/comments is more restful, allow inline comment 
editing in the admin.  [court3nay]
technoweenie (author)
Sat Feb 02 17:26:47 -0800 2008
commit  a1329bde8030def40ed0cc227e34c14a2b43058f
tree    02b889394f6738fe2ee4228d0b65b173ba28a71c
parent  f3ae6c08dd171d3346cc8a18be7eaba58b498d0e
...
3
4
5
6
7
8
9
...
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
 
98
99
100
...
3
4
5
 
6
7
8
...
68
69
70
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
71
72
73
74
0
@@ -3,7 +3,6 @@ class Admin::ArticlesController < Admin::BaseController
0
   with_options :only => [:create, :update, :destroy, :upload] do |c|
0
     c.before_filter :set_default_section_ids
0
     c.cache_sweeper :article_sweeper, :assigned_section_sweeper
0
- cache_sweeper :comment_sweeper, :only => [:approve, :unapprove, :destroy_comment]
0
   end
0
 
0
   before_filter :convert_times_to_utc, :only => [:create, :update, :upload]
0
@@ -69,32 +68,7 @@ class Admin::ArticlesController < Admin::BaseController
0
   end
0
 
0
   def comments
0
- @comments =
0
- case params[:filter]
0
- when 'approved' then :comments
0
- when 'unapproved' then :unapproved_comments
0
- else :all_comments
0
- end
0
- @comments = @article.send @comments
0
- @articles = @site.unapproved_comments.count :all, :group => :article, :order => '1 desc'
0
- end
0
-
0
- # xhr baby
0
- # needs some restful lovin'
0
- def approve
0
- @comment = @article.unapproved_comments.approve(params[:comment])
0
- @comment.mark_as_ham(site, request)
0
- end
0
-
0
- def unapprove
0
- @comment = @article.comments.unapprove(params[:comment])
0
- @comment.mark_as_spam(site, request)
0
- render :action => 'approve'
0
- end
0
-
0
- def destroy_comment
0
- @comments = site.all_comments.find :all, :conditions => ['id in (?)', [params[:comment]].flatten] rescue []
0
- Comment.transaction { @comments.each(&:destroy) } if @comments.any?
0
+ redirect_to article_comments_path(@article)
0
   end
0
 
0
   def upload
...
1
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2
3
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4
5
6
...
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
27
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
62
63
64
65
66
67
68
69
70
0
@@ -1,6 +1,70 @@
0
 class Admin::CommentsController < Admin::BaseController
0
+
0
+ member_actions.push(*%w(index unapproved create edit update approve unapprove destroy close ))
0
+
0
+private
0
+
0
+ before_filter :find_site_article, :except => [ :close ]
0
+ def find_site_article
0
+ @article = site.articles.find params[:article_id]
0
+ end
0
+
0
+ cache_sweeper :comment_sweeper, :only => [:approve, :unapprove, :destroy, :create]
0
+
0
+public
0
+
0
   def index
0
- @comments = site.unapproved_comments.find(:all, :include => :article)
0
+ @comments = if params[:article_id]
0
+ @comment = Comment.new
0
+ @articles = site.unapproved_comments.count :all, :group => :article, :order => '1 desc'
0
+ @article.send case params[:filter]
0
+ when 'approved' then :comments
0
+ when 'unapproved' then :unapproved_comments
0
+ else :all_comments
0
+ end
0
+ end
0
+ end
0
+
0
+ def unapproved
0
+ site.unapproved_comments.find(:all, :include => :article)
0
+ end
0
+
0
+ def create
0
+ @comment = @article.comments.build(params[:comment].merge(
0
+ :user_id => session[:user],
0
+ :author_ip => request.remote_ip,
0
+ :user_agent => request.env['HTTP_USER_AGENT'],
0
+ :referrer => request.env['HTTP_REFERER'])
0
+ )
0
+ @comment.approved = true
0
+ @comment.save
0
+ end
0
+
0
+ def edit
0
+ @comment = @article.all_comments.find params[:id]
0
+ end
0
+
0
+ def update
0
+ @comment = @article.all_comments.find params[:id]
0
+ @comment.update_attributes(params[:comment])
0
+ end
0
+
0
+ # xhr baby
0
+ # needs some restful lovin'
0
+ def approve
0
+ @comment = @article.unapproved_comments.approve(params[:comment] || params[:id])
0
+ @comment.mark_as_ham(site, request)
0
+ end
0
+
0
+ def unapprove
0
+ @comment = @article.comments.unapprove(params[:comment] || params[:id])
0
+ @comment.mark_as_spam(site, request)
0
+ render :action => 'approve'
0
+ end
0
+
0
+ def destroy
0
+ @comments = site.all_comments.find :all, :conditions => ['id in (?)', [ (params[:comment] || params[:id])].flatten] # rescue []
0
+ Comment.transaction { @comments.each(&:destroy) } if @comments.any?
0
   end
0
   
0
   # ajax action, called from _page_nav
...
5
6
7
8
 
9
10
11
...
5
6
7
 
8
9
10
11
0
@@ -5,7 +5,7 @@
0
     <% if article.comments.size == 0 %>
0
       none
0
     <% else %>
0
- <%= link_to article.comments.size.to_s.rjust(2, '0'), { :action => 'comments', :id => article } %>
0
+ <%= link_to article.comments.size.to_s.rjust(2, '0'), { :controller => 'admin/comments', :action => 'comments', :id => article } %>
0
     <% end %>
0
   </td>
0
   <td><span class="date"><%= published_at_for article %></span></td>
...
22
23
24
25
 
26
27
28
...
22
23
24
 
25
26
27
28
0
@@ -22,7 +22,7 @@
0
       <div id="optgroup" style="display: none">
0
         <ul id="options">
0
         <% unless @article.new_record? -%>
0
- <li><%= link_to 'Edit this article', :action => 'edit', :id => @article, :version => nil %></li>
0
+ <li><%= link_to 'Edit this article', :controller => 'articles', :action => 'edit', :id => @article, :version => nil %></li>
0
         <% end -%>
0
         <% if @article.comments.any? && controller.action_name != 'comments' -%>
0
           <li><%= link_to "View comments", :controller => 'articles', :action => 'comments', :id => @article %></li>
...
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
27
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
...
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
0
0
@@ -1,57 +0,0 @@
0
-<%= render :partial => "page_nav" %>
0
-
0
-
0
-<h3 style="border-bottom:1px solid #ccc;padding:5px">Comments on <%= link_to @article.title, { :action => 'edit', :id => @article }, :style => 'border:none' %> <span class="right"><%= @article.published? ? link_to(image_tag('/images/mephisto/icons/24-zoom-in.png', :style => 'vertical-align: middle'), @site.permalink_for(@article), :style => 'border:none;') : '&nbsp;' %></span></h3>
0
-
0
-<ul class="pagelist commentlist">
0
- <% if @comments.any? %>
0
- <% @comments.reverse.each_with_index do |comment, i| -%>
0
- <li class="event-comment<%= " shade" if (i % 2 > 0) %>" id="comment-<%= comment.id %>">
0
- <% if false %>
0
- <input type="checkbox" title="" />
0
- <% end %>
0
- <a name="comment-<%= comment.id %>"></a>
0
- <% unless comment.body.blank? -%>
0
- <blockquote><p>"<%= strip_tags(comment.body) %>"</p></blockquote>
0
- <% end -%>
0
- <span class="meta">
0
- <cite>&mdash; <%= author_link_for comment %><%= %( (#{comment.author_email})) unless comment.author_email.blank? %> said <%= time_ago_in_words comment.created_at %> ago</cite>
0
-
0
- <% if comment.approved? -%>
0
- <%= link_to_remote 'Unapprove', :url => { :action => 'unapprove', :id => @article, :comment => comment } %> |
0
- <% else -%>
0
- <%= link_to_remote 'Approve', :url => { :action => 'approve', :id => @article, :comment => comment } %> |
0
- <% end -%>
0
- <%= link_to_remote 'Delete', :url => { :action => 'destroy_comment', :id => @article, :comment => comment } %>
0
- </span>
0
- </li>
0
- <% end -%>
0
- <% else %>
0
- <li class="event-none shade">This article has no <%= params[:filter].to_s.humanize.downcase %> comments.</li>
0
- <% end %>
0
-</ul>
0
-
0
-
0
-<% content_for :sidebar do %>
0
- <% if @articles.size > 1 -%>
0
- <div class="sgroup">
0
- <h3>Comments awaiting your approval</h3>
0
- <ul class="slist">
0
- <% @articles.each do |article, count| -%>
0
- <% if article.title != @article.title -%>
0
- <li><%= link_to "<strong>(#{count})</strong> #{h(article.title)}", :controller => 'articles', :action => 'comments', :id => article.id, :filter => :unapproved %></li>
0
- <% end -%>
0
- <% end -%>
0
- </ul>
0
- </div>
0
- <% end -%>
0
-<% end %>
0
-
0
-
0
-<script type="text/javascript" language="javascript" charset="utf-8">
0
-// <![CDATA[
0
- var comment = $(document.location.hash.substring(1));
0
- if(comment) Element.addClassName(comment, 'focused');
0
-
0
-// ]]>
0
-</script>
0
\ No newline at end of file
...
1
2
3
4
5
6
 
 
 
7
8
9
10
11
12
 
13
14
15
16
17
18
19
20
 
 
 
 
 
 
21
22
23
...
1
2
3
 
 
 
4
5
6
7
8
9
10
11
 
12
13
14
15
 
 
 
 
 
16
17
18
19
20
21
22
23
24
0
@@ -1,23 +1,24 @@
0
 <%= render :partial => "page_nav" %>
0
 
0
 <% fields_for :article, @version do |f| -%>
0
-<% content_for :sidebar do %>
0
- <%= render :partial => 'shared_options', :locals => { :form => f } %>
0
-<% end %>
0
+ <% content_for :sidebar do %>
0
+ <%= render :partial => 'shared_options', :locals => { :form => f } %>
0
+ <% end %>
0
 <% end %>
0
 
0
 <%= error_messages_for :article %>
0
 
0
 <% content_for :form do -%>
0
- <%= form_tag({:action => 'update', :id => @article}, {:id => 'article-form', :multipart => true}) %>
0
+ <%= form_tag({:action => 'update', :id => @article}, {:id => 'article-form', :multipart => true, :method => :put}) %>
0
 <% end -%>
0
 
0
 <% fields_for :article, @version do |f| -%>
0
-<%= render :partial => 'form', :object => f %>
0
-<p class="btns">
0
- <%= submit_tag 'Apply Changes' %>
0
- <%= submit_tag 'Save without Revision' %>
0
- <%= link_to "cancel", :controller => "articles" %></p>
0
+ <%= render :partial => 'form', :object => f %>
0
+ <p class="btns">
0
+ <%= submit_tag 'Apply Changes' %>
0
+ <%= submit_tag 'Save without Revision' %>
0
+ <%= link_to "cancel", :controller => "articles" %>
0
+ </p>
0
 <% end -%>
0
 
0
 
...
81
82
83
84
 
85
86
87
...
81
82
83
 
84
85
86
87
0
@@ -81,7 +81,7 @@
0
     <h3>Comments awaiting your approval</h3>
0
     <ul class="slist">
0
     <% @comments.each do |article, count| -%>
0
- <li><%= link_to "<strong>(#{count})</strong> #{h(article.title)}", :controller => 'articles', :action => 'comments', :id => article.id, :filter => :unapproved %></li>
0
+ <li><%= link_to "<strong>(#{count})</strong> #{h(article.title)}", article_comments_path(article), :filter => :unapproved %></li>
0
     <% end -%>
0
     </ul>
0
   </div>
...
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
27
 
28
29
 
30
31
32
 
 
 
33
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
34
...
 
 
 
 
 
 
 
 
 
 
 
 
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
27
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
0
@@ -1,33 +1,57 @@
0
-<% content_for :action_nav do %>
0
-<!-- begin action nav -->
0
-<div id="page-nav">
0
- <ul id="act-nav" class="clear">
0
- <li><%= link_to_remote 'Delete these comments', :confirm => "Are you sure you wish to delete all of these comments?",
0
- :url => { :controller => 'articles', :action => 'destroy_comment' },
0
- :with => "ArticleForm.getAvailableComments().toQueryString('comment')"
0
- %></li>
0
- </ul>
0
-</div>
0
-<!-- /end action nav -->
0
-<% end %>
0
+<%= render :partial => "admin/articles/page_nav" %>
0
+
0
+<h3 style="border-bottom:1px solid #ccc;padding:5px">Comments on <%= link_to @article.title, edit_article_path(@article), :style => 'border:none' %> <span class="right"><%= @article.published? ? link_to(image_tag('/images/mephisto/icons/24-zoom-in.png', :style => 'vertical-align: middle'), @site.permalink_for(@article), :style => 'border:none;') : '&nbsp;' %></span></h3>
0
 
0
-<h3><%= pluralize(@comments.size, 'Unapproved Comment') %></h3>
0
+ <%= link_to_function "New comment", "$('new-comment-form').toggle()" %>
0
+ <div id="new-comment-form" style="display:none"><%= render :partial => "new_comment" %></div>
0
 
0
-<ul class="pagelist commentlist">
0
+<ul class="pagelist commentlist" id="comment-list">
0
+ <% if @comments.any? %>
0
   <% @comments.reverse.each_with_index do |comment, i| -%>
0
   <li class="event-comment<%= " shade" if (i % 2 > 0) %>" id="comment-<%= comment.id %>">
0
- <h3><a name="comment-<%= comment.id %>"></a> <%= link_to comment.article.title, :controller => 'articles', :action => 'edit', :id => comment.article %></h3>
0
- <blockquote><p>"<%= truncate strip_tags(comment.body), 255 %>"</p></blockquote>
0
+ <a name="comment-<%= comment.id %>"></a>
0
+ <% unless comment.body.blank? -%>
0
+ <blockquote><p>"<%= strip_tags(comment.body) %>"</p></blockquote>
0
+ <% end -%>
0
     <span class="meta">
0
- <cite>&mdash; <%= author_link_for comment %><%= %( (#{comment.author_email})) unless comment.author_email.blank? %></cite>
0
-
0
+ <cite>&mdash; <%= author_link_for comment %><%= %( (#{comment.author_email})) unless comment.author_email.blank? %> said <%= time_ago_in_words comment.created_at %> ago</cite>
0
+
0
+ <%= link_to_remote 'Edit', :url => edit_article_comment_path(@article, comment), :method => :get %> |
0
     <% if comment.approved? -%>
0
- <%= link_to_remote 'Unapprove', :url => { :action => 'unapprove', :controller => 'articles', :id => comment.article, :comment => comment } %> |
0
+ <%= link_to_remote 'Unapprove', :url => unapprove_article_comment_path(@article, comment) %> |
0
     <% else -%>
0
- <%= link_to_remote 'Approve', :url => { :action => 'approve', :controller => 'articles', :id => comment.article, :comment => comment } %> |
0
+ <%= link_to_remote 'Approve', :url => approve_article_comment_path(@article, comment) %> |
0
     <% end -%>
0
- <%= link_to_remote 'Delete', :url => { :action => 'destroy_comment', :controller => 'articles', :id => comment.article, :comment => comment } %>
0
+ <%= link_to_remote 'Delete', :url => article_comment_path(@article, comment), :method => :delete %>
0
     </span>
0
   </li>
0
   <% end -%>
0
+ <% else %>
0
+ <li class="event-none shade">This article has no <%= params[:filter].to_s.humanize.downcase %> comments.</li>
0
+ <% end %>
0
 </ul>
0
+
0
+
0
+<% content_for :sidebar do %>
0
+ <% if @articles.size > 1 -%>
0
+ <div class="sgroup">
0
+ <h3>Comments awaiting your approval</h3>
0
+ <ul class="slist">
0
+ <% @articles.each do |article, count| -%>
0
+ <% if article.title != @article.title -%>
0
+ <li><%= link_to "<strong>(#{count})</strong> #{h(article.title)}", :controller => 'articles', :action => 'comments', :id => article.id, :filter => :unapproved %></li>
0
+ <% end -%>
0
+ <% end -%>
0
+ </ul>
0
+ </div>
0
+ <% end -%>
0
+<% end %>
0
+
0
+
0
+<script type="text/javascript" language="javascript" charset="utf-8">
0
+// <![CDATA[
0
+ var comment = $(document.location.hash.substring(1));
0
+ if(comment) Element.addClassName(comment, 'focused');
0
+
0
+// ]]>
0
+</script>
0
\ No newline at end of file
...
14
15
16
17
 
 
 
 
 
18
19
20
...
22
23
24
 
25
26
 
27
28
29
...
14
15
16
 
17
18
19
20
21
22
23
24
...
26
27
28
29
30
31
32
33
34
35
0
@@ -14,7 +14,11 @@ module Mephisto
0
         m.js 'javascripts/:path.:ext', :dir => 'javascripts'
0
         m.images 'images/:path.:ext', :dir => 'images'
0
       end
0
-
0
+
0
+ map.resources :articles, :path_prefix => 'admin', :controller => 'admin/articles' do |r|
0
+ r.resources :comments, :controller => 'admin/comments', :member => { :unapprove => :post, :approve => :post, :edit => :get }
0
+ end
0
+
0
       map.overview 'admin/overview.xml', :controller => 'admin/overview', :action => 'feed'
0
       map.admin 'admin', :controller => 'admin/overview', :action => 'index'
0
       map.resources :assets, :path_prefix => '/admin', :controller => 'admin/assets', :member => { :add_bucket => :post },
0
@@ -22,8 +26,10 @@ module Mephisto
0
       
0
       map.connect 'xmlrpc', :controller => 'backend', :action => 'xmlrpc'
0
       
0
+
0
       map.connect ':controller/:action/:id/:version', :version => nil, :controller => /routing_navigator|account|(admin\/\w+)/, :id => /[^\/]*/
0
 
0
+
0
       yield if block_given?
0
       Mephisto::Plugin.custom_routes.each do |path, options|
0
         map.connect path, options
...
51
52
53
54
55
 
 
56
57
58
59
 
60
61
62
63
64
65
 
 
66
67
68
69
70
 
71
72
73
...
51
52
53
 
 
54
55
56
57
58
 
59
60
61
62
63
 
 
64
65
66
67
68
69
 
70
71
72
73
0
@@ -51,23 +51,23 @@ module Mephisto
0
       end
0
 
0
       def revise(article, contents)
0
- post "/admin/articles/update/#{article.id}", to_article_params(article, contents.is_a?(Hash) ? contents : {:body => contents})
0
- assert_redirected_to "/admin/articles/edit/#{assigns(:article).id}"
0
+ put "/admin/articles/#{article.id}", to_article_params(article, contents.is_a?(Hash) ? contents : {:body => contents})
0
+ assert_redirected_to "/admin/articles/#{assigns(:article).id}/edit"
0
       end
0
 
0
       def remove_article(article)
0
- post "/admin/articles/destroy/#{article.id}"
0
+ delete "/admin/articles/#{article.id}"
0
         assert_equal 200, status, "Removing article #{article.id}"
0
       end
0
 
0
       def create(params)
0
- post '/admin/articles/create', to_article_params(params)
0
- assert_redirected_to "/admin/articles/edit/#{assigns(:article).id}"
0
+ post '/admin/articles', to_article_params(params)
0
+ assert_redirected_to "/admin/articles/#{assigns(:article).id}/edit"
0
       end
0
 
0
       private
0
         def manage_comment(action, comment)
0
- post "/admin/articles/#{action}/#{comment.article_id}", :comment => comment.id
0
+ post "/admin/articles/#{comment.article_id}/comments/#{comment.id}/#{action}", :comment => comment.id
0
         end
0
 
0
         def to_article_params(*args)
...
125
126
127
128
 
129
130
131
...
182
183
184
185
 
 
 
186
187
188
...
125
126
127
 
128
129
130
131
...
182
183
184
 
185
186
187
188
189
190
0
@@ -125,7 +125,7 @@ class Admin::ArticlesControllerTest < Test::Unit::TestCase
0
   def test_should_show_default_checked_sections
0
     get :new
0
     assert_response :success
0
- assert_tag 'form', :attributes => { :action => '/admin/articles/create' }
0
+ assert_tag 'form', :attributes => { :action => '/admin/articles', :method => 'post' }
0
     assert_tag 'input', :attributes => { :id => "article_section_ids_#{sections(:home).id.to_s}" }
0
     assert_no_tag 'input', :attributes => { :id => "article_section_ids_#{sections(:about).id.to_s}", :checked => 'checked' }
0
   end
0
@@ -182,7 +182,9 @@ class Admin::ArticlesControllerTest < Test::Unit::TestCase
0
   def test_edit_form_should_have_correct_post_action
0
     get :edit, :id => contents(:welcome).id
0
     assert_response :success
0
- assert_tag :tag => 'form', :attributes => { :action => "/admin/articles/update/#{contents(:welcome).id}" }
0
+ assert_tag :tag => 'form', :attributes => { :action => "/admin/articles/#{contents(:welcome).id}" } do
0
+ assert_tag :tag => 'input', :attributes => { :name => "_method", :value => "put" }
0
+ end
0
   end
0
 
0
   def test_should_update_article_with_correct_time
...
10
11
12
13
 
14
15
16
...
18
19
20
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
21
...
10
11
12
 
13
14
15
16
...
18
19
20
21
22
23
24
25
26
27
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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
0
@@ -10,7 +10,7 @@ class Admin::CommentsControllerTest < Test::Unit::TestCase
0
     @controller = Admin::CommentsController.new
0
     @request = ActionController::TestRequest.new
0
     @response = ActionController::TestResponse.new
0
- login_as :ben
0
+ login_as :quentin
0
   end
0
 
0
   def test_should_disable_comments_on_article
0
@@ -18,4 +18,60 @@ class Admin::CommentsControllerTest < Test::Unit::TestCase
0
     assert_equal -1, contents(:welcome).reload.comment_age
0
     assert_response :success
0
   end
0
+
0
+ def test_should_destroy_comment
0
+ comment = contents(:welcome_comment)
0
+
0
+ xhr :delete, :destroy, :id => '3', :article_id => '1'
0
+ assert_response :success
0
+ assert_equal [comment], assigns(:comments)
0
+ assert_raise(ActiveRecord::RecordNotFound) { comment.reload }
0
+ end
0
+
0
+ def test_should_destroy_comments
0
+ comment = contents(:welcome_comment)
0
+
0
+ xhr :delete, :destroy, :comment => ['3'], :article_id => '1'
0
+ assert_response :success
0
+ assert_equal [comment], assigns(:comments)
0
+ assert_raise(ActiveRecord::RecordNotFound) { comment.reload }
0
+ end
0
+
0
+ def test_should_list_comments_on_article
0
+ get :index, :article_id => '1'
0
+ assert_response :success
0
+ end
0
+
0
+ def test_should_list_approved_comments_on_article
0
+ get :index, :article_id => '1', :filter => 'approved'
0
+ assert_response :success
0
+ end
0
+
0
+ def test_should_list_unapproved_comments_on_article
0
+ get :index, :article_id => '1', :filter => 'unapproved'
0
+ assert_response :success
0
+ end
0
+
0
+ def test_should_create_comment
0
+ post :create, :article_id => '1', :comment => {}
0
+ assert_response :success
0
+ end
0
+
0
+ def test_should_edit_comment
0
+ get :edit, :article_id => '1', :id => '3'
0
+ assert_response :success
0
+ end
0
+
0
+ def test_should_approve_comment
0
+ contents(:welcome_comment).update_attribute(:approved, false)
0
+ xhr :get, :approve, :article_id => '1', :id => '3'
0
+ assert_response :success
0
+ end
0
+
0
+ def test_should_unapprove_comment
0
+ xhr :get, :unapprove, :article_id => '1', :id => '3'
0
+ assert_response :success
0
+ assert_template 'approve'
0
+ end
0
+
0
 end
...
238
239
240
241
 
242
243
244
...
256
257
258
259
 
260
261
262
...
238
239
240
 
241
242
243
244
...
256
257
258
 
259
260
261
262
0
@@ -238,7 +238,7 @@ class CachingTest < ActionController::IntegrationTest
0
     end
0
 
0
     assert_expires_pages overview_path, contents(:welcome).full_permalink do
0
- writer.post "admin/articles/destroy_comment/#{contents(:welcome).id}", :comment => contents(:welcome_comment).id
0
+ writer.delete "admin/articles/#{contents(:welcome).id}/comments/#{contents(:welcome_comment).id}"
0
     end
0
   end
0
 
0
@@ -256,7 +256,7 @@ class CachingTest < ActionController::IntegrationTest
0
 
0
     assert_expires_pages overview_path do
0
       contents(:welcome_comment).update_attribute :approved, false
0
- writer.post "admin/articles/destroy_comment/#{contents(:welcome).id}", :comment => contents(:welcome_comment).id
0
+ writer.delete "admin/articles/#{contents(:welcome).id}/comments/#{contents(:welcome_comment).id}"
0
     end
0
 
0
     assert_cached contents(:welcome).full_permalink
...
393
394
395
 
 
 
 
 
 
396
397
...
393
394
395
396
397
398
399
400
401
402
403
0
@@ -393,4 +393,10 @@ module Mephisto
0
     class NonPlugin
0
     end
0
   end
0
+end
0
+
0
+begin
0
+ require 'ruby-debug'
0
+ Debugger.start
0
+rescue LoadError
0
 end
0
\ No newline at end of file

Comments

    No one has commented yet.