Commit 3f055a209006cd5c2d836ab78ef4967d0a2b7415

Authored by Rodrigo Souto
Committed by Antonio Terceiro
1 parent 72e95e07

Environment theme overcome profile theme if it's nil

* Profile theme is nil by default.
	* Profile#theme was removed.

(ActionItem1432)
app/helpers/application_helper.rb
... ... @@ -336,7 +336,7 @@ module ApplicationHelper
336 336 elsif ENV['RAILS_ENV'] == 'development' && params[:theme]
337 337 params[:theme]
338 338 else
339   - if profile
  339 + if profile && !profile.theme.nil?
340 340 profile.theme
341 341 elsif environment
342 342 environment.theme
... ...
app/models/profile.rb
... ... @@ -587,10 +587,6 @@ private :generate_url, :url_options
587 587 end
588 588 end
589 589  
590   - def theme
591   - self[:theme] || environment && environment.theme || 'default'
592   - end
593   -
594 590 def public?
595 591 visible && public_profile
596 592 end
... ...
test/unit/application_helper_test.rb
... ... @@ -555,6 +555,12 @@ class ApplicationHelperTest < Test::Unit::TestCase
555 555 assert_equal 'profile-theme', current_theme
556 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 564 protected
559 565  
560 566 def url_for(args = {})
... ...
test/unit/profile_test.rb
... ... @@ -909,15 +909,6 @@ class ProfileTest < Test::Unit::TestCase
909 909 assert_equal 'my-shiny-theme', p.theme
910 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 912 should 'respond to public? as public_profile' do
922 913 p1 = fast_create(Profile)
923 914 p2 = fast_create(Profile, :public_profile => false)
... ...