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