Skip to content

Fixture loading issue #6

@nicolalorusso

Description

@nicolalorusso

Hi guys,
I have an issue with test fixture. The fixture related to extended model is not loaded into the test DB.

My environment: OSX, Rails 5.1.4, Ruby 2.4.2, active_record-mti 0.3.0.pre.rc4

My code (extract)
Migrations:

create_table :rules do |t|
      t.string :regex,             null: false
     ...
      t.timestamps
    end

create_table :rule_products, inherits: :rules do |t|
      t.xxx xxx ....
end

Models:

class Rule < ApplicationRecord
  validates :regex, presence: true
  ...
end

class RuleProduct < Rule
  self.table_name = 'rule_products'
  ...
end

Fixtures:

--- rules.yml
one:
  regex: rule_one.*

two:
  regex: rule_two.*

--- rule_products.yml
one:
  regex: one.*
  otherfield: value1

two:
  regex: two.*
  otherfield: value2

Now in the test, if I use:

rule = rules(:one)

all works fine, but, if I use:

rule = rule_products(:one)

I got the following error:

Minitest::UnexpectedError: ActiveRecord::RecordNotFound: Couldn't find RuleProduct with 'id'=980190962

and, if I check the test DB, the related table is empty.

I'm doing something wrong?
Thanks for the help.
Best Regards,
Nicola

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions