Commit 3edf123793384bda9020004ef6435e8033d67c27
Committed by
Antonio Terceiro
1 parent
f442790a
Exists in
master
and in
28 other branches
ActionItem1223: short_name in header/control panel
Showing
4 changed files
with
34 additions
and
5 deletions
Show diff stats
app/models/profile.rb
... | ... | @@ -543,11 +543,12 @@ class Profile < ActiveRecord::Base |
543 | 543 | def custom_header_expanded |
544 | 544 | header = custom_header |
545 | 545 | if header |
546 | - if self.respond_to?(:name) && header.include?('{name}') | |
547 | - header.gsub('{name}', self.name) | |
548 | - else | |
549 | - header | |
546 | + %w[name short_name].each do |att| | |
547 | + if self.respond_to?(att) && header.include?("{#{att}}") | |
548 | + header.gsub!("{#{att}}", self.send(att)) | |
549 | + end | |
550 | 550 | end |
551 | + header | |
551 | 552 | end |
552 | 553 | end |
553 | 554 | ... | ... |
app/views/profile_editor/index.rhtml
1 | 1 | <div id="profile-editor-index"> |
2 | 2 | |
3 | 3 | <h1 class="block-title"> |
4 | - <span class='control-panel-title'><%= profile.name %></span> | |
4 | + <span class='control-panel-title'><%= profile.short_name %></span> | |
5 | 5 | <span class='control-panel-sep'>–</span> |
6 | 6 | <span class='control-panel-subtitle'><%= _('Control Panel') %></span> |
7 | 7 | </h1> | ... | ... |
test/functional/profile_editor_controller_test.rb
... | ... | @@ -816,4 +816,20 @@ class ProfileEditorControllerTest < Test::Unit::TestCase |
816 | 816 | end |
817 | 817 | end |
818 | 818 | |
819 | + should 'show profile nickname on title' do | |
820 | + person = create_user('testuser', {}, :nickname => 'my nick').person | |
821 | + get :index, :profile => 'testuser' | |
822 | + assert_tag :tag => 'h1', :attributes => { :class => 'block-title'}, :descendant => { | |
823 | + :tag => 'span', :attributes => { :class => 'control-panel-title' }, :content => 'my nick' | |
824 | + } | |
825 | + end | |
826 | + | |
827 | + should 'show profile name on title when no nickname' do | |
828 | + person = create_user('testuser').person | |
829 | + get :index, :profile => 'testuser' | |
830 | + assert_tag :tag => 'h1', :attributes => { :class => 'block-title'}, :descendant => { | |
831 | + :tag => 'span', :attributes => { :class => 'control-panel-title' }, :content => 'testuser' | |
832 | + } | |
833 | + end | |
834 | + | |
819 | 835 | end | ... | ... |
test/unit/profile_test.rb
... | ... | @@ -809,6 +809,18 @@ class ProfileTest < Test::Unit::TestCase |
809 | 809 | assert_equal 'Custom header of Test', Profile.new(:custom_header => 'Custom header of {name}', :name => 'Test').custom_header_expanded |
810 | 810 | end |
811 | 811 | |
812 | + should 'provide custom header with nickname when use short_name variable' do | |
813 | + profile = Profile.new(:custom_header => 'Custom header of {short_name}', :name => 'Test', :nickname => 'Nickname test') | |
814 | + assert_equal 'Custom header of {short_name}', profile.custom_header | |
815 | + assert_equal 'Custom header of Nickname test', profile.custom_header_expanded | |
816 | + end | |
817 | + | |
818 | + should 'provide custom header with name when use short_name variable and no nickname' do | |
819 | + profile = Profile.new(:custom_header => 'Custom header of {short_name}', :name => 'Test') | |
820 | + assert_equal 'Custom header of {short_name}', profile.custom_header | |
821 | + assert_equal 'Custom header of Test', profile.custom_header_expanded | |
822 | + end | |
823 | + | |
812 | 824 | should 'provide custom footer' do |
813 | 825 | assert_equal 'my custom footer', Profile.new(:custom_footer => 'my custom footer').custom_footer |
814 | 826 | end | ... | ... |