From 2abbfad18cc73c80408a1d57fe78e8c60d340664 Mon Sep 17 00:00:00 2001 From: Luis Ramos Date: Sun, 23 Aug 2020 14:47:30 +0100 Subject: [PATCH] Remove the need to import both :role and :state factory to OFN --- spec/factories/user_factory.rb | 2 +- spec/features/admin/configuration/states_spec.rb | 2 +- spec/services/default_stock_location_spec.rb | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/spec/factories/user_factory.rb b/spec/factories/user_factory.rb index de1774b472..ef5a991461 100644 --- a/spec/factories/user_factory.rb +++ b/spec/factories/user_factory.rb @@ -34,7 +34,7 @@ FactoryBot.define do end factory :admin_user do - spree_roles { [Spree::Role.find_by(name: 'admin') || create(:role, name: 'admin')] } + spree_roles { [Spree::Role.find_or_create_by!(name: 'admin')] } after(:create) do |user| user.spree_roles << Spree::Role.find_or_create_by!(name: 'admin') diff --git a/spec/features/admin/configuration/states_spec.rb b/spec/features/admin/configuration/states_spec.rb index e3a761088d..422cabe745 100755 --- a/spec/features/admin/configuration/states_spec.rb +++ b/spec/features/admin/configuration/states_spec.rb @@ -25,7 +25,7 @@ describe "States" do end context "admin visiting states listing" do - let!(:state) { create(:state, country: country) } + let!(:state) { Spree::State.create(name: 'Alabama', country: country) } it "should correctly display the states" do visit spree.admin_country_states_path(country) diff --git a/spec/services/default_stock_location_spec.rb b/spec/services/default_stock_location_spec.rb index 3bd3a1eb26..52ee7680ca 100644 --- a/spec/services/default_stock_location_spec.rb +++ b/spec/services/default_stock_location_spec.rb @@ -33,7 +33,7 @@ describe DefaultStockLocation do context 'when a location named default already exists' do let!(:location) do country = create(:country) - state = create(:state, country: country) + state = Spree::State.create(name: 'Alabama', country: country) Spree::StockLocation.create!( name: 'default', country_id: country.id,