diff --git a/app/models/link_list_block.rb b/app/models/link_list_block.rb index 216bef9..3a093e4 100644 --- a/app/models/link_list_block.rb +++ b/app/models/link_list_block.rb @@ -70,6 +70,8 @@ class LinkListBlock < Block def expand_address(address) add = if owner.respond_to?(:identifier) address.gsub('{profile}', owner.identifier) + elsif owner.is_a?(Environment) && owner.enabled?('use_portal_community') && owner.portal_community + address.gsub('{portal}', owner.portal_community.identifier) else address end diff --git a/test/unit/link_list_block_test.rb b/test/unit/link_list_block_test.rb index cbc52df..9d2210c 100644 --- a/test/unit/link_list_block_test.rb +++ b/test/unit/link_list_block_test.rb @@ -39,6 +39,32 @@ class LinkListBlockTest < ActiveSupport::TestCase assert_tag_in_string l.content, :tag => 'a', :attributes => {:href => '/test_profile/address'} end + should 'replace {portal} with environment portal identifier' do + env = Environment.default + env.enable('use_portal_community') + portal = fast_create(Community, :identifier => 'portal-community', :environment_id => env.id) + env.portal_community = portal + env.save + + stubs(:environment).returns(env) + l = LinkListBlock.new(:links => [{:name => 'categ', :address => '/{portal}/address'}]) + l.stubs(:owner).returns(env) + assert_tag_in_string l.content, :tag => 'a', :attributes => {:href => '/portal-community/address'} + end + + should 'not change address if no {portal} there' do + env = Environment.default + env.enable('use_portal_community') + portal = fast_create(Community, :identifier => 'portal-community', :environment_id => env.id) + env.portal_community = portal + env.save + + stubs(:environment).returns(env) + l = LinkListBlock.new(:links => [{:name => 'categ', :address => '/address'}]) + l.stubs(:owner).returns(env) + assert_tag_in_string l.content, :tag => 'a', :attributes => {:href => '/address'} + end + should 'display options for icons' do l = LinkListBlock.new l.icons_options.each do |option| -- libgit2 0.21.2