From d1d958601d05b1521e5eff160095490d3bff03d9 Mon Sep 17 00:00:00 2001 From: Shivam Mishra Date: Mon, 3 Jun 2024 22:49:02 +0530 Subject: [PATCH] test: update cache_key --- spec/controllers/microsoft/callbacks_controller_spec.rb | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/spec/controllers/microsoft/callbacks_controller_spec.rb b/spec/controllers/microsoft/callbacks_controller_spec.rb index 41f91b368..41d8dbd29 100644 --- a/spec/controllers/microsoft/callbacks_controller_spec.rb +++ b/spec/controllers/microsoft/callbacks_controller_spec.rb @@ -4,9 +4,10 @@ RSpec.describe 'Microsoft::CallbacksController', type: :request do let(:account) { create(:account) } let(:code) { SecureRandom.hex(10) } let(:email) { Faker::Internet.email } + let(:cache_key) { "microsoft::#{email.downcase}" } before do - Redis::Alfred.set(email, account.id) + Redis::Alfred.set(cache_key, account.id) end describe 'GET /microsoft/callback' do @@ -35,7 +36,7 @@ RSpec.describe 'Microsoft::CallbacksController', type: :request do expect(inbox.channel.reload.provider_config.keys).to include('access_token', 'refresh_token', 'expires_on') expect(inbox.channel.reload.provider_config['access_token']).to eq response_body_success[:access_token] expect(inbox.channel.imap_address).to eq 'outlook.office365.com' - expect(Redis::Alfred.get(email)).to be_nil + expect(Redis::Alfred.get(cache_key)).to be_nil end it 'creates updates inbox channel config if inbox exists and authentication is successful' do @@ -54,7 +55,7 @@ RSpec.describe 'Microsoft::CallbacksController', type: :request do expect(inbox.channel.reload.provider_config.keys).to include('access_token', 'refresh_token', 'expires_on') expect(inbox.channel.reload.provider_config['access_token']).to eq response_body_success[:access_token] expect(inbox.channel.imap_address).to eq 'outlook.office365.com' - expect(Redis::Alfred.get(email)).to be_nil + expect(Redis::Alfred.get(cache_key)).to be_nil end it 'creates inboxes with fallback_name when account name is not present in id_token' do @@ -80,7 +81,7 @@ RSpec.describe 'Microsoft::CallbacksController', type: :request do get microsoft_callback_url, params: { code: code } expect(response).to redirect_to '/' - expect(Redis::Alfred.get(email).to_i).to eq account.id + expect(Redis::Alfred.get(cache_key).to_i).to eq account.id end end end