diff --git a/app/models/location_block.rb b/app/models/location_block.rb
index 9c7e9de..95fde1c 100644
--- a/app/models/location_block.rb
+++ b/app/models/location_block.rb
@@ -1,7 +1,7 @@
class LocationBlock < Block
- settings_items :zoom, :type => :integer , :default => 4
- settings_items :map_type, :type => :string , :default => 'roadmap'
+ settings_items :zoom, :type => :integer, :default => 4
+ settings_items :map_type, :type => :string, :default => 'roadmap'
def self.description
_('Location map')
@@ -12,18 +12,10 @@ class LocationBlock < Block
end
def content(args={})
+ block = self
profile = self.owner
- title = self.title
- if profile.lat
- block_title(title) +
- content_tag('div',
- '
',
- :class => 'the-localization-map' )
- else
- content_tag('i', _('This profile has no geographical position registered.'))
+ lambda do
+ render :file => 'blocks/location', :locals => {:block => block, :profile => profile}
end
end
diff --git a/app/views/blocks/location.html.erb b/app/views/blocks/location.html.erb
new file mode 100644
index 0000000..d0ceae4
--- /dev/null
+++ b/app/views/blocks/location.html.erb
@@ -0,0 +1,9 @@
+<% if profile.lat %>
+ <%= block_title block.title %>
+
+

+
+
+<% else %>
+ <%= _('This profile has no geographical position registered.') %>
+<% end %>
diff --git a/test/test_helper.rb b/test/test_helper.rb
index 998581b..36935d4 100644
--- a/test/test_helper.rb
+++ b/test/test_helper.rb
@@ -79,7 +79,7 @@ class ActiveSupport::TestCase
destname = 'test_should_' + name.gsub(/[^a-zA-z0-9]+/, '_')
if @shoulds.include?(destname)
- raise "there is already a test named \"#{destname}\""
+ raise "there is already a test named \"#{destname}\""
end
@shoulds << destname
@@ -121,7 +121,7 @@ class ActiveSupport::TestCase
object.valid?
assert !object.errors.invalid?(attribute)
end
-
+
def assert_subclass(parent, child)
assert_equal parent, child.superclass, "Class #{child} expected to be a subclass of #{parent}"
end
@@ -150,7 +150,7 @@ class ActiveSupport::TestCase
get action, params
end
doc = Hpricot @response.body
-
+
# Test style references:
(doc/'style').each do |s|
s = s.to_s().gsub( /\/\*.*\*\//, '' ).
@@ -193,6 +193,12 @@ class ActiveSupport::TestCase
assert !tag, "expected no tag #{options.inspect}, but tag found in #{text.inspect}"
end
+ # For models that render views (blocks, articles, ...)
+ def render(*args)
+ view_paths = @explicit_view_paths || ActionController::Base.view_paths
+ ActionView::Base.new(view_paths, {}).render(*args)
+ end
+
private
def uses_host(name)
diff --git a/test/unit/location_block_test.rb b/test/unit/location_block_test.rb
index d66699f..7839432 100644
--- a/test/unit/location_block_test.rb
+++ b/test/unit/location_block_test.rb
@@ -2,6 +2,9 @@ require File.dirname(__FILE__) + '/../test_helper'
class LocationBlockTest < ActiveSupport::TestCase
+ ActionView::Base.send :include, BlockHelper
+ include BoxesHelper
+
def setup
@profile = create_user('lele').person
@block = LocationBlock.new
@@ -15,7 +18,7 @@ class LocationBlockTest < ActiveSupport::TestCase
end
should 'display no localization map without lat' do
- assert_tag_in_string block.content, :tag => 'i'
+ assert_tag_in_string extract_block_content(block.content), :tag => 'i'
end
should 'be editable' do
@@ -28,8 +31,10 @@ class LocationBlockTest < ActiveSupport::TestCase
should 'use google maps api v3' do
@block.owner.lat = '-12.34'; @block.owner.save!
- assert_match 'http://maps.google.com/maps/api/staticmap', @block.content
- assert_no_match /key=/, @block.content
+ content = extract_block_content(@block.content)
+
+ assert_match 'http://maps.google.com/maps/api/staticmap', content
+ assert_no_match /key=/, content
end
end
--
libgit2 0.21.2