Skip to content

Commit

Permalink
Revert changed address factory
Browse files Browse the repository at this point in the history
In solidusio/solidus#3584, they changed the address factory [1],
so the firstname and lastname will differ from the previous version.

This commits reverts the changes, so if in your applications test you're
using the old address factory, the specs will continue to work properly.

1: https://github.com/solidusio/solidus/pull/3584/files#diff-8e88fbe32e58692ffaf3629a7fdfdadfa4378dd248a011fc8d2d266a5ed299a4
  • Loading branch information
MassimilianoLattanzio committed Aug 11, 2023
1 parent 17a7cd7 commit 905953e
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 0 deletions.
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,12 @@ You can load Solidus core factories along with this extension's factories using
SolidusDevSupport::TestingSupport::Factories.load_for(SolidusAddressName::Engine)
```

or, if you're not using `SolidusDevSupport`:

```ruby
require 'solidus_address_name/testing_support/factories'
```

### Running the sandbox

To run this extension in a sandboxed Solidus application, you can run `bin/sandbox`. The path for
Expand Down
13 changes: 13 additions & 0 deletions lib/solidus_address_name/testing_support/factories.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,17 @@
# frozen_string_literal: true

FactoryBot.modify do
# Revert the firstname and lastname to their original values before
# https://github.com/solidusio/solidus/pull/3584/files#diff-8e88fbe32e58692ffaf3629a7fdfdadfa4378dd248a011fc8d2d266a5ed299a4
factory :address do
transient do
name { nil }
end

firstname { 'John' }
lastname { nil }
end
end

FactoryBot.define do
end
12 changes: 12 additions & 0 deletions spec/models/spree/address_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -300,4 +300,16 @@

it { is_expected.to be_require_phone }
end

context 'when using address factory' do
let(:address) { build(:address) }

it 'has John as first_name' do
expect(address.firstname).to eq 'John'
end

it 'has a nil last_name' do
expect(address.lastname).to be_nil
end
end
end

0 comments on commit 905953e

Please sign in to comment.