Refactoring: Migrate user_mail_delivery_failed to RSpec
This commit is contained in:
parent
444e48e377
commit
17ed0a13f6
2 changed files with 23 additions and 40 deletions
|
@ -436,6 +436,29 @@ RSpec.describe User, type: :model do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
describe '#preferences' do
|
||||||
|
describe '"mail_delivery_failed{,_data}" keys' do
|
||||||
|
before do
|
||||||
|
user.update(
|
||||||
|
preferences: {
|
||||||
|
mail_delivery_failed: true,
|
||||||
|
mail_delivery_failed_data: Time.current
|
||||||
|
}
|
||||||
|
)
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'deletes "mail_delivery_failed"' do
|
||||||
|
expect { user.update(email: Faker::Internet.email) }
|
||||||
|
.to change { user.preferences.key?(:mail_delivery_failed) }.to(false)
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'leaves "mail_delivery_failed_data" untouched' do
|
||||||
|
expect { user.update(email: Faker::Internet.email) }
|
||||||
|
.to not_change { user.preferences[:mail_delivery_failed_data] }
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe 'Associations:' do
|
describe 'Associations:' do
|
||||||
|
|
|
@ -1,40 +0,0 @@
|
||||||
require 'test_helper'
|
|
||||||
|
|
||||||
class UserMailDeliveryFailedTest < ActiveSupport::TestCase
|
|
||||||
setup do
|
|
||||||
|
|
||||||
UserInfo.current_user_id = 1
|
|
||||||
|
|
||||||
roles = Role.where(name: 'Customer')
|
|
||||||
@customer1 = User.create_or_update(
|
|
||||||
login: 'user-mail-delivery-failed-customer1@example.com',
|
|
||||||
firstname: 'UserOutOfOffice',
|
|
||||||
lastname: 'Customer1',
|
|
||||||
email: 'user-mail-delivery-failed-customer1@example.com',
|
|
||||||
password: 'agentpw',
|
|
||||||
active: true,
|
|
||||||
roles: roles,
|
|
||||||
)
|
|
||||||
|
|
||||||
end
|
|
||||||
|
|
||||||
test 'check reset of mail_delivery_failed' do
|
|
||||||
|
|
||||||
@customer1.preferences[:mail_delivery_failed] = true
|
|
||||||
@customer1.preferences[:mail_delivery_failed_data] = Time.zone.now
|
|
||||||
@customer1.save!
|
|
||||||
@customer1.reload
|
|
||||||
|
|
||||||
assert_equal(@customer1.preferences[:mail_delivery_failed], true)
|
|
||||||
assert(@customer1.preferences[:mail_delivery_failed_data])
|
|
||||||
|
|
||||||
@customer1.email = 'new-user-mail-delivery-failed-customer1@example.com'
|
|
||||||
@customer1.save!
|
|
||||||
@customer1.reload
|
|
||||||
|
|
||||||
assert_not(@customer1.preferences[:mail_delivery_failed], true)
|
|
||||||
assert(@customer1.preferences[:mail_delivery_failed_data])
|
|
||||||
|
|
||||||
end
|
|
||||||
|
|
||||||
end
|
|
Loading…
Reference in a new issue