diff --git a/gems/activerecord/7.2/_test/test.rb b/gems/activerecord/7.2/_test/test.rb index 5f81cb50..e3c45866 100644 --- a/gems/activerecord/7.2/_test/test.rb +++ b/gems/activerecord/7.2/_test/test.rb @@ -39,6 +39,7 @@ class Article < ApplicationRecord User.insert_all!([{ id: 1, name: 'James' }], returning: %i[id name], record_timestamps: true) User.upsert({ id: 1, name: 'James' }, returning: %i[id name], unique_by: :id, record_timestamps: true) User.upsert_all([{ id: 1, name: 'James' }], returning: %i[id name], unique_by: :id, record_timestamps: true) + User.with(admin_users: User.where(role: 0)) user = User.new(secret: 'dummy', key: 'dummy', token: 'dummy', phrase: 'dummy') user.encrypt user.encrypted_attribute?(:secret) @@ -50,6 +51,7 @@ class Article < ApplicationRecord user.articles.insert_all!([{ id: 1, name: 'James' }], returning: %i[id name], record_timestamps: true) user.articles.upsert({ id: 1, name: 'James' }, returning: %i[id name], unique_by: :id, record_timestamps: true) user.articles.upsert_all([{ id: 1, name: 'James' }], returning: %i[id name], unique_by: :id, record_timestamps: true) + user.generate_token_for(:password_reset) user = User.new user.normalize_attribute(:email) diff --git a/gems/activerecord/7.2/activerecord-7.2.rbs b/gems/activerecord/7.2/activerecord-7.2.rbs index 3391bd78..60d6754a 100644 --- a/gems/activerecord/7.2/activerecord-7.2.rbs +++ b/gems/activerecord/7.2/activerecord-7.2.rbs @@ -4,6 +4,10 @@ module ActiveRecord extend Encryption::EncryptableRecord::ClassMethods include Normalization extend Normalization::ClassMethods + include SecurePassword + extend SecurePassword::ClassMethods + include TokenFor + extend TokenFor::ClassMethods end class Relation @@ -133,11 +137,35 @@ module ActiveRecord def timestamps_for_create: () -> Hash[String, String] end + + module SecurePassword + module ClassMethods + def authenticate_by: (untyped attributes) -> instance? + end + end + + module TokenFor + module ClassMethods + def generates_token_for: (Symbol purpose, ?expires_in: ActiveSupport::Duration) ? { () [self: instance] -> untyped } -> untyped + def find_by_token_for: (Symbol purpose, String token) -> untyped + def find_by_token_for!: (Symbol purpose, String token) -> untyped + end + + def generate_token_for: (Symbol purpose) -> String + end +end + +module Arel + class Table + def initialize: (untyped name, ?type_caster: untyped type_caster, ?as: untyped? as, ?klass: untyped?) -> void + end end module ActiveRecord class Relation module Methods[Model, PrimaryKey] + def authenticate_by: (untyped attributes) -> Model? + def with: (*untyped args) -> self def with_recursive: (*untyped) -> self def with_recursive!: (*untyped) -> self end @@ -145,6 +173,7 @@ module ActiveRecord class Base module ClassMethods[Model, Relation, PrimaryKey] + def with: (*untyped args) -> Relation def with_recursive: (*untyped) -> Relation end end