Skip to content

Commit

Permalink
Merge pull request #6 from nebulab/ml/revert-address-factory
Browse files Browse the repository at this point in the history
Revert changed address factory
  • Loading branch information
MassimilianoLattanzio authored Aug 23, 2023
2 parents 17a7cd7 + 905953e commit 2855069
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 2855069

Please sign in to comment.