talktome 1.2.0 → 1.3.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c02c611e3628b2f56012103e2c8ae0a5bb600ee9e11a24a7c7acf748475c9380
4
- data.tar.gz: f1dadedcddd3f434298359293ef656be2f14396c7d9dd8c597ea5db2bb7a138b
3
+ metadata.gz: 8ca8cf300ad4144fd6336f1ff56e4fc97140742869f10397ce62c9d0fecd3c03
4
+ data.tar.gz: 9d439309e79ebb3da0ea177af0606e882a643adc55e045cca5a56bb154ac6888
5
5
  SHA512:
6
- metadata.gz: 76e3843b6ec151090b9c88f26180a620d82bb737360fbb43b8f70f6f10d559401bf822f626cfde81c3edd43df253388ded9ca8761ce849c2af55262eb6e66503
7
- data.tar.gz: 5f6558c21f2eeebd114a876232be0eb2c6dfdde84d7862d105c6da2400ee55d367f1428289e572a02c64fb5e8056e4e8999a9bb28de0b2af1199c1dd5613bc73
6
+ metadata.gz: d4bd93a6e3bde5390185ebd55844a0db7b48fd81ca0c0982289d67ca15c5866f402b645191f6ba1826a7c4b5147b67937e0d7c07cd9f08788a616b2f019751c4
7
+ data.tar.gz: 9b255ab12108b8e37c024aff7bbe49b8ce85c543cc14fe62b797d64aadcbd59c2a9fe33530bdfa3e35872a7a3a553673ff064472e4fbf4cf4563377c2de4ad14
data/lib/talktome/app.rb CHANGED
@@ -13,6 +13,7 @@ module Talktome
13
13
 
14
14
  set :raise_errors, true
15
15
  set :show_exceptions, false
16
+ set :talktome, Talktome::Client::Local.new(ROOT_FOLDER/'templates')
16
17
 
17
18
  VALIDATION_SCHEMA = ::Finitio.system(<<~FIO)
18
19
  @import finitio/data
@@ -24,16 +25,14 @@ module Talktome
24
25
  }
25
26
  FIO
26
27
 
27
- TALKTOME = Talktome::Client::Local.new(ROOT_FOLDER/'templates')
28
-
29
- post %r{/([a-z-]+)/} do |action|
28
+ post %r{/([a-z-]+([\/][a-z-]+)*)/} do |action, _|
30
29
  begin
31
30
  as_array = info.map{|k,v| {'key' => k.capitalize, 'value' => v}}
32
31
  subject = Talktome.env('TALKTOME_EMAIL_SUBJECT', 'Someone wants to reach you!')
33
32
  footer = Talktome.env('TALKTOME_EMAIL_FOOTER', "Truly yours,\n
34
33
  Sent by [Enspirit.be](https://enspirit.be/), contact us if you need help with any IT task.")
35
34
  user = load_user_from_info!
36
- TALKTOME.talktome(action, user, info.merge(allvars: as_array, subject: subject, footer: footer), [:email]){|email|
35
+ settings.talktome.talktome(action, user, info.merge(allvars: as_array, subject: subject, footer: footer), [:email]){|email|
37
36
  email.reply_to = info[:reply_to] if info.has_key?(:reply_to)
38
37
  }
39
38
  [ 200, { "Content-Type" => "text/plain"}, ["Ok"] ]
@@ -1,7 +1,7 @@
1
1
  module Talktome
2
2
  module Version
3
3
  MAJOR = 1
4
- MINOR = 2
4
+ MINOR = 3
5
5
  TINY = 0
6
6
  end
7
7
  VERSION = "#{Version::MAJOR}.#{Version::MINOR}.#{Version::TINY}"
data/spec/app/test_app.rb CHANGED
@@ -9,6 +9,7 @@ module Talktome
9
9
  }
10
10
 
11
11
  before(:each) do
12
+ Talktome::App.set :talktome, Talktome::Client::Local.new(Path.dir.parent/'fixtures')
12
13
  ENV['TALKTOME_EMAIL_DEFAULT_TO'] = "to@talktome.com"
13
14
  ENV['TALKTOME_EMAIL_DEFAULT_FROM'] = "from@talktome.com"
14
15
  Mail::TestMailer.deliveries.clear
@@ -162,5 +163,24 @@ module Talktome
162
163
  end
163
164
  end
164
165
 
166
+ context 'POST /multi-lingual/en/' do
167
+
168
+ it 'works' do
169
+ post "/multi-lingual/en/", {
170
+ reply_to: 'hello@visitor.com',
171
+ message: 'Hello from visitor',
172
+ key: 'value',
173
+ }.to_json, { "CONTENT_TYPE" => "application/json" }
174
+ expect(last_response.status).to eql(200)
175
+ expect(last_response).to be_ok
176
+ expect(Mail::TestMailer.deliveries.length).to eql(1)
177
+ expect(Mail::TestMailer.deliveries.first.to).to eql(["to@talktome.com"])
178
+ expect(Mail::TestMailer.deliveries.first.from).to eql(["from@talktome.com"])
179
+ expect(Mail::TestMailer.deliveries.first.subject).to eql("Someone wants to reach you!")
180
+ expect(Mail::TestMailer.deliveries.first.html_part.body).to include("<li>Key: value</li>")
181
+ expect(Mail::TestMailer.deliveries.first.html_part.body).to include("Truly yours")
182
+ end
183
+ end
184
+
165
185
  end
166
186
  end
@@ -0,0 +1,13 @@
1
+ ---
2
+ subject: |-
3
+ {{subject}}
4
+ ---
5
+ Hello,
6
+
7
+ This person is trying to reach you:
8
+
9
+ {{#allvars}}
10
+ * {{key}}: {{value}}
11
+ {{/allvars}}
12
+
13
+ {{footer}}
@@ -0,0 +1,13 @@
1
+ ---
2
+ subject: |-
3
+ {{subject}}
4
+ ---
5
+ Hello,
6
+
7
+ This person is trying to reach you:
8
+
9
+ {{#allvars}}
10
+ * {{key}}: {{value}}
11
+ {{/allvars}}
12
+
13
+ {{footer}}
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: talktome
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.0
4
+ version: 1.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Bernard Lambeau
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-05-05 00:00:00.000000000 Z
11
+ date: 2021-05-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
@@ -191,7 +191,9 @@ files:
191
191
  - lib/talktome/version.rb
192
192
  - spec/app/test_app.rb
193
193
  - spec/client/test_local.rb
194
+ - spec/fixtures/contact-us/email.md
194
195
  - spec/fixtures/layouts/email.html
196
+ - spec/fixtures/multi-lingual/en/email.md
195
197
  - spec/fixtures/welcome/email.md
196
198
  - spec/fixtures/welcome/footer.mustache
197
199
  - spec/message/test_initialize.rb