From e062e71c4a8ae6343179362541a049d5cb71c6c0 Mon Sep 17 00:00:00 2001 From: Justin Powell Date: Thu, 16 May 2019 15:36:54 -0500 Subject: [PATCH 1/2] resolve site config constant before instantiating --- .../wcc/contentful/app/pages_controller.rb | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/wcc-contentful-app/app/controllers/wcc/contentful/app/pages_controller.rb b/wcc-contentful-app/app/controllers/wcc/contentful/app/pages_controller.rb index 53330fd7..1e4555df 100644 --- a/wcc-contentful-app/app/controllers/wcc/contentful/app/pages_controller.rb +++ b/wcc-contentful-app/app/controllers/wcc/contentful/app/pages_controller.rb @@ -46,10 +46,16 @@ def redirect_model WCC::Contentful::Model.resolve_constant('redirect') end - def global_site_config + def site_config_model # They may have not installed `site-config` in the project - return unless defined?(WCC::Contentful::Model::SiteConfig) + WCC::Contentful::Model.resolve_constant('site-config') + rescue WCC::Contentful::ContentTypeNotFoundError + nil + end + + def global_site_config + return unless model = site_config_model - @global_site_config ||= WCC::Contentful::Model::SiteConfig.instance(preview?) + @global_site_config ||= model.instance(preview?) end end From 465377ed680a20219059be2072d6ee227c37e6dc Mon Sep 17 00:00:00 2001 From: Justin Powell Date: Thu, 16 May 2019 15:45:50 -0500 Subject: [PATCH 2/2] dont assign test var to appease rubocop --- .../spec/wcc/contentful/store/lazy_cache_store_spec.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wcc-contentful/spec/wcc/contentful/store/lazy_cache_store_spec.rb b/wcc-contentful/spec/wcc/contentful/store/lazy_cache_store_spec.rb index a30e83cb..13b3da33 100644 --- a/wcc-contentful/spec/wcc/contentful/store/lazy_cache_store_spec.rb +++ b/wcc-contentful/spec/wcc/contentful/store/lazy_cache_store_spec.rb @@ -224,7 +224,7 @@ .times(2) # act - main_menu = store.find_all(content_type: 'menu') + store.find_all(content_type: 'menu') .apply(name: 'Main Menu') .first end