Skip to content

Commit

Permalink
Follow FactoryBot rename
Browse files Browse the repository at this point in the history
FactoryGirl has been renamed to FactoryBot. This changes all occurences of
FactoryGirl to follow their new naming convention.

This also fixes our sample app builds.
  • Loading branch information
mamhoff committed Oct 23, 2017
1 parent 88f531a commit 60df971
Show file tree
Hide file tree
Showing 103 changed files with 260 additions and 260 deletions.
16 changes: 8 additions & 8 deletions api/spec/features/checkout_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,16 @@
module Spree
describe 'Api Feature Specs', type: :request do
before { Spree::Api::Config[:requires_authentication] = false }
let!(:promotion) { FactoryGirl.create(:promotion, :with_order_adjustment, code: 'foo', weighted_order_adjustment_amount: 10) }
let!(:promotion) { FactoryBot.create(:promotion, :with_order_adjustment, code: 'foo', weighted_order_adjustment_amount: 10) }
let(:promotion_code) { promotion.codes.first }
let!(:store) { FactoryGirl.create(:store) }
let(:bill_address) { FactoryGirl.create(:address) }
let(:ship_address) { FactoryGirl.create(:address) }
let(:variant_1) { FactoryGirl.create(:variant, price: 100.00) }
let(:variant_2) { FactoryGirl.create(:variant, price: 200.00) }
let(:payment_method) { FactoryGirl.create(:check_payment_method) }
let!(:store) { FactoryBot.create(:store) }
let(:bill_address) { FactoryBot.create(:address) }
let(:ship_address) { FactoryBot.create(:address) }
let(:variant_1) { FactoryBot.create(:variant, price: 100.00) }
let(:variant_2) { FactoryBot.create(:variant, price: 200.00) }
let(:payment_method) { FactoryBot.create(:check_payment_method) }
let!(:shipping_method) do
FactoryGirl.create(:shipping_method).tap do |shipping_method|
FactoryBot.create(:shipping_method).tap do |shipping_method|
shipping_method.zones.first.zone_members.create!(zoneable: ship_address.country)
shipping_method.calculator.set_preference(:amount, 10.0)
end
Expand Down
4 changes: 2 additions & 2 deletions api/spec/requests/spree/api/orders_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ module Spree

describe 'GET #show' do
let(:order) { create :order_with_line_items }
let(:adjustment) { FactoryGirl.create(:adjustment, adjustable: order, order: order) }
let(:adjustment) { FactoryBot.create(:adjustment, adjustable: order, order: order) }

subject { get spree.api_order_path(order) }

Expand Down Expand Up @@ -569,7 +569,7 @@ module Spree

context "when in delivery" do
let!(:shipping_method) do
FactoryGirl.create(:shipping_method).tap do |shipping_method|
FactoryBot.create(:shipping_method).tap do |shipping_method|
shipping_method.calculator.preferred_amount = 10
shipping_method.calculator.save
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ module Spree

shared_examples_for 'a return authorization creator' do
it "can create a new return authorization" do
stock_location = FactoryGirl.create(:stock_location)
reason = FactoryGirl.create(:return_reason)
stock_location = FactoryBot.create(:stock_location)
reason = FactoryBot.create(:return_reason)
rma_params = { stock_location_id: stock_location.id,
return_reason_id: reason.id,
memo: "Defective" }
Expand Down Expand Up @@ -74,7 +74,7 @@ module Spree
sign_in_as_admin!

it "can show return authorization" do
FactoryGirl.create(:return_authorization, order: order)
FactoryBot.create(:return_authorization, order: order)
return_authorization = order.return_authorizations.first
get spree.api_order_return_authorization_path(order, return_authorization.id)
expect(response.status).to eq(200)
Expand All @@ -83,8 +83,8 @@ module Spree
end

