From 5a3b9c97e34ee69312ef9bcf575894a106c5a271 Mon Sep 17 00:00:00 2001 From: Robert Speicher Date: Wed, 23 Dec 2015 17:14:18 -0500 Subject: [PATCH] Account for `@project.description` being nil --- app/helpers/page_layout_helper.rb | 2 +- spec/helpers/page_layout_helper_spec.rb | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/app/helpers/page_layout_helper.rb b/app/helpers/page_layout_helper.rb index 6b16528dde6..c4eb09bea2b 100644 --- a/app/helpers/page_layout_helper.rb +++ b/app/helpers/page_layout_helper.rb @@ -40,7 +40,7 @@ module PageLayoutHelper # a view def page_description_default if @project - @project.description + @project.description || brand_title else brand_title end diff --git a/spec/helpers/page_layout_helper_spec.rb b/spec/helpers/page_layout_helper_spec.rb index a60b8f508f2..5d95beac908 100644 --- a/spec/helpers/page_layout_helper_spec.rb +++ b/spec/helpers/page_layout_helper_spec.rb @@ -37,6 +37,14 @@ describe PageLayoutHelper do expect(helper.page_description_default).to eq 'Project Description' end + it 'uses brand_title when Project description is nil' do + project = double(description: nil) + helper.instance_variable_set(:@project, project) + + expect(helper).to receive(:brand_title).and_return('Brand Title') + expect(helper.page_description_default).to eq 'Brand Title' + end + it 'falls back to brand_title' do allow(helper).to receive(:brand_title).and_return('Brand Title')