diff --git a/app/models/channel.rb b/app/models/channel.rb index e65576c74..372adec54 100644 --- a/app/models/channel.rb +++ b/app/models/channel.rb @@ -8,7 +8,7 @@ class Channel < ApplicationModel store :options store :preferences - after_initialize :refresh_xoaut2! + after_initialize :refresh_xoauth2! after_create :email_address_check after_update :email_address_check after_destroy :email_address_check @@ -336,7 +336,7 @@ get instance of channel driver self.class.driver_class(options[:adapter]) end - def refresh_xoaut2! + def refresh_xoauth2! return if options.dig(:auth, :type) != 'XOAUTH2' result = ExternalCredential.refresh_token(options[:auth][:provider], options[:auth]) diff --git a/spec/factories/channel.rb b/spec/factories/channel.rb index 36e670a37..2096fcb1a 100644 --- a/spec/factories/channel.rb +++ b/spec/factories/channel.rb @@ -1,6 +1,6 @@ FactoryBot.define do factory :channel do - # ensure the `refresh_xoaut2!` `after_initialize` callback gets executed + # ensure the `refresh_xoauth2!` `after_initialize` callback gets executed # https://stackoverflow.com/questions/5916162/problem-with-factory-girl-association-and-after-initialize#comment51639005_28057070 initialize_with { new(attributes) } diff --git a/spec/lib/external_credential/google_spec.rb b/spec/lib/external_credential/google_spec.rb index 33b1f584c..f559de240 100644 --- a/spec/lib/external_credential/google_spec.rb +++ b/spec/lib/external_credential/google_spec.rb @@ -241,7 +241,7 @@ RSpec.describe ExternalCredential::Google do it 'does not refresh' do expect do - channel.refresh_xoaut2! + channel.refresh_xoauth2! end.not_to change { channel.options['auth']['created_at'] } end end @@ -265,7 +265,7 @@ RSpec.describe ExternalCredential::Google do it 'refreshes token' do expect do - channel.refresh_xoaut2! + channel.refresh_xoauth2! end.to change { channel.options['auth'] }.to a_hash_including( 'created_at' => Time.zone.now, 'access_token' => refreshed_access_token, @@ -286,7 +286,7 @@ RSpec.describe ExternalCredential::Google do shared_examples 'failed attempt' do it 'raises an exception' do expect do - channel.refresh_xoaut2! + channel.refresh_xoauth2! end.to raise_error(RuntimeError, exception_message) end end diff --git a/spec/lib/external_credential/microsoft365_spec.rb b/spec/lib/external_credential/microsoft365_spec.rb index 514084ccf..caae2a1cb 100644 --- a/spec/lib/external_credential/microsoft365_spec.rb +++ b/spec/lib/external_credential/microsoft365_spec.rb @@ -202,7 +202,7 @@ RSpec.describe ExternalCredential::Microsoft365 do it 'does not refresh' do expect do - channel.refresh_xoaut2! + channel.refresh_xoauth2! end.not_to change { channel.options['auth']['created_at'] } end end @@ -226,7 +226,7 @@ RSpec.describe ExternalCredential::Microsoft365 do it 'refreshes token' do expect do - channel.refresh_xoaut2! + channel.refresh_xoauth2! end.to change { channel.options['auth'] }.to a_hash_including( 'created_at' => Time.zone.now, 'access_token' => refreshed_access_token, @@ -247,7 +247,7 @@ RSpec.describe ExternalCredential::Microsoft365 do shared_examples 'failed attempt' do it 'raises an exception' do expect do - channel.refresh_xoaut2! + channel.refresh_xoauth2! end.to raise_error(RuntimeError, exception_message) end end