openproject-token 5.6.0 → 6.0.0

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
  SHA256:
3
- metadata.gz: 36aeb4422e747d1b83436aa76276aa14096e3a3ca202cae90d5b3a3a8bfd4b81
4
- data.tar.gz: ab34247624cc0385b4ea80ba9b5598a734dcab4373cd1d10574b2ad08aad3e53
3
+ metadata.gz: 77fc561da569bc057220c91166f038cd49f8e645d5b9dde533aceb1c80bce8ea
4
+ data.tar.gz: c9c2a688b6bf1d1f9ab2547e8b19ce42c45e1dc7f0f7500210a99be3d767786f
5
5
  SHA512:
6
- metadata.gz: 5f1382852ff0802b7c420a189dc6b814edcbdc2477f499dbb52a2ebba56e7cdb4a5ede694cc30bd3f2888d3bddbe34a57205739fbf8869b055d162eecda4282d
7
- data.tar.gz: 3b68c01e6543e188373cb4116ad341402ba44608c09d8565ed28f1d79100d36f216146e649c21b39e3bc132de12ac28b002453d4a9b7ff796acf50399589ed33
6
+ metadata.gz: 9d992f97a309f26e11cba8cb5e85fb739f5a31d3efd5278e05c967033ca29cf400c7d8cbb49875ff952f359328c312310a6d842aed5c7526d7be27bfc5077d1e
7
+ data.tar.gz: 3d752d3adafa60f6c6af059e5b06ffa1cc0a955e72b55d77440d4e3fac443b1a72b48e0420eaa0cfb0acdec9c52eb242b41988cb437eeaf6eba7f1dc7fb979d7
@@ -2,6 +2,6 @@
2
2
 
3
3
  module OpenProject
4
4
  class Token
5
- VERSION = "5.6.0"
5
+ VERSION = "6.0.0"
6
6
  end
7
7
  end
@@ -58,7 +58,8 @@ module OpenProject
58
58
  include ActiveModel::Validations
59
59
 
60
60
  attr_reader :version, :plan
61
- attr_accessor :subscriber, :mail, :company, :domain, :starts_at, :issued_at, :expires_at, :reprieve_days, :notify_admins_at,
61
+ attr_accessor :subscriber, :mail, :company, :domain, :validate_domain,
62
+ :starts_at, :issued_at, :expires_at, :reprieve_days, :notify_admins_at,
62
63
  :notify_users_at, :block_changes_at, :restrictions, :features
63
64
 
64
65
  validates_presence_of :subscriber
@@ -74,6 +75,8 @@ module OpenProject
74
75
  record.errors.add attr, "is not a date" if !value.is_a?(Date)
75
76
  end
76
77
 
78
+ validate :expires_at_set_when_domain_opted_out
79
+
77
80
  validates_each :restrictions, allow_nil: true do |record, attr, value|
78
81
  record.errors.add attr, :invalid if !value.is_a?(Hash)
79
82
  end
@@ -154,6 +157,8 @@ module OpenProject
154
157
 
155
158
  # tokens with no version or a version lower than 2.0 don't have the attributes company or domain
156
159
  def validate_domain?
160
+ return validate_domain unless validate_domain.nil?
161
+
157
162
  version && Gem::Version.new(version) >= domain_required_from_version
158
163
  end
159
164
 
@@ -183,6 +188,7 @@ module OpenProject
183
188
  hash["mail"] = mail
184
189
  hash["company"] = company
185
190
  hash["domain"] = domain
191
+ hash["validate_domain"] = validate_domain
186
192
  hash["plan"] = plan
187
193
 
188
194
  hash["issued_at"] = issued_at
@@ -226,6 +232,7 @@ module OpenProject
226
232
  @mail = attributes["mail"]
227
233
  @company = attributes["company"]
228
234
  @domain = attributes["domain"]
235
+ @validate_domain = attributes["validate_domain"]
229
236
 
230
237
  date_attribute_keys.each do |attr|
231
238
  value = attributes[attr]
@@ -326,5 +333,13 @@ module OpenProject
326
333
  def apply_default_reprieve?(version)
327
334
  Gem::Version.new(version) < Gem::Version.new("2.2.0")
328
335
  end
336
+
337
+ # We want to ensure an expires_at is set
338
+ # when there is no domain present
339
+ def expires_at_set_when_domain_opted_out
340
+ if validate_domain == false && expires_at.nil?
341
+ errors.add(:expires_at, "must be present when domain is opted out")
342
+ end
343
+ end
329
344
  end
330
345
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: openproject-token
3
3
  version: !ruby/object:Gem::Version
4
- version: 5.6.0
4
+ version: 6.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - OpenProject GmbH