Commit a263c092034b23b9db149c3ecc1cc6c11a7e20cb

Authored by AntonioTerceiro
1 parent d058068c

ActionItem135: implementing the possibility of not using design blocks


git-svn-id: https://svn.colivre.coop.br/svn/noosfero/trunk@1095 3f533792-8f58-4932-b0fe-aaf55b0a4547
app/controllers/application.rb
... ... @@ -7,6 +7,17 @@ class ApplicationController < ActionController::Base
7 7  
8 8 design :holder => 'environment'
9 9  
  10 + def self.no_design_blocks
  11 + @no_design_blocks = true
  12 + end
  13 + module UsesDesignBlocksHelper
  14 + def uses_design_blocks?
  15 + ! self.class.instance_variable_get('@no_design_blocks')
  16 + end
  17 + end
  18 + helper UsesDesignBlocksHelper
  19 + include UsesDesignBlocksHelper
  20 +
10 21 # Be sure to include AuthenticationSystem in Application Controller instead
11 22 include AuthenticatedSystem
12 23 include PermissionCheck
... ...
app/views/layouts/application.rhtml
... ... @@ -21,9 +21,6 @@
21 21 <% if params[:controller] == 'cms' %>
22 22 <%= javascript_include_tag 'cms' %>
23 23 <% end %>
24   -
25   - <%# FIXME this is temporary for tests %>
26   - <%= stylesheet_link_tag 'composer' %>
27 24 </head>
28 25  
29 26 <body class='category<%= category_color %>'>
... ... @@ -80,11 +77,10 @@
80 77 <div id='header_content'>
81 78 </div>
82 79  
83   - <%# FIXME this is temporary %>
84   - <% if params[:controller] == 'composer' %>
85   - <%= yield %>
86   - <% else %>
  80 + <% if uses_design_blocks? %>
87 81 <%= design_display(yield) %>
  82 + <% else %>
  83 + <%= yield %>
88 84 <% end %>
89 85  
90 86 </div><!-- id="content" -->
... ...
test/functional/application_controller_test.rb
... ... @@ -92,4 +92,30 @@ class ApplicationControllerTest &lt; Test::Unit::TestCase
92 92 :attributes => { :class => 'help_box'},
93 93 })
94 94 end
  95 +
  96 + should 'be able to not use design blocks' do
  97 +
  98 + class UsesBlocksTestController < ApplicationController
  99 + end
  100 + assert UsesBlocksTestController.new.uses_design_blocks?
  101 +
  102 + class DoesNotUsesBlocksTestController < ApplicationController
  103 + no_design_blocks
  104 + end
  105 + assert !DoesNotUsesBlocksTestController.new.uses_design_blocks?
  106 + end
  107 +
  108 + should 'use design plugin to generate blocks' do
  109 + get :index
  110 + assert_tag :tag => 'div', :attributes => { :id => 'boxes', :class => 'design_boxes' }
  111 + end
  112 +
  113 + should 'not use design plugin when tells so' do
  114 + class NoDesignBlocksTestController < ApplicationController
  115 + no_design_blocks
  116 + end
  117 + @controller = NoDesignBlocksTestController.new
  118 + get :index
  119 + assert_no_tag :tag => 'div', :attributes => { :id => 'boxes', :class => 'design_boxes' }
  120 + end
95 121 end
... ...
test/mocks/test/test_controller.rb
1 1 class TestController < ApplicationController
2 2  
3 3 def index
4   - render :text => 'index'
  4 + render :text => 'index', :layout => true
5 5 end
6 6  
7 7 post_only 'post_only'
... ...