-
Notifications
You must be signed in to change notification settings - Fork 899
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
Pass ar5 tests #689
Pass ar5 tests #689
Conversation
Having some issues with tests intermittently failing. Any ideas on that are also welcome. |
Interesting... Ten tests failed the first time I ran Here's the log: https://gist.github.com/bronson/70dd3c4aaf395df4bf93 And, if I Is that the problem you're seeing? |
I'm at 25 iterations, no failures yet. I'll let it run for a few hundred. ctr=; while rake; do echo ITERATION $((ctr += 1)); done But, no, I'm not seeing any intermittent errors on your branch. I'm using sqlite, are you testing on a different database? |
Owen, thanks for this! I'll review what I can this week.
Scott, Yeah, that's a known issue with running the local test suite. If you can fix it, that'd be great. |
260 iterations, 0 failures. I don't see any intermittent issues. (sqlite, mac, ruby 2.2.2) |
Initially tested using sqlite3 locally, no issues. As you can see, Travis CI failed all my builds for various reasons; it looks like Postgresql is the main issue now. Simulating locally it took me 22 runs before this failure (postgres, mac, 2.3.0):
|
Switched to postgres and I finally got a failure after 76 iterations: https://gist.github.com/bronson/01f05504f81efe072b40 Glancing at it, maybe it died because name contained a single quote... A sql injection opportunity? :) I'll look closer tomorrow if nobody beats me to it. Also, there might be a test order dependency. At least:
Do the tests have a required order? |
Confirmed, unescaped input (only when using postgres). I've written some failing tests and will open an issue. Unfortunately it seems unrelated to the failures from Travis here and here. I'm not familiar with the impact of seeding on this test suite and I couldn't reproduce those spec failures with seeds 1 and 10 (mac, postgres, ruby 2.2.2). |
When comparing gem versions, I like to use - ActiveRecord::VERSION::STRING >= '5.'
+ Gem::Version.new(ActiveRecord::VERSION::STRING) >= Gem::Version.new("5") PS: If we didn't have to support AR3, we could use the more convenient |
@@ -162,6 +164,15 @@ def reify_has_ones(transaction_id, model, options = {}) | |||
end | |||
end | |||
|
|||
# Suppress #save so we can reassociate with the reified master of a has_one relationship |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you expand on this comment? Specifically, please explain what changed in AR5.
Also, please alphabetize methods.
Owen, I've been cherry-picking the less controversial commits out of here.
I thought there was no sense in waiting, but it will mean you'll have to rebase this PR, sorry. |
No problem at all; like I said, this code is not right and should be improved before merging. Some comments:
|
Owen, It looks like this needs another rebase, sorry. |
ActionDispatch::IntegrationTest.send(:include, Rails::Controller::Testing::Integration) | ||
|
||
ActionView::TestCase.send(:include, Rails::Controller::Testing::TemplateAssertions) | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This whole on_load
could use a comment, e.g. why are we including these modules, why are we using send
, why on_load
, etc. I don't personally understand any of it, so the comment is mostly for me :p
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Copied wholesale from rails-controller-testing. I don't know why putting it here works but requiring the library doesn't. I've also tried require: false
in the Gemfile and manually requiring it instead but that doesn't help. Removing this code, I get:
NoMethodError: assigns has been extracted to a gem. To continue using it,
add `gem 'rails-controller-testing'` to your Gemfile.
Not knowing if this is caused by something in PaperTrail or an issue with rails-controller-testing itself (or Rails 5), I'm not sure whether I should raise an issue over there.
Is this change documented in a changelog somewhere, or a guide? |
Found it. It's in the release notes for ActionPack 5:
|
else | ||
args | ||
end | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add a comment explaining the change to ".. keyword arguments syntax in ActionController::TestCase and ActionDispatch::Integration HTTP request methods." and include a link to the ActionPack changelog (https://github.com/tgxworld/rails/blob/master/actionpack/CHANGELOG.md)
Rebased. I also fixed one more deprecation warning (use_transactional_tests) and added a note about 1-second differences in tests (for MySQL and AR5). Still not happy. |
I think this is just about done. Please review and let me know; I'll squash the commits. |
Time travel is required due to a change in ActiveRecord 5 (if no attributes change, nothing is done). We could |
Merged. Thanks for your work on this, Owen. |
Wooo! Great job Owen. |
Update test code to address deprecations/warnings and fix one legitimate issue with AR5. Not happy with several aspects of this change:
rails-controller-testing
does not work as advertised (possibly an issue with load order?) and I could only get it working when manually included, seetest_helper.rb
Having said that, the changes pass tests locally on MRI 2.3 (ar5) and 1.9.3-p551 (ar3/ar4). Comments and suggestions welcome.
@jaredbeck