Skip to content

Commit

Permalink
By clearing the page's cached URL on save as well as that of its chil…
Browse files Browse the repository at this point in the history
…dren all tests pass once more. No longer highlighting a menu item if it has a child that's hidden.
  • Loading branch information
parndt committed May 25, 2011
1 parent 9de9e0a commit 57436f1
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 12 deletions.
14 changes: 3 additions & 11 deletions pages/app/models/page.rb
Original file line number Diff line number Diff line change
Expand Up @@ -66,14 +66,6 @@ def translation
:approximate_ascii => RefinerySetting.find_or_set(:approximate_ascii, false, :scoping => "pages"),
:strip_non_ascii => RefinerySetting.find_or_set(:strip_non_ascii, false, :scoping => "pages")

def to_param_cache
slug.try(:name)
end

def to_param
to_param_cache || super
end

has_many :parts,
:class_name => "PagePart",
:order => "position ASC",
Expand Down Expand Up @@ -389,9 +381,9 @@ def normalize_friendly_id(slug_string)
def invalidate_cached_urls
return true unless self.class.use_marketable_urls?

children.each do |child|
Rails.cache.delete(child.url_cache_key)
Rails.cache.delete(child.path_cache_key)
[self, children].flatten.each do |page|
Rails.cache.delete(page.url_cache_key)
Rails.cache.delete(page.path_cache_key)
end
end
alias_method :invalidate_child_cached_url, :invalidate_cached_urls
Expand Down
9 changes: 8 additions & 1 deletion pages/features/visit_pages.feature
Original file line number Diff line number Diff line change
Expand Up @@ -13,25 +13,29 @@ Feature: Visit Pages
And the page titled "Hidden" is a child of Home
And the page titled "Hidden" is not shown in the menu

@pages-visit-home
Scenario: Home Page
When I go to the home page
Then I should see "Home"
And I should see "About"
And I should see "Home" within ".selected"

@pages-visit-show
Scenario: Content Page
When I go to the page titled "About"
Then I should see "Home"
And I should see "About"
And I should see "About" within ".selected > a"

@pages-visit-special
Scenario: Special Characters Title
When I go to the page titled "ä ö ü spéciål chåråctÉrs"
Then I should see "Home"
And I should see "About"
And I should see "ä ö ü spéciål chåråctÉrs"
And I should see "ä ö ü spéciål chåråctÉrs" within ".selected > a"

@pages-visit-special
Scenario: Special Characters Title as submenu page
Given the page titled "ä ö ü spéciål chåråctÉrs" is a child of About
When I go to the page titled "ä ö ü spéciål chåråctÉrs"
Expand All @@ -40,12 +44,15 @@ Feature: Visit Pages
And I should see "ä ö ü spéciål chåråctÉrs"
And I should see "ä ö ü spéciål chåråctÉrs" within ".selected * > .selected a"

@pages-visit-hidden
Scenario: Hidden Page
When I go to the page titled "Hidden"
Then I should see "Home"
And I should see "About"
And I should see "Home" within ".selected > a"
And I should see "Hidden"
And I should not see "Hidden" within "nav"

@pages-visit-skip
Scenario: Skip to first child
Given I have a page titled "Child Page"
And the page titled "Child Page" is a child of About
Expand Down

0 comments on commit 57436f1

Please sign in to comment.