From 1944e11a514cf06a0be2048ccce4645cf3a31ecb Mon Sep 17 00:00:00 2001 From: Eugene Kenny Date: Fri, 24 Jun 2016 17:40:57 +0100 Subject: [PATCH] Restore Config.api_key= with deprecation warning We've removed the import rake task, along with the associated `api_key` configuration option. This means that users who have added an API key to their initializer will get this error when they update the gem: NoMethodError: method `api_key=' for IntercomRails::Config:Class This brings back the method, but without any behaviour; it just prints a deprecation warning. This will allow those users to update to the latest version of the gem without causing an error when their app boots. --- lib/intercom-rails/config.rb | 4 ++++ spec/config_spec.rb | 6 ++++++ 2 files changed, 10 insertions(+) diff --git a/lib/intercom-rails/config.rb b/lib/intercom-rails/config.rb index 751d949..2725dc4 100644 --- a/lib/intercom-rails/config.rb +++ b/lib/intercom-rails/config.rb @@ -98,6 +98,10 @@ def self.reset! config_accessor :enabled_environments, &ARRAY_VALIDATOR config_accessor :include_for_logged_out_users + def self.api_key=(*) + warn "Setting an Intercom API key is no longer supported; remove the `config.api_key = ...` line from config/initializers/intercom.rb" + end + config_group :user do config_accessor :current, &IS_PROC_OR_ARRAY_OF_PROC_VALIDATOR config_accessor :exclude_if, &IS_PROC_VALIDATOR diff --git a/spec/config_spec.rb b/spec/config_spec.rb index 83502b5..9e28d77 100644 --- a/spec/config_spec.rb +++ b/spec/config_spec.rb @@ -75,4 +75,10 @@ expect(IntercomRails.config.user.custom_data).to eq(nil) expect(IntercomRails.config.inbox.style).to eq(nil) end + + it 'prints a deprecation warning when #api_key= is used' do + expect do + IntercomRails.config.api_key = "foo" + end.to output(/no longer supported/).to_stderr + end end