Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move require "models/post" before require "models/comment" #26370

Merged
merged 1 commit into from
Sep 5, 2016

Conversation

yahonda
Copy link
Member

@yahonda yahonda commented Sep 2, 2016

Summary

This pull request addresses #26368.

Here are two minimum test cases:

  • Testcase 1 "test/cases/relation/where_test.rb" "test/cases/base_test.rb"
for i in sqlite3 mysql2 postgresql
do
ARCONN=$i bundle exec ruby -w -I"lib:test" -I"/home/yahonda/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/rake-11.1.2/lib" "/home/yahonda/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/rake-11.1.2/lib/rake/rake_test_loader.rb" \
"test/cases/relation/where_test.rb" "test/cases/base_test.rb"
done
Using sqlite3
Run options: --seed 42128

# Running:

.............................................................................................................................................F............................S................

Finished in 1.433237s, 130.4739 runs/s, 286.0657 assertions/s.

  1) Failure:
BasicsTest#test_readonly_attributes [/home/yahonda/git/rails/activerecord/test/cases/base_test.rb:642]:
--- expected
+++ actual
@@ -1 +1 @@
-#<Set: {"title", "comments_count"}>
+#<Set: {"title"}>


187 runs, 410 assertions, 1 failures, 0 errors, 1 skips

You have skipped tests. Run with --verbose for details.
Using mysql2
Run options: --seed 2204

# Running:

.......................................................................................................................F...........................................S........................

Finished in 2.111748s, 89.0258 runs/s, 194.6255 assertions/s.

  1) Failure:
BasicsTest#test_readonly_attributes [/home/yahonda/git/rails/activerecord/test/cases/base_test.rb:642]:
--- expected
+++ actual
@@ -1 +1 @@
-#<Set: {"title", "comments_count"}>
+#<Set: {"title"}>


188 runs, 411 assertions, 1 failures, 0 errors, 1 skips

You have skipped tests. Run with --verbose for details.
Using postgresql
Run options: --seed 20170

# Running:

.......................................................F..................................................................................................................................

Finished in 2.641518s, 70.4141 runs/s, 156.7281 assertions/s.

  1) Failure:
BasicsTest#test_readonly_attributes [/home/yahonda/git/rails/activerecord/test/cases/base_test.rb:642]:
--- expected
+++ actual
@@ -1 +1 @@
-#<Set: {"title", "comments_count"}>
+#<Set: {"title"}>


186 runs, 414 assertions, 1 failures, 0 errors, 0 skips
$
  • Testcase 2 "test/cases/autosave_association_test.rb" and "test/cases/base_test.rb"
for i in sqlite3 mysql2 postgresql
do
ARCONN=$i bundle exec ruby -w -I"lib:test" -I"/home/yahonda/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/rake-11.1.2/lib" "/home/yahonda/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/rake-11.1.2/lib/rake/rake_test_loader.rb" "test/cases/autosave_association_test.rb" "t
est/cases/base_test.rb"
done
Using sqlite3
Run options: --seed 20992

# Running:

..........................................................................................................................................................................................S................F................................................................................................................

Finished in 4.864530s, 64.9600 runs/s, 165.8947 assertions/s.

  1) Failure:
BasicsTest#test_readonly_attributes [/home/yahonda/git/rails/activerecord/test/cases/base_test.rb:642]:
--- expected
+++ actual
@@ -1 +1 @@
-#<Set: {"title", "comments_count"}>
+#<Set: {"title"}>


316 runs, 807 assertions, 1 failures, 0 errors, 1 skips

You have skipped tests. Run with --verbose for details.
Using mysql2
Run options: --seed 48388

# Running:

...................................................................................................................................................................................................S.........................................F...............................................................................

Finished in 7.794468s, 40.6699 runs/s, 103.6633 assertions/s.

  1) Failure:
BasicsTest#test_readonly_attributes [/home/yahonda/git/rails/activerecord/test/cases/base_test.rb:642]:
--- expected
+++ actual
@@ -1 +1 @@
-#<Set: {"title", "comments_count"}>
+#<Set: {"title"}>


317 runs, 808 assertions, 1 failures, 0 errors, 1 skips

You have skipped tests. Run with --verbose for details.
Using postgresql
Run options: --seed 53624

# Running:

.........................................................................................................................................................................................................................................F.................................................................................

Finished in 8.795197s, 35.8150 runs/s, 92.2094 assertions/s.

  1) Failure:
BasicsTest#test_readonly_attributes [/home/yahonda/git/rails/activerecord/test/cases/base_test.rb:642]:
--- expected
+++ actual
@@ -1 +1 @@
-#<Set: {"title", "comments_count"}>
+#<Set: {"title"}>


315 runs, 811 assertions, 1 failures, 0 errors, 0 skips
$

Other Information

It reproduces only when both of these conditions are satisfied:

  • Other test files autosave_association_test.rb or where_test.rb
    which executes require "models/comment" then require "models/post"
  • When autosave_association_test.rb or where_test.rb executed before base_test.rb

…"models/comment"`

to address BasicsTest#test_readonly_attributes failure rails#26368

It reproduces only when both of these conditions are satisfied:

- Other test files `autosave_association_test.rb` or `where_test.rb`
  which executes `require "models/comment"` then `require "models/post"`
- When `autosave_association_test.rb` or `where_test.rb` executed before `base_test.rb`
@rails-bot
Copy link

r? @pixeltrix

(@rails-bot has picked a reviewer for you, use r? to override)

@prathamesh-sonpatki
Copy link
Member

@yahonda Did you figure out why changing the order of model fixes the problem?

@yahonda
Copy link
Member Author

yahonda commented Sep 4, 2016

@prathamesh-sonpatki Actually I do not know why. Just got to know how to address them based on your suggestions. Let me take some more look at this.

@vipulnsward
Copy link
Member

Some history.
vipulnsward@a841cd2
https://rails.lighthouseapp.com/projects/8994/tickets/2550-fix-models-load-order-in-activerecords-tests

The fix is 👍

@pixeltrix pixeltrix merged commit da33612 into rails:master Sep 5, 2016
@pixeltrix
Copy link
Contributor

@yahonda thanks! 👍

@yahonda yahonda deleted the rails26368 branch December 9, 2016 21:20
yahonda added a commit to yahonda/rails that referenced this pull request Jan 4, 2017
yahonda added a commit to yahonda/rails that referenced this pull request Aug 23, 2017
There were similar pull requests rails#26370 rails#27575 fixed by different way
by moving `require "models/post"` before `require "models/comment"`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants