Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revert changed address factory #6

Merged
merged 1 commit into from
Aug 23, 2023
Merged
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
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