I have a rails app with two models: Data and Request. Data has a property called “path” that gets assigned during the “create” controller action. Request belongs_to Data.
My test fixture for Data does not specify the path attribute.
When I test creation of Request, it finds the appropriate test fixture for Data in the database but the “path” attribute is not set. So it seems the test fixture just goes straight into the database. Is it possible to force the test fixtures to get processed by the controller “create” action instead? Or am I missing something bigger?
I’m using ActionController::TestCase and am new to testing in rails.
The right way to do this is go ahead and set the
pathattribute in your test fixture. Your fixtures are just a way to get some models into your database for use in your tests.When you’re testing your Request controller, you want it to have some valid Data objects in the database to test against. Those objects aren’t really valid without that
pathattribute set.