Skip to content

armgit / spree

Public Imported from GitHub
0

Open Source Platform for DTC, B2B Commerce, Marketplaces & Omnichannel. REST APIs, TypeScript SDKs, and production-ready Next.js storefront. Self-host it. Own your data. No vendor lock-in. Zero platform fees.

Fixed test environment for Admin Dashboard (#11546)

Damian Legawiecdfc27ab03236
diff --git a/core/lib/spree/testing_support/authorization_helpers.rb b/core/lib/spree/testing_support/authorization_helpers.rb
index 53b7c68f9a..668e3da875 100644
--- a/core/lib/spree/testing_support/authorization_helpers.rb
+++ b/core/lib/spree/testing_support/authorization_helpers.rb
@@ -37,11 +37,13 @@ module Spree
ability_class.register_ability(ability)
end
- let(:admin_token) { Spree::OauthAccessToken.create!(scopes: 'admin read write').token }
+ let(:admin_app) { Spree::OauthApplication.create!(name: 'Admin Panel', scopes: 'admin') }
+ let(:admin_token) { Spree::OauthAccessToken.create!(application: admin_app, scopes: 'admin').token }
before do
allow(Spree.user_class).to receive(:find_by).and_return(Spree.user_class.new)
if defined?(Spree::Admin)
+ allow_any_instance_of(Spree::Admin::BaseController).to receive(:admin_oauth_application).and_return(admin_app)
allow_any_instance_of(Spree::Admin::BaseController).to receive(:admin_oauth_token).and_return(admin_token)
end
end