From d261dfd39434e20692aa7e5d869010da1171b2e1 Mon Sep 17 00:00:00 2001 From: Vishnu Narayanan Date: Thu, 20 Nov 2025 23:11:59 +0530 Subject: [PATCH] fix: shopify and locale spec --- .../shopify/callbacks_controller_spec.rb | 6 ++---- spec/models/concerns/switch_locale_spec.rb | 13 ++++++------- 2 files changed, 8 insertions(+), 11 deletions(-) diff --git a/spec/controllers/shopify/callbacks_controller_spec.rb b/spec/controllers/shopify/callbacks_controller_spec.rb index cb75e23b4..fbff93cb4 100644 --- a/spec/controllers/shopify/callbacks_controller_spec.rb +++ b/spec/controllers/shopify/callbacks_controller_spec.rb @@ -94,10 +94,8 @@ RSpec.describe Shopify::CallbacksController, type: :request do context 'when state parameter is invalid' do before do - controller = described_class.new - allow(controller).to receive(:verify_shopify_token).with(state).and_return(nil) - allow(controller).to receive(:account).and_return(nil) - allow(described_class).to receive(:new).and_return(controller) + allow_any_instance_of(Shopify::CallbacksController).to receive(:verify_shopify_token).and_return(nil) + allow_any_instance_of(Shopify::CallbacksController).to receive(:account).and_return(nil) end it 'redirects to the frontend URL with error' do diff --git a/spec/models/concerns/switch_locale_spec.rb b/spec/models/concerns/switch_locale_spec.rb index 05853cbf2..421f254a0 100644 --- a/spec/models/concerns/switch_locale_spec.rb +++ b/spec/models/concerns/switch_locale_spec.rb @@ -81,15 +81,14 @@ RSpec.describe 'SwitchLocale Concern', type: :controller do end describe '#switch_locale_using_account_locale' do + before do + routes.draw { get 'account_locale' => 'anonymous#account_locale' } + end + it 'sets locale from account' do controller.instance_variable_set(:@current_account, account) - - result = nil - controller.send(:switch_locale_using_account_locale) do - result = I18n.locale.to_s - end - - expect(result).to eq('es') + get :account_locale + expect(response.body).to eq('es') end end end