Actions
Refactor #13971
closedChange model.exists?(record) and .find(record) to use IDs
Description
Rails 4.2 contains the following deprecation:
Deprecated passing Active Record objects to .find or .exists?. Call id on the objects first.
(http://edgeguides.rubyonrails.org/4_2_release_notes.html#active-record-deprecations)
This causes:
> Domain.find(Domain.first)
2016-03-01T12:35:12 [app] [W] DEPRECATION WARNING: You are passing an instance of ActiveRecord::Base to `find`. Please pass the id of the object by calling `.id`. (called from irb_binding at (irb):1)
All instances where we pass objects into .find etc, mostly in tests, need to be changed to call .id.
This happens a lot in functional tests when a User is passed into the session object, e.g.
delete :destroy, {:id => user}, set_session_user.merge(:user => users(:admin))
causes
DEPRECATION WARNING: You are passing an instance of ActiveRecord::Base to `find`. Please pass the id of the object by calling `.id`. (called from authenticate at /home/dcleal/code/foreman/foreman/app/controllers/concerns/foreman/controller/authentication.rb:10)
Actions