diff options
author | Sean McGivern <sean@mcgivern.me.uk> | 2017-08-03 17:28:59 +0000 |
---|---|---|
committer | Sean McGivern <sean@mcgivern.me.uk> | 2017-08-03 17:28:59 +0000 |
commit | 080cd74a374f5c6b0ed5d718f04f1d2c90fe864f (patch) | |
tree | 06a51d5f0cc421129805754d1261a91456fa0991 | |
parent | 9751349dace087b776345f8f99e35f329701390c (diff) | |
parent | 15643ff91e3a01d6f090c0566abe4ded20ad1eb4 (diff) | |
download | gitlab-ce-080cd74a374f5c6b0ed5d718f04f1d2c90fe864f.tar.gz |
Merge branch 'dev.referable-inspect' into 'master'
implement #inspect for all Referables
See merge request !13285
-rw-r--r-- | app/models/concerns/referable.rb | 12 | ||||
-rw-r--r-- | app/models/user.rb | 5 |
2 files changed, 17 insertions, 0 deletions
diff --git a/app/models/concerns/referable.rb b/app/models/concerns/referable.rb index da803c7f481..10f4be72016 100644 --- a/app/models/concerns/referable.rb +++ b/app/models/concerns/referable.rb @@ -25,6 +25,18 @@ module Referable to_reference(from_project) end + def referable_inspect + if respond_to?(:id) + "#<#{self.class.name} id:#{id} #{to_reference(full: true)}>" + else + "#<#{self.class.name} #{to_reference(full: true)}>" + end + end + + def inspect + referable_inspect + end + module ClassMethods # The character that prefixes the actual reference identifier # diff --git a/app/models/user.rb b/app/models/user.rb index 6e66c587a1f..267eebb42ff 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -47,6 +47,11 @@ class User < ActiveRecord::Base devise :lockable, :recoverable, :rememberable, :trackable, :validatable, :omniauthable, :confirmable, :registerable + # devise overrides #inspect, so we manually use the Referable one + def inspect + referable_inspect + end + # Override Devise::Models::Trackable#update_tracked_fields! # to limit database writes to at most once every hour def update_tracked_fields!(request) |