Commit 3f055a209006cd5c2d836ab78ef4967d0a2b7415
Committed by
Antonio Terceiro
1 parent
72e95e07
Exists in
master
and in
29 other branches
Environment theme overcome profile theme if it's nil
* Profile theme is nil by default. * Profile#theme was removed. (ActionItem1432)
Showing
4 changed files
with
7 additions
and
14 deletions
Show diff stats
app/helpers/application_helper.rb
@@ -336,7 +336,7 @@ module ApplicationHelper | @@ -336,7 +336,7 @@ module ApplicationHelper | ||
336 | elsif ENV['RAILS_ENV'] == 'development' && params[:theme] | 336 | elsif ENV['RAILS_ENV'] == 'development' && params[:theme] |
337 | params[:theme] | 337 | params[:theme] |
338 | else | 338 | else |
339 | - if profile | 339 | + if profile && !profile.theme.nil? |
340 | profile.theme | 340 | profile.theme |
341 | elsif environment | 341 | elsif environment |
342 | environment.theme | 342 | environment.theme |
app/models/profile.rb
@@ -587,10 +587,6 @@ private :generate_url, :url_options | @@ -587,10 +587,6 @@ private :generate_url, :url_options | ||
587 | end | 587 | end |
588 | end | 588 | end |
589 | 589 | ||
590 | - def theme | ||
591 | - self[:theme] || environment && environment.theme || 'default' | ||
592 | - end | ||
593 | - | ||
594 | def public? | 590 | def public? |
595 | visible && public_profile | 591 | visible && public_profile |
596 | end | 592 | end |
test/unit/application_helper_test.rb
@@ -555,6 +555,12 @@ class ApplicationHelperTest < Test::Unit::TestCase | @@ -555,6 +555,12 @@ class ApplicationHelperTest < Test::Unit::TestCase | ||
555 | assert_equal 'profile-theme', current_theme | 555 | assert_equal 'profile-theme', current_theme |
556 | end | 556 | end |
557 | 557 | ||
558 | + should 'use environment theme if the profile theme is nil' do | ||
559 | + stubs(:environment).returns(fast_create(Environment, :theme => 'new-theme')) | ||
560 | + stubs(:profile).returns(fast_create(Profile)) | ||
561 | + assert_equal environment.theme, current_theme | ||
562 | + end | ||
563 | + | ||
558 | protected | 564 | protected |
559 | 565 | ||
560 | def url_for(args = {}) | 566 | def url_for(args = {}) |
test/unit/profile_test.rb
@@ -909,15 +909,6 @@ class ProfileTest < Test::Unit::TestCase | @@ -909,15 +909,6 @@ class ProfileTest < Test::Unit::TestCase | ||
909 | assert_equal 'my-shiny-theme', p.theme | 909 | assert_equal 'my-shiny-theme', p.theme |
910 | end | 910 | end |
911 | 911 | ||
912 | - should 'delegate theme selection to environment by default' do | ||
913 | - p = Profile.new | ||
914 | - env = mock | ||
915 | - p.stubs(:environment).returns(env) | ||
916 | - env.expects(:theme).returns('environment-stored-theme') | ||
917 | - | ||
918 | - assert_equal 'environment-stored-theme', p.theme | ||
919 | - end | ||
920 | - | ||
921 | should 'respond to public? as public_profile' do | 912 | should 'respond to public? as public_profile' do |
922 | p1 = fast_create(Profile) | 913 | p1 = fast_create(Profile) |
923 | p2 = fast_create(Profile, :public_profile => false) | 914 | p2 = fast_create(Profile, :public_profile => false) |