Fix after_initialize and Base.create edge case #2236

Merged
merged 3 commits into from Jul 25, 2011

Conversation

Projects
None yet
5 participants
@cldwalker
Contributor

cldwalker commented Jul 24, 2011

This time rebased off master as requested in #2194

hmcfletch and others added some commits Jul 21, 2011

@@ -0,0 +1,9 @@
+class WholesaleProduct < ActiveRecord::Base

This comment has been minimized.

Show comment Hide comment
@guilleiguaran

guilleiguaran Jul 24, 2011

Owner

Actually the ActiveRecord maintainers would prefer that you use existing models for new tests instead of add new models

@guilleiguaran

guilleiguaran Jul 24, 2011

Owner

Actually the ActiveRecord maintainers would prefer that you use existing models for new tests instead of add new models

This comment has been minimized.

Show comment Hide comment
@hmcfletch

hmcfletch Jul 24, 2011

Contributor

I poked around existing models to see if there was one I could use for this test, but I didn't see one that I could easily repurpose. I didn't want to mess with one that looked they were being used for specific test cases, which most of the ones I looked at seemed to be. I could have put it at the top of the test file, but none of the other classes up there had method declarations. It's my first submitted patch, so I just tried to not mess with things that were already in place too much.

@hmcfletch

hmcfletch Jul 24, 2011

Contributor

I poked around existing models to see if there was one I could use for this test, but I didn't see one that I could easily repurpose. I didn't want to mess with one that looked they were being used for specific test cases, which most of the ones I looked at seemed to be. I could have put it at the top of the test file, but none of the other classes up there had method declarations. It's my first submitted patch, so I just tried to not mess with things that were already in place too much.

@cldwalker

This comment has been minimized.

Show comment Hide comment
@cldwalker

cldwalker Jul 24, 2011

Contributor

@guilleiguaran Updated tests to use existing model. Personally, I don't see it as a good testing practice to be using one model for multiple unrelated tests. Leads to unnecessary coupling and hard to find bugs

Contributor

cldwalker commented Jul 24, 2011

@guilleiguaran Updated tests to use existing model. Personally, I don't see it as a good testing practice to be using one model for multiple unrelated tests. Leads to unnecessary coupling and hard to find bugs

@guilleiguaran

This comment has been minimized.

Show comment Hide comment
@guilleiguaran

guilleiguaran Jul 24, 2011

Owner

I agree with you but we must try to avoid defining extra models since we already have tonnes of them and if every patch add a new model it would quickly get out of hand.

Your code and tests looks great, thanks!!!

Owner

guilleiguaran commented Jul 24, 2011

I agree with you but we must try to avoid defining extra models since we already have tonnes of them and if every patch add a new model it would quickly get out of hand.

Your code and tests looks great, thanks!!!

spastorino added a commit that referenced this pull request Jul 25, 2011

Merge pull request #2236 from cldwalker/after_initialize
Fix after_initialize and Base.create edge case

@spastorino spastorino merged commit 64affc9 into rails:master Jul 25, 2011

@bboe

This comment has been minimized.

Show comment Hide comment
@bboe

bboe Aug 15, 2011

Contributor

Should a similar change also be applied to create! in validations.rb? I'm not familiar enough with the rails code to know if there are other similar places where code should be changed.

Contributor

bboe commented on f956759 Aug 15, 2011

Should a similar change also be applied to create! in validations.rb? I'm not familiar enough with the rails code to know if there are other similar places where code should be changed.

@vijaydev vijaydev referenced this pull request Nov 22, 2011

Closed

3 0 stable #2175

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment