Require conflicting dependencies
spec/lib/tasks/dev_seed_spec.rb:8
This test was failing and we could see messages like:
db/dev_seeds/polls.rb:147:
warning: toplevel constant Answer referenced by Poll::Answer
Resulting in the error:
rake db:dev_seed seeds the database without errors
Failure/Error: expect { run_rake_task }.not_to raise_error
expected no Exception, got #<ActiveModel::UnknownAttributeError:
unknown attribute 'question_id' for Answer
Apparently the lookup was not correclty being performed, due to
conflicting names.
"Naming conflicts of this kind are rare in practice, but if one
occurs, require_dependency provides a solution by ensuring that
the constant needed to trigger the heuristic is defined in the
conflicting place."
https://guides.rubyonrails.org/v5.0/autoloading_and_reloading_constants.html
This commit is contained in:
@@ -1,3 +1,6 @@
|
||||
require_dependency "poll/answer"
|
||||
require_dependency "poll/question/answer"
|
||||
|
||||
section "Creating polls" do
|
||||
|
||||
Poll.create(name: I18n.t("seeds.polls.current_poll"),
|
||||
|
||||
Reference in New Issue
Block a user