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:
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
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:
Models:
Fixtures:
Now in the test, if I use:
all works fine, but, if I use:
I got the following error:
and, if I check the test DB, the related table is empty.
I'm doing something wrong?
Thanks for the help.
Best Regards,
Nicola