dorsale 3.10.0 → 3.10.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 99dec4abf499000f2dd5056f0ad64e158982020b
4
- data.tar.gz: 8880c252a553956e6d24ac1723c20a9d46108a36
3
+ metadata.gz: 6559b13a1111e750335152391d9ad213511c9ff0
4
+ data.tar.gz: dff3aeadb39a076fdbde226fab8be96655a36a9b
5
5
  SHA512:
6
- metadata.gz: 98a8ede0dc3303cf86f0f275a153df7d4cc0fd4409dfd0faee7baf3101cb5c03c0a6bd6d0bc72e64fbec1bc3f12bd012c5c3b989935f3964e59818c0d682fb04
7
- data.tar.gz: 29e5a4f979b8fa53a478f65a6092ac5fd5c74bb6a92618d74f4a97e6d8fabe1264e468de69cae688555ea4195287809b9852947b08772e9633ebc71f0e3b238a
6
+ metadata.gz: 2d68ee55bcee6d19c132bab307068d404c01c8e297332d806b8c58bae0bc529c6ea3c8f93f406b15aadf2d2a253e0d506a18543cae11566f4b9c8f7e3f748576
7
+ data.tar.gz: 10287be7d16627f1a5f74cd8821dcd23e14e97f46ed6c50ff3d74355dbc0858501fe6ef13891f15657beaba7132f809f5d3ebbc9470b9ffed4dd813801094b0c
@@ -2,6 +2,10 @@
2
2
 
3
3
  ## Next version
4
4
 
5
+ ## 3.10.1
6
+
7
+ - Email fixes and improvements
8
+
5
9
  ## 3.10.0
6
10
 
7
11
  - Billing Machine : fix amounts round
@@ -13,7 +13,9 @@ class Dorsale::BillingMachine::Email < Dorsale::Email
13
13
  end
14
14
 
15
15
  def default_to
16
- "#{document.customer} <#{document.customer.email}>" if document.customer
16
+ return if document.customer&.email.blank?
17
+
18
+ "#{document.customer} <#{document.customer.email}>"
17
19
  end
18
20
 
19
21
  def default_subject
@@ -1,3 +1,5 @@
1
+ require "mail"
2
+
1
3
  class Dorsale::Email
2
4
  include ActiveModel::Model
3
5
  include Agilibox::ModelToS
@@ -7,6 +9,8 @@ class Dorsale::Email
7
9
  validates :subject, presence: true
8
10
  validates :body, presence: true
9
11
 
12
+ validate :validate_to_and_cc_format
13
+
10
14
  attr_accessor(
11
15
  :current_user,
12
16
  :from,
@@ -77,4 +81,17 @@ class Dorsale::Email
77
81
  def default_attachments
78
82
  {}
79
83
  end
84
+
85
+ def validate_to_and_cc_format
86
+ validate_addrs_format(:to)
87
+ validate_addrs_format(:cc)
88
+ end
89
+
90
+ def validate_addrs_format(attr)
91
+ string = public_send(attr).to_s
92
+ return if string.blank?
93
+ addrs = Mail.new(to: string).to_addrs
94
+ return true if addrs.any? && addrs.all? { |addr| URI::MailTo::EMAIL_REGEXP.match?(addr) }
95
+ errors.add(attr, :invalid)
96
+ end
80
97
  end
@@ -46,7 +46,7 @@ fr:
46
46
  dorsale/email:
47
47
  from: "Expéditeur"
48
48
  to: "Destinataire"
49
- cc: "Copie cachée"
49
+ cc: "Copie"
50
50
  subject: "Objet"
51
51
  body: "Message"
52
52
  attachments: "Pièces jointes"
@@ -1,3 +1,3 @@
1
1
  module Dorsale
2
- VERSION = "3.10.0"
2
+ VERSION = "3.10.1"
3
3
  end
@@ -0,0 +1,39 @@
1
+ require "rails_helper"
2
+
3
+ describe Dorsale::Email do
4
+ describe "validations" do
5
+ it "should validate :to format" do
6
+ email = described_class.new
7
+
8
+ expect(email).to allow_value("user@example.org").for(:to)
9
+ expect(email).to allow_value("user1@example.org,user2@example.org").for(:to)
10
+ expect(email).to allow_value("user1@example.org;user2@example.org").for(:to)
11
+ expect(email).to allow_value("User <user@example.com>").for(:to)
12
+ expect(email).to allow_value("<user@example.com>").for(:to)
13
+ expect(email).to allow_value("User <user@example.com>;user2@example.org").for(:to)
14
+
15
+ expect(email).to_not allow_value("user").for(:to)
16
+ expect(email).to_not allow_value("user@example.com>").for(:to)
17
+ expect(email).to_not allow_value("<user@example.com").for(:to)
18
+ expect(email).to_not allow_value("valid@example.com;invalid").for(:to)
19
+ end
20
+
21
+ it "should validate :cc format" do
22
+ email = described_class.new
23
+
24
+ expect(email).to allow_value("").for(:cc)
25
+
26
+ expect(email).to allow_value("user@example.org").for(:cc)
27
+ expect(email).to allow_value("user1@example.org,user2@example.org").for(:cc)
28
+ expect(email).to allow_value("user1@example.org;user2@example.org").for(:cc)
29
+ expect(email).to allow_value("User <user@example.com>").for(:cc)
30
+ expect(email).to allow_value("<user@example.com>").for(:cc)
31
+ expect(email).to allow_value("User <user@example.com>;user2@example.org").for(:cc)
32
+
33
+ expect(email).to_not allow_value("user").for(:cc)
34
+ expect(email).to_not allow_value("user@example.com>").for(:cc)
35
+ expect(email).to_not allow_value("<user@example.com").for(:cc)
36
+ expect(email).to_not allow_value("valid@example.com;invalid").for(:to)
37
+ end
38
+ end # describe "validations" do
39
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dorsale
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.10.0
4
+ version: 3.10.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - agilidée
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-08-07 00:00:00.000000000 Z
11
+ date: 2018-09-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -971,6 +971,7 @@ files:
971
971
  - spec/models/dorsale/customer_vault/link_spec.rb
972
972
  - spec/models/dorsale/customer_vault/origin_spec.rb
973
973
  - spec/models/dorsale/customer_vault/person_spec.rb
974
+ - spec/models/dorsale/email_spec.rb
974
975
  - spec/models/dorsale/expense_gun/category_spec.rb
975
976
  - spec/models/dorsale/expense_gun/expense_line_spec.rb
976
977
  - spec/models/dorsale/expense_gun/expense_spec.rb
@@ -1037,6 +1038,7 @@ test_files:
1037
1038
  - spec/models/dorsale/expense_gun/expense_spec.rb
1038
1039
  - spec/models/dorsale/expense_gun/expense_line_spec.rb
1039
1040
  - spec/models/dorsale/expense_gun/category_spec.rb
1041
+ - spec/models/dorsale/email_spec.rb
1040
1042
  - spec/models/dorsale/customer_vault/person_spec.rb
1041
1043
  - spec/models/dorsale/customer_vault/individual_spec.rb
1042
1044
  - spec/models/dorsale/customer_vault/activity_type_spec.rb