Fixed issue #1579 - leading and tailing utf8 spaces are not removed for email addresses are not removed.
This commit is contained in:
parent
aeb1feb826
commit
b35ff0fef2
10 changed files with 348 additions and 158 deletions
|
@ -536,10 +536,10 @@ condition example
|
||||||
selector = selector_raw.stringify_keys
|
selector = selector_raw.stringify_keys
|
||||||
raise "Invalid selector, operator missing #{selector.inspect}" if !selector['operator']
|
raise "Invalid selector, operator missing #{selector.inspect}" if !selector['operator']
|
||||||
|
|
||||||
# validate value / allow empty but only if pre_condition exists and is not specific
|
# validate value / allow blank but only if pre_condition exists and is not specific
|
||||||
if !selector.key?('value') || ((selector['value'].class == String || selector['value'].class == Array) && (selector['value'].respond_to?(:empty?) && selector['value'].empty?))
|
if !selector.key?('value') || ((selector['value'].class == String || selector['value'].class == Array) && (selector['value'].respond_to?(:empty?) && selector['value'].empty?))
|
||||||
return nil if selector['pre_condition'].nil?
|
return nil if selector['pre_condition'].nil?
|
||||||
return nil if selector['pre_condition'].respond_to?(:empty?) && selector['pre_condition'].empty?
|
return nil if selector['pre_condition'].respond_to?(:blank?) && selector['pre_condition'].blank?
|
||||||
return nil if selector['pre_condition'] == 'specific'
|
return nil if selector['pre_condition'] == 'specific'
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -82,8 +82,7 @@ returns
|
||||||
subject = subject[ 0, ticket_subject_size.to_i ] + '[...]'
|
subject = subject[ 0, ticket_subject_size.to_i ] + '[...]'
|
||||||
end
|
end
|
||||||
|
|
||||||
subject.gsub!(/^[[:space:]]+/, '')
|
subject.strip!
|
||||||
subject.gsub!(/[[:space:]]+$/, '')
|
|
||||||
subject
|
subject
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -96,16 +96,16 @@ returns
|
||||||
|
|
||||||
def fullname
|
def fullname
|
||||||
name = ''
|
name = ''
|
||||||
if firstname && !firstname.empty?
|
if firstname.present?
|
||||||
name = name + firstname
|
name = firstname
|
||||||
end
|
end
|
||||||
if lastname && !lastname.empty?
|
if lastname.present?
|
||||||
if name != ''
|
if name != ''
|
||||||
name += ' '
|
name += ' '
|
||||||
end
|
end
|
||||||
name += lastname
|
name += lastname
|
||||||
end
|
end
|
||||||
if name == '' && email
|
if name.blank? && email.present?
|
||||||
name = email
|
name = email
|
||||||
end
|
end
|
||||||
name
|
name
|
||||||
|
@ -486,7 +486,7 @@ returns
|
||||||
|
|
||||||
get all users with permission
|
get all users with permission
|
||||||
|
|
||||||
users = User.with_permissions('admin.session')
|
users = User.with_permissions('ticket.agent')
|
||||||
|
|
||||||
get all users with permission "admin.session" or "ticket.agent"
|
get all users with permission "admin.session" or "ticket.agent"
|
||||||
|
|
||||||
|
@ -847,41 +847,54 @@ returns
|
||||||
end
|
end
|
||||||
|
|
||||||
def check_name
|
def check_name
|
||||||
return true if !firstname.empty? && !lastname.empty?
|
if firstname.present?
|
||||||
|
firstname.strip!
|
||||||
|
end
|
||||||
|
if lastname.present?
|
||||||
|
lastname.strip!
|
||||||
|
end
|
||||||
|
|
||||||
if !firstname.empty? && lastname.empty?
|
return true if firstname.present? && lastname.present?
|
||||||
|
|
||||||
|
if (firstname.blank? && lastname.present?) || (firstname.present? && lastname.blank?)
|
||||||
|
|
||||||
# "Lastname, Firstname"
|
# "Lastname, Firstname"
|
||||||
scan = firstname.scan(/, /)
|
used_name = if firstname.blank?
|
||||||
if scan[0]
|
lastname
|
||||||
name = firstname.split(', ', 2)
|
else
|
||||||
if !name[0].nil?
|
firstname
|
||||||
|
end
|
||||||
|
name = used_name.split(', ', 2)
|
||||||
|
if name.count == 2
|
||||||
|
if name[0].present?
|
||||||
self.lastname = name[0]
|
self.lastname = name[0]
|
||||||
end
|
end
|
||||||
if !name[1].nil?
|
if name[1].present?
|
||||||
self.firstname = name[1]
|
self.firstname = name[1]
|
||||||
end
|
end
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
|
|
||||||
# "Firstname Lastname"
|
# "Firstname Lastname"
|
||||||
name = firstname.split(' ', 2)
|
name = used_name.split(' ', 2)
|
||||||
if !name[0].nil?
|
if name.count == 2
|
||||||
|
if name[0].present?
|
||||||
self.firstname = name[0]
|
self.firstname = name[0]
|
||||||
end
|
end
|
||||||
if !name[1].nil?
|
if name[1].present?
|
||||||
self.lastname = name[1]
|
self.lastname = name[1]
|
||||||
end
|
end
|
||||||
return true
|
return true
|
||||||
|
end
|
||||||
|
|
||||||
# -no name- "firstname.lastname@example.com"
|
# -no name- "firstname.lastname@example.com"
|
||||||
elsif firstname.empty? && lastname.empty? && !email.empty?
|
elsif firstname.blank? && lastname.blank? && email.present?
|
||||||
scan = email.scan(/^(.+?)\.(.+?)\@.+?$/)
|
scan = email.scan(/^(.+?)\.(.+?)\@.+?$/)
|
||||||
if scan[0]
|
if scan[0]
|
||||||
if !scan[0][0].nil?
|
if scan[0][0].present?
|
||||||
self.firstname = scan[0][0].capitalize
|
self.firstname = scan[0][0].capitalize
|
||||||
end
|
end
|
||||||
if !scan[0][1].nil?
|
if scan[0][1].present?
|
||||||
self.lastname = scan[0][1].capitalize
|
self.lastname = scan[0][1].capitalize
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,4 +1,31 @@
|
||||||
class String
|
class String
|
||||||
|
alias old_strip strip
|
||||||
|
alias old_strip! strip!
|
||||||
|
|
||||||
|
def strip!
|
||||||
|
begin
|
||||||
|
sub!(/\A[[[:space:]]\u{200B}\u{FEFF}]+/, '')
|
||||||
|
sub!(/[[[:space:]]\u{200B}\u{FEFF}]+\Z/, '')
|
||||||
|
|
||||||
|
# if incompatible encoding regexp match (UTF-8 regexp with ASCII-8BIT string) (Encoding::CompatibilityError), use default
|
||||||
|
rescue
|
||||||
|
old_strip!
|
||||||
|
end
|
||||||
|
self
|
||||||
|
end
|
||||||
|
|
||||||
|
def strip
|
||||||
|
begin
|
||||||
|
new_string = sub(/\A[[[:space:]]\u{200B}\u{FEFF}]+/, '')
|
||||||
|
new_string.sub!(/[[[:space:]]\u{200B}\u{FEFF}]+\Z/, '')
|
||||||
|
|
||||||
|
# if incompatible encoding regexp match (UTF-8 regexp with ASCII-8BIT string) (Encoding::CompatibilityError), use default
|
||||||
|
rescue
|
||||||
|
new_string = old_strip
|
||||||
|
end
|
||||||
|
new_string
|
||||||
|
end
|
||||||
|
|
||||||
def message_quote
|
def message_quote
|
||||||
quote = split("\n")
|
quote = split("\n")
|
||||||
body_quote = ''
|
body_quote = ''
|
||||||
|
|
|
@ -127,7 +127,7 @@ module Enrichment
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
return if @config['api_key'].empty?
|
return if @config['api_key'].blank?
|
||||||
|
|
||||||
record = {
|
record = {
|
||||||
direction: 'out',
|
direction: 'out',
|
||||||
|
|
|
@ -135,8 +135,7 @@ or with filter:
|
||||||
end
|
end
|
||||||
|
|
||||||
def self._url_cleanup(url)
|
def self._url_cleanup(url)
|
||||||
url.gsub!(/^[[:space:]]+/, '')
|
url.strip!
|
||||||
url.gsub!(/[[:space:]]+$/, '')
|
|
||||||
raise "Invalid endpoint '#{url}', need to start with http:// or https://" if url !~ %r{^http(s|)://}i
|
raise "Invalid endpoint '#{url}', need to start with http:// or https://" if url !~ %r{^http(s|)://}i
|
||||||
url = _url_cleanup_baseurl(url)
|
url = _url_cleanup_baseurl(url)
|
||||||
url = "#{url}/src/jsonrpc.php"
|
url = "#{url}/src/jsonrpc.php"
|
||||||
|
@ -144,8 +143,7 @@ or with filter:
|
||||||
end
|
end
|
||||||
|
|
||||||
def self._url_cleanup_baseurl(url)
|
def self._url_cleanup_baseurl(url)
|
||||||
url.gsub!(/^[[:space:]]+/, '')
|
url.strip!
|
||||||
url.gsub!(/[[:space:]]+$/, '')
|
|
||||||
raise "Invalid endpoint '#{url}', need to start with http:// or https://" if url !~ %r{^http(s|)://}i
|
raise "Invalid endpoint '#{url}', need to start with http:// or https://" if url !~ %r{^http(s|)://}i
|
||||||
url.gsub!(%r{src/jsonrpc.php}, '')
|
url.gsub!(%r{src/jsonrpc.php}, '')
|
||||||
url.gsub(%r{([^:])//+}, '\\1/')
|
url.gsub(%r{([^:])//+}, '\\1/')
|
||||||
|
|
|
@ -37,7 +37,7 @@ class ClearbitTest < ActiveSupport::TestCase
|
||||||
})
|
})
|
||||||
|
|
||||||
# case 1 - person + company (demo data set)
|
# case 1 - person + company (demo data set)
|
||||||
customer1 = User.create(
|
customer1 = User.create!(
|
||||||
firstname: '',
|
firstname: '',
|
||||||
lastname: 'Should be still there',
|
lastname: 'Should be still there',
|
||||||
email: 'alex@alexmaccaw.com',
|
email: 'alex@alexmaccaw.com',
|
||||||
|
@ -52,20 +52,20 @@ class ClearbitTest < ActiveSupport::TestCase
|
||||||
|
|
||||||
assert(ExternalSync.find_by(source: 'clearbit', object: 'User', o_id: customer1.id))
|
assert(ExternalSync.find_by(source: 'clearbit', object: 'User', o_id: customer1.id))
|
||||||
|
|
||||||
customer1_lookup = User.lookup(id: customer1.id)
|
customer1.reload
|
||||||
|
|
||||||
assert_equal('Alex', customer1_lookup.firstname)
|
assert_equal('Should', customer1.firstname)
|
||||||
assert_equal('Should be still there', customer1_lookup.lastname)
|
assert_equal('be still there', customer1.lastname)
|
||||||
assert_equal('O\'Reilly author, software engineer & traveller. Founder of https://clearbit.com', customer1_lookup.note)
|
assert_equal('O\'Reilly author, software engineer & traveller. Founder of https://clearbit.com', customer1.note)
|
||||||
assert_equal('1455 Market Street, San Francisco, CA 94103, USA', customer1_lookup.address)
|
assert_equal('1455 Market Street, San Francisco, CA 94103, USA', customer1.address)
|
||||||
|
|
||||||
organization1_lookup = Organization.find_by(name: 'Uber, Inc.')
|
organization1 = Organization.find_by(name: 'Uber, Inc.')
|
||||||
assert(ExternalSync.find_by(source: 'clearbit', object: 'Organization', o_id: organization1_lookup.id))
|
assert(ExternalSync.find_by(source: 'clearbit', object: 'Organization', o_id: organization1.id))
|
||||||
assert_equal(false, organization1_lookup.shared)
|
assert_equal(false, organization1.shared)
|
||||||
assert_equal('Uber is a mobile app connecting passengers with drivers for hire.', organization1_lookup.note)
|
assert_equal('Uber is a mobile app connecting passengers with drivers for hire.', organization1.note)
|
||||||
|
|
||||||
# case 2 - person + company
|
# case 2 - person + company
|
||||||
customer2 = User.create(
|
customer2 = User.create!(
|
||||||
firstname: '',
|
firstname: '',
|
||||||
lastname: '',
|
lastname: '',
|
||||||
email: 'me@example.com',
|
email: 'me@example.com',
|
||||||
|
@ -80,17 +80,17 @@ class ClearbitTest < ActiveSupport::TestCase
|
||||||
|
|
||||||
assert(ExternalSync.find_by(source: 'clearbit', object: 'User', o_id: customer2.id))
|
assert(ExternalSync.find_by(source: 'clearbit', object: 'User', o_id: customer2.id))
|
||||||
|
|
||||||
customer2_lookup = User.lookup(id: customer2.id)
|
customer2.reload
|
||||||
|
|
||||||
assert_equal('Martin', customer2_lookup.firstname)
|
assert_equal('Martin', customer2.firstname)
|
||||||
assert_equal('Edenhofer', customer2_lookup.lastname)
|
assert_equal('Edenhofer', customer2.lastname)
|
||||||
assert_equal("Open Source professional and geek. Also known as OTRS inventor. ;)\r\nEntrepreneur and Advisor for open source people in need.", customer2_lookup.note)
|
assert_equal("Open Source professional and geek. Also known as OTRS inventor. ;)\r\nEntrepreneur and Advisor for open source people in need.", customer2.note)
|
||||||
assert_equal('Norsk-Data-Straße 1, 61352 Bad Homburg vor der Höhe, Germany', customer2_lookup.address)
|
assert_equal('Norsk-Data-Straße 1, 61352 Bad Homburg vor der Höhe, Germany', customer2.address)
|
||||||
|
|
||||||
organization2_lookup = Organization.find_by(name: 'OTRS')
|
organization2 = Organization.find_by(name: 'OTRS')
|
||||||
assert(ExternalSync.find_by(source: 'clearbit', object: 'Organization', o_id: organization2_lookup.id))
|
assert(ExternalSync.find_by(source: 'clearbit', object: 'Organization', o_id: organization2.id))
|
||||||
assert_equal(false, organization2_lookup.shared)
|
assert_equal(false, organization2.shared)
|
||||||
assert_equal('OTRS is an Open Source helpdesk software and an IT Service Management software free of licence costs. Improve your Customer Service Management with OTRS.', organization2_lookup.note)
|
assert_equal('OTRS is an Open Source helpdesk software and an IT Service Management software free of licence costs. Improve your Customer Service Management with OTRS.', organization2.note)
|
||||||
|
|
||||||
# update with own values (do not overwrite)
|
# update with own values (do not overwrite)
|
||||||
customer2.update!(
|
customer2.update!(
|
||||||
|
@ -103,23 +103,23 @@ class ClearbitTest < ActiveSupport::TestCase
|
||||||
|
|
||||||
assert(ExternalSync.find_by(source: 'clearbit', object: 'User', o_id: customer2.id))
|
assert(ExternalSync.find_by(source: 'clearbit', object: 'User', o_id: customer2.id))
|
||||||
|
|
||||||
customer2_lookup = User.lookup(id: customer2.id)
|
customer2.reload
|
||||||
|
|
||||||
assert_equal('Martini', customer2_lookup.firstname)
|
assert_equal('Martini', customer2.firstname)
|
||||||
assert_equal('Edenhofer', customer2_lookup.lastname)
|
assert_equal('Edenhofer', customer2.lastname)
|
||||||
assert_equal('changed by my self', customer2_lookup.note)
|
assert_equal('changed by my self', customer2.note)
|
||||||
assert_equal('Norsk-Data-Straße 1, 61352 Bad Homburg vor der Höhe, Germany', customer2_lookup.address)
|
assert_equal('Norsk-Data-Straße 1, 61352 Bad Homburg vor der Höhe, Germany', customer2.address)
|
||||||
|
|
||||||
customer2_enrichment = Enrichment::Clearbit::User.new(customer2)
|
customer2_enrichment = Enrichment::Clearbit::User.new(customer2)
|
||||||
customer2_enrichment.synced?
|
customer2_enrichment.synced?
|
||||||
Scheduler.worker(true)
|
Scheduler.worker(true)
|
||||||
|
|
||||||
customer2_lookup = User.lookup(id: customer2.id)
|
customer2.reload
|
||||||
|
|
||||||
assert_equal('Martini', customer2_lookup.firstname)
|
assert_equal('Martini', customer2.firstname)
|
||||||
assert_equal('Edenhofer', customer2_lookup.lastname)
|
assert_equal('Edenhofer', customer2.lastname)
|
||||||
assert_equal('changed by my self', customer2_lookup.note)
|
assert_equal('changed by my self', customer2.note)
|
||||||
assert_equal('Norsk-Data-Straße 1, 61352 Bad Homburg vor der Höhe, Germany', customer2_lookup.address)
|
assert_equal('Norsk-Data-Straße 1, 61352 Bad Homburg vor der Höhe, Germany', customer2.address)
|
||||||
|
|
||||||
# update with own values (do not overwrite)
|
# update with own values (do not overwrite)
|
||||||
customer2.update!(
|
customer2.update!(
|
||||||
|
@ -131,12 +131,12 @@ class ClearbitTest < ActiveSupport::TestCase
|
||||||
customer2_enrichment.synced?
|
customer2_enrichment.synced?
|
||||||
Scheduler.worker(true)
|
Scheduler.worker(true)
|
||||||
|
|
||||||
customer2_lookup = User.lookup(id: customer2.id)
|
customer2.reload
|
||||||
|
|
||||||
assert_equal('Martin', customer2_lookup.firstname)
|
assert_equal('Martin', customer2.firstname)
|
||||||
assert_equal('Edenhofer', customer2_lookup.lastname)
|
assert_equal('Edenhofer', customer2.lastname)
|
||||||
assert_equal('changed by my self', customer2_lookup.note)
|
assert_equal('changed by my self', customer2.note)
|
||||||
assert_equal('Norsk-Data-Straße 1, 61352 Bad Homburg vor der Höhe, Germany', customer2_lookup.address)
|
assert_equal('Norsk-Data-Straße 1, 61352 Bad Homburg vor der Höhe, Germany', customer2.address)
|
||||||
|
|
||||||
# update with changed values at clearbit site (do overwrite)
|
# update with changed values at clearbit site (do overwrite)
|
||||||
customer2.update!(
|
customer2.update!(
|
||||||
|
@ -147,20 +147,20 @@ class ClearbitTest < ActiveSupport::TestCase
|
||||||
customer2_enrichment.synced?
|
customer2_enrichment.synced?
|
||||||
Scheduler.worker(true)
|
Scheduler.worker(true)
|
||||||
|
|
||||||
customer2_lookup = User.lookup(id: customer2.id)
|
customer2.reload
|
||||||
|
|
||||||
assert_equal('Martini', customer2_lookup.firstname)
|
assert_equal('Martini', customer2.firstname)
|
||||||
assert_equal('Edenhofer', customer2_lookup.lastname)
|
assert_equal('Edenhofer', customer2.lastname)
|
||||||
assert_equal('changed by my self', customer2_lookup.note)
|
assert_equal('changed by my self', customer2.note)
|
||||||
assert_equal('Norsk-Data-Straße 1, 61352 Bad Homburg vor der Höhe, Germany', customer2_lookup.address)
|
assert_equal('Norsk-Data-Straße 1, 61352 Bad Homburg vor der Höhe, Germany', customer2.address)
|
||||||
|
|
||||||
organization2_lookup = Organization.find_by(name: 'OTRS AG')
|
organization2 = Organization.find_by(name: 'OTRS AG')
|
||||||
assert(ExternalSync.find_by(source: 'clearbit', object: 'Organization', o_id: organization2_lookup.id))
|
assert(ExternalSync.find_by(source: 'clearbit', object: 'Organization', o_id: organization2.id))
|
||||||
assert_equal(false, organization2_lookup.shared)
|
assert_equal(false, organization2.shared)
|
||||||
assert_equal('OTRS is an Open Source helpdesk software and an IT Service Management software free of licence costs. Improve your Customer Service Management with OTRS.', organization2_lookup.note)
|
assert_equal('OTRS is an Open Source helpdesk software and an IT Service Management software free of licence costs. Improve your Customer Service Management with OTRS.', organization2.note)
|
||||||
|
|
||||||
# case 3 - no person
|
# case 3 - no person
|
||||||
customer3 = User.create(
|
customer3 = User.create!(
|
||||||
firstname: '',
|
firstname: '',
|
||||||
lastname: '',
|
lastname: '',
|
||||||
email: 'testing3@znuny.com',
|
email: 'testing3@znuny.com',
|
||||||
|
@ -175,22 +175,21 @@ class ClearbitTest < ActiveSupport::TestCase
|
||||||
|
|
||||||
assert_not(ExternalSync.find_by(source: 'clearbit', object: 'User', o_id: customer3.id))
|
assert_not(ExternalSync.find_by(source: 'clearbit', object: 'User', o_id: customer3.id))
|
||||||
|
|
||||||
customer3_lookup = User.lookup(id: customer3.id)
|
customer3.reload
|
||||||
assert_not_equal(customer3.updated_at, customer3_lookup.updated_at)
|
|
||||||
|
|
||||||
assert_equal('', customer3_lookup.firstname)
|
assert_equal('', customer3.firstname)
|
||||||
assert_equal('', customer3_lookup.lastname)
|
assert_equal('', customer3.lastname)
|
||||||
assert_equal('', customer3_lookup.note)
|
assert_equal('', customer3.note)
|
||||||
assert_equal('http://znuny.com', customer3_lookup.web)
|
assert_equal('http://znuny.com', customer3.web)
|
||||||
assert_equal('Marienstraße 11, 10117 Berlin, Germany', customer3_lookup.address)
|
assert_equal('Marienstraße 11, 10117 Berlin, Germany', customer3.address)
|
||||||
|
|
||||||
organization3_lookup = Organization.find_by(name: 'Znuny / ES for OTRS')
|
organization3 = Organization.find_by(name: 'Znuny / ES for OTRS')
|
||||||
assert(ExternalSync.find_by(source: 'clearbit', object: 'Organization', o_id: organization3_lookup.id))
|
assert(ExternalSync.find_by(source: 'clearbit', object: 'Organization', o_id: organization3.id))
|
||||||
assert_equal(false, organization3_lookup.shared)
|
assert_equal(false, organization3.shared)
|
||||||
assert_equal('OTRS Support, Consulting, Development, Training and Customizing - Znuny GmbH', organization3_lookup.note)
|
assert_equal('OTRS Support, Consulting, Development, Training and Customizing - Znuny GmbH', organization3.note)
|
||||||
|
|
||||||
# case 4 - person with organization but organization is already assigned (own created)
|
# case 4 - person with organization but organization is already assigned (own created)
|
||||||
customer4 = User.create(
|
customer4 = User.create!(
|
||||||
firstname: '',
|
firstname: '',
|
||||||
lastname: '',
|
lastname: '',
|
||||||
email: 'testing4@znuny.com',
|
email: 'testing4@znuny.com',
|
||||||
|
@ -206,25 +205,24 @@ class ClearbitTest < ActiveSupport::TestCase
|
||||||
|
|
||||||
assert(ExternalSync.find_by(source: 'clearbit', object: 'User', o_id: customer4.id))
|
assert(ExternalSync.find_by(source: 'clearbit', object: 'User', o_id: customer4.id))
|
||||||
|
|
||||||
customer4_lookup = User.lookup(id: customer4.id)
|
customer4.reload
|
||||||
assert_not_equal(customer4.updated_at, customer4_lookup.updated_at)
|
|
||||||
|
|
||||||
assert_equal('Fred', customer4_lookup.firstname)
|
assert_equal('Fred', customer4.firstname)
|
||||||
assert_equal('Jupiter', customer4_lookup.lastname)
|
assert_equal('Jupiter', customer4.lastname)
|
||||||
assert_equal('some_fred_bio', customer4_lookup.note)
|
assert_equal('some_fred_bio', customer4.note)
|
||||||
assert_equal('http://fred.znuny.com', customer4_lookup.web)
|
assert_equal('http://fred.znuny.com', customer4.web)
|
||||||
assert_equal('Marienstraße 11, 10117 Berlin, Germany', customer4_lookup.address)
|
assert_equal('Marienstraße 11, 10117 Berlin, Germany', customer4.address)
|
||||||
|
|
||||||
organization4_lookup = Organization.find_by(name: 'ZnunyOfFred')
|
organization4 = Organization.find_by(name: 'ZnunyOfFred')
|
||||||
assert_not(organization4_lookup)
|
assert_not(organization4)
|
||||||
|
|
||||||
# case 5 - person with organization but organization is already assigned (own created)
|
# case 5 - person with organization but organization is already assigned (own created)
|
||||||
customer5 = User.create(
|
customer5 = User.create!(
|
||||||
firstname: '',
|
firstname: '',
|
||||||
lastname: '',
|
lastname: '',
|
||||||
email: 'testing5@znuny.com',
|
email: 'testing5@znuny.com',
|
||||||
note: '',
|
note: '',
|
||||||
organization_id: organization3_lookup.id,
|
organization_id: organization3.id,
|
||||||
updated_by_id: 1,
|
updated_by_id: 1,
|
||||||
created_by_id: 1,
|
created_by_id: 1,
|
||||||
)
|
)
|
||||||
|
@ -235,23 +233,22 @@ class ClearbitTest < ActiveSupport::TestCase
|
||||||
|
|
||||||
assert(ExternalSync.find_by(source: 'clearbit', object: 'User', o_id: customer5.id))
|
assert(ExternalSync.find_by(source: 'clearbit', object: 'User', o_id: customer5.id))
|
||||||
|
|
||||||
customer5_lookup = User.lookup(id: customer5.id)
|
customer5.reload
|
||||||
assert_not_equal(customer5.updated_at, customer5_lookup.updated_at)
|
|
||||||
|
|
||||||
assert_equal('Alex', customer5_lookup.firstname)
|
assert_equal('Alex', customer5.firstname)
|
||||||
assert_equal('Dont', customer5_lookup.lastname)
|
assert_equal('Dont', customer5.lastname)
|
||||||
assert_equal('some_bio_alex', customer5_lookup.note)
|
assert_equal('some_bio_alex', customer5.note)
|
||||||
assert_equal('http://znuny.com', customer5_lookup.web)
|
assert_equal('http://znuny.com', customer5.web)
|
||||||
assert_equal('Marienstraße 11, 10117 Berlin, Germany', customer5_lookup.address)
|
assert_equal('Marienstraße 11, 10117 Berlin, Germany', customer5.address)
|
||||||
|
|
||||||
organization5_lookup = Organization.find_by(name: 'Znuny GmbH')
|
organization5 = Organization.find_by(name: 'Znuny GmbH')
|
||||||
assert_equal(organization3_lookup.id, organization5_lookup.id)
|
assert_equal(organization3.id, organization5.id)
|
||||||
assert(ExternalSync.find_by(source: 'clearbit', object: 'Organization', o_id: organization5_lookup.id))
|
assert(ExternalSync.find_by(source: 'clearbit', object: 'Organization', o_id: organization5.id))
|
||||||
assert_equal(false, organization5_lookup.shared)
|
assert_equal(false, organization5.shared)
|
||||||
assert_equal('OTRS Support, Consulting, Development, Training and Customizing - Znuny GmbH', organization5_lookup.note)
|
assert_equal('OTRS Support, Consulting, Development, Training and Customizing - Znuny GmbH', organization5.note)
|
||||||
|
|
||||||
# case 6 - no person / real api call
|
# case 6 - no person / real api call
|
||||||
customer6 = User.create(
|
customer6 = User.create!(
|
||||||
firstname: '',
|
firstname: '',
|
||||||
lastname: '',
|
lastname: '',
|
||||||
email: 'testing6@clearbit.com',
|
email: 'testing6@clearbit.com',
|
||||||
|
@ -266,21 +263,20 @@ class ClearbitTest < ActiveSupport::TestCase
|
||||||
|
|
||||||
assert_not(ExternalSync.find_by(source: 'clearbit', object: 'User', o_id: customer6.id))
|
assert_not(ExternalSync.find_by(source: 'clearbit', object: 'User', o_id: customer6.id))
|
||||||
|
|
||||||
customer6_lookup = User.lookup(id: customer6.id)
|
customer6.reload
|
||||||
assert_not_equal(customer6.updated_at, customer6_lookup.updated_at)
|
|
||||||
|
|
||||||
assert_equal('', customer6_lookup.firstname)
|
assert_equal('', customer6.firstname)
|
||||||
assert_equal('', customer6_lookup.lastname)
|
assert_equal('', customer6.lastname)
|
||||||
assert_equal('', customer6_lookup.note)
|
assert_equal('', customer6.note)
|
||||||
assert_equal('http://clearbit.com', customer6_lookup.web)
|
assert_equal('http://clearbit.com', customer6.web)
|
||||||
assert_equal('3030 16th St, San Francisco, CA 94103, USA', customer6_lookup.address)
|
assert_equal('3030 16th St, San Francisco, CA 94103, USA', customer6.address)
|
||||||
#assert_equal('San Francisco, CA, USA', customer6_lookup.address)
|
#assert_equal('San Francisco, CA, USA', customer6.address)
|
||||||
|
|
||||||
organization6_lookup = Organization.find_by(name: 'APIHub, Inc')
|
organization6 = Organization.find_by(name: 'APIHub, Inc')
|
||||||
assert(organization6_lookup, 'unable to find org of user')
|
assert(organization6, 'unable to find org of user')
|
||||||
assert(ExternalSync.find_by(source: 'clearbit', object: 'Organization', o_id: organization6_lookup.id))
|
assert(ExternalSync.find_by(source: 'clearbit', object: 'Organization', o_id: organization6.id))
|
||||||
assert_equal(false, organization6_lookup.shared)
|
assert_equal(false, organization6.shared)
|
||||||
assert_equal('Clearbit provides powerful products and data APIs to help your business grow. Contact enrichment, lead generation, financial compliance, and more...', organization6_lookup.note)
|
assert_equal('Clearbit provides powerful products and data APIs to help your business grow. Contact enrichment, lead generation, financial compliance, and more...', organization6.note)
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -316,7 +312,7 @@ class ClearbitTest < ActiveSupport::TestCase
|
||||||
})
|
})
|
||||||
|
|
||||||
# case 1 - person + company (demo data set)
|
# case 1 - person + company (demo data set)
|
||||||
customer1 = User.create(
|
customer1 = User.create!(
|
||||||
firstname: '',
|
firstname: '',
|
||||||
lastname: 'Should be still there',
|
lastname: 'Should be still there',
|
||||||
email: 'testing6@znuny.com',
|
email: 'testing6@znuny.com',
|
||||||
|
@ -331,17 +327,17 @@ class ClearbitTest < ActiveSupport::TestCase
|
||||||
|
|
||||||
assert(ExternalSync.find_by(source: 'clearbit', object: 'User', o_id: customer1.id))
|
assert(ExternalSync.find_by(source: 'clearbit', object: 'User', o_id: customer1.id))
|
||||||
|
|
||||||
customer1_lookup = User.lookup(id: customer1.id)
|
customer1.reload
|
||||||
|
|
||||||
assert_equal('Bob', customer1_lookup.firstname)
|
assert_equal('Should', customer1.firstname)
|
||||||
assert_equal('Should be still there', customer1_lookup.lastname)
|
assert_equal('be still there', customer1.lastname)
|
||||||
assert_equal('', customer1_lookup.note)
|
assert_equal('', customer1.note)
|
||||||
assert_equal('Marienstraße 11, 10117 Berlin, Germany', customer1_lookup.address)
|
assert_equal('Marienstraße 11, 10117 Berlin, Germany', customer1.address)
|
||||||
|
|
||||||
organization1_lookup = Organization.find_by(name: 'Znuny2')
|
organization1 = Organization.find_by(name: 'Znuny2')
|
||||||
assert(ExternalSync.find_by(source: 'clearbit', object: 'Organization', o_id: organization1_lookup.id))
|
assert(ExternalSync.find_by(source: 'clearbit', object: 'Organization', o_id: organization1.id))
|
||||||
assert_equal(true, organization1_lookup.shared)
|
assert_equal(true, organization1.shared)
|
||||||
assert_equal('', organization1_lookup.note)
|
assert_equal('', organization1.note)
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
|
@ -4,6 +4,55 @@ require 'test_helper'
|
||||||
|
|
||||||
class AaaStringTest < ActiveSupport::TestCase
|
class AaaStringTest < ActiveSupport::TestCase
|
||||||
|
|
||||||
|
test 'strip' do
|
||||||
|
raw = ' test '
|
||||||
|
result = 'test'
|
||||||
|
assert_equal(raw.strip, result)
|
||||||
|
|
||||||
|
raw = "test\n"
|
||||||
|
result = 'test'
|
||||||
|
assert_equal(raw.strip, result)
|
||||||
|
|
||||||
|
raw = " test \n test "
|
||||||
|
result = "test \n test"
|
||||||
|
assert_equal(raw.strip, result)
|
||||||
|
|
||||||
|
raw = " \r\n test \u{200B} \n test\u{200B} \u{200B}"
|
||||||
|
result = "test \u{200B} \n test"
|
||||||
|
assert_equal(raw.strip, result)
|
||||||
|
|
||||||
|
raw = "\xC2\xA92011 Z ".force_encoding('ASCII-8BIT')
|
||||||
|
result = "\xC2\xA92011 Z".force_encoding('ASCII-8BIT')
|
||||||
|
assert_equal(raw.strip, result)
|
||||||
|
end
|
||||||
|
|
||||||
|
test 'strip!' do
|
||||||
|
raw = ' test '
|
||||||
|
result = 'test'
|
||||||
|
raw.strip!
|
||||||
|
assert_equal(raw, result)
|
||||||
|
|
||||||
|
raw = "test\n"
|
||||||
|
result = 'test'
|
||||||
|
raw.strip!
|
||||||
|
assert_equal(raw, result)
|
||||||
|
|
||||||
|
raw = " test \n test "
|
||||||
|
result = "test \n test"
|
||||||
|
raw.strip!
|
||||||
|
assert_equal(raw, result)
|
||||||
|
|
||||||
|
raw = " \r\n test \u{200B} \n test\u{200B} \u{200B}"
|
||||||
|
result = "test \u{200B} \n test"
|
||||||
|
raw.strip!
|
||||||
|
assert_equal(raw, result)
|
||||||
|
|
||||||
|
raw = "\xC2\xA92011 Z ".force_encoding('ASCII-8BIT')
|
||||||
|
result = "\xC2\xA92011 Z".force_encoding('ASCII-8BIT')
|
||||||
|
raw.strip!
|
||||||
|
assert_equal(raw, result)
|
||||||
|
end
|
||||||
|
|
||||||
test 'to_filename ref' do
|
test 'to_filename ref' do
|
||||||
modul = 'test'
|
modul = 'test'
|
||||||
result = 'test'
|
result = 'test'
|
||||||
|
|
|
@ -62,7 +62,7 @@ class EmailSignaturDetectionTest < ActiveSupport::TestCase
|
||||||
fixture_files = {
|
fixture_files = {
|
||||||
'email_signature_detection/client_c_1.html' => { line: 8, content_type: 'text/html' },
|
'email_signature_detection/client_c_1.html' => { line: 8, content_type: 'text/html' },
|
||||||
'email_signature_detection/client_c_2.html' => { line: 29, content_type: 'text/html' },
|
'email_signature_detection/client_c_2.html' => { line: 29, content_type: 'text/html' },
|
||||||
'email_signature_detection/client_c_3.html' => { line: 9, content_type: 'text/html' },
|
'email_signature_detection/client_c_3.html' => { line: 6, content_type: 'text/html' },
|
||||||
}
|
}
|
||||||
|
|
||||||
fixture_messages = []
|
fixture_messages = []
|
||||||
|
|
|
@ -42,7 +42,25 @@ class UserTest < ActiveSupport::TestCase
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: '#3 - simple create - nil as lastname',
|
name: '#3 - simple create - no firstname',
|
||||||
|
create: {
|
||||||
|
firstname: '',
|
||||||
|
lastname: 'Firstname Lastname',
|
||||||
|
email: 'some@example.com',
|
||||||
|
login: 'some@example.com',
|
||||||
|
updated_by_id: 1,
|
||||||
|
created_by_id: 1,
|
||||||
|
},
|
||||||
|
create_verify: {
|
||||||
|
firstname: 'Firstname',
|
||||||
|
lastname: 'Lastname',
|
||||||
|
image: nil,
|
||||||
|
email: 'some@example.com',
|
||||||
|
login: 'some@example.com',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: '#4 - simple create - nil as lastname',
|
||||||
create: {
|
create: {
|
||||||
firstname: 'Firstname Lastname',
|
firstname: 'Firstname Lastname',
|
||||||
lastname: '',
|
lastname: '',
|
||||||
|
@ -60,7 +78,7 @@ class UserTest < ActiveSupport::TestCase
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: '#4 - simple create - no lastname, firstname with ","',
|
name: '#5 - simple create - no lastname, firstname with ","',
|
||||||
create: {
|
create: {
|
||||||
firstname: 'Lastname, Firstname',
|
firstname: 'Lastname, Firstname',
|
||||||
lastname: '',
|
lastname: '',
|
||||||
|
@ -77,7 +95,7 @@ class UserTest < ActiveSupport::TestCase
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: '#5 - simple create - no lastname/firstname',
|
name: '#6 - simple create - no lastname/firstname',
|
||||||
create: {
|
create: {
|
||||||
firstname: '',
|
firstname: '',
|
||||||
lastname: '',
|
lastname: '',
|
||||||
|
@ -95,7 +113,7 @@ class UserTest < ActiveSupport::TestCase
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: '#6 - simple create - no lastname/firstnam',
|
name: '#7 - simple create - no lastname/firstnam',
|
||||||
create: {
|
create: {
|
||||||
firstname: '',
|
firstname: '',
|
||||||
lastname: '',
|
lastname: '',
|
||||||
|
@ -112,7 +130,7 @@ class UserTest < ActiveSupport::TestCase
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: '#7 - simple create - nill as fristname and lastname',
|
name: '#8 - simple create - nill as fristname and lastname',
|
||||||
create: {
|
create: {
|
||||||
firstname: '',
|
firstname: '',
|
||||||
lastname: '',
|
lastname: '',
|
||||||
|
@ -129,7 +147,7 @@ class UserTest < ActiveSupport::TestCase
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: '#8 - update with avatar check',
|
name: '#9 - update with avatar check',
|
||||||
create: {
|
create: {
|
||||||
firstname: 'Bob',
|
firstname: 'Bob',
|
||||||
lastname: 'Smith',
|
lastname: 'Smith',
|
||||||
|
@ -158,7 +176,7 @@ class UserTest < ActiveSupport::TestCase
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: '#9 - update create with avatar check',
|
name: '#10 - update create with avatar check',
|
||||||
create: {
|
create: {
|
||||||
firstname: 'Bob',
|
firstname: 'Bob',
|
||||||
lastname: 'Smith',
|
lastname: 'Smith',
|
||||||
|
@ -188,7 +206,7 @@ class UserTest < ActiveSupport::TestCase
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: '#10 - update create with login/email check',
|
name: '#11 - update create with login/email check',
|
||||||
create: {
|
create: {
|
||||||
firstname: '',
|
firstname: '',
|
||||||
lastname: '',
|
lastname: '',
|
||||||
|
@ -215,7 +233,7 @@ class UserTest < ActiveSupport::TestCase
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: '#11 - update create with login/email check',
|
name: '#12 - update create with login/email check',
|
||||||
create: {
|
create: {
|
||||||
firstname: 'Firstname',
|
firstname: 'Firstname',
|
||||||
lastname: 'Lastname',
|
lastname: 'Lastname',
|
||||||
|
@ -245,12 +263,12 @@ class UserTest < ActiveSupport::TestCase
|
||||||
tests.each do |test|
|
tests.each do |test|
|
||||||
|
|
||||||
# check if user exists
|
# check if user exists
|
||||||
user = User.where(login: test[:create][:login]).first
|
user = User.find_by(login: test[:create][:login])
|
||||||
if user
|
if user
|
||||||
user.destroy!
|
user.destroy!
|
||||||
end
|
end
|
||||||
|
|
||||||
user = User.create( test[:create] )
|
user = User.create!(test[:create])
|
||||||
|
|
||||||
test[:create_verify].each do |key, value|
|
test[:create_verify].each do |key, value|
|
||||||
next if key == :image_md5
|
next if key == :image_md5
|
||||||
|
@ -259,16 +277,16 @@ class UserTest < ActiveSupport::TestCase
|
||||||
if value.nil?
|
if value.nil?
|
||||||
assert_nil(result, "create check #{key} in (#{test[:name]})")
|
assert_nil(result, "create check #{key} in (#{test[:name]})")
|
||||||
else
|
else
|
||||||
assert_equal(value, result, "create check #{key} in (#{test[:name]})")
|
assert_equal(result, value, "create check #{key} in (#{test[:name]})")
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
assert_equal(value, user[key], "create check #{key} in (#{test[:name]})")
|
assert_equal(user[key], value, "create check #{key} in (#{test[:name]})")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
if test[:create_verify][:image_md5]
|
if test[:create_verify][:image_md5]
|
||||||
file = Avatar.get_by_hash(user.image)
|
file = Avatar.get_by_hash(user.image)
|
||||||
file_md5 = Digest::MD5.hexdigest(file.content)
|
file_md5 = Digest::MD5.hexdigest(file.content)
|
||||||
assert_equal(test[:create_verify][:image_md5], file_md5, "create avatar md5 check in (#{test[:name]})")
|
assert_equal(file_md5, test[:create_verify][:image_md5], "create avatar md5 check in (#{test[:name]})")
|
||||||
end
|
end
|
||||||
if test[:update]
|
if test[:update]
|
||||||
user.update!(test[:update])
|
user.update!(test[:update])
|
||||||
|
@ -276,16 +294,16 @@ class UserTest < ActiveSupport::TestCase
|
||||||
test[:update_verify].each do |key, value|
|
test[:update_verify].each do |key, value|
|
||||||
next if key == :image_md5
|
next if key == :image_md5
|
||||||
if user.respond_to?(key)
|
if user.respond_to?(key)
|
||||||
assert_equal(value, user.send(key), "update check #{key} in (#{test[:name]})")
|
assert_equal(user.send(key), value, "update check #{key} in (#{test[:name]})")
|
||||||
else
|
else
|
||||||
assert_equal(value, user[key], "update check #{key} in (#{test[:name]})")
|
assert_equal(user[key], value, "update check #{key} in (#{test[:name]})")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
if test[:update_verify][:image_md5]
|
if test[:update_verify][:image_md5]
|
||||||
file = Avatar.get_by_hash(user.image)
|
file = Avatar.get_by_hash(user.image)
|
||||||
file_md5 = Digest::MD5.hexdigest(file.content)
|
file_md5 = Digest::MD5.hexdigest(file.content)
|
||||||
assert_equal( test[:update_verify][:image_md5], file_md5, "update avatar md5 check in (#{test[:name]})")
|
assert_equal(file_md5, test[:update_verify][:image_md5], "update avatar md5 check in (#{test[:name]})")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -293,6 +311,96 @@ class UserTest < ActiveSupport::TestCase
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
test 'strange spaces' do
|
||||||
|
name = "#{Time.zone.now.to_i}-#{rand(999_999_999_999)}"
|
||||||
|
email = "customer_email#{name}@example.com"
|
||||||
|
customer = User.create!(
|
||||||
|
firstname: 'Role',
|
||||||
|
lastname: "Customer#{name}",
|
||||||
|
email: " #{email} ",
|
||||||
|
password: 'customerpw',
|
||||||
|
active: true,
|
||||||
|
roles: Role.where(name: %w(Customer)),
|
||||||
|
updated_by_id: 1,
|
||||||
|
created_by_id: 1,
|
||||||
|
)
|
||||||
|
assert(customer)
|
||||||
|
assert_equal(email, customer.email)
|
||||||
|
customer.destroy!
|
||||||
|
|
||||||
|
name = "#{Time.zone.now.to_i}-#{rand(999_999_999_999)}"
|
||||||
|
email = "customer_email#{name}@example.com"
|
||||||
|
customer = User.create!(
|
||||||
|
firstname: "\u{00a0}\u{00a0}Role",
|
||||||
|
lastname: "Customer#{name} \u{00a0}",
|
||||||
|
email: "\u{00a0}#{email}\u{00a0}",
|
||||||
|
password: 'customerpw',
|
||||||
|
active: true,
|
||||||
|
roles: Role.where(name: %w(Customer)),
|
||||||
|
updated_by_id: 1,
|
||||||
|
created_by_id: 1,
|
||||||
|
)
|
||||||
|
assert(customer)
|
||||||
|
assert_equal('Role', customer.firstname)
|
||||||
|
assert_equal("Customer#{name}", customer.lastname)
|
||||||
|
assert_equal(email, customer.email)
|
||||||
|
customer.destroy!
|
||||||
|
|
||||||
|
name = "#{Time.zone.now.to_i}-#{rand(999_999_999_999)}"
|
||||||
|
email = "customer_email#{name}@example.com"
|
||||||
|
customer = User.create!(
|
||||||
|
firstname: "\u{200B}\u{200B}Role",
|
||||||
|
lastname: "Customer#{name} \u{200B}",
|
||||||
|
email: "\u{200B}#{email}\u{200B}",
|
||||||
|
password: 'customerpw',
|
||||||
|
active: true,
|
||||||
|
roles: Role.where(name: %w(Customer)),
|
||||||
|
updated_by_id: 1,
|
||||||
|
created_by_id: 1,
|
||||||
|
)
|
||||||
|
assert(customer)
|
||||||
|
assert_equal('Role', customer.firstname)
|
||||||
|
assert_equal("Customer#{name}", customer.lastname)
|
||||||
|
assert_equal(email, customer.email)
|
||||||
|
customer.destroy!
|
||||||
|
|
||||||
|
name = "#{Time.zone.now.to_i}-#{rand(999_999_999_999)}"
|
||||||
|
email = "customer_email#{name}@example.com"
|
||||||
|
customer = User.create!(
|
||||||
|
firstname: "\u{200B}\u{200B}Role\u{00a0}",
|
||||||
|
lastname: "\u{00a0}\u{00a0}Customer#{name} \u{200B}",
|
||||||
|
email: "\u{200B}#{email}\u{200B}",
|
||||||
|
password: 'customerpw',
|
||||||
|
active: true,
|
||||||
|
roles: Role.where(name: %w(Customer)),
|
||||||
|
updated_by_id: 1,
|
||||||
|
created_by_id: 1,
|
||||||
|
)
|
||||||
|
assert(customer)
|
||||||
|
assert_equal('Role', customer.firstname)
|
||||||
|
assert_equal("Customer#{name}", customer.lastname)
|
||||||
|
assert_equal(email, customer.email)
|
||||||
|
customer.destroy!
|
||||||
|
|
||||||
|
name = "#{Time.zone.now.to_i}-#{rand(999_999_999_999)}"
|
||||||
|
email = "customer_email#{name}@example.com"
|
||||||
|
customer = User.create!(
|
||||||
|
firstname: "\u{200a}\u{200b}\u{202F}\u{205F}Role\u{2007}\u{2008}",
|
||||||
|
lastname: "\u{00a0}\u{00a0}Customer#{name}\u{3000}\u{FEFF}\u{2000}",
|
||||||
|
email: "\u{200B}#{email}\u{200B}\u{2007}\u{2008}",
|
||||||
|
password: 'customerpw',
|
||||||
|
active: true,
|
||||||
|
roles: Role.where(name: %w(Customer)),
|
||||||
|
updated_by_id: 1,
|
||||||
|
created_by_id: 1,
|
||||||
|
)
|
||||||
|
assert(customer)
|
||||||
|
assert_equal('Role', customer.firstname)
|
||||||
|
assert_equal("Customer#{name}", customer.lastname)
|
||||||
|
assert_equal(email, customer.email)
|
||||||
|
customer.destroy!
|
||||||
|
end
|
||||||
|
|
||||||
test 'without email - but login eq email' do
|
test 'without email - but login eq email' do
|
||||||
name = rand(999_999_999)
|
name = rand(999_999_999)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue