Commit 4585f58a55387022d3d01945a74007eaa646cd09

Authored by Antonio Terceiro
1 parent 78f01eb3

ActionItem1245: don't crash before having an environment

app/models/profile.rb
... ... @@ -540,7 +540,7 @@ private :generate_url, :url_options
540 540 end
541 541  
542 542 def custom_header
543   - self[:custom_header] || environment.custom_header
  543 + self[:custom_header] || environment && environment.custom_header
544 544 end
545 545  
546 546 def custom_header_expanded
... ... @@ -556,7 +556,7 @@ private :generate_url, :url_options
556 556 end
557 557  
558 558 def custom_footer
559   - self[:custom_footer] || environment.custom_footer
  559 + self[:custom_footer] || environment && environment.custom_footer
560 560 end
561 561  
562 562 def custom_footer_expanded
... ...
test/unit/profile_test.rb
... ... @@ -851,7 +851,7 @@ class ProfileTest < Test::Unit::TestCase
851 851 profile = Profile.new
852 852 env = mock
853 853 env.expects(:custom_header).returns('environment header')
854   - profile.expects(:environment).returns(env)
  854 + profile.stubs(:environment).returns(env)
855 855  
856 856 assert_equal 'environment header', profile.custom_header
857 857 end
... ... @@ -860,7 +860,7 @@ class ProfileTest < Test::Unit::TestCase
860 860 profile = Profile.new
861 861 env = mock
862 862 env.expects(:custom_footer).returns('environment footer')
863   - profile.expects(:environment).returns(env)
  863 + profile.stubs(:environment).returns(env)
864 864  
865 865 assert_equal 'environment footer', profile.custom_footer
866 866 end
... ...