diff --git a/app/models/profile.rb b/app/models/profile.rb
index c3316c3..4788089 100644
--- a/app/models/profile.rb
+++ b/app/models/profile.rb
@@ -543,11 +543,12 @@ class Profile < ActiveRecord::Base
def custom_header_expanded
header = custom_header
if header
- if self.respond_to?(:name) && header.include?('{name}')
- header.gsub('{name}', self.name)
- else
- header
+ %w[name short_name].each do |att|
+ if self.respond_to?(att) && header.include?("{#{att}}")
+ header.gsub!("{#{att}}", self.send(att))
+ end
end
+ header
end
end
diff --git a/app/views/profile_editor/index.rhtml b/app/views/profile_editor/index.rhtml
index 6c4ef76..8244e40 100644
--- a/app/views/profile_editor/index.rhtml
+++ b/app/views/profile_editor/index.rhtml
@@ -1,7 +1,7 @@
- <%= profile.name %>
+ <%= profile.short_name %>
<%= _('Control Panel') %>
diff --git a/test/functional/profile_editor_controller_test.rb b/test/functional/profile_editor_controller_test.rb
index 9430143..b59b63a 100644
--- a/test/functional/profile_editor_controller_test.rb
+++ b/test/functional/profile_editor_controller_test.rb
@@ -816,4 +816,20 @@ class ProfileEditorControllerTest < Test::Unit::TestCase
end
end
+ should 'show profile nickname on title' do
+ person = create_user('testuser', {}, :nickname => 'my nick').person
+ get :index, :profile => 'testuser'
+ assert_tag :tag => 'h1', :attributes => { :class => 'block-title'}, :descendant => {
+ :tag => 'span', :attributes => { :class => 'control-panel-title' }, :content => 'my nick'
+ }
+ end
+
+ should 'show profile name on title when no nickname' do
+ person = create_user('testuser').person
+ get :index, :profile => 'testuser'
+ assert_tag :tag => 'h1', :attributes => { :class => 'block-title'}, :descendant => {
+ :tag => 'span', :attributes => { :class => 'control-panel-title' }, :content => 'testuser'
+ }
+ end
+
end
diff --git a/test/unit/profile_test.rb b/test/unit/profile_test.rb
index 132bc71..5f8890c 100644
--- a/test/unit/profile_test.rb
+++ b/test/unit/profile_test.rb
@@ -809,6 +809,18 @@ class ProfileTest < Test::Unit::TestCase
assert_equal 'Custom header of Test', Profile.new(:custom_header => 'Custom header of {name}', :name => 'Test').custom_header_expanded
end
+ should 'provide custom header with nickname when use short_name variable' do
+ profile = Profile.new(:custom_header => 'Custom header of {short_name}', :name => 'Test', :nickname => 'Nickname test')
+ assert_equal 'Custom header of {short_name}', profile.custom_header
+ assert_equal 'Custom header of Nickname test', profile.custom_header_expanded
+ end
+
+ should 'provide custom header with name when use short_name variable and no nickname' do
+ profile = Profile.new(:custom_header => 'Custom header of {short_name}', :name => 'Test')
+ assert_equal 'Custom header of {short_name}', profile.custom_header
+ assert_equal 'Custom header of Test', profile.custom_header_expanded
+ end
+
should 'provide custom footer' do
assert_equal 'my custom footer', Profile.new(:custom_footer => 'my custom footer').custom_footer
end
--
libgit2 0.21.2