Browse Source

Devise fields don't need versioning (#455)

pull/456/head
baarkerlounger 3 years ago committed by GitHub
parent
commit
433748f5b6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 13
      app/models/admin_user.rb
  2. 13
      app/models/user.rb
  3. 19
      spec/models/admin_user_spec.rb
  4. 19
      spec/models/user_spec.rb

13
app/models/admin_user.rb

@ -6,7 +6,18 @@ class AdminUser < ApplicationRecord
has_one_time_password(encrypted: true)
has_paper_trail
has_paper_trail ignore: %w[last_sign_in_at
current_sign_in_at
current_sign_in_ip
last_sign_in_ip
failed_attempts
unlock_token
locked_at
reset_password_token
reset_password_sent_at
remember_created_at
sign_in_count
updated_at]
validates :phone, presence: true, numericality: true

13
app/models/user.rb

@ -8,7 +8,18 @@ class User < ApplicationRecord
has_many :owned_case_logs, through: :organisation
has_many :managed_case_logs, through: :organisation
has_paper_trail
has_paper_trail ignore: %w[last_sign_in_at
current_sign_in_at
current_sign_in_ip
last_sign_in_ip
failed_attempts
unlock_token
locked_at
reset_password_token
reset_password_sent_at
remember_created_at
sign_in_count
updated_at]
ROLES = {
data_accessor: 0,

19
spec/models/admin_user_spec.rb

@ -61,5 +61,24 @@ RSpec.describe AdminUser, type: :model do
admin_user.update!(phone: "09673867853")
expect(admin_user.paper_trail.previous_version.phone).to eq("07563867654")
end
it "signing in does not create a new version" do
expect {
admin_user.update!(
last_sign_in_at: Time.zone.now,
current_sign_in_at: Time.zone.now,
current_sign_in_ip: "127.0.0.1",
last_sign_in_ip: "127.0.0.1",
failed_attempts: 3,
unlock_token: "dummy",
locked_at: Time.zone.now,
reset_password_token: "dummy",
reset_password_sent_at: Time.zone.now,
remember_created_at: Time.zone.now,
sign_in_count: 5,
updated_at: Time.zone.now,
)
}.not_to change(admin_user.versions, :count)
end
end
end

19
spec/models/user_spec.rb

@ -77,5 +77,24 @@ RSpec.describe User, type: :model do
user.update!(name: "new test name")
expect(user.paper_trail.previous_version.name).to eq("Danny Rojas")
end
it "signing in does not create a new version" do
expect {
user.update!(
last_sign_in_at: Time.zone.now,
current_sign_in_at: Time.zone.now,
current_sign_in_ip: "127.0.0.1",
last_sign_in_ip: "127.0.0.1",
failed_attempts: 3,
unlock_token: "dummy",
locked_at: Time.zone.now,
reset_password_token: "dummy",
reset_password_sent_at: Time.zone.now,
remember_created_at: Time.zone.now,
sign_in_count: 5,
updated_at: Time.zone.now,
)
}.not_to change(user.versions, :count)
end
end
end

Loading…
Cancel
Save