t.add :scopes
end
+ UNLOGGED_ATTRIBUTES = ['last_used_at', 'last_used_by_ip_address',
+ 'updated_at']
+
def assign_random_api_token
self.api_token ||= rand(2**256).to_s(36)
end
not self.user_id_changed? and
not self.owner_uuid_changed?)
end
+
+ def log_update
+ super unless (changed - UNLOGGED_ATTRIBUTES).empty?
+ end
end
end
end
end
+
+ test "don't log changes only to ApiClientAuthorization.last_used_*" do
+ set_user_from_auth :admin_trustedclient
+ auth = api_client_authorizations(:spectator)
+ start_log_count = get_logs_about(auth).size
+ auth.last_used_at = Time.now
+ auth.last_used_by_ip_address = '::1'
+ auth.save!
+ assert_equal(start_log_count, get_logs_about(auth).size,
+ "log count changed after 'using' ApiClientAuthorization")
+ auth.created_by_ip_address = '::1'
+ auth.save!
+ assert_equal(start_log_count + 1, get_logs_about(auth).size,
+ "no log after changed stable ApiClientAuthorization attribute")
+ end
end