it "can get a list of return authorizations" do
FactoryGirl.create(:return_authorization, order: order)
FactoryGirl.create(:return_authorization, order: order)
FactoryBot.create(:return_authorization, order: order)
FactoryBot.create(:return_authorization, order: order)
get spree.api_order_return_authorizations_path(order), params: { order_id: order.number }
expect(response.status).to eq(200)
return_authorizations = json_response["return_authorizations"]
Expand All @@ -93,16 +93,16 @@ module Spree
end

it 'can control the page size through a parameter' do
FactoryGirl.create(:return_authorization, order: order)
FactoryGirl.create(:return_authorization, order: order)
FactoryBot.create(:return_authorization, order: order)
FactoryBot.create(:return_authorization, order: order)
get spree.api_order_return_authorizations_path(order), params: { order_id: order.number, per_page: 1 }
expect(json_response['count']).to eq(1)
expect(json_response['current_page']).to eq(1)
expect(json_response['pages']).to eq(2)
end

it 'can query the results through a paramter' do
FactoryGirl.create(:return_authorization, order: order)
FactoryBot.create(:return_authorization, order: order)
expected_result = create(:return_authorization, memo: 'damaged')
order.return_authorizations << expected_result
get spree.api_order_return_authorizations_path(order), params: { q: { memo_cont: 'damaged' } }
Expand All @@ -118,15 +118,15 @@ module Spree
end

it "can update a return authorization on the order" do
FactoryGirl.create(:return_authorization, order: order)
FactoryBot.create(:return_authorization, order: order)
return_authorization = order.return_authorizations.first
put spree.api_order_return_authorization_path(order, return_authorization.id), params: { return_authorization: { memo: "ABC" } }
expect(response.status).to eq(200)
expect(json_response).to have_attributes(attributes)
end

it "can cancel a return authorization on the order" do
FactoryGirl.create(:new_return_authorization, order: order)
FactoryBot.create(:new_return_authorization, order: order)
return_authorization = order.return_authorizations.first
expect(return_authorization.state).to eq("authorized")
put spree.cancel_api_order_return_authorization_path(order, return_authorization.id)
Expand All @@ -135,7 +135,7 @@ module Spree
end

it "can delete a return authorization on the order" do
FactoryGirl.create(:return_authorization, order: order)
FactoryBot.create(:return_authorization, order: order)
return_authorization = order.return_authorizations.first
delete spree.api_order_return_authorization_path(order, return_authorization.id)
expect(response.status).to eq(204)
Expand All @@ -152,15 +152,15 @@ module Spree
end

it "cannot update a return authorization on the order" do
FactoryGirl.create(:return_authorization, order: order)
FactoryBot.create(:return_authorization, order: order)
return_authorization = order.return_authorizations.first
put spree.api_order_return_authorization_path(order, return_authorization.id), params: { return_authorization: { memo: "ABC" } }
assert_unauthorized!
expect(return_authorization.reload.memo).not_to eq("ABC")
end

it "cannot delete a return authorization on the order" do
FactoryGirl.create(:return_authorization, order: order)
FactoryBot.create(:return_authorization, order: order)
return_authorization = order.return_authorizations.first
delete spree.api_order_return_authorization_path(order, return_authorization.id)
assert_unauthorized!
Expand Down
2 changes: 1 addition & 1 deletion api/spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
c.syntax = :expect
end

config.include FactoryGirl::Syntax::Methods
config.include FactoryBot::Syntax::Methods
config.include Spree::Api::TestingSupport::Helpers, type: :request
config.extend Spree::Api::TestingSupport::Setup, type: :request
config.include Spree::Api::TestingSupport::Helpers, type: :controller
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ module Admin

context "with a country with the ISO code of 'US' existing" do
before do
FactoryGirl.create(:country, iso: 'US')
FactoryBot.create(:country, iso: 'US')
end

it "can create a new stock location" do
Expand Down
4 changes: 2 additions & 2 deletions backend/spec/features/admin/orders/listing_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,11 @@

context "searching orders" do
context "when there are multiple stores" do
let(:stores) { FactoryGirl.create_pair(:store) }
let(:stores) { FactoryBot.create_pair(:store) }

