openproject-token 6.0.0 → 7.1.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: 77fc561da569bc057220c91166f038cd49f8e645d5b9dde533aceb1c80bce8ea
4
- data.tar.gz: c9c2a688b6bf1d1f9ab2547e8b19ce42c45e1dc7f0f7500210a99be3d767786f
3
+ metadata.gz: 63665d957815aafd0308a5628591c5ac6cd840c9f12e6464a20dfd76f27dd259
4
+ data.tar.gz: b53da714e6cdbfcd18dae002131654ab2e796e2e7d81714b9b167525a9da108c
5
5
  SHA512:
6
- metadata.gz: 9d992f97a309f26e11cba8cb5e85fb739f5a31d3efd5278e05c967033ca29cf400c7d8cbb49875ff952f359328c312310a6d842aed5c7526d7be27bfc5077d1e
7
- data.tar.gz: 3d752d3adafa60f6c6af059e5b06ffa1cc0a955e72b55d77440d4e3fac443b1a72b48e0420eaa0cfb0acdec9c52eb242b41988cb437eeaf6eba7f1dc7fb979d7
6
+ metadata.gz: d80260f9e40dfac79c368f4efebe814dc225d47a6605a163d34b2a02072ecfac769f77e76587fcd5f67a673ed669e360b3dc8fa213e02b0f71cf0c199bcd0348
7
+ data.tar.gz: 4f92593ff133135690a016f6b80e1103f23a72b514d02cc27890eb2f5a66d9fb4496b861830758254601f3f86a02704ee8354c9396d70854615d83e518fa22e9
@@ -2,6 +2,6 @@
2
2
 
3
3
  module OpenProject
4
4
  class Token
5
- VERSION = "6.0.0"
5
+ VERSION = "7.1.0"
6
6
  end
7
7
  end
@@ -60,7 +60,7 @@ module OpenProject
60
60
  attr_reader :version, :plan
61
61
  attr_accessor :subscriber, :mail, :company, :domain, :validate_domain,
62
62
  :starts_at, :issued_at, :expires_at, :reprieve_days, :notify_admins_at,
63
- :notify_users_at, :block_changes_at, :restrictions, :features
63
+ :notify_users_at, :block_changes_at, :trial, :restrictions, :features
64
64
 
65
65
  validates_presence_of :subscriber
66
66
  validates_presence_of :mail
@@ -76,6 +76,7 @@ module OpenProject
76
76
  end
77
77
 
78
78
  validate :expires_at_set_when_domain_opted_out
79
+ validate :expires_at_set_when_trial
79
80
 
80
81
  validates_each :restrictions, allow_nil: true do |record, attr, value|
81
82
  record.errors.add attr, :invalid if !value.is_a?(Hash)
@@ -101,6 +102,10 @@ module OpenProject
101
102
  block_changes_at
102
103
  end
103
104
 
105
+ def trial?
106
+ trial
107
+ end
108
+
104
109
  def has_feature?(name)
105
110
  available_features.include?(name.to_sym)
106
111
  end
@@ -196,6 +201,8 @@ module OpenProject
196
201
  hash["expires_at"] = expires_at if will_expire?
197
202
  hash["reprieve_days"] = reprieve_days if will_expire?
198
203
 
204
+ hash["trial"] = trial
205
+
199
206
  hash["notify_admins_at"] = notify_admins_at if will_notify_admins?
200
207
  hash["notify_users_at"] = notify_users_at if will_notify_users?
201
208
  hash["block_changes_at"] = block_changes_at if will_block_changes?
@@ -272,6 +279,8 @@ module OpenProject
272
279
  end
273
280
 
274
281
  @plan = attributes["plan"].presence&.to_sym || OpenProject::Token::DEFAULT_PLAN
282
+
283
+ @trial = !!attributes["trial"]
275
284
  end
276
285
 
277
286
  ##
@@ -292,19 +301,12 @@ module OpenProject
292
301
  # @param attr [Hash] Parsed token attributes.
293
302
  def read_version(attr)
294
303
  value = attr.include?("version") ? attr["version"] : current_gem_version.to_s
295
- version = nil
296
304
 
297
305
  if value.to_s == "1"
298
- version = 1
306
+ 1
299
307
  elsif value.present? && value.to_s != "-1"
300
- version = Gem::Version.new value
301
-
302
- if version > current_gem_version
303
- raise ArgumentError, "Version is too new"
304
- end
308
+ Gem::Version.new value
305
309
  end
306
-
307
- version
308
310
  end
309
311
 
310
312
  def read_domain!(input)
@@ -341,5 +343,12 @@ module OpenProject
341
343
  errors.add(:expires_at, "must be present when domain is opted out")
342
344
  end
343
345
  end
346
+
347
+ # We want to ensure an expires_at is set when the token is a trial token
348
+ def expires_at_set_when_trial
349
+ if trial? && expires_at.nil?
350
+ errors.add(:expires_at, "must be present for a trial")
351
+ end
352
+ end
344
353
  end
345
354
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: openproject-token
3
3
  version: !ruby/object:Gem::Version
4
- version: 6.0.0
4
+ version: 7.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - OpenProject GmbH
8
8
  bindir: bin
9
9
  cert_chain: []
10
- date: 2025-05-07 00:00:00.000000000 Z
10
+ date: 2025-06-10 00:00:00.000000000 Z
11
11
  dependencies:
12
12
  - !ruby/object:Gem::Dependency
13
13
  name: activemodel