chore: Auto capitalize the name field while sending the canned response/variables (#6758)
* capitalize name before sending the message * Fix specs * Code cleanups
This commit is contained in:
@@ -10,6 +10,11 @@ describe ::ContactDrop do
|
||||
contact.update!(name: 'John Doe')
|
||||
expect(subject.first_name).to eq 'John'
|
||||
end
|
||||
|
||||
it('return the capitalized name') do
|
||||
contact.update!(name: 'john doe')
|
||||
expect(subject.name).to eq 'John doe'
|
||||
end
|
||||
end
|
||||
|
||||
context 'when last name' do
|
||||
|
||||
@@ -12,6 +12,11 @@ describe ::UserDrop do
|
||||
end
|
||||
end
|
||||
|
||||
it('return the capitalized name') do
|
||||
user.update!(name: 'peter')
|
||||
expect(subject.name).to eq 'Peter'
|
||||
end
|
||||
|
||||
context 'when last name' do
|
||||
it 'returns the last name' do
|
||||
user.update!(name: 'John Doe')
|
||||
|
||||
@@ -21,7 +21,7 @@ shared_examples_for 'liqudable' do
|
||||
it 'set replaces liquid variables in message' do
|
||||
message.content = 'hey {{contact.name}} how are you?'
|
||||
message.save!
|
||||
expect(message.content).to eq 'hey john how are you?'
|
||||
expect(message.content).to eq 'hey John how are you?'
|
||||
end
|
||||
|
||||
it 'process liquid operators like default value' do
|
||||
@@ -45,19 +45,19 @@ shared_examples_for 'liqudable' do
|
||||
it 'will not process liquid tags in multiple code blocks' do
|
||||
message.content = 'hey {{contact.name}} how are you? ```code: {{contact.name}}``` ``` code: {{contact.name}} ``` test `{{contact.name}}`'
|
||||
message.save!
|
||||
expect(message.content).to eq 'hey john how are you? ```code: {{contact.name}}``` ``` code: {{contact.name}} ``` test `{{contact.name}}`'
|
||||
expect(message.content).to eq 'hey John how are you? ```code: {{contact.name}}``` ``` code: {{contact.name}} ``` test `{{contact.name}}`'
|
||||
end
|
||||
|
||||
it 'will not process liquid tags in single ticks' do
|
||||
message.content = 'hey {{contact.name}} how are you? ` code: {{contact.name}} ` ` code: {{contact.name}} ` test'
|
||||
message.save!
|
||||
expect(message.content).to eq 'hey john how are you? ` code: {{contact.name}} ` ` code: {{contact.name}} ` test'
|
||||
expect(message.content).to eq 'hey John how are you? ` code: {{contact.name}} ` ` code: {{contact.name}} ` test'
|
||||
end
|
||||
|
||||
it 'will not throw error for broken quotes' do
|
||||
message.content = 'hey {{contact.name}} how are you? ` code: {{contact.name}} ` ` code: {{contact.name}} test'
|
||||
message.save!
|
||||
expect(message.content).to eq 'hey john how are you? ` code: {{contact.name}} ` ` code: john test'
|
||||
expect(message.content).to eq 'hey John how are you? ` code: {{contact.name}} ` ` code: John test'
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user