Changeset 1668
- Timestamp:
- 02/29/08 00:26:28 (3 months ago)
- Files:
-
- trunk/app/controllers/comments_controller.rb (modified) (1 diff)
- trunk/app/controllers/feedback_controller.rb (modified) (2 diffs)
- trunk/app/controllers/trackbacks_controller.rb (modified) (1 diff)
- trunk/app/models/comment.rb (modified) (1 diff)
- trunk/app/models/url_policy.rb (modified) (2 diffs)
- trunk/spec/models/url_policy_spec.rb (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/app/controllers/comments_controller.rb
r1665 r1668 14 14 else 15 15 redirect_to article_path(@article) 16 end 17 end 18 end 19 20 def show 21 @comment = @article.comments.find_by_guid(params[:id]) 22 23 respond_to do |format| 24 format.html do 25 redirect_to article_path(@article) + "\##{dom_id(@comment)}" 16 26 end 17 27 end trunk/app/controllers/feedback_controller.rb
r1602 r1668 4 4 session :new_session => false 5 5 before_filter :login_required, :only => [:update, :destroy] 6 before_filter :get_article, :only => [:create, :update ]6 before_filter :get_article, :only => [:create, :update, :show] 7 7 8 8 cache_sweeper :blog_sweeper … … 13 13 format.html do 14 14 if params[:article_id] 15 article = this_blog.requested_article(params)15 article = Article.find_by_params_hash(params) 16 16 redirect_to "#{article_path(article)}\##{@page_title.underscore}" 17 17 else trunk/app/controllers/trackbacks_controller.rb
r1645 r1668 30 30 @trackbacks = 31 31 if params[:article_id] 32 this_blog.requested_article(params).published_trackbacks32 Article.find_by_params_hash(params).published_trackbacks 33 33 else 34 34 this_blog.published_trackbacks.find(:all, this_blog.rss_limit_params(:order => 'created_at DESC')) trunk/app/models/comment.rb
r1555 r1668 50 50 end 51 51 52 def to_params(builder) 53 builder.comment_params(self) 54 end 55 56 def to_param 57 guid 58 end 59 52 60 protected 53 61 trunk/app/models/url_policy.rb
r1666 r1668 18 18 with_options(:only_path => true) do |o| 19 19 case args.first 20 when nil 21 raise ArgumentError, "Argument cannot be nil" 20 22 when ActiveRecord::Base 21 23 o.url_for_object(*args) … … 55 57 end 56 58 59 def comment_params(comment) 60 returning(:controller => 'comments', :action => 'show') do |params| 61 article_params(comment.article).each do |k,v| 62 next if k == :controller || k == :action 63 params["article_#{k}".to_sym] = v 64 end 65 params[:id] = comment.to_param 66 end 67 end 57 68 end trunk/spec/models/url_policy_spec.rb
r1666 r1668 10 10 end 11 11 12 it "#url_for(contents(:article3)) should == / 2004/06/01/article-3" do12 it "#url_for(contents(:article3)) should == /articles/2004/06/01/article-3" do 13 13 UrlPolicy.instance.url_for(contents(:article3)).should == '/articles/2004/06/01/article-3' 14 end 15 16 it "#url_for(<comment on article 3>).should == /2004/06/01/article-3/comments/#\{comment.guid}" do 17 article = contents(:article3) 18 comment = article.comments.build(:author => 'Piers Cawley', :body => "body") 19 comment.save(false) 20 UrlPolicy.instance.url_for(comment).should == "/articles/2004/06/01/article-3/comments/#{comment.guid}" 14 21 end 15 22 … … 18 25 end 19 26 20 it "#edit_url_for(contents(:article3)) should == / 2004/06/01/article-3/edit" do27 it "#edit_url_for(contents(:article3)) should == /articles/2004/06/01/article-3/edit" do 21 28 UrlPolicy.instance.edit_url_for(contents(:article3)).should == '/articles/2004/06/01/article-3/edit' 22 29 end
