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

Inconsistent behaviour of Factory.structs between v0.11 and v0.12 #88

Open
ishando opened this issue Apr 5, 2024 · 0 comments
Open

Comments

@ishando
Copy link

ishando commented Apr 5, 2024

Describe the bug

IDs are not created for associations in v0.12 as they were in v0.11

To Reproduce

with Factories:

Factory.define(:operator) do |f|
  f.id { SecureRandom.uuid }
  f.name 'Some Operator'
  f.created_at { Date.today.prev_month }
  ...
end

Factory.define(:membership) do |f|
  f.id { SecureRandom.uuid }
  f.customer_id { SecureRandom.uuid }
  f.created_at { Date.today.prev_month }
  f.status 'active'
  f.association(:operator)
  ...
end

def build(name, **args)
  Factory.structs[name, **args]
end

and called in rspec tests with

  let(:membership) { build(:membership) }

Expected behavior

in v0.11 it returned:

membership: #<ROM::Struct::Membership
  id="8e2225df-a2bb-4305-b949-67587bd4c949"
  customer_id="f2e10f3c-52cc-43fe-9958-6a17255208fb"
  created_at=#<Date: 2024-03-05 ((2460375j,0s,0n),+0s,2299161j)>
  status="active"
  operator_id="93f53cca-603f-41b3-bb67-e2f3fa8b6fc3"
  operator=#<ROM::Struct::Operator
    id="93f53cca-603f-41b3-bb67-e2f3fa8b6fc3"
    name="Some Operator"
    created_at=#<Date: 2024-03-05 ((2460375j,0s,0n),+0s,2299161j)>
    ...
  >
  ...
>

in v0.12 it returns:

membership: #<ROM::Struct::Membership
  id="8e2225df-a2bb-4305-b949-67587bd4c949"
  customer_id="f2e10f3c-52cc-43fe-9958-6a17255208fb"
  created_at=#<Date: 2024-03-05 ((2460375j,0s,0n),+0s,2299161j)>
  status="active"
  operator_id=nil
  operator=#<ROM::Struct::Operator
    id=nil
    name="Some Operator"
    created_at=#<Date: 2024-03-05 ((2460375j,0s,0n),+0s,2299161j)>
    ...
  >
  ...

I would have expected the same result as in v0.11

My environment

  • Affects my production application: NO, currently only using factory for tests
  • Ruby version: 2.7.7, and 3.2.2
  • OS: linux/alpine
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant