Commit 0b890e4b authored by Igor Drozdov's avatar Igor Drozdov Committed by Thong Kuah

Clean up kwargs deprecation warnings paths

parent 0998b2da
......@@ -53,10 +53,6 @@ module AlertManagement
endpoint_identifier == LEGACY_IDENTIFIER
end
def token_changed?
attribute_changed?(:token)
end
# Blank token assignment triggers token reset
def prevent_token_assignment
if token.present? && token_changed?
......
......@@ -27,6 +27,22 @@ module AttrEncrypted
AttrEncrypted.instance_method(:attribute_instance_methods_as_symbols).bind(self).call
end
end
protected
# The attr_encrypted gem is not actively maintained
# At the same time it contains the code that raises kwargs deprecation warnings:
# https://github.com/attr-encrypted/attr_encrypted/blob/master/lib/attr_encrypted/adapters/active_record.rb#L65
#
def attr_encrypted(*attrs)
super
attr = attrs.first
redefine_method(:"#{attr}_changed?") do |**options|
attribute_changed?(attr, **options)
end
end
end
end
end
......
......@@ -55,11 +55,7 @@ module DeprecationToolkitEnv
# one by one
def self.allowed_kwarg_warning_paths
%w[
activerecord-6.0.3.7/lib/active_record/migration.rb
activesupport-6.0.3.7/lib/active_support/cache.rb
activerecord-6.0.3.7/lib/active_record/relation.rb
asciidoctor-2.0.12/lib/asciidoctor/extensions.rb
attr_encrypted-3.1.0/lib/attr_encrypted/adapters/active_record.rb
gitlab-labkit-0.18.0/lib/labkit/correlation/grpc/client_interceptor.rb
]
end
......
......@@ -4,18 +4,20 @@ require 'spec_helper'
RSpec.describe 'GitLab monkey-patches to AttrEncrypted' do
describe '#attribute_instance_methods_as_symbols_available?' do
it 'returns false' do
expect(ActiveRecord::Base.__send__(:attribute_instance_methods_as_symbols_available?)).to be_falsy
end
it 'does not define virtual attributes' do
klass = Class.new(ActiveRecord::Base) do
let(:klass) do
Class.new(ActiveRecord::Base) do
# We need some sort of table to work on
self.table_name = 'projects'
attr_encrypted :foo
end
end
it 'returns false' do
expect(ActiveRecord::Base.__send__(:attribute_instance_methods_as_symbols_available?)).to be_falsy
end
it 'does not define virtual attributes' do
instance = klass.new
aggregate_failures do
......@@ -28,5 +30,11 @@ RSpec.describe 'GitLab monkey-patches to AttrEncrypted' do
end
end
end
it 'calls attr_changed? method with kwargs' do
obj = klass.new
expect(obj.foo_changed?).to eq(false)
end
end
end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment