diff --git a/plugins/people_block/lib/friends_block.rb b/plugins/people_block/lib/friends_block.rb
index f8865e0..594c90d 100644
--- a/plugins/people_block/lib/friends_block.rb
+++ b/plugins/people_block/lib/friends_block.rb
@@ -24,7 +24,7 @@ class FriendsBlock < PeopleBlockBase
profile = self.owner
suggestions = self.suggestions
proc do
- render :file => 'blocks/friends', :locals => { :profile => profile, :suggestions => suggestions }
+ render :file => 'blocks/footers/friends', :locals => { :profile => profile, :suggestions => suggestions }
end
end
diff --git a/plugins/people_block/lib/members_block.rb b/plugins/people_block/lib/members_block.rb
index 9abb3d3..4514597 100644
--- a/plugins/people_block/lib/members_block.rb
+++ b/plugins/people_block/lib/members_block.rb
@@ -25,7 +25,7 @@ class MembersBlock < PeopleBlockBase
role_key = visible_role
s = show_join_leave_button
proc do
- render :file => 'blocks/members', :locals => { :profile => profile, :show_join_leave_button => s, :role_key => role_key}
+ render :file => 'blocks/footers/members', :locals => { :profile => profile, :show_join_leave_button => s, :role_key => role_key}
end
end
diff --git a/plugins/people_block/lib/people_block.rb b/plugins/people_block/lib/people_block.rb
index 2836f35..b70c774 100644
--- a/plugins/people_block/lib/people_block.rb
+++ b/plugins/people_block/lib/people_block.rb
@@ -18,7 +18,7 @@ class PeopleBlock < PeopleBlockBase
def footer
proc do
- render :file => 'blocks/people'
+ render :file => 'blocks/footers/people'
end
end
diff --git a/plugins/people_block/lib/people_block_base.rb b/plugins/people_block/lib/people_block_base.rb
index 149b450..0531e43 100644
--- a/plugins/people_block/lib/people_block_base.rb
+++ b/plugins/people_block/lib/people_block_base.rb
@@ -42,6 +42,7 @@ class PeopleBlockBase < Block
profiles.visible.count
end
+=begin
def content(args={})
profiles = self.profile_list
title = self.view_title
@@ -84,7 +85,7 @@ class PeopleBlockBase < Block
block_title(title) + content_tag('div', list + tag('br', :style => 'clear:both'))
end
end
-
+=end
def expand_address(address)
if address !~ /^[a-z]+:\/\// && address !~ /^\//
'http://' + address
diff --git a/plugins/people_block/lib/people_block_helper.rb b/plugins/people_block/lib/people_block_helper.rb
new file mode 100644
index 0000000..1492812
--- /dev/null
+++ b/plugins/people_block/lib/people_block_helper.rb
@@ -0,0 +1,9 @@
+module PeopleBlockHelper
+ def profiles_images_list(profiles)
+ profiles.map { |profile| profile_image_link(profile, :minor) }.join("\n")
+ end
+
+ def set_address_protocol(address)
+ !URI.parse(address).scheme ? 'http://'+address : address
+ end
+end
diff --git a/plugins/people_block/test/unit/friends_block_test.rb b/plugins/people_block/test/unit/friends_block_test.rb
index 390ea39..f813af7 100644
--- a/plugins/people_block/test/unit/friends_block_test.rb
+++ b/plugins/people_block/test/unit/friends_block_test.rb
@@ -60,26 +60,6 @@ class FriendsBlockTest < ActionView::TestCase
assert_equal 20, block.limit
end
- should 'list friends from person' do
- owner = fast_create(Person)
- friend1 = fast_create(Person)
- friend2 = fast_create(Person)
- owner.add_friend(friend1)
- owner.add_friend(friend2)
-
- block = FriendsBlock.new
-
- block.expects(:owner).returns(owner).at_least_once
- expects(:profile_image_link).with(friend1, :minor).returns(friend1.name)
- expects(:profile_image_link).with(friend2, :minor).returns(friend2.name)
- expects(:block_title).with(anything).returns('')
-
- content = instance_eval(&block.content)
-
- assert_match(/#{friend1.name}/, content)
- assert_match(/#{friend2.name}/, content)
- end
-
should 'link to "all friends"' do
person1 = create_user('mytestperson').person
@@ -151,3 +131,29 @@ class FriendsBlockTest < ActionView::TestCase
include NoosferoTestHelper
end
+
+require 'boxes_helper'
+
+class FriendsBlockViewTest < ActionView::TestCase
+ include BoxesHelper
+
+ should 'list friends from person' do
+ owner = fast_create(Person)
+ friend1 = fast_create(Person)
+ friend2 = fast_create(Person)
+ owner.add_friend(friend1)
+ owner.add_friend(friend2)
+
+ block = FriendsBlock.new
+
+ block.expects(:owner).returns(owner).at_least_once
+ ActionView::Base.any_instance.expects(:profile_image_link).with(friend1, :minor).returns(friend1.name)
+ ActionView::Base.any_instance.expects(:profile_image_link).with(friend2, :minor).returns(friend2.name)
+ ActionView::Base.any_instance.expects(:block_title).with(anything).returns('')
+
+ content = render_block_content(block)
+
+ assert_match(/#{friend1.name}/, content)
+ assert_match(/#{friend2.name}/, content)
+ end
+end
diff --git a/plugins/people_block/test/unit/members_block_test.rb b/plugins/people_block/test/unit/members_block_test.rb
index a3a8c9d..1dcae46 100644
--- a/plugins/people_block/test/unit/members_block_test.rb
+++ b/plugins/people_block/test/unit/members_block_test.rb
@@ -90,26 +90,6 @@ class MembersBlockTest < ActionView::TestCase
end
- should 'list members from community' do
- owner = fast_create(Community)
- person1 = fast_create(Person)
- person2 = fast_create(Person)
- owner.add_member(person1)
- owner.add_member(person2)
-
- block = MembersBlock.new
-
- block.expects(:owner).returns(owner).at_least_once
- expects(:profile_image_link).with(person1, :minor).returns(person1.name)
- expects(:profile_image_link).with(person2, :minor).returns(person2.name)
- expects(:block_title).with(anything).returns('')
-
- content = instance_eval(&block.content)
-
- assert_match(/#{person1.name}/, content)
- assert_match(/#{person2.name}/, content)
- end
-
should 'count number of public and private members' do
owner = fast_create(Community)
private_p = fast_create(Person, {:public_profile => false})
@@ -299,3 +279,31 @@ class MembersBlockTest < ActionView::TestCase
include NoosferoTestHelper
end
+
+require 'boxes_helper'
+
+class MembersBlockViewTest < ActionView::TestCase
+ include BoxesHelper
+
+ should 'list members from community' do
+ owner = fast_create(Community)
+ person1 = fast_create(Person)
+ person2 = fast_create(Person)
+ owner.add_member(person1)
+ owner.add_member(person2)
+ profile = Profile.new
+ profile.identifier = 42
+
+ block = MembersBlock.new
+
+ block.expects(:owner).returns(owner).at_least_once
+ ActionView::Base.any_instance.expects(:profile_image_link).with(person1, :minor).returns(person1.name)
+ ActionView::Base.any_instance.expects(:profile_image_link).with(person2, :minor).returns(person2.name)
+ ActionView::Base.any_instance.expects(:block_title).with(anything).returns('')
+
+ content = render_block_content(block)
+
+ assert_match(/#{person1.name}/, content)
+ assert_match(/#{person2.name}/, content)
+ end
+end
diff --git a/plugins/people_block/test/unit/people_block_helper_test.rb b/plugins/people_block/test/unit/people_block_helper_test.rb
new file mode 100644
index 0000000..ea52ded
--- /dev/null
+++ b/plugins/people_block/test/unit/people_block_helper_test.rb
@@ -0,0 +1,37 @@
+require 'test_helper'
+
+class PeopleBlockHelperTest < ActionView::TestCase
+ include PeopleBlockHelper
+
+ should 'list profiles as images links' do
+ owner = fast_create(Environment)
+ profiles = [
+ fast_create(Person, :environment_id => owner.id),
+ fast_create(Person, :environment_id => owner.id),
+ fast_create(Person, :environment_id => owner.id)
+ ]
+ link_html = ""
+
+ profiles.each do |profile|
+ expects(:profile_image_link).with(profile, :minor).returns(link_html)
+ end
+
+ list = profiles_images_list(profiles)
+
+ assert_equal list, ([link_html]*profiles.count).join("\n")
+ end
+
+ should 'prepend the protocol to urls missing it' do
+ address = 'noosfero.org'
+
+ assert_equal set_address_protocol(address), 'http://'+address
+ end
+
+ should 'leave urls already with protocol unchanged' do
+ address = 'http://noosfero.org'
+ ssl_address = 'https://noosfero.org'
+
+ assert_equal set_address_protocol(address), address
+ assert_equal set_address_protocol(ssl_address), ssl_address
+ end
+end
\ No newline at end of file
diff --git a/plugins/people_block/test/unit/people_block_test.rb b/plugins/people_block/test/unit/people_block_test.rb
index bf5e7ba..1350c38 100644
--- a/plugins/people_block/test/unit/people_block_test.rb
+++ b/plugins/people_block/test/unit/people_block_test.rb
@@ -85,25 +85,6 @@ class PeopleBlockTest < ActionView::TestCase
end
- should 'list people from environment' do
- owner = fast_create(Environment)
- person1 = fast_create(Person, :environment_id => owner.id)
- person2 = fast_create(Person, :environment_id => owner.id)
-
- block = PeopleBlock.new
-
- block.expects(:owner).returns(owner).at_least_once
- expects(:profile_image_link).with(person1, :minor).returns(person1.name)
- expects(:profile_image_link).with(person2, :minor).returns(person2.name)
- expects(:block_title).with(anything).returns('')
-
- content = instance_exec(&block.content)
-
- assert_match(/#{person1.name}/, content)
- assert_match(/#{person2.name}/, content)
- end
-
-
should 'link to "all people"' do
env = fast_create(Environment)
block = PeopleBlock.new
@@ -142,3 +123,27 @@ class PeopleBlockTest < ActionView::TestCase
include NoosferoTestHelper
end
+
+require 'boxes_helper'
+
+class PeopleBlockViewTest < ActionView::TestCase
+ include BoxesHelper
+
+ should 'list people from environment' do
+ owner = fast_create(Environment)
+ person1 = fast_create(Person, :environment_id => owner.id)
+ person2 = fast_create(Person, :environment_id => owner.id)
+
+ block = PeopleBlock.new
+
+ block.expects(:owner).returns(owner).at_least_once
+ ActionView::Base.any_instance.expects(:profile_image_link).with(person1, :minor).returns(person1.name)
+ ActionView::Base.any_instance.expects(:profile_image_link).with(person2, :minor).returns(person2.name)
+ ActionView::Base.any_instance.stubs(:block_title).returns("")
+
+ content = render_block_content(block)
+
+ assert_match(/#{person1.name}/, content)
+ assert_match(/#{person2.name}/, content)
+ end
+end
diff --git a/plugins/people_block/views/blocks/footers/friends.html.erb b/plugins/people_block/views/blocks/footers/friends.html.erb
new file mode 100644
index 0000000..1908442
--- /dev/null
+++ b/plugins/people_block/views/blocks/footers/friends.html.erb
@@ -0,0 +1,13 @@
+<%= link_to s_('friends|View all'), {:profile => profile.identifier, :controller => 'profile', :action => 'friends'}, :class => 'view-all' %>
+
+<% if !suggestions.empty? && user == profile %>
+