From 86f4b04a61c186bfd11571cf7f39134266944590 Mon Sep 17 00:00:00 2001 From: AntonioTerceiro Date: Sat, 19 Jul 2008 19:37:34 +0000 Subject: [PATCH] ActionItem559: fixing SellersSearchBlock to use the editable title --- app/models/sellers_search_block.rb | 11 ++++++++++- app/views/search/_sellers_form.rhtml | 2 +- test/unit/sellers_search_block_test.rb | 17 ++++++++++++++--- 3 files changed, 25 insertions(+), 5 deletions(-) diff --git a/app/models/sellers_search_block.rb b/app/models/sellers_search_block.rb index ef375f4..7cf52d6 100644 --- a/app/models/sellers_search_block.rb +++ b/app/models/sellers_search_block.rb @@ -4,11 +4,20 @@ class SellersSearchBlock < Block _('A search for enterprises by products selled and local') end + def self.short_description + _('Sellers search block') + end + + def default_title + _('Search for sellers') + end + def content + title = self.title lambda do @categories = ProductCategory.find(:all) @regions = Region.find(:all).select{|r|r.lat && r.lng} - render :file => 'search/_sellers_form' + render :file => 'search/_sellers_form', :locals => { :title => title } end end end diff --git a/app/views/search/_sellers_form.rhtml b/app/views/search/_sellers_form.rhtml index f7f7da3..d3d087a 100644 --- a/app/views/search/_sellers_form.rhtml +++ b/app/views/search/_sellers_form.rhtml @@ -1,4 +1,4 @@ -

<%= _('Search for sellers') %>

+

<%= title %>

<% form_tag({:controller => 'search', :action => 'assets'}, {:method => 'get'}) do %> diff --git a/test/unit/sellers_search_block_test.rb b/test/unit/sellers_search_block_test.rb index 71c5aa9..7776074 100644 --- a/test/unit/sellers_search_block_test.rb +++ b/test/unit/sellers_search_block_test.rb @@ -1,8 +1,19 @@ require File.dirname(__FILE__) + '/../test_helper' class SellersSearchBlockTest < ActiveSupport::TestCase - # Replace this with your real tests. - def test_truth - assert true + + should 'provide description' do + assert_not_equal Block.description, SellersSearchBlock.description + end + + should 'provide default title' do + assert_not_equal Block.new.default_title, SellersSearchBlock.new.default_title end + + should 'not use a fixed title' do + block = SellersSearchBlock.new(:title => 'my custom title') + expects(:render).with(:file => 'search/_sellers_form', :locals => { :title => 'my custom title'}) + instance_eval(&block.content) + end + end -- libgit2 0.21.2