Changeset 1669

Show
Ignore:
Timestamp:
02/29/08 00:40:03 (3 months ago)
Author:
pdcawley
Message:

More UrlPolicy? work.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/app/controllers/comments_controller.rb

    r1668 r1669  
    1414      else 
    1515        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)}" 
    2616      end 
    2717    end 
  • trunk/app/controllers/feedback_controller.rb

    r1668 r1669  
    2121      format.atom { render :partial => 'articles/atom_feed', :object => get_feedback } 
    2222      format.rss { render :partial => 'articles/rss20_feed', :object => get_feedback } 
     23    end 
     24  end 
     25 
     26  def show 
     27    @feedback = @article.feedback.find_by_guid(params[:id]) 
     28 
     29    respond_to do |format| 
     30      format.html do 
     31        redirect_to article_path(@article) + "\##{dom_id(@feedback)}" 
     32      end 
    2333    end 
    2434  end 
  • trunk/app/models/comment.rb

    r1668 r1669  
    5050  end 
    5151 
    52   def to_params(builder) 
    53     builder.comment_params(self) 
    54   end 
    55  
    56   def to_param 
    57     guid 
    58   end 
    59  
    6052  protected 
    6153 
  • trunk/app/models/feedback.rb

    r1552 r1669  
    2424  def self.default_order 
    2525    'created_at ASC' 
     26  end 
     27 
     28  def to_params(builder) 
     29    builder.feedback_params(self) 
     30  end 
     31 
     32  def to_param 
     33    guid 
    2634  end 
    2735 
  • trunk/app/models/url_policy.rb

    r1668 r1669  
    5757  end 
    5858 
    59   def comment_params(comment
    60     returning(:controller => 'comments', :action => 'show') do |params| 
    61       article_params(comment.article).each do |k,v| 
     59  def feedback_params(feedback
     60    returning(:controller => feedback.class.name.pluralize.underscore, :action => 'show') do |params| 
     61      article_params(feedback.article).each do |k,v| 
    6262        next if k == :controller || k == :action 
    6363        params["article_#{k}".to_sym] = v 
    6464      end 
    65       params[:id] = comment.to_param 
     65      params[:id] = feedback.to_param 
    6666    end 
    6767  end 
  • trunk/spec/models/url_policy_spec.rb

    r1668 r1669  
    1414  end 
    1515 
    16   it "#url_for(<comment on article 3>).should == /2004/06/01/article-3/comments/#\{comment.guid}" do 
     16  it "#url_for(<comment on article 3>).should == /articles/2004/06/01/article-3/comments/#\{comment.guid}" do 
    1717    article = contents(:article3) 
    1818    comment = article.comments.build(:author => 'Piers Cawley', :body => "body") 
    1919    comment.save(false) 
    2020    UrlPolicy.instance.url_for(comment).should == "/articles/2004/06/01/article-3/comments/#{comment.guid}" 
     21  end 
     22 
     23  it "#url_for(<trackback on article 3>).should == /articles/2004/06/01/article-3/comments/#\{trackback.guid}" do 
     24    article = contents(:article3) 
     25    trackback = article.trackbacks.build(:title => 'Foo', :excerpt => 'bar', :url => 'http://empty.cabi.net/') 
     26    trackback.save(false) 
     27    UrlPolicy.instance.url_for(trackback).should == 
     28      "/articles/2004/06/01/article-3/trackbacks/#{trackback.guid}" 
    2129  end 
    2230