Commit a263c092034b23b9db149c3ecc1cc6c11a7e20cb
1 parent
d058068c
Exists in
master
and in
29 other branches
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
Showing
4 changed files
with
41 additions
and
8 deletions
Show diff stats
app/controllers/application.rb
| @@ -7,6 +7,17 @@ class ApplicationController < ActionController::Base | @@ -7,6 +7,17 @@ class ApplicationController < ActionController::Base | ||
| 7 | 7 | ||
| 8 | design :holder => 'environment' | 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 | # Be sure to include AuthenticationSystem in Application Controller instead | 21 | # Be sure to include AuthenticationSystem in Application Controller instead |
| 11 | include AuthenticatedSystem | 22 | include AuthenticatedSystem |
| 12 | include PermissionCheck | 23 | include PermissionCheck |
app/views/layouts/application.rhtml
| @@ -21,9 +21,6 @@ | @@ -21,9 +21,6 @@ | ||
| 21 | <% if params[:controller] == 'cms' %> | 21 | <% if params[:controller] == 'cms' %> |
| 22 | <%= javascript_include_tag 'cms' %> | 22 | <%= javascript_include_tag 'cms' %> |
| 23 | <% end %> | 23 | <% end %> |
| 24 | - | ||
| 25 | - <%# FIXME this is temporary for tests %> | ||
| 26 | - <%= stylesheet_link_tag 'composer' %> | ||
| 27 | </head> | 24 | </head> |
| 28 | 25 | ||
| 29 | <body class='category<%= category_color %>'> | 26 | <body class='category<%= category_color %>'> |
| @@ -80,11 +77,10 @@ | @@ -80,11 +77,10 @@ | ||
| 80 | <div id='header_content'> | 77 | <div id='header_content'> |
| 81 | </div> | 78 | </div> |
| 82 | 79 | ||
| 83 | - <%# FIXME this is temporary %> | ||
| 84 | - <% if params[:controller] == 'composer' %> | ||
| 85 | - <%= yield %> | ||
| 86 | - <% else %> | 80 | + <% if uses_design_blocks? %> |
| 87 | <%= design_display(yield) %> | 81 | <%= design_display(yield) %> |
| 82 | + <% else %> | ||
| 83 | + <%= yield %> | ||
| 88 | <% end %> | 84 | <% end %> |
| 89 | 85 | ||
| 90 | </div><!-- id="content" --> | 86 | </div><!-- id="content" --> |
test/functional/application_controller_test.rb
| @@ -92,4 +92,30 @@ class ApplicationControllerTest < Test::Unit::TestCase | @@ -92,4 +92,30 @@ class ApplicationControllerTest < Test::Unit::TestCase | ||
| 92 | :attributes => { :class => 'help_box'}, | 92 | :attributes => { :class => 'help_box'}, |
| 93 | }) | 93 | }) |
| 94 | end | 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 | end | 121 | end |
test/mocks/test/test_controller.rb