From 9d4eed1bcf05c2f7b6c5884e92eead3fb526e857 Mon Sep 17 00:00:00 2001 From: AntonioTerceiro Date: Mon, 14 Jul 2008 16:06:01 +0000 Subject: [PATCH] ActionItem514: caching the correct content --- app/views/layouts/application.rhtml | 3 ++- app/views/shared/categories_menu.rhtml | 22 +--------------------- test/integration/categories_menu_test.rb | 19 +++++++++++++++---- 3 files changed, 18 insertions(+), 26 deletions(-) diff --git a/app/views/layouts/application.rhtml b/app/views/layouts/application.rhtml index b8741f0..4309425 100644 --- a/app/views/layouts/application.rhtml +++ b/app/views/layouts/application.rhtml @@ -94,9 +94,10 @@ { :controller=>"home" }, :id=>"menu_link_to_envhome", :title=>@environment.name %> - <% cache(:controller => 'public', :action => 'categories_menu', :asset => params[:asset]) do %> + <% cache(:controller => 'public', :action => 'categories_menu') do %> <%= render :file => 'shared/categories_menu' %> <% end %> + <%= render :file => 'shared/assets_menu' %> diff --git a/test/integration/categories_menu_test.rb b/test/integration/categories_menu_test.rb index 9c89be3..3636224 100644 --- a/test/integration/categories_menu_test.rb +++ b/test/integration/categories_menu_test.rb @@ -13,19 +13,30 @@ class CategoriesMenuTest < ActionController::IntegrationTest should 'display link to categories' do get '/' - assert_tag :tag => 'a', :attributes => { :href => '/cat/food/vegetables' } + assert_tag :attributes => { :id => 'cat_menu' }, :descendant => { :tag => 'a', :attributes => { :href => '/cat/food/vegetables' } } end should 'display link to sub-categories' do get '/cat/food' # there must be a link to the subcategory - assert_tag :tag => 'a', :attributes => { :href => '/cat/food/vegetables' } + assert_tag :attributes => { :id => 'cat_menu' }, :descendant => { :tag => 'a', :attributes => { :href => '/cat/food/vegetables' } } end should 'link to other assets in the same category when viewing an asset' do get '/assets/articles/food/vegetables' - assert_no_tag :tag => 'a', :attributes => { :href => '/cat/food/vegetables' } - assert_tag :tag => 'a', :attributes => { :href => '/assets/enterprises/food/vegetables' } + assert_no_tag :attributes => { :id => 'assets_menu' }, :descendant => { :tag => 'a', :attributes => { :href => '/cat/food/vegetables' } } + assert_tag :attributes => { :id => 'assets_menu' }, :descendant => { :tag => 'a', :attributes => { :href => '/assets/enterprises/food/vegetables' } } + end + + should "always link to category's initial page in category menu" do + get '/assets/products/food/vegetables' + assert_tag :attributes => { :id => 'cat_menu' }, :descendant => { :tag => 'a', :attributes => { :href => '/cat/food/vegetables' } } + assert_no_tag :attributes => { :id => 'cat_menu' }, :descendant => { :tag => 'a', :attributes => { :href => '/assets/products/food/vegetables' } } + end + + should 'cache the categories menu' do + ActionView::Base.any_instance.expects(:cache).with(:controller => 'public', :action => 'categories_menu') + get '/' end end -- libgit2 0.21.2