Changeset 815

Show
Ignore:
Timestamp:
04/18/08 15:47:39 (4 months ago)
Author:
seancribbs
Message:

Fix if_ancestor_or_self spec, add spec for if_self, and fix regression in implementation.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/radiant/CHANGELOG

    r813 r815  
    22 
    33=== SVN 
     4* Add if_self and if_ancestor_or_self tags. [Marty Haught] 
    45* Rename created_by and updated_by columns on standard models. [Sean Cribbs] 
    56* Fix Dir glob for extension rake tasks. [Sean Cribbs] 
  • trunk/radiant/CONTRIBUTORS

    r811 r815  
    66 
    77=== SVN 
     8* Marty Haught 
    89* xtoddx 
    910* Michael Klett 
  • trunk/radiant/app/models/standard_tags.rb

    r814 r815  
    336336  desc %{ 
    337337    Renders the contained elements if the current contextual page is either the actual page or one of its parents. 
    338  
    339                This is typically used inside another tag (like <r:children:each>) to add conditional mark-up if the child element is or descends from the current page. 
    340                     
     338     
     339    This is typically used inside another tag (like <r:children:each>) to add conditional mark-up if the child element is or descends from the current page. 
     340     
    341341    *Usage:* 
    342342    <pre><code><r:if_ancestor_or_self>...</if_ancestor_or_self></code></pre> 
    343343  }   
    344        tag "if_ancestor_or_self" do |tag| 
    345                tag.expand if (tag.globals.actual_page.ancestors + [tag.globals.actual_page]).include?(tag.locals.page) 
    346        end 
    347          
     344  tag "if_ancestor_or_self" do |tag| 
     345    tag.expand if (tag.globals.page.ancestors + [tag.globals.page]).include?(tag.locals.page) 
     346  end 
     347   
    348348  desc %{ 
    349349    Renders the contained elements if the current contextual page is also the actual page. 
    350  
    351                This is typically used inside another tag (like &lt;r:children:each&gt;) to add conditional mark-up if the child element is the current page. 
    352                  
    353                *Usage:* 
     350     
     351    This is typically used inside another tag (like &lt;r:children:each&gt;) to add conditional mark-up if the child element is the current page. 
     352     
     353    *Usage:* 
    354354    <pre><code><r:if_self>...</if_self></code></pre> 
    355355  } 
    356356  tag "if_self" do |tag| 
    357     tag.expand if tag.locals.page == tag.globals.actual_page 
     357    tag.expand if tag.locals.page == tag.globals.page 
    358358  end 
    359359   
  • trunk/radiant/spec/models/standard_tags_spec.rb

    r814 r815  
    464464  end 
    465465   
    466         describe "<r:if_ancestor_or_self>" do 
    467           it "should render the tag's content when the current page is an ancestor of tag.locals.page" do 
    468         page(:home).should render(%{<r:find url="/radius"><r:if_ancestor_or_self>true</r:if_ancestor_or_self></r:find>}).as('true') 
    469           end      
    470          
    471                 it "should not render the tag's content when current page is not an ancestor of tag.locals.page" do 
    472             page(:parent).should render(%{<r:find url="/radius"><r:if_ancestor_or_self>true</r:if_ancestor_or_self></r:find>}).as('') 
    473           end 
    474         end 
     466  describe "<r:if_ancestor_or_self>" do 
     467    it "should render the tag's content when the current page is an ancestor of tag.locals.page" do 
     468      page(:radius).should render(%{<r:find url="/"><r:if_ancestor_or_self>true</r:if_ancestor_or_self></r:find>}).as('true') 
     469    end    
     470   
     471    it "should not render the tag's content when current page is not an ancestor of tag.locals.page" do 
     472      page(:parent).should render(%{<r:find url="/radius"><r:if_ancestor_or_self>true</r:if_ancestor_or_self></r:find>}).as('') 
     473    end 
     474  end 
     475   
     476  describe "<r:if_self>" do 
     477    it "should render the tag's content when the current page is the same as the local contextual page" do 
     478      page(:home).should render(%{<r:find url="/"><r:if_self>true</r:if_self></r:find>}).as('true') 
     479    end 
     480     
     481    it "should not render the tag's content when the current page is not the same as the local contextual page" do 
     482      page(:radius).should render(%{<r:find url="/"><r:if_self>true</r:if_self></r:find>}).as('') 
     483    end 
     484  end 
    475485 
    476486  private