timely 0.8.0 → 0.11.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 +4 -4
- data/CHANGELOG.md +12 -0
- data/README.md +13 -2
- data/lib/timely/rails/calendar_tag.rb +3 -1
- data/lib/timely/version.rb +1 -1
- data/timely.gemspec +6 -10
- metadata +22 -115
- data/.gitignore +0 -6
- data/.rspec +0 -2
- data/.rubocop.yml +0 -28
- data/.ruby-version +0 -1
- data/.travis.yml +0 -17
- data/Gemfile +0 -4
- data/LICENSE +0 -21
- data/Rakefile +0 -14
- data/gemfiles/rails5.gemfile +0 -8
- data/gemfiles/rails6.gemfile +0 -8
- data/rails/init.rb +0 -3
- data/spec/calendar_tag_spec.rb +0 -30
- data/spec/date_chooser_spec.rb +0 -115
- data/spec/date_group_spec.rb +0 -124
- data/spec/date_range_spec.rb +0 -89
- data/spec/date_spec.rb +0 -78
- data/spec/extensions_spec.rb +0 -28
- data/spec/rails/date_spec.rb +0 -18
- data/spec/rails/date_time_spec.rb +0 -28
- data/spec/rails/period_spec.rb +0 -19
- data/spec/rails/time_spec.rb +0 -73
- data/spec/schema.rb +0 -17
- data/spec/season_spec.rb +0 -62
- data/spec/spec_helper.rb +0 -46
- data/spec/support/coverage_loader.rb +0 -6
- data/spec/temporal_patterns_spec.rb +0 -28
- data/spec/time_since_spec.rb +0 -26
- data/spec/time_spec.rb +0 -70
- data/spec/trackable_date_set_spec.rb +0 -82
- data/spec/week_days_spec.rb +0 -76
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 4467e2ff404ef68bb2dcb40195a70018b558a5c74026b793a013da161175dd21
|
|
4
|
+
data.tar.gz: 4fe035551c4f8674f53d73f2381c044dbcbe80b1ae871bbcc93ddcc63f432441
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 20463685e09eb233b0d50ddbf481b203b00fab4d5e1824a61e9a4d119bcbc8ff0f59e8d0a62cf7d32caba758f66ed438792e6c59aa2d76d19210169186f7d424
|
|
7
|
+
data.tar.gz: 58a1531ed015969171807ee0f20faaabe12a40dbaee521dd4b9f86d8cf7df7f4b289da16f304860856588cb6b96e99a9c2e40bda5c63d6c93e1ad5376bf3de69
|
data/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.11.0
|
|
4
|
+
|
|
5
|
+
* [PLAT-346] Handle `to_s` deprecation on Rails 7
|
|
6
|
+
|
|
7
|
+
## 0.10.0
|
|
8
|
+
|
|
9
|
+
* [PLAT-183] Publish coveralls with github actions add ruby 3.1 to test matrix
|
|
10
|
+
|
|
11
|
+
## 0.9.0
|
|
12
|
+
|
|
13
|
+
* [TT-8614] Update to build with github actions / ruby 3.0 / rails 6.1
|
|
14
|
+
|
|
3
15
|
## 0.8.0
|
|
4
16
|
|
|
5
17
|
* [TT-6441] Turns out we don't actually need time difference in QT
|
data/README.md
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
# Timely
|
|
2
2
|
|
|
3
|
-
[](https://github.com/sealink/timely/actions)
|
|
4
4
|
[](https://coveralls.io/r/sealink/timely)
|
|
5
|
-
[](https://gemnasium.com/sealink/timely)
|
|
6
5
|
[](https://codeclimate.com/github/sealink/timely)
|
|
7
6
|
|
|
8
7
|
# DESCRIPTION
|
|
@@ -59,3 +58,15 @@ some_date.at_time(some_time) # => Sat May 03 13:40:22 -0500 2008
|
|
|
59
58
|
some_time.on(some_date) # => Sat May 03 13:40:22 -0500 2008
|
|
60
59
|
some_date.at(some_time) # => Sat May 03 13:40:22 -0500 2008
|
|
61
60
|
```
|
|
61
|
+
|
|
62
|
+
# Release
|
|
63
|
+
|
|
64
|
+
To publish a new version of this gem the following steps must be taken.
|
|
65
|
+
|
|
66
|
+
* Update the version in the following files
|
|
67
|
+
```
|
|
68
|
+
CHANGELOG.md
|
|
69
|
+
lib/timely/version.rb
|
|
70
|
+
````
|
|
71
|
+
* Create a tag using the format v0.1.0
|
|
72
|
+
* Follow build progress in GitHub actions
|
|
@@ -11,7 +11,9 @@ module Timely
|
|
|
11
11
|
def calendar_tag(name, value = Timely.current_date, *args)
|
|
12
12
|
options = args.extract_options!
|
|
13
13
|
|
|
14
|
-
|
|
14
|
+
if value.respond_to?(:day)
|
|
15
|
+
value = value.respond_to?(:to_fs) ? value.to_fs(:calendar) : value.to_s(:calendar)
|
|
16
|
+
end
|
|
15
17
|
|
|
16
18
|
name = name.to_s if name.is_a?(Symbol)
|
|
17
19
|
|
data/lib/timely/version.rb
CHANGED
data/timely.gemspec
CHANGED
|
@@ -15,26 +15,22 @@ Gem::Specification.new do |spec|
|
|
|
15
15
|
|
|
16
16
|
spec.license = 'MIT'
|
|
17
17
|
|
|
18
|
-
spec.files
|
|
19
|
-
spec.executables =
|
|
20
|
-
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
|
18
|
+
spec.files = Dir["CHANGELOG.md", "README.md", "timely.gemspec", "lib/**/*"]
|
|
19
|
+
spec.executables = []
|
|
21
20
|
spec.require_paths = ['lib']
|
|
21
|
+
spec.required_ruby_version = '>= 2.7'
|
|
22
22
|
|
|
23
|
-
spec.add_development_dependency '
|
|
24
|
-
spec.add_development_dependency '
|
|
25
|
-
spec.add_development_dependency '
|
|
26
|
-
spec.add_development_dependency 'bundler', '~> 2.1.0'
|
|
23
|
+
spec.add_development_dependency 'activerecord', '>=6', '<8'
|
|
24
|
+
spec.add_development_dependency 'activesupport', '>=6', '<8'
|
|
25
|
+
spec.add_development_dependency 'bundler'
|
|
27
26
|
spec.add_development_dependency 'coverage-kit'
|
|
28
|
-
spec.add_development_dependency 'coveralls'
|
|
29
27
|
spec.add_development_dependency 'rake'
|
|
30
28
|
spec.add_development_dependency 'rspec'
|
|
31
29
|
spec.add_development_dependency 'rspec-its'
|
|
32
30
|
spec.add_development_dependency 'database_cleaner'
|
|
33
31
|
spec.add_development_dependency 'rubocop'
|
|
34
32
|
spec.add_development_dependency 'rubocop-rails'
|
|
35
|
-
spec.add_development_dependency 'simplecov-rcov'
|
|
36
33
|
spec.add_development_dependency 'sqlite3'
|
|
37
34
|
spec.add_development_dependency 'timecop'
|
|
38
|
-
spec.add_development_dependency 'travis'
|
|
39
35
|
spec.add_development_dependency 'pry'
|
|
40
36
|
end
|
metadata
CHANGED
|
@@ -1,73 +1,57 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: timely
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.11.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Michael Noack
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date:
|
|
11
|
+
date: 2022-04-26 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
|
-
- !ruby/object:Gem::Dependency
|
|
14
|
-
name: actionpack
|
|
15
|
-
requirement: !ruby/object:Gem::Requirement
|
|
16
|
-
requirements:
|
|
17
|
-
- - ">="
|
|
18
|
-
- !ruby/object:Gem::Version
|
|
19
|
-
version: '0'
|
|
20
|
-
type: :development
|
|
21
|
-
prerelease: false
|
|
22
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
23
|
-
requirements:
|
|
24
|
-
- - ">="
|
|
25
|
-
- !ruby/object:Gem::Version
|
|
26
|
-
version: '0'
|
|
27
13
|
- !ruby/object:Gem::Dependency
|
|
28
14
|
name: activerecord
|
|
29
15
|
requirement: !ruby/object:Gem::Requirement
|
|
30
16
|
requirements:
|
|
31
17
|
- - ">="
|
|
32
18
|
- !ruby/object:Gem::Version
|
|
33
|
-
version: '
|
|
19
|
+
version: '6'
|
|
20
|
+
- - "<"
|
|
21
|
+
- !ruby/object:Gem::Version
|
|
22
|
+
version: '8'
|
|
34
23
|
type: :development
|
|
35
24
|
prerelease: false
|
|
36
25
|
version_requirements: !ruby/object:Gem::Requirement
|
|
37
26
|
requirements:
|
|
38
27
|
- - ">="
|
|
39
28
|
- !ruby/object:Gem::Version
|
|
40
|
-
version: '
|
|
29
|
+
version: '6'
|
|
30
|
+
- - "<"
|
|
31
|
+
- !ruby/object:Gem::Version
|
|
32
|
+
version: '8'
|
|
41
33
|
- !ruby/object:Gem::Dependency
|
|
42
34
|
name: activesupport
|
|
43
35
|
requirement: !ruby/object:Gem::Requirement
|
|
44
36
|
requirements:
|
|
45
37
|
- - ">="
|
|
46
38
|
- !ruby/object:Gem::Version
|
|
47
|
-
version: '
|
|
39
|
+
version: '6'
|
|
40
|
+
- - "<"
|
|
41
|
+
- !ruby/object:Gem::Version
|
|
42
|
+
version: '8'
|
|
48
43
|
type: :development
|
|
49
44
|
prerelease: false
|
|
50
45
|
version_requirements: !ruby/object:Gem::Requirement
|
|
51
46
|
requirements:
|
|
52
47
|
- - ">="
|
|
53
48
|
- !ruby/object:Gem::Version
|
|
54
|
-
version: '
|
|
55
|
-
-
|
|
56
|
-
name: bundler
|
|
57
|
-
requirement: !ruby/object:Gem::Requirement
|
|
58
|
-
requirements:
|
|
59
|
-
- - "~>"
|
|
49
|
+
version: '6'
|
|
50
|
+
- - "<"
|
|
60
51
|
- !ruby/object:Gem::Version
|
|
61
|
-
version:
|
|
62
|
-
type: :development
|
|
63
|
-
prerelease: false
|
|
64
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
65
|
-
requirements:
|
|
66
|
-
- - "~>"
|
|
67
|
-
- !ruby/object:Gem::Version
|
|
68
|
-
version: 2.1.0
|
|
52
|
+
version: '8'
|
|
69
53
|
- !ruby/object:Gem::Dependency
|
|
70
|
-
name:
|
|
54
|
+
name: bundler
|
|
71
55
|
requirement: !ruby/object:Gem::Requirement
|
|
72
56
|
requirements:
|
|
73
57
|
- - ">="
|
|
@@ -81,7 +65,7 @@ dependencies:
|
|
|
81
65
|
- !ruby/object:Gem::Version
|
|
82
66
|
version: '0'
|
|
83
67
|
- !ruby/object:Gem::Dependency
|
|
84
|
-
name:
|
|
68
|
+
name: coverage-kit
|
|
85
69
|
requirement: !ruby/object:Gem::Requirement
|
|
86
70
|
requirements:
|
|
87
71
|
- - ">="
|
|
@@ -178,20 +162,6 @@ dependencies:
|
|
|
178
162
|
- - ">="
|
|
179
163
|
- !ruby/object:Gem::Version
|
|
180
164
|
version: '0'
|
|
181
|
-
- !ruby/object:Gem::Dependency
|
|
182
|
-
name: simplecov-rcov
|
|
183
|
-
requirement: !ruby/object:Gem::Requirement
|
|
184
|
-
requirements:
|
|
185
|
-
- - ">="
|
|
186
|
-
- !ruby/object:Gem::Version
|
|
187
|
-
version: '0'
|
|
188
|
-
type: :development
|
|
189
|
-
prerelease: false
|
|
190
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
191
|
-
requirements:
|
|
192
|
-
- - ">="
|
|
193
|
-
- !ruby/object:Gem::Version
|
|
194
|
-
version: '0'
|
|
195
165
|
- !ruby/object:Gem::Dependency
|
|
196
166
|
name: sqlite3
|
|
197
167
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -220,20 +190,6 @@ dependencies:
|
|
|
220
190
|
- - ">="
|
|
221
191
|
- !ruby/object:Gem::Version
|
|
222
192
|
version: '0'
|
|
223
|
-
- !ruby/object:Gem::Dependency
|
|
224
|
-
name: travis
|
|
225
|
-
requirement: !ruby/object:Gem::Requirement
|
|
226
|
-
requirements:
|
|
227
|
-
- - ">="
|
|
228
|
-
- !ruby/object:Gem::Version
|
|
229
|
-
version: '0'
|
|
230
|
-
type: :development
|
|
231
|
-
prerelease: false
|
|
232
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
233
|
-
requirements:
|
|
234
|
-
- - ">="
|
|
235
|
-
- !ruby/object:Gem::Version
|
|
236
|
-
version: '0'
|
|
237
193
|
- !ruby/object:Gem::Dependency
|
|
238
194
|
name: pry
|
|
239
195
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -255,18 +211,8 @@ executables: []
|
|
|
255
211
|
extensions: []
|
|
256
212
|
extra_rdoc_files: []
|
|
257
213
|
files:
|
|
258
|
-
- ".gitignore"
|
|
259
|
-
- ".rspec"
|
|
260
|
-
- ".rubocop.yml"
|
|
261
|
-
- ".ruby-version"
|
|
262
|
-
- ".travis.yml"
|
|
263
214
|
- CHANGELOG.md
|
|
264
|
-
- Gemfile
|
|
265
|
-
- LICENSE
|
|
266
215
|
- README.md
|
|
267
|
-
- Rakefile
|
|
268
|
-
- gemfiles/rails5.gemfile
|
|
269
|
-
- gemfiles/rails6.gemfile
|
|
270
216
|
- lib/timely.rb
|
|
271
217
|
- lib/timely/date.rb
|
|
272
218
|
- lib/timely/date_chooser.rb
|
|
@@ -294,26 +240,6 @@ files:
|
|
|
294
240
|
- lib/timely/trackable_date_set.rb
|
|
295
241
|
- lib/timely/version.rb
|
|
296
242
|
- lib/timely/week_days.rb
|
|
297
|
-
- rails/init.rb
|
|
298
|
-
- spec/calendar_tag_spec.rb
|
|
299
|
-
- spec/date_chooser_spec.rb
|
|
300
|
-
- spec/date_group_spec.rb
|
|
301
|
-
- spec/date_range_spec.rb
|
|
302
|
-
- spec/date_spec.rb
|
|
303
|
-
- spec/extensions_spec.rb
|
|
304
|
-
- spec/rails/date_spec.rb
|
|
305
|
-
- spec/rails/date_time_spec.rb
|
|
306
|
-
- spec/rails/period_spec.rb
|
|
307
|
-
- spec/rails/time_spec.rb
|
|
308
|
-
- spec/schema.rb
|
|
309
|
-
- spec/season_spec.rb
|
|
310
|
-
- spec/spec_helper.rb
|
|
311
|
-
- spec/support/coverage_loader.rb
|
|
312
|
-
- spec/temporal_patterns_spec.rb
|
|
313
|
-
- spec/time_since_spec.rb
|
|
314
|
-
- spec/time_spec.rb
|
|
315
|
-
- spec/trackable_date_set_spec.rb
|
|
316
|
-
- spec/week_days_spec.rb
|
|
317
243
|
- timely.gemspec
|
|
318
244
|
homepage: http://github.com/sealink/timely
|
|
319
245
|
licenses:
|
|
@@ -327,34 +253,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
327
253
|
requirements:
|
|
328
254
|
- - ">="
|
|
329
255
|
- !ruby/object:Gem::Version
|
|
330
|
-
version: '
|
|
256
|
+
version: '2.7'
|
|
331
257
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
332
258
|
requirements:
|
|
333
259
|
- - ">="
|
|
334
260
|
- !ruby/object:Gem::Version
|
|
335
261
|
version: '0'
|
|
336
262
|
requirements: []
|
|
337
|
-
rubygems_version: 3.
|
|
263
|
+
rubygems_version: 3.3.3
|
|
338
264
|
signing_key:
|
|
339
265
|
specification_version: 4
|
|
340
266
|
summary: Set of time, date, weekday related methods.
|
|
341
|
-
test_files:
|
|
342
|
-
- spec/calendar_tag_spec.rb
|
|
343
|
-
- spec/date_chooser_spec.rb
|
|
344
|
-
- spec/date_group_spec.rb
|
|
345
|
-
- spec/date_range_spec.rb
|
|
346
|
-
- spec/date_spec.rb
|
|
347
|
-
- spec/extensions_spec.rb
|
|
348
|
-
- spec/rails/date_spec.rb
|
|
349
|
-
- spec/rails/date_time_spec.rb
|
|
350
|
-
- spec/rails/period_spec.rb
|
|
351
|
-
- spec/rails/time_spec.rb
|
|
352
|
-
- spec/schema.rb
|
|
353
|
-
- spec/season_spec.rb
|
|
354
|
-
- spec/spec_helper.rb
|
|
355
|
-
- spec/support/coverage_loader.rb
|
|
356
|
-
- spec/temporal_patterns_spec.rb
|
|
357
|
-
- spec/time_since_spec.rb
|
|
358
|
-
- spec/time_spec.rb
|
|
359
|
-
- spec/trackable_date_set_spec.rb
|
|
360
|
-
- spec/week_days_spec.rb
|
|
267
|
+
test_files: []
|
data/.gitignore
DELETED
data/.rspec
DELETED
data/.rubocop.yml
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
AllCops:
|
|
2
|
-
TargetRubyVersion: 2.6
|
|
3
|
-
Exclude:
|
|
4
|
-
- lib/timely/temporal_patterns/*.rb
|
|
5
|
-
|
|
6
|
-
Metrics/LineLength:
|
|
7
|
-
Max: 200
|
|
8
|
-
|
|
9
|
-
Style/Documentation:
|
|
10
|
-
Enabled: false
|
|
11
|
-
|
|
12
|
-
Style/FrozenStringLiteralComment:
|
|
13
|
-
Enabled: true
|
|
14
|
-
|
|
15
|
-
Metrics/BlockLength:
|
|
16
|
-
Enabled: false
|
|
17
|
-
|
|
18
|
-
Metrics/MethodLength:
|
|
19
|
-
Enabled: false
|
|
20
|
-
|
|
21
|
-
Metrics/AbcSize:
|
|
22
|
-
Enabled: false
|
|
23
|
-
|
|
24
|
-
Metrics/CyclomaticComplexity:
|
|
25
|
-
Enabled: false
|
|
26
|
-
|
|
27
|
-
Metrics/PerceivedComplexity:
|
|
28
|
-
Enabled: false
|
data/.ruby-version
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
2.6.3
|
data/.travis.yml
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
language: ruby
|
|
2
|
-
rvm:
|
|
3
|
-
- 2.6
|
|
4
|
-
- 2.7
|
|
5
|
-
matrix:
|
|
6
|
-
fast_finish: true
|
|
7
|
-
before_install:
|
|
8
|
-
- gem install bundler
|
|
9
|
-
script: bundle exec rake spec
|
|
10
|
-
gemfile:
|
|
11
|
-
- gemfiles/rails5.gemfile
|
|
12
|
-
- gemfiles/rails6.gemfile
|
|
13
|
-
notifications:
|
|
14
|
-
email:
|
|
15
|
-
- support@travellink.com.au
|
|
16
|
-
sudo: false
|
|
17
|
-
cache: bundler
|
data/Gemfile
DELETED
data/LICENSE
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
The MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) Tom Preston-Werner
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in
|
|
13
|
-
all copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
21
|
-
THE SOFTWARE.
|
data/Rakefile
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
require 'bundler/gem_tasks'
|
|
4
|
-
|
|
5
|
-
desc 'Default: run specs.'
|
|
6
|
-
task default: :spec
|
|
7
|
-
|
|
8
|
-
require 'rspec/core/rake_task'
|
|
9
|
-
|
|
10
|
-
desc 'Run specs'
|
|
11
|
-
RSpec::Core::RakeTask.new do |t|
|
|
12
|
-
t.pattern = './spec/**/*_spec.rb' # don't need this, it's default.
|
|
13
|
-
# Put spec opts in a file named .rspec in root
|
|
14
|
-
end
|
data/gemfiles/rails5.gemfile
DELETED
data/gemfiles/rails6.gemfile
DELETED
data/rails/init.rb
DELETED
data/spec/calendar_tag_spec.rb
DELETED
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
require 'spec_helper'
|
|
4
|
-
|
|
5
|
-
class ActionViewTest
|
|
6
|
-
include Timely::ActionViewHelpers::FormTagHelper
|
|
7
|
-
end
|
|
8
|
-
|
|
9
|
-
describe Timely::ActionViewHelpers do
|
|
10
|
-
subject { ActionViewTest.new }
|
|
11
|
-
let(:string) { double(:string) }
|
|
12
|
-
let(:date) { Date.new(2000, 12, 25) }
|
|
13
|
-
before do
|
|
14
|
-
expect(date).to receive(:to_s).with(:calendar).and_return('25-12-2000')
|
|
15
|
-
expect(Timely).to receive(:current_date).and_return(date)
|
|
16
|
-
end
|
|
17
|
-
|
|
18
|
-
it 'should generate calendar tags' do
|
|
19
|
-
expect(string).to receive(:html_safe)
|
|
20
|
-
expect(subject).to receive(:tag).with(:input,
|
|
21
|
-
id: 'test',
|
|
22
|
-
class: 'datepicker',
|
|
23
|
-
size: 10,
|
|
24
|
-
maxlength: 10,
|
|
25
|
-
name: 'test',
|
|
26
|
-
type: 'text',
|
|
27
|
-
value: '25-12-2000').and_return(string)
|
|
28
|
-
subject.calendar_tag :test
|
|
29
|
-
end
|
|
30
|
-
end
|
data/spec/date_chooser_spec.rb
DELETED
|
@@ -1,115 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
require 'spec_helper'
|
|
4
|
-
|
|
5
|
-
describe Timely::DateChooser do
|
|
6
|
-
before(:all) do
|
|
7
|
-
@from = '01-01-2011'.to_date
|
|
8
|
-
@to = '01-03-2011'.to_date
|
|
9
|
-
end
|
|
10
|
-
|
|
11
|
-
# Validation
|
|
12
|
-
it 'rejects blank FROM dates' do
|
|
13
|
-
expect { Timely::DateChooser.new(from: '') }.to raise_error(
|
|
14
|
-
Timely::DateChooserException, 'A Start Date is required'
|
|
15
|
-
)
|
|
16
|
-
end
|
|
17
|
-
|
|
18
|
-
it 'rejects TO dates later than FROM dates' do
|
|
19
|
-
expect do
|
|
20
|
-
Timely::DateChooser.new(
|
|
21
|
-
multiple_dates: true, from: @from + 10, to: @from
|
|
22
|
-
)
|
|
23
|
-
end .to raise_error(Timely::DateChooserException, 'Start Date is after End Date')
|
|
24
|
-
end
|
|
25
|
-
|
|
26
|
-
# Operation
|
|
27
|
-
it 'returns today if client only wants single date' do
|
|
28
|
-
expect(Timely::DateChooser.new(
|
|
29
|
-
multiple_dates: false, from: @from
|
|
30
|
-
).choose_dates).to eq [@from]
|
|
31
|
-
end
|
|
32
|
-
|
|
33
|
-
# Test specific date of month
|
|
34
|
-
it 'returns from and to as same (one) day in the case that only from date is given' do
|
|
35
|
-
expect(Timely::DateChooser.new(
|
|
36
|
-
multiple_dates: true, from: @from, to: ''
|
|
37
|
-
).choose_dates).to eq [@from]
|
|
38
|
-
end
|
|
39
|
-
|
|
40
|
-
it 'returns all days between from and to days in the basic case' do
|
|
41
|
-
expect(Timely::DateChooser.new(
|
|
42
|
-
multiple_dates: true, from: @from, to: @to
|
|
43
|
-
).choose_dates).to eq((@from..@to).to_a)
|
|
44
|
-
end
|
|
45
|
-
|
|
46
|
-
it 'returns the recurring dates within the range if this option is picked' do
|
|
47
|
-
expect(Timely::DateChooser.new(
|
|
48
|
-
multiple_dates: true, select: 'days', dates: '1,11,3', from: @from, to: @to
|
|
49
|
-
).choose_dates).to eq %w[
|
|
50
|
-
1-01-2011 3-01-2011 11-01-2011 1-02-2011
|
|
51
|
-
3-02-2011 11-02-2011 1-03-2011
|
|
52
|
-
].map(&:to_date)
|
|
53
|
-
end
|
|
54
|
-
|
|
55
|
-
it 'returns the specific dates, within or outside of the range, if this option is picked' do
|
|
56
|
-
expect(Timely::DateChooser.new(
|
|
57
|
-
multiple_dates: true, select: 'specific_days', specific_dates: '11-01-2011, 18-02-2011, 22-06-2011', from: @from, to: @to
|
|
58
|
-
).choose_dates).to eq %w[
|
|
59
|
-
11-01-2011 18-02-2011 22-06-2011
|
|
60
|
-
].map(&:to_date)
|
|
61
|
-
end
|
|
62
|
-
|
|
63
|
-
# Test days of week, every X weeks
|
|
64
|
-
it 'returns every sunday correctly' do
|
|
65
|
-
expect(Timely::DateChooser.new(
|
|
66
|
-
multiple_dates: true, select: 'weekdays', from: @from, to: @to,
|
|
67
|
-
interval: { level: '1', unit: 'week' }, weekdays: { sun: true }
|
|
68
|
-
).choose_dates).to eq %w[
|
|
69
|
-
2-01-2011 9-01-2011 16-01-2011 23-01-2011 30-01-2011
|
|
70
|
-
06-02-2011 13-02-2011 20-02-2011 27-02-2011
|
|
71
|
-
].map(&:to_date)
|
|
72
|
-
end
|
|
73
|
-
|
|
74
|
-
it 'returns every thursday and sunday correctly' do
|
|
75
|
-
expect(Timely::DateChooser.new(
|
|
76
|
-
multiple_dates: true, select: 'weekdays',
|
|
77
|
-
interval: { level: '1', unit: 'week' },
|
|
78
|
-
weekdays: { sun: true, thu: true }, from: @from, to: @to
|
|
79
|
-
).choose_dates).to eq %w[
|
|
80
|
-
2-01-2011 6-01-2011 9-01-2011 13-01-2011 16-01-2011
|
|
81
|
-
20-01-2011 23-01-2011 27-01-2011 30-01-2011 3-02-2011
|
|
82
|
-
06-02-2011 10-02-2011 13-02-2011 17-02-2011 20-02-2011
|
|
83
|
-
24-02-2011 27-02-2011
|
|
84
|
-
].map(&:to_date)
|
|
85
|
-
end
|
|
86
|
-
|
|
87
|
-
it 'returns every 2nd thursday and sunday correctly' do
|
|
88
|
-
expect(Timely::DateChooser.new(
|
|
89
|
-
multiple_dates: true, select: 'weekdays',
|
|
90
|
-
interval: { level: '2', unit: 'week' },
|
|
91
|
-
weekdays: { sun: '1', thu: '1' }, from: @from, to: @to
|
|
92
|
-
).choose_dates).to eq %w[
|
|
93
|
-
2-01-2011 6-01-2011 16-01-2011 20-01-2011 30-01-2011
|
|
94
|
-
3-02-2011 13-02-2011 17-02-2011 27-02-2011
|
|
95
|
-
].map(&:to_date)
|
|
96
|
-
end
|
|
97
|
-
|
|
98
|
-
# Test correct results for every Nth week of month
|
|
99
|
-
it 'returns every 1st Tuesday' do
|
|
100
|
-
expect(Timely::DateChooser.new(
|
|
101
|
-
multiple_dates: true, select: 'weekdays', from: @from, to: @to,
|
|
102
|
-
interval: { level: '1', unit: 'week_of_month' }, weekdays: { tue: true }
|
|
103
|
-
).choose_dates).to eq %w[4-01-2011 1-02-2011 1-03-2011].map(&:to_date)
|
|
104
|
-
end
|
|
105
|
-
|
|
106
|
-
it 'returns every 3st Monday and Friday' do
|
|
107
|
-
expect(Timely::DateChooser.new(
|
|
108
|
-
multiple_dates: true, select: 'weekdays',
|
|
109
|
-
interval: { level: '3', unit: 'week_of_month' },
|
|
110
|
-
weekdays: { mon: true, fri: true }, from: @from, to: @to
|
|
111
|
-
).choose_dates).to eq %w[
|
|
112
|
-
17-01-2011 21-01-2011 18-02-2011 21-02-2011
|
|
113
|
-
].map(&:to_date)
|
|
114
|
-
end
|
|
115
|
-
end
|