before do
stores.each do |store|
FactoryGirl.create(:completed_order_with_totals, number: "R#{store.id}999", store: store)
FactoryBot.create(:completed_order_with_totals, number: "R#{store.id}999", store: store)
end
end

Expand Down
4 changes: 2 additions & 2 deletions backend/spec/features/admin/payments/store_credits_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
RSpec.describe 'Store credits', type: :feature do
stub_authorization!

let(:order) { FactoryGirl.create(:completed_order_with_totals) }
let(:order) { FactoryBot.create(:completed_order_with_totals) }
let(:payment) do
FactoryGirl.create(
FactoryBot.create(
:store_credit_payment,
order: order,
amount: 20
Expand Down
2 changes: 1 addition & 1 deletion backend/spec/features/admin/products/products_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
end

def build_option_type_with_values(name, values)
ot = FactoryGirl.create(:option_type, name: name)
ot = FactoryBot.create(:option_type, name: name)
values.each do |val|
ot.option_values.create(name: val.downcase, presentation: val)
end
Expand Down
2 changes: 1 addition & 1 deletion backend/spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@
end
end

config.include FactoryGirl::Syntax::Methods
config.include FactoryBot::Syntax::Methods

config.include Spree::TestingSupport::Preferences
config.include Spree::TestingSupport::UrlHelpers
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
require 'spec_helper'

describe "spree/admin/shared/_navigation_footer", type: :view do
let(:user) { FactoryGirl.build_stubbed(:admin_user) }
let(:user) { FactoryBot.build_stubbed(:admin_user) }
before do
allow(view).to receive(:try_spree_current_user).and_return(user)
end
Expand Down
2 changes: 1 addition & 1 deletion common_spree_dependencies.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
gem 'capybara-screenshot'
gem 'database_cleaner', '~> 1.3'
gem 'email_spec'
gem 'factory_girl_rails', '~> 4.8'
gem 'factory_bot_rails', '~> 4.8'
gem 'launchy'
gem 'rspec-activemodel-mocks', '~>1.0.2'
gem 'rspec-rails', '~> 3.6.0'
Expand Down
2 changes: 1 addition & 1 deletion core/lib/spree/testing_support/factories.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
require 'factory_girl'
require 'factory_bot'

Dir["#{File.dirname(__FILE__)}/factories/**"].each do |f|
require File.expand_path(f)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
require 'spree/testing_support/factories/state_factory'
require 'spree/testing_support/factories/country_factory'

FactoryGirl.define do
FactoryBot.define do
factory :address, class: 'Spree::Address' do
transient do
# There's `Spree::Address#country_iso=`, prohibiting me from using `country_iso` here
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
require 'spree/testing_support/factories/tax_rate_factory'
require 'spree/testing_support/factories/zone_factory'

FactoryGirl.define do
FactoryBot.define do
factory :adjustment, class: 'Spree::Adjustment' do
order
adjustable { order }
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FactoryGirl.define do
FactoryBot.define do
factory :adjustment_reason, class: 'Spree::AdjustmentReason' do
sequence(:name) { |n| "Refund for return ##{n}" }
sequence(:code) { |n| "Code #{n}" }
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FactoryGirl.define do
FactoryBot.define do
factory :calculator, aliases: [:flat_rate_calculator], class: 'Spree::Calculator::FlatRate' do
preferred_amount 10.0
end
Expand Down
2 changes: 1 addition & 1 deletion core/lib/spree/testing_support/factories/carton_factory.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
require 'spree/testing_support/factories/shipment_factory'
require 'spree/testing_support/factories/inventory_unit_factory'

FactoryGirl.define do
FactoryBot.define do
factory :carton, class: 'Spree::Carton' do
address
stock_location
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
require 'carmen'

FactoryGirl.define do
FactoryBot.define do
factory :country, class: 'Spree::Country' do
iso 'US'

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FactoryGirl.define do
FactoryBot.define do
factory :credit_card, class: 'Spree::CreditCard' do
verification_value 123
month 12
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
require 'spree/testing_support/factories/order_factory'
require 'spree/testing_support/factories/return_item_factory'

FactoryGirl.define do
FactoryBot.define do
factory :customer_return, class: 'Spree::CustomerReturn' do
association(:stock_location, factory: :stock_location)

Expand Down
2 changes: 1 addition & 1 deletion core/lib/spree/testing_support/factories/image_factory.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FactoryGirl.define do
FactoryBot.define do
factory :image, class: 'Spree::Image' do
attachment { File.new(Spree::Core::Engine.root + 'spec/fixtures/thinking-cat.jpg') }
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
require 'spree/testing_support/factories/order_factory'
require 'spree/testing_support/factories/shipment_factory'

FactoryGirl.define do
FactoryBot.define do
factory :inventory_unit, class: 'Spree::InventoryUnit' do
variant
order
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
require 'spree/testing_support/factories/order_factory'
require 'spree/testing_support/factories/product_factory'

FactoryGirl.define do
FactoryBot.define do
factory :line_item, class: 'Spree::LineItem' do
quantity 1
price { BigDecimal.new('10.00') }
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FactoryGirl.define do
FactoryBot.define do
factory :option_type, class: 'Spree::OptionType' do
sequence(:name) { |n| "foo-size-#{n}" }
presentation 'Size'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FactoryGirl.define do
FactoryBot.define do
factory :option_value, class: 'Spree::OptionValue' do
sequence(:name) { |n| "Size-#{n}" }

Expand Down
2 changes: 1 addition & 1 deletion core/lib/spree/testing_support/factories/order_factory.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
require 'spree/testing_support/factories/line_item_factory'
require 'spree/testing_support/factories/payment_factory'

FactoryGirl.define do
FactoryBot.define do
factory :order, class: 'Spree::Order' do
user
bill_address
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
require 'spree/testing_support/factories/order_factory'
require 'spree/testing_support/factories/promotion_factory'

FactoryGirl.define do
FactoryBot.define do
factory :order_promotion, class: 'Spree::OrderPromotion' do
association :order
association :promotion
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
require 'spree/testing_support/factories/order_factory'
require 'spree/testing_support/factories/store_credit_factory'

FactoryGirl.define do
FactoryBot.define do
factory :payment, aliases: [:credit_card_payment], class: 'Spree::Payment' do
association(:payment_method, factory: :credit_card_payment_method)
source { create(:credit_card, user: order.user, address: order.bill_address) }
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FactoryGirl.define do
FactoryBot.define do
factory :payment_method, aliases: [:credit_card_payment_method], class: 'Spree::PaymentMethod::BogusCreditCard' do
name 'Credit Card'
available_to_admin true
Expand Down
2 changes: 1 addition & 1 deletion core/lib/spree/testing_support/factories/price_factory.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
require 'spree/testing_support/factories/variant_factory'

FactoryGirl.define do
FactoryBot.define do
factory :price, class: 'Spree::Price' do
variant
amount 19.99
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
require 'spree/testing_support/factories/tax_category_factory'
require 'spree/testing_support/factories/product_option_type_factory'

FactoryGirl.define do
FactoryBot.define do
factory :base_product, class: 'Spree::Product' do
sequence(:name) { |n| "Product ##{n} - #{Kernel.rand(9999)}" }
description "As seen on TV!"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
require 'spree/testing_support/factories/product_factory'
require 'spree/testing_support/factories/option_type_factory'

FactoryGirl.define do
FactoryBot.define do
factory :product_option_type, class: 'Spree::ProductOptionType' do
product
option_type
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
require 'spree/testing_support/factories/product_factory'
require 'spree/testing_support/factories/property_factory'

FactoryGirl.define do
FactoryBot.define do
factory :product_property, class: 'Spree::ProductProperty' do
product
property
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FactoryGirl.define do
FactoryBot.define do
factory :promotion_category, class: 'Spree::PromotionCategory' do
name 'Promotion Category'
end
Expand Down
Loading

0 comments on commit 60df971

Please sign in to comment.