From b74b1e3275a25fc3ff5179ddb8b08d55c91509ed Mon Sep 17 00:00:00 2001 From: AntonioTerceiro Date: Wed, 6 Feb 2008 22:02:00 +0000 Subject: [PATCH] ActionItem139: adding new implementation of "profile info" block --- app/models/profile_info_block.rb | 14 ++++++++++++++ app/views/blocks/profile_info.rhtml | 7 +++++++ test/unit/profile_info_block_test.rb | 24 ++++++++++++++++++++++++ 3 files changed, 45 insertions(+), 0 deletions(-) create mode 100644 app/models/profile_info_block.rb create mode 100644 app/views/blocks/profile_info.rhtml create mode 100644 test/unit/profile_info_block_test.rb diff --git a/app/models/profile_info_block.rb b/app/models/profile_info_block.rb new file mode 100644 index 0000000..2c0995f --- /dev/null +++ b/app/models/profile_info_block.rb @@ -0,0 +1,14 @@ +class ProfileInfoBlock < Block + + def self.description + _('Profile information block') + end + + def content + user = owner + lambda do + render :file => 'account/user_info', :locals => { :user => user } + end + end + +end diff --git a/app/views/blocks/profile_info.rhtml b/app/views/blocks/profile_info.rhtml new file mode 100644 index 0000000..a76c312 --- /dev/null +++ b/app/views/blocks/profile_info.rhtml @@ -0,0 +1,7 @@ +

<%= block.owner.name %>

+ + + diff --git a/test/unit/profile_info_block_test.rb b/test/unit/profile_info_block_test.rb new file mode 100644 index 0000000..c70f18e --- /dev/null +++ b/test/unit/profile_info_block_test.rb @@ -0,0 +1,24 @@ +require File.dirname(__FILE__) + '/../test_helper' + +class ProfileInfoBlockTest < Test::Unit::TestCase + + def setup + @profile = create_user('mytestuser').person + + @block = ProfileInfoBlock.new + @profile.boxes.first.blocks << @block + + @block.save! + end + attr_reader :block, :profile + + should 'provide description' do + assert_not_equal Block.description, ProfileInfoBlock.description + end + + should 'display profile information' do + self.expects(:render).with(:file => 'blocks/profile_info', :locals => { :block => block}) + instance_eval(& block.content) + end + +end -- libgit2 0.21.2