timely 0.9.0 → 0.10.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/lib/timely/version.rb +1 -1
- data/timely.gemspec +6 -10
- metadata +22 -103
- data/.github/dependabot.yml +0 -6
- data/.github/workflows/release.yml +0 -59
- data/.github/workflows/ruby.yml +0 -19
- data/.gitignore +0 -6
- data/.rspec +0 -2
- data/.rubocop.yml +0 -28
- data/.ruby-version +0 -1
- data/Gemfile +0 -4
- data/LICENSE +0 -21
- data/Rakefile +0 -14
- data/gemfiles/rails60.gemfile +0 -8
- data/gemfiles/rails61.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: 6aa86a2d85c75b320398194d92abfa5ddb0cf5eb15e26312d619c07fd8d89783
|
4
|
+
data.tar.gz: 6062dae4792ec644a1b7c9de0cfbcc14dba8b560e3b79f117f9e95f6bd311608
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 65880f47a10857ebaa6a5f6cb7a1cbf2bd9436d125a454ddff9f28a2144ec2eb9a917e26458efacd4865e5ef984d870ba2da3b0114d2f3e5d18f036218176965
|
7
|
+
data.tar.gz: ccfa4cf94063269922a0bf08c4ba3be6e67ee74d8be3f94857c1a75a506e109f25fef42d794e6e301d7d5dd06a519fd817f5fb169bfa18c2a66b49b73b53339e
|
data/CHANGELOG.md
CHANGED
data/lib/timely/version.rb
CHANGED
data/timely.gemspec
CHANGED
@@ -15,25 +15,21 @@ 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']
|
22
|
-
spec.required_ruby_version = '>= 2.
|
21
|
+
spec.required_ruby_version = '>= 2.7'
|
23
22
|
|
24
|
-
spec.add_development_dependency '
|
25
|
-
spec.add_development_dependency '
|
26
|
-
spec.add_development_dependency '
|
27
|
-
spec.add_development_dependency 'bundler', '~> 2.2.0'
|
23
|
+
spec.add_development_dependency 'activerecord', '>=6', '<8'
|
24
|
+
spec.add_development_dependency 'activesupport', '>=6', '<8'
|
25
|
+
spec.add_development_dependency 'bundler'
|
28
26
|
spec.add_development_dependency 'coverage-kit'
|
29
|
-
spec.add_development_dependency 'coveralls'
|
30
27
|
spec.add_development_dependency 'rake'
|
31
28
|
spec.add_development_dependency 'rspec'
|
32
29
|
spec.add_development_dependency 'rspec-its'
|
33
30
|
spec.add_development_dependency 'database_cleaner'
|
34
31
|
spec.add_development_dependency 'rubocop'
|
35
32
|
spec.add_development_dependency 'rubocop-rails'
|
36
|
-
spec.add_development_dependency 'simplecov-rcov'
|
37
33
|
spec.add_development_dependency 'sqlite3'
|
38
34
|
spec.add_development_dependency 'timecop'
|
39
35
|
spec.add_development_dependency 'pry'
|
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.10.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-01-25 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
|
-
- - "~>"
|
60
|
-
- !ruby/object:Gem::Version
|
61
|
-
version: 2.2.0
|
62
|
-
type: :development
|
63
|
-
prerelease: false
|
64
|
-
version_requirements: !ruby/object:Gem::Requirement
|
65
|
-
requirements:
|
66
|
-
- - "~>"
|
49
|
+
version: '6'
|
50
|
+
- - "<"
|
67
51
|
- !ruby/object:Gem::Version
|
68
|
-
version:
|
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
|
@@ -241,20 +211,8 @@ executables: []
|
|
241
211
|
extensions: []
|
242
212
|
extra_rdoc_files: []
|
243
213
|
files:
|
244
|
-
- ".github/dependabot.yml"
|
245
|
-
- ".github/workflows/release.yml"
|
246
|
-
- ".github/workflows/ruby.yml"
|
247
|
-
- ".gitignore"
|
248
|
-
- ".rspec"
|
249
|
-
- ".rubocop.yml"
|
250
|
-
- ".ruby-version"
|
251
214
|
- CHANGELOG.md
|
252
|
-
- Gemfile
|
253
|
-
- LICENSE
|
254
215
|
- README.md
|
255
|
-
- Rakefile
|
256
|
-
- gemfiles/rails60.gemfile
|
257
|
-
- gemfiles/rails61.gemfile
|
258
216
|
- lib/timely.rb
|
259
217
|
- lib/timely/date.rb
|
260
218
|
- lib/timely/date_chooser.rb
|
@@ -282,26 +240,6 @@ files:
|
|
282
240
|
- lib/timely/trackable_date_set.rb
|
283
241
|
- lib/timely/version.rb
|
284
242
|
- lib/timely/week_days.rb
|
285
|
-
- rails/init.rb
|
286
|
-
- spec/calendar_tag_spec.rb
|
287
|
-
- spec/date_chooser_spec.rb
|
288
|
-
- spec/date_group_spec.rb
|
289
|
-
- spec/date_range_spec.rb
|
290
|
-
- spec/date_spec.rb
|
291
|
-
- spec/extensions_spec.rb
|
292
|
-
- spec/rails/date_spec.rb
|
293
|
-
- spec/rails/date_time_spec.rb
|
294
|
-
- spec/rails/period_spec.rb
|
295
|
-
- spec/rails/time_spec.rb
|
296
|
-
- spec/schema.rb
|
297
|
-
- spec/season_spec.rb
|
298
|
-
- spec/spec_helper.rb
|
299
|
-
- spec/support/coverage_loader.rb
|
300
|
-
- spec/temporal_patterns_spec.rb
|
301
|
-
- spec/time_since_spec.rb
|
302
|
-
- spec/time_spec.rb
|
303
|
-
- spec/trackable_date_set_spec.rb
|
304
|
-
- spec/week_days_spec.rb
|
305
243
|
- timely.gemspec
|
306
244
|
homepage: http://github.com/sealink/timely
|
307
245
|
licenses:
|
@@ -315,34 +253,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
315
253
|
requirements:
|
316
254
|
- - ">="
|
317
255
|
- !ruby/object:Gem::Version
|
318
|
-
version: '2.
|
256
|
+
version: '2.7'
|
319
257
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
320
258
|
requirements:
|
321
259
|
- - ">="
|
322
260
|
- !ruby/object:Gem::Version
|
323
261
|
version: '0'
|
324
262
|
requirements: []
|
325
|
-
rubygems_version: 3.
|
263
|
+
rubygems_version: 3.3.3
|
326
264
|
signing_key:
|
327
265
|
specification_version: 4
|
328
266
|
summary: Set of time, date, weekday related methods.
|
329
|
-
test_files:
|
330
|
-
- spec/calendar_tag_spec.rb
|
331
|
-
- spec/date_chooser_spec.rb
|
332
|
-
- spec/date_group_spec.rb
|
333
|
-
- spec/date_range_spec.rb
|
334
|
-
- spec/date_spec.rb
|
335
|
-
- spec/extensions_spec.rb
|
336
|
-
- spec/rails/date_spec.rb
|
337
|
-
- spec/rails/date_time_spec.rb
|
338
|
-
- spec/rails/period_spec.rb
|
339
|
-
- spec/rails/time_spec.rb
|
340
|
-
- spec/schema.rb
|
341
|
-
- spec/season_spec.rb
|
342
|
-
- spec/spec_helper.rb
|
343
|
-
- spec/support/coverage_loader.rb
|
344
|
-
- spec/temporal_patterns_spec.rb
|
345
|
-
- spec/time_since_spec.rb
|
346
|
-
- spec/time_spec.rb
|
347
|
-
- spec/trackable_date_set_spec.rb
|
348
|
-
- spec/week_days_spec.rb
|
267
|
+
test_files: []
|
data/.github/dependabot.yml
DELETED
@@ -1,59 +0,0 @@
|
|
1
|
-
name: Release
|
2
|
-
|
3
|
-
on:
|
4
|
-
push:
|
5
|
-
tags:
|
6
|
-
- "v*"
|
7
|
-
|
8
|
-
jobs:
|
9
|
-
build:
|
10
|
-
name: Build
|
11
|
-
runs-on: ubuntu-latest
|
12
|
-
steps:
|
13
|
-
- name: Checkout
|
14
|
-
uses: actions/checkout@v2
|
15
|
-
- uses: ruby/setup-ruby@v1
|
16
|
-
with:
|
17
|
-
bundler-cache: true
|
18
|
-
- run: bundle exec rake
|
19
|
-
|
20
|
-
release:
|
21
|
-
needs: build
|
22
|
-
name: Release
|
23
|
-
runs-on: ubuntu-latest
|
24
|
-
steps:
|
25
|
-
- name: Checkout
|
26
|
-
uses: actions/checkout@v2
|
27
|
-
|
28
|
-
- name: Generate Changelog
|
29
|
-
run: |
|
30
|
-
# Get version from github ref (remove 'refs/tags/' and prefix 'v')
|
31
|
-
version="${GITHUB_REF#refs/tags/v}"
|
32
|
-
npx changelog-parser CHANGELOG.md | jq -cr ".versions | .[] | select(.version == \"$version\") | .body" > ${{ github.workflow }}-CHANGELOG.txt
|
33
|
-
|
34
|
-
- name: Release
|
35
|
-
uses: softprops/action-gh-release@v1
|
36
|
-
with:
|
37
|
-
body_path: ${{ github.workflow }}-CHANGELOG.txt
|
38
|
-
env:
|
39
|
-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
40
|
-
|
41
|
-
publish:
|
42
|
-
needs: [build, release]
|
43
|
-
name: Publish
|
44
|
-
runs-on: ubuntu-latest
|
45
|
-
|
46
|
-
steps:
|
47
|
-
- uses: actions/checkout@v2
|
48
|
-
- uses: ruby/setup-ruby@v1
|
49
|
-
|
50
|
-
- name: Publish to RubyGems
|
51
|
-
run: |
|
52
|
-
mkdir -p $HOME/.gem
|
53
|
-
touch $HOME/.gem/credentials
|
54
|
-
chmod 0600 $HOME/.gem/credentials
|
55
|
-
printf -- "---\n:rubygems_api_key: ${GEM_HOST_API_KEY}\n" > $HOME/.gem/credentials
|
56
|
-
gem build *.gemspec
|
57
|
-
gem push *.gem
|
58
|
-
env:
|
59
|
-
GEM_HOST_API_KEY: "${{secrets.RUBYGEMS_AUTH_TOKEN}}"
|
data/.github/workflows/ruby.yml
DELETED
@@ -1,19 +0,0 @@
|
|
1
|
-
name: Build and Test
|
2
|
-
on: [push, pull_request]
|
3
|
-
jobs:
|
4
|
-
test:
|
5
|
-
strategy:
|
6
|
-
fail-fast: false
|
7
|
-
matrix:
|
8
|
-
gemfile: [rails60, rails61]
|
9
|
-
ruby: ["2.6", "2.7", "3.0"]
|
10
|
-
runs-on: ubuntu-latest
|
11
|
-
env:
|
12
|
-
BUNDLE_GEMFILE: gemfiles/${{ matrix.gemfile }}.gemfile
|
13
|
-
steps:
|
14
|
-
- uses: actions/checkout@v2
|
15
|
-
- uses: ruby/setup-ruby@v1
|
16
|
-
with:
|
17
|
-
ruby-version: ${{ matrix.ruby }}
|
18
|
-
bundler-cache: true
|
19
|
-
- run: bundle exec rake
|
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
|
-
3.0.0
|
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/rails60.gemfile
DELETED
data/gemfiles/rails61.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
|