Commit 86f4b04a61c186bfd11571cf7f39134266944590

Authored by AntonioTerceiro
1 parent 7569b3e9

ActionItem559: fixing SellersSearchBlock to use the editable title

git-svn-id: https://svn.colivre.coop.br/svn/noosfero/trunk@2289 3f533792-8f58-4932-b0fe-aaf55b0a4547
app/models/sellers_search_block.rb
... ... @@ -4,11 +4,20 @@ class SellersSearchBlock < Block
4 4 _('A search for enterprises by products selled and local')
5 5 end
6 6  
  7 + def self.short_description
  8 + _('Sellers search block')
  9 + end
  10 +
  11 + def default_title
  12 + _('Search for sellers')
  13 + end
  14 +
7 15 def content
  16 + title = self.title
8 17 lambda do
9 18 @categories = ProductCategory.find(:all)
10 19 @regions = Region.find(:all).select{|r|r.lat && r.lng}
11   - render :file => 'search/_sellers_form'
  20 + render :file => 'search/_sellers_form', :locals => { :title => title }
12 21 end
13 22 end
14 23 end
... ...
app/views/search/_sellers_form.rhtml
1   -<h3><%= _('Search for sellers') %></h3>
  1 +<h3><%= title %></h3>
2 2  
3 3 <% form_tag({:controller => 'search', :action => 'assets'}, {:method => 'get'}) do %>
4 4  
... ...
test/unit/sellers_search_block_test.rb
1 1 require File.dirname(__FILE__) + '/../test_helper'
2 2  
3 3 class SellersSearchBlockTest < ActiveSupport::TestCase
4   - # Replace this with your real tests.
5   - def test_truth
6   - assert true
  4 +
  5 + should 'provide description' do
  6 + assert_not_equal Block.description, SellersSearchBlock.description
  7 + end
  8 +
  9 + should 'provide default title' do
  10 + assert_not_equal Block.new.default_title, SellersSearchBlock.new.default_title
7 11 end
  12 +
  13 + should 'not use a fixed title' do
  14 + block = SellersSearchBlock.new(:title => 'my custom title')
  15 + expects(:render).with(:file => 'search/_sellers_form', :locals => { :title => 'my custom title'})
  16 + instance_eval(&block.content)
  17 + end
  18 +
8 19 end
... ...