+
Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions api/spec/controllers/spree/api/orders_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,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 { api_get :show, id: order.to_param }

Expand Down Expand Up @@ -560,7 +560,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 @@ -16,8 +16,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 @@ -76,7 +76,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
api_get :show, order_id: order.number, id: return_authorization.id
expect(response.status).to eq(200)
Expand All @@ -85,8 +85,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)
api_get :index, { order_id: order.number }
expect(response.status).to eq(200)
return_authorizations = json_response["return_authorizations"]
Expand All @@ -95,16 +95,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)
api_get :index, 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
api_get :index, q: { memo_cont: 'damaged' }
Expand All @@ -120,15 +120,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
api_put :update, id: return_authorization.id, 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")
api_delete :cancel, id: return_authorization.id
Expand All @@ -137,7 +137,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
api_delete :destroy, id: return_authorization.id
expect(response.status).to eq(204)
Expand All @@ -154,15 +154,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
api_put :update, id: return_authorization.id, 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
api_delete :destroy, id: return_authorization.id
assert_unauthorized!
Expand Down
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
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: :controller
config.extend Spree::Api::TestingSupport::Setup, type: :controller
config.include Spree::TestingSupport::Preferences
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 @@ -46,11 +46,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
12 changes: 6 additions & 6 deletions 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 Expand Up @@ -111,22 +111,22 @@ def build_option_type_with_values(name, values)

context "creating a new product from a prototype" do
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
ot
end

let(:product_attributes) do
# FactoryGirl.attributes_for is un-deprecated!
# FactoryBot.attributes_for is un-deprecated!
# https://github.com/thoughtbot/factory_girl/issues/274#issuecomment-3592054
FactoryGirl.attributes_for(:simple_product)
FactoryBot.attributes_for(:simple_product)
end

let(:prototype) do
size = build_option_type_with_values("size", %w(Small Medium Large))
FactoryGirl.create(:prototype, name: "Size", option_types: [size])
FactoryBot.create(:prototype, name: "Size", option_types: [size])
end

let(:option_values_hash) do
Expand Down Expand Up @@ -298,7 +298,7 @@ def build_option_type_with_values(name, values)

let(:prototype) do
size = build_option_type_with_values("size", %w(Small Medium Large))
FactoryGirl.create(:prototype, name: "Size", option_types: [size])
FactoryBot.create(:prototype, name: "Size", option_types: [size])
end

before(:each) do
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 @@ -102,7 +102,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
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.5.0'
gem 'factory_bot'
gem 'launchy'
gem 'rspec-activemodel-mocks', '~>1.0.2'
gem 'rspec-collection_matchers'
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
26 changes: 13 additions & 13 deletions core/lib/spree/testing_support/factories/address_factory.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,23 @@
require 'spree/testing_support/factories/country_factory'
require 'twitter_cldr'

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
country_iso_code 'US'
state_code 'AL'
country_iso_code { 'US' }
state_code { 'AL' }
end

firstname 'John'
lastname 'Doe'
company 'Company'
address1 '10 Lovely Street'
address2 'Northwest'
city 'Herndon'
firstname { 'John' }
lastname { 'Doe' }
company { 'Company' }
address1 { '10 Lovely Street' }
address2 { 'Northwest' }
city { 'Herndon' }
zipcode { TwitterCldr::Shared::PostalCodes.for_territory(country_iso_code).sample.first }
phone '555-555-0199'
alternative_phone '555-555-0199'
phone { '555-555-0199' }
alternative_phone { '555-555-0199' }

state do |address|
Spree::State.joins(:country).where('spree_countries.iso = (?)', country_iso_code).find_by(abbr: state_code) ||
Expand All @@ -35,10 +35,10 @@
end

factory :ship_address, parent: :address do
address1 'A Different Road'
address1 { 'A Different Road' }
end

factory :bill_address, parent: :address do
address1 'PO Box 1337'
address1 { 'PO Box 1337' }
end
end
12 changes: 6 additions & 6 deletions core/lib/spree/testing_support/factories/adjustment_factory.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@
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 }
amount 100.0
label 'Shipping'
amount { 100.0 }
label { 'Shipping' }
association(:source, factory: :tax_rate)
eligible true
eligible { true }

after(:build) do |adjustment|
adjustments = adjustment.adjustable.adjustments
Expand All @@ -23,8 +23,8 @@
factory :tax_adjustment, class: Spree::Adjustment do
order { adjustable.order }
association(:adjustable, factory: :line_item)
amount 10.0
label 'VAT 5%'
amount { 10.0 }
label { 'VAT 5%' }

after(:create) do |adjustment|
# Set correct tax category, so that adjustment amount is not 0
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
12 changes: 6 additions & 6 deletions core/lib/spree/testing_support/factories/calculator_factory.rb
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
FactoryGirl.define do
FactoryBot.define do
factory :calculator, aliases: [:flat_rate_calculator], class: Spree::Calculator::FlatRate do
preferred_amount 10.0
preferred_amount { 10.0 }
end

factory :no_amount_calculator, class: Spree::Calculator::FlatRate do
preferred_amount 0
preferred_amount { 0 }
end

factory :default_tax_calculator, class: Spree::Calculator::DefaultTax do
end

factory :shipping_calculator, class: Spree::Calculator::Shipping::FlatRate do
preferred_amount 10.0
preferred_amount { 10.0 }
end

factory :shipping_no_amount_calculator, class: Spree::Calculator::Shipping::FlatRate do
preferred_amount 0
preferred_amount { 0 }
end

factory :percent_on_item_calculator, class: Spree::Calculator::PercentOnLineItem do
preferred_percent 10
preferred_percent { 10 }
end
end
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
4 changes: 2 additions & 2 deletions core/lib/spree/testing_support/factories/country_factory.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
require 'carmen'

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

transient do
carmen_country { Carmen::Country.coded(iso) || fail("Unknown country iso code: #{iso.inspect}") }
Expand Down
Loading
点击 这是indexloc提供的php浏览器服务,不要输入任何密码和下载