Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion app/models/user.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,7 @@ class User < ApplicationRecord
has_many :procedures, dependent: :destroy
has_many :health_insurances, dependent: :destroy

validates :email, uniqueness: { case_sensitive: false }
def destroy
Copy link
Member

@edimossilva edimossilva Sep 8, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should do this at controller level, not at model level.

We only need to update to use realy_destroy here https://github.com/espoo-dev/med_system_backend/blob/main/app/controllers/api/v1/users_controller.rb#L14

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

to olhando aqui e o serviceo ja usa o destroy_fully!, agora eh esperar o Roanderson falar o que aconteceu

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok

destroy_fully!
end
end
14 changes: 14 additions & 0 deletions config/locales/pt-BR/devise.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,20 @@ pt-BR:
user:
one: Usuário
other: Usuários
errors:
messages:
taken: "já está sendo usado"
blank: "não pode ficar em branco"
too_short: "é muito curta (mínimo de %{count} caracteres)"
invalid: "não é válido"
confirmation: "não confere"
errors:
messages:
taken: "já está sendo usado"
blank: "não pode ficar em branco"
too_short: "é muito curta (mínimo de %{count} caracteres)"
invalid: "não é válido"
confirmation: "não confere"
devise:
confirmations:
confirmed: A sua conta foi confirmada com sucesso.
Expand Down
13 changes: 13 additions & 0 deletions db/migrate/20250814223547_remove_unique_index_from_users_email.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# frozen_string_literal: true

class RemoveUniqueIndexFromUsersEmail < ActiveRecord::Migration[7.1]
def up
remove_index :users, name: "index_users_on_email"
add_index :users, :email, name: "index_users_on_email"
end

def down
remove_index :users, name: "index_users_on_email"
add_index :users, :email, name: "index_users_on_email", unique: true
end
end
4 changes: 2 additions & 2 deletions db/schema.rb

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 0 additions & 6 deletions spec/models/user_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,6 @@
RSpec.describe User do
subject { build(:user) }

describe "soft delete behavior" do
let(:user) { create(:user) }

it_behaves_like "acts as paranoid", :user
end

describe "associations" do
it { is_expected.to have_many(:event_procedures).dependent(:destroy) }
it { is_expected.to have_many(:medical_shifts).dependent(:destroy) }
Expand Down