Skip to content

Commit

Permalink
✅ (Tests) Atualiza configurações de inicialização
Browse files Browse the repository at this point in the history
  • Loading branch information
victorLessa committed Apr 25, 2024
1 parent ddaaeb0 commit ca8c383
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 12 deletions.
4 changes: 0 additions & 4 deletions src/Functional/createAudit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,6 @@ export default async function ({
ip = request?.ip() ?? null
}

// Pluralize and snackCase user entityName

console.error('=====', getUserEntityName(auth.user))

// get user data to store
const userId = get(auth, 'user.id', null)
// save audit
Expand Down
3 changes: 3 additions & 0 deletions test/audit.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ test.group('Auto preload', (group) => {
@column()
public userId: number | null = null

@column()
public userEntityName: string

/** Entity Id */
@column()
public auditableId: string | null
Expand Down
3 changes: 3 additions & 0 deletions test/helpers/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,9 @@ export default class Audit extends BaseModel {
/** User Id */
@column()
public userEntityName: string
@column()
public userId: number | null = null
Expand Down
11 changes: 3 additions & 8 deletions test/helpers/database.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,9 @@ export async function createAuditsTable(Database: DatabaseContract) {
await Database.connection().schema.createTable('audits', (table) => {
table.increments('id')
// User id from Auth in ctx
table
.integer('user_id')
.unsigned()
.nullable()
.defaultTo(null)
.references('id')
.inTable('users')
.onDelete('SET NULL')
table.integer('user_id').unsigned().notNullable()
// User id from Auth in ctx
table.string('user_entity_name').defaultTo('users')
// Entity Id
table.string('auditable_id').nullable()
// Entity Name
Expand Down

0 comments on commit ca8c383

Please sign in to comment.