Testing Ruby on Rails Migrations

How do you test the code into the up method that creates a new record on a newly added association between User and Email before removing the email column from the User table?It’s a pretty common scenario and you could think that this logic should live into a separate object that you can test in isolation. I agree, but you still can’t really test it since if you call that object with the last version of your database schema (after this migration run), you’ll have an exception since User has no more the email column. 🤷‍This example is easily fixable by just stubbing the email message on any instance of User:.
Testing Ruby on Rails Migrations #ruby #rubydeveloper #rubyonrails #testing https://rubyonrails.ba/single/testing-ruby-on-rails-migrations

Nezir Zahirovic

Contractor Ruby On Rails (8+ years) / MCPD .Net / C# / Asp.Net / CSS / SQL / (11 years)

related articles