Commit 87d91ff8683d473a1832c10e74dcd31e17046b05
1 parent
b607a383
Exists in
master
and in
27 other branches
Added variable for link list block of environment
The string {portal} now is replaced by the portal community identifier
(ActionItem3069)
Showing
2 changed files
with
28 additions
and
0 deletions
Show diff stats
app/models/link_list_block.rb
| @@ -70,6 +70,8 @@ class LinkListBlock < Block | @@ -70,6 +70,8 @@ class LinkListBlock < Block | ||
| 70 | def expand_address(address) | 70 | def expand_address(address) |
| 71 | add = if owner.respond_to?(:identifier) | 71 | add = if owner.respond_to?(:identifier) |
| 72 | address.gsub('{profile}', owner.identifier) | 72 | address.gsub('{profile}', owner.identifier) |
| 73 | + elsif owner.is_a?(Environment) && owner.enabled?('use_portal_community') && owner.portal_community | ||
| 74 | + address.gsub('{portal}', owner.portal_community.identifier) | ||
| 73 | else | 75 | else |
| 74 | address | 76 | address |
| 75 | end | 77 | end |
test/unit/link_list_block_test.rb
| @@ -39,6 +39,32 @@ class LinkListBlockTest < ActiveSupport::TestCase | @@ -39,6 +39,32 @@ class LinkListBlockTest < ActiveSupport::TestCase | ||
| 39 | assert_tag_in_string l.content, :tag => 'a', :attributes => {:href => '/test_profile/address'} | 39 | assert_tag_in_string l.content, :tag => 'a', :attributes => {:href => '/test_profile/address'} |
| 40 | end | 40 | end |
| 41 | 41 | ||
| 42 | + should 'replace {portal} with environment portal identifier' do | ||
| 43 | + env = Environment.default | ||
| 44 | + env.enable('use_portal_community') | ||
| 45 | + portal = fast_create(Community, :identifier => 'portal-community', :environment_id => env.id) | ||
| 46 | + env.portal_community = portal | ||
| 47 | + env.save | ||
| 48 | + | ||
| 49 | + stubs(:environment).returns(env) | ||
| 50 | + l = LinkListBlock.new(:links => [{:name => 'categ', :address => '/{portal}/address'}]) | ||
| 51 | + l.stubs(:owner).returns(env) | ||
| 52 | + assert_tag_in_string l.content, :tag => 'a', :attributes => {:href => '/portal-community/address'} | ||
| 53 | + end | ||
| 54 | + | ||
| 55 | + should 'not change address if no {portal} there' do | ||
| 56 | + env = Environment.default | ||
| 57 | + env.enable('use_portal_community') | ||
| 58 | + portal = fast_create(Community, :identifier => 'portal-community', :environment_id => env.id) | ||
| 59 | + env.portal_community = portal | ||
| 60 | + env.save | ||
| 61 | + | ||
| 62 | + stubs(:environment).returns(env) | ||
| 63 | + l = LinkListBlock.new(:links => [{:name => 'categ', :address => '/address'}]) | ||
| 64 | + l.stubs(:owner).returns(env) | ||
| 65 | + assert_tag_in_string l.content, :tag => 'a', :attributes => {:href => '/address'} | ||
| 66 | + end | ||
| 67 | + | ||
| 42 | should 'display options for icons' do | 68 | should 'display options for icons' do |
| 43 | l = LinkListBlock.new | 69 | l = LinkListBlock.new |
| 44 | l.icons_options.each do |option| | 70 | l.icons_options.each do |option| |