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.

Add first and last name attributes to `admin_user` factory (#12323)

Damian Kaczmarczyk1f3ced513104
diff --git a/core/db/migrate/20250122113708_add_first_and_last_name_to_spree_admin_class.rb b/core/db/migrate/20250122113708_add_first_and_last_name_to_spree_admin_class.rb
new file mode 100644
index 0000000000..89b0ebfa5c
--- /dev/null
+++ b/core/db/migrate/20250122113708_add_first_and_last_name_to_spree_admin_class.rb
@@ -0,0 +1,9 @@
+class AddFirstAndLastNameToSpreeAdminClass < ActiveRecord::Migration[7.2]
+ def change
+ if Spree.admin_user_class.present?
+ admin_users_table_name = Spree.admin_user_class.table_name
+ add_column admin_users_table_name, :first_name, :string unless column_exists?(admin_users_table_name, :first_name)
+ add_column admin_users_table_name, :last_name, :string unless column_exists?(admin_users_table_name, :last_name)
+ end
+ end
+end
diff --git a/core/lib/spree/testing_support/factories/user_factory.rb b/core/lib/spree/testing_support/factories/user_factory.rb
index 1722c5a048..4a7bac5ce3 100644
--- a/core/lib/spree/testing_support/factories/user_factory.rb
+++ b/core/lib/spree/testing_support/factories/user_factory.rb
@@ -27,6 +27,8 @@ FactoryBot.define do
login { email }
password { 'secret' }
password_confirmation { password }
+ first_name { FFaker::Name.first_name }
+ last_name { FFaker::Name.last_name }
spree_roles { [Spree::Role.find_by(name: 'admin') || create(:role, name: 'admin')] }
end