dgp-schedule_attributes 0.4.0 → 0.5.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 +15 -0
- data/CODE_OF_CONDUCT.md +22 -0
- data/Gemfile.lock +31 -17
- data/gemfiles/rails_3.2.gemfile.lock +7 -0
- data/gemfiles/rails_4.0.gemfile.lock +7 -0
- data/gemfiles/rails_4.1.gemfile.lock +7 -0
- data/gemfiles/rails_4.2.gemfile.lock +7 -0
- data/gemfiles/rails_edge.gemfile.lock +7 -0
- data/lib/schedule_attributes/core.rb +18 -0
- data/lib/schedule_attributes/input.rb +7 -2
- data/lib/schedule_attributes/version.rb +1 -1
- data/schedule_attributes.gemspec +1 -0
- data/spec/active_record_integration_spec.rb +11 -10
- data/spec/schedule_attributes/configuration_spec.rb +4 -4
- data/spec/schedule_attributes/input_spec.rb +34 -34
- data/spec/schedule_attributes/rule_parser/day_spec.rb +21 -21
- data/spec/schedule_attributes/rule_parser/month_spec.rb +9 -9
- data/spec/schedule_attributes/rule_parser/week_spec.rb +6 -6
- data/spec/schedule_attributes/rule_parser/year_spec.rb +10 -10
- data/spec/schedule_attributes/rule_parser_spec.rb +1 -1
- data/spec/schedule_attributes/time_helpers_spec.rb +5 -5
- data/spec/schedule_attributes_spec.rb +63 -63
- data/spec/spec_helper.rb +6 -2
- data/spec/support/parser_macros.rb +0 -4
- metadata +17 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 031b0bf395bee38af7d2516bb2358b4385128527
|
4
|
+
data.tar.gz: e9881c68f4dd05c30701e75ec7f4dbad5a6eb863
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e77a84adc8c0cb9825eef971704fb37fe8397d83501e21c72574e437ef3955ede56eb97fcd85daf97f605e2a07c33ef44b90e762a6163f93d10565644ccb4b00
|
7
|
+
data.tar.gz: c4109d2763a4a0a4a77d568538f7590d268aa5e258e1e17f59bef312666c48b67e2a8bf1daf70e35501e104c6f294dbd7106d21cea31ff67900b57200bc5e66f
|
data/CHANGELOG.md
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
# Changelog
|
2
|
+
All notable changes to this project will be documented in this file.
|
3
|
+
|
4
|
+
## HEAD
|
5
|
+
|
6
|
+
## 0.5.0
|
7
|
+
|
8
|
+
- Added Code of Conduct from Contributor Covenant ~ @dgilperez
|
9
|
+
- Tests are now rspec-3 like ~ @dgilperez
|
10
|
+
- Activate IceCube.compatibility = 12 in specs ~ @dgilperez
|
11
|
+
- *POSSIBLE BREAKING CHANGE* Detect :start_date and :end_date attributes and merge them into :start_time and :end_time respective ones before passing them to IceCube::Schedule objects.
|
12
|
+
|
13
|
+
## 0.4.0
|
14
|
+
|
15
|
+
- Renamed gem to dgp-schedule_attributes to reflect changes in ice_cube dependencies and Rails support ~ @dgilperez
|
data/CODE_OF_CONDUCT.md
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
# Contributor Code of Conduct
|
2
|
+
|
3
|
+
As contributors and maintainers of this project, and in the interest of fostering an open and welcoming community, we pledge to respect all people who contribute through reporting issues, posting feature requests, updating documentation, submitting pull requests or patches, and other activities.
|
4
|
+
|
5
|
+
We are committed to making participation in this project a harassment-free experience for everyone, regardless of level of experience, gender, gender identity and expression, sexual orientation, disability, personal appearance, body size, race, ethnicity, age, religion, or nationality.
|
6
|
+
|
7
|
+
Examples of unacceptable behavior by participants include:
|
8
|
+
|
9
|
+
* The use of sexualized language or imagery
|
10
|
+
* Personal attacks
|
11
|
+
* Trolling or insulting/derogatory comments
|
12
|
+
* Public or private harassment
|
13
|
+
* Publishing other's private information, such as physical or electronic addresses, without explicit permission
|
14
|
+
* Other unethical or unprofessional conduct.
|
15
|
+
|
16
|
+
Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct. By adopting this Code of Conduct, project maintainers commit themselves to fairly and consistently applying these principles to every aspect of managing this project. Project maintainers who do not follow or enforce the Code of Conduct may be permanently removed from the project team.
|
17
|
+
|
18
|
+
This code of conduct applies both within project spaces and in public spaces when an individual is representing the project or its community.
|
19
|
+
|
20
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by opening an issue or contacting one or more of the project maintainers.
|
21
|
+
|
22
|
+
This Code of Conduct is adapted from the [Contributor Covenant](http://contributor-covenant.org), version 1.2.0, available at [http://contributor-covenant.org/version/1/2/0/](http://contributor-covenant.org/version/1/2/0/)
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
dgp-schedule_attributes (0.
|
4
|
+
dgp-schedule_attributes (0.5.0)
|
5
5
|
activesupport (>= 3.2)
|
6
6
|
ice_cube (~> 0.13)
|
7
7
|
tzinfo
|
@@ -9,33 +9,44 @@ PATH
|
|
9
9
|
GEM
|
10
10
|
remote: http://rubygems.org/
|
11
11
|
specs:
|
12
|
-
activemodel (
|
13
|
-
activesupport (=
|
14
|
-
builder (~> 3.
|
15
|
-
activerecord (
|
16
|
-
activemodel (=
|
17
|
-
activesupport (=
|
18
|
-
arel (~>
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
12
|
+
activemodel (4.2.4)
|
13
|
+
activesupport (= 4.2.4)
|
14
|
+
builder (~> 3.1)
|
15
|
+
activerecord (4.2.4)
|
16
|
+
activemodel (= 4.2.4)
|
17
|
+
activesupport (= 4.2.4)
|
18
|
+
arel (~> 6.0)
|
19
|
+
activesupport (4.2.4)
|
20
|
+
i18n (~> 0.7)
|
21
|
+
json (~> 1.7, >= 1.7.7)
|
22
|
+
minitest (~> 5.1)
|
23
|
+
thread_safe (~> 0.3, >= 0.3.4)
|
24
|
+
tzinfo (~> 1.1)
|
23
25
|
appraisal (2.1.0)
|
24
26
|
bundler
|
25
27
|
rake
|
26
28
|
thor (>= 0.14.0)
|
27
|
-
arel (
|
28
|
-
builder (3.
|
29
|
+
arel (6.0.3)
|
30
|
+
builder (3.2.2)
|
31
|
+
byebug (2.7.0)
|
32
|
+
columnize (~> 0.3)
|
33
|
+
debugger-linecache (~> 1.2)
|
29
34
|
coderay (1.0.9)
|
35
|
+
columnize (0.9.0)
|
36
|
+
debugger-linecache (1.2.0)
|
30
37
|
diff-lcs (1.2.5)
|
31
|
-
i18n (0.
|
38
|
+
i18n (0.7.0)
|
32
39
|
ice_cube (0.13.0)
|
40
|
+
json (1.8.3)
|
33
41
|
method_source (0.8.1)
|
34
|
-
|
42
|
+
minitest (5.8.0)
|
35
43
|
pry (0.9.12.1)
|
36
44
|
coderay (~> 1.0.5)
|
37
45
|
method_source (~> 0.8)
|
38
46
|
slop (~> 3.4)
|
47
|
+
pry-byebug (1.3.2)
|
48
|
+
byebug (~> 2.7)
|
49
|
+
pry (~> 0.9.12)
|
39
50
|
rake (10.0.4)
|
40
51
|
rspec (2.99.0)
|
41
52
|
rspec-core (~> 2.99.0)
|
@@ -48,7 +59,9 @@ GEM
|
|
48
59
|
slop (3.4.4)
|
49
60
|
sqlite3 (1.3.10)
|
50
61
|
thor (0.19.1)
|
51
|
-
|
62
|
+
thread_safe (0.3.5)
|
63
|
+
tzinfo (1.2.2)
|
64
|
+
thread_safe (~> 0.1)
|
52
65
|
|
53
66
|
PLATFORMS
|
54
67
|
ruby
|
@@ -58,6 +71,7 @@ DEPENDENCIES
|
|
58
71
|
appraisal
|
59
72
|
dgp-schedule_attributes!
|
60
73
|
pry
|
74
|
+
pry-byebug
|
61
75
|
rake
|
62
76
|
rspec (~> 2.99)
|
63
77
|
sqlite3
|
@@ -49,7 +49,10 @@ GEM
|
|
49
49
|
thor (>= 0.14.0)
|
50
50
|
arel (3.0.3)
|
51
51
|
builder (3.0.4)
|
52
|
+
byebug (5.0.0)
|
53
|
+
columnize (= 0.9.0)
|
52
54
|
coderay (1.1.0)
|
55
|
+
columnize (0.9.0)
|
53
56
|
diff-lcs (1.2.5)
|
54
57
|
erubis (2.7.0)
|
55
58
|
hike (1.2.3)
|
@@ -63,6 +66,9 @@ GEM
|
|
63
66
|
coderay (~> 1.1.0)
|
64
67
|
method_source (~> 0.8.1)
|
65
68
|
slop (~> 3.4)
|
69
|
+
pry-byebug (3.2.0)
|
70
|
+
byebug (~> 5.0)
|
71
|
+
pry (~> 0.10)
|
66
72
|
rack (1.4.7)
|
67
73
|
rack-cache (1.2)
|
68
74
|
rack (>= 0.4)
|
@@ -106,6 +112,7 @@ DEPENDENCIES
|
|
106
112
|
appraisal
|
107
113
|
dgp-schedule_attributes!
|
108
114
|
pry
|
115
|
+
pry-byebug
|
109
116
|
rake
|
110
117
|
rspec (~> 2.99)
|
111
118
|
sqlite3
|
@@ -36,7 +36,10 @@ GEM
|
|
36
36
|
thor (>= 0.14.0)
|
37
37
|
arel (4.0.2)
|
38
38
|
builder (3.1.4)
|
39
|
+
byebug (5.0.0)
|
40
|
+
columnize (= 0.9.0)
|
39
41
|
coderay (1.1.0)
|
42
|
+
columnize (0.9.0)
|
40
43
|
diff-lcs (1.2.5)
|
41
44
|
i18n (0.7.0)
|
42
45
|
ice_cube (0.13.0)
|
@@ -47,6 +50,9 @@ GEM
|
|
47
50
|
coderay (~> 1.1.0)
|
48
51
|
method_source (~> 0.8.1)
|
49
52
|
slop (~> 3.4)
|
53
|
+
pry-byebug (3.2.0)
|
54
|
+
byebug (~> 5.0)
|
55
|
+
pry (~> 0.10)
|
50
56
|
rake (10.4.2)
|
51
57
|
rspec (2.99.0)
|
52
58
|
rspec-core (~> 2.99.0)
|
@@ -71,6 +77,7 @@ DEPENDENCIES
|
|
71
77
|
appraisal
|
72
78
|
dgp-schedule_attributes!
|
73
79
|
pry
|
80
|
+
pry-byebug
|
74
81
|
rake
|
75
82
|
rspec (~> 2.99)
|
76
83
|
sqlite3
|
@@ -34,7 +34,10 @@ GEM
|
|
34
34
|
thor (>= 0.14.0)
|
35
35
|
arel (5.0.1.20140414130214)
|
36
36
|
builder (3.2.2)
|
37
|
+
byebug (5.0.0)
|
38
|
+
columnize (= 0.9.0)
|
37
39
|
coderay (1.1.0)
|
40
|
+
columnize (0.9.0)
|
38
41
|
diff-lcs (1.2.5)
|
39
42
|
i18n (0.7.0)
|
40
43
|
ice_cube (0.13.0)
|
@@ -45,6 +48,9 @@ GEM
|
|
45
48
|
coderay (~> 1.1.0)
|
46
49
|
method_source (~> 0.8.1)
|
47
50
|
slop (~> 3.4)
|
51
|
+
pry-byebug (3.2.0)
|
52
|
+
byebug (~> 5.0)
|
53
|
+
pry (~> 0.10)
|
48
54
|
rake (10.4.2)
|
49
55
|
rspec (2.99.0)
|
50
56
|
rspec-core (~> 2.99.0)
|
@@ -70,6 +76,7 @@ DEPENDENCIES
|
|
70
76
|
appraisal
|
71
77
|
dgp-schedule_attributes!
|
72
78
|
pry
|
79
|
+
pry-byebug
|
73
80
|
rake
|
74
81
|
rspec (~> 2.99)
|
75
82
|
sqlite3
|
@@ -34,7 +34,10 @@ GEM
|
|
34
34
|
thor (>= 0.14.0)
|
35
35
|
arel (6.0.3)
|
36
36
|
builder (3.2.2)
|
37
|
+
byebug (5.0.0)
|
38
|
+
columnize (= 0.9.0)
|
37
39
|
coderay (1.1.0)
|
40
|
+
columnize (0.9.0)
|
38
41
|
diff-lcs (1.2.5)
|
39
42
|
i18n (0.7.0)
|
40
43
|
ice_cube (0.13.0)
|
@@ -45,6 +48,9 @@ GEM
|
|
45
48
|
coderay (~> 1.1.0)
|
46
49
|
method_source (~> 0.8.1)
|
47
50
|
slop (~> 3.4)
|
51
|
+
pry-byebug (3.2.0)
|
52
|
+
byebug (~> 5.0)
|
53
|
+
pry (~> 0.10)
|
48
54
|
rake (10.4.2)
|
49
55
|
rspec (2.99.0)
|
50
56
|
rspec-core (~> 2.99.0)
|
@@ -70,6 +76,7 @@ DEPENDENCIES
|
|
70
76
|
appraisal
|
71
77
|
dgp-schedule_attributes!
|
72
78
|
pry
|
79
|
+
pry-byebug
|
73
80
|
rake
|
74
81
|
rspec (~> 2.99)
|
75
82
|
sqlite3
|
@@ -40,7 +40,10 @@ GEM
|
|
40
40
|
rake
|
41
41
|
thor (>= 0.14.0)
|
42
42
|
builder (3.2.2)
|
43
|
+
byebug (5.0.0)
|
44
|
+
columnize (= 0.9.0)
|
43
45
|
coderay (1.1.0)
|
46
|
+
columnize (0.9.0)
|
44
47
|
concurrent-ruby (0.9.1)
|
45
48
|
diff-lcs (1.2.5)
|
46
49
|
i18n (0.7.0)
|
@@ -52,6 +55,9 @@ GEM
|
|
52
55
|
coderay (~> 1.1.0)
|
53
56
|
method_source (~> 0.8.1)
|
54
57
|
slop (~> 3.4)
|
58
|
+
pry-byebug (3.2.0)
|
59
|
+
byebug (~> 5.0)
|
60
|
+
pry (~> 0.10)
|
55
61
|
rake (10.4.2)
|
56
62
|
rspec (2.99.0)
|
57
63
|
rspec-core (~> 2.99.0)
|
@@ -78,6 +84,7 @@ DEPENDENCIES
|
|
78
84
|
arel!
|
79
85
|
dgp-schedule_attributes!
|
80
86
|
pry
|
87
|
+
pry-byebug
|
81
88
|
rake
|
82
89
|
rspec (~> 2.99)
|
83
90
|
sqlite3
|
@@ -28,6 +28,8 @@ module ScheduleAttributes
|
|
28
28
|
extend ActiveSupport::Concern
|
29
29
|
|
30
30
|
def schedule_attributes=(options)
|
31
|
+
merge_date_and_time_into_time_attribute!(options)
|
32
|
+
|
31
33
|
input = ScheduleAttributes::Input.new(options)
|
32
34
|
new_schedule = IceCube::Schedule.new(input.start_time || TimeHelpers.today)
|
33
35
|
|
@@ -142,5 +144,21 @@ module ScheduleAttributes
|
|
142
144
|
OpenStruct.new(atts.delete_if { |_,v| v.blank? })
|
143
145
|
end
|
144
146
|
|
147
|
+
private
|
148
|
+
|
149
|
+
# Modifies the passed options hash
|
150
|
+
def merge_date_and_time_into_time_attribute!(options)
|
151
|
+
merged_start_time = "#{options['start_date']} #{options['start_time']}".strip.presence
|
152
|
+
merged_end_time = "#{options['end_date']} #{options['end_time']}".strip.presence
|
153
|
+
if merged_start_time
|
154
|
+
options.delete('start_date')
|
155
|
+
options['start_time'] = merged_start_time.to_s
|
156
|
+
end
|
157
|
+
if merged_start_time
|
158
|
+
options.delete('end_date')
|
159
|
+
options['end_time'] = merged_end_time.to_s
|
160
|
+
end
|
161
|
+
end
|
162
|
+
|
145
163
|
end
|
146
164
|
end
|
@@ -135,11 +135,16 @@ module ScheduleAttributes
|
|
135
135
|
end
|
136
136
|
|
137
137
|
def end_date
|
138
|
-
|
138
|
+
if @params[:end_date]
|
139
|
+
parse_date_time(@params[:end_date], @params[:end_time] || @params[:start_time])
|
140
|
+
elsif @params[:end_time]
|
141
|
+
parse_date_time(@params[:end_time])
|
142
|
+
end
|
139
143
|
end
|
140
144
|
|
141
145
|
def ends?
|
142
|
-
|
146
|
+
return false if @params[:ends] == "never"
|
147
|
+
@params[:end_date].present? || @params[:end_time].present?
|
143
148
|
end
|
144
149
|
|
145
150
|
def dates
|
data/schedule_attributes.gemspec
CHANGED
@@ -3,13 +3,13 @@ require 'support/scheduled_active_record_model'
|
|
3
3
|
|
4
4
|
describe CustomScheduledActiveRecordModel do
|
5
5
|
it "should have a default schedule" do
|
6
|
-
subject.my_schedule.
|
6
|
+
expect(subject.my_schedule).to eq(hourly)
|
7
7
|
end
|
8
8
|
|
9
9
|
def hourly
|
10
|
-
IceCube::Schedule.new(Date.today.to_time).tap
|
10
|
+
IceCube::Schedule.new(Date.today.to_time).tap do |s|
|
11
11
|
s.add_recurrence_rule IceCube::Rule.hourly
|
12
|
-
|
12
|
+
end
|
13
13
|
end
|
14
14
|
end
|
15
15
|
|
@@ -17,10 +17,9 @@ describe DefaultScheduledActiveRecordModel do
|
|
17
17
|
alias :model :subject
|
18
18
|
|
19
19
|
it "should have a default schedule" do
|
20
|
-
subject.schedule.
|
20
|
+
expect(subject.schedule).to be_a IceCube::Schedule
|
21
21
|
end
|
22
22
|
|
23
|
-
|
24
23
|
describe "schedule_attributes" do
|
25
24
|
it "round-trips a schedule from the database" do
|
26
25
|
model.schedule_attributes = {
|
@@ -32,10 +31,12 @@ describe DefaultScheduledActiveRecordModel do
|
|
32
31
|
"sunday"=>"0", "monday"=>"0", "tuesday"=>"0", "wednesday"=>"0",
|
33
32
|
"thursday"=>"0", "friday"=>"0", "saturday"=>"0"
|
34
33
|
}
|
35
|
-
|
36
|
-
|
34
|
+
start_time = Time.local(2013, 2, 26)
|
35
|
+
end_time = Time.local(2016, 7, 7)
|
36
|
+
expected = IceCube::Schedule.new(start_time, end_time: end_time) do |s|
|
37
|
+
s.rrule IceCube::Rule.daily(3).until(end_time)
|
37
38
|
end
|
38
|
-
model.schedule.
|
39
|
+
expect(model.schedule).to eq(expected)
|
39
40
|
end
|
40
41
|
|
41
42
|
it "should deal with all_occurrences with no infinite loops" do
|
@@ -49,8 +50,8 @@ describe DefaultScheduledActiveRecordModel do
|
|
49
50
|
# Calling schedule_attributes should not change Schedule::Rule.
|
50
51
|
model.schedule_attributes
|
51
52
|
|
52
|
-
model.schedule.
|
53
|
-
model.schedule.all_occurrences.size.
|
53
|
+
expect(model.schedule).to eq(schedule)
|
54
|
+
expect(model.schedule.all_occurrences.size).to eq(5)
|
54
55
|
end
|
55
56
|
end
|
56
57
|
|
@@ -5,12 +5,12 @@ describe "ScheduleAttributes" do
|
|
5
5
|
describe ".configure" do
|
6
6
|
it "yields a configuration instance" do
|
7
7
|
ScheduleAttributes.configure do |config|
|
8
|
-
config.
|
8
|
+
expect(config).to be_a ScheduleAttributes::Configuration
|
9
9
|
end
|
10
10
|
end
|
11
11
|
|
12
12
|
it "returns a configuration instance" do
|
13
|
-
ScheduleAttributes.configure.
|
13
|
+
expect(ScheduleAttributes.configure).to be_a ScheduleAttributes::Configuration
|
14
14
|
end
|
15
15
|
end
|
16
16
|
end
|
@@ -18,12 +18,12 @@ end
|
|
18
18
|
describe ScheduleAttributes::Configuration do
|
19
19
|
describe ".time_format" do
|
20
20
|
it "has a default" do
|
21
|
-
subject.time_format.
|
21
|
+
expect(subject.time_format).to eq('%H:%M')
|
22
22
|
end
|
23
23
|
|
24
24
|
it "is settable" do
|
25
25
|
subject.time_format = '%l:%M %P'
|
26
|
-
subject.time_format.
|
26
|
+
expect(subject.time_format).to eq('%l:%M %P')
|
27
27
|
end
|
28
28
|
end
|
29
29
|
end
|
@@ -8,18 +8,18 @@ describe ScheduleAttributes::Input do
|
|
8
8
|
subject(:repeat) { input.repeat? }
|
9
9
|
|
10
10
|
context 'no arguments', args: {} do
|
11
|
-
it {
|
11
|
+
it { is_expected.to be true }
|
12
12
|
end
|
13
13
|
|
14
14
|
[0, '0', 'false', 'f', 'F', 'no', 'none'].each do |cond|
|
15
15
|
context 'false', args: {repeat: cond} do
|
16
|
-
it {
|
16
|
+
it { is_expected.to be false }
|
17
17
|
end
|
18
18
|
end
|
19
19
|
|
20
20
|
[1, '1', 'true', 't', 'T', 'yes', 'whatever'].each do |cond|
|
21
21
|
context 'true', args: {repeat: cond} do
|
22
|
-
it {
|
22
|
+
it { is_expected.to be true }
|
23
23
|
end
|
24
24
|
end
|
25
25
|
end
|
@@ -28,35 +28,35 @@ describe ScheduleAttributes::Input do
|
|
28
28
|
subject(:start_time) { input.start_time }
|
29
29
|
|
30
30
|
context 'no arguments', args: {} do
|
31
|
-
it {
|
31
|
+
it { is_expected.to be nil }
|
32
32
|
end
|
33
33
|
|
34
34
|
context 'date argument', args: {date: '2000-12-31'} do
|
35
|
-
it {
|
35
|
+
it { is_expected.to eq(Time.new(2000,12,31,0,0,0)) }
|
36
36
|
end
|
37
37
|
|
38
38
|
context 'start_date argument', args: {start_date: '2000-12-31'} do
|
39
|
-
it {
|
39
|
+
it { is_expected.to eq(Time.new(2000,12,31,0,0,0)) }
|
40
40
|
end
|
41
41
|
|
42
42
|
context 'date and start_date arguments', args: {date: '2000-06-06', start_date: '2000-12-31'} do
|
43
|
-
it {
|
43
|
+
it { is_expected.to eq(Time.new(2000,12,31,0,0,0)) }
|
44
44
|
end
|
45
45
|
|
46
46
|
context 'both dates and repeat arguments', args: {repeat: '0', date: '2000-06-06', start_date: '2000-12-31'} do
|
47
47
|
it "uses date instead of start_date when not repeating" do
|
48
|
-
|
48
|
+
is_expected.to eq(Time.new(2000,6,6,0,0,0))
|
49
49
|
end
|
50
50
|
end
|
51
51
|
|
52
52
|
context 'start_date and start_time arguments', args: {start_date: '2000-12-31', start_time: '14:30'} do
|
53
53
|
it "combines start_date and start_time" do
|
54
|
-
|
54
|
+
is_expected.to eq(Time.new(2000,12,31,14,30,0))
|
55
55
|
end
|
56
56
|
end
|
57
57
|
|
58
58
|
context 'start_time argument', args: {start_time: '14:00'} do
|
59
|
-
it {
|
59
|
+
it { is_expected.to eq(Date.today.to_time + 14.hours) }
|
60
60
|
end
|
61
61
|
end
|
62
62
|
|
@@ -64,31 +64,31 @@ describe ScheduleAttributes::Input do
|
|
64
64
|
subject(:end_time) { input.end_time }
|
65
65
|
|
66
66
|
context 'no arguments', args: {} do
|
67
|
-
it {
|
67
|
+
it { is_expected.to be nil }
|
68
68
|
end
|
69
69
|
|
70
70
|
context 'end_time argument', args: {end_time: '14:00'} do
|
71
|
-
it {
|
71
|
+
it { is_expected.to eq(Date.today.to_time + 14.hours) }
|
72
72
|
end
|
73
73
|
|
74
74
|
context 'start_date and end_time arguments', args: {start_date: '2000-12-31', end_time: '14:00'} do
|
75
|
-
it {
|
75
|
+
it { is_expected.to eq(Time.new(2000,12,31,14,0,0)) }
|
76
76
|
end
|
77
77
|
|
78
78
|
context 'start_date, end_date and end_time arguments', args: {start_date: '2000-06-06', end_date: '2000-12-31', end_time: '14:00'} do
|
79
|
-
it {
|
79
|
+
it { is_expected.to eq(Time.new(2000,6,6,14,0,0)) }
|
80
80
|
end
|
81
81
|
|
82
82
|
context 'date and end_time arguments', args: {date: '2000-12-31', end_time: '14:00'} do
|
83
|
-
it {
|
83
|
+
it { is_expected.to eq(Time.new(2000,12,31,14,0,0)) }
|
84
84
|
end
|
85
85
|
|
86
86
|
context 'start_date and _time and end_date and _time arguments', args: {start_date: '2000-06-06', end_date: '2000-12-31', start_time: '06:00', end_time: '14:00'} do
|
87
|
-
it {
|
87
|
+
it { is_expected.to eq(Time.new(2000,6,6,14,0,0)) }
|
88
88
|
end
|
89
89
|
|
90
90
|
context 'start_date and _time and end_date and _time arguments, 24h format', args: {start_date: '2000-06-06', end_date: '2000-12-31', start_time: '20:00', end_time: '14:00'} do
|
91
|
-
it {
|
91
|
+
it { is_expected.to eq(Time.new(2000,6,7,14,0,0)) }
|
92
92
|
end
|
93
93
|
end
|
94
94
|
|
@@ -96,15 +96,15 @@ describe ScheduleAttributes::Input do
|
|
96
96
|
subject(:duration) { input.duration }
|
97
97
|
|
98
98
|
context 'no arguments', args: {} do
|
99
|
-
it {
|
99
|
+
it { is_expected.to be nil }
|
100
100
|
end
|
101
101
|
|
102
102
|
context 'start_time argument', args: {start_time: '8:00'} do
|
103
|
-
it {
|
103
|
+
it { is_expected.to be nil }
|
104
104
|
end
|
105
105
|
|
106
106
|
context 'start_time and end_time arguments', args: {start_time: '8:00', end_time: '14:00'} do
|
107
|
-
it {
|
107
|
+
it { is_expected.to eq(6.hours) }
|
108
108
|
end
|
109
109
|
end
|
110
110
|
|
@@ -112,27 +112,27 @@ describe ScheduleAttributes::Input do
|
|
112
112
|
subject(:dates) { input.dates }
|
113
113
|
|
114
114
|
context 'no arguments', args: {} do
|
115
|
-
it {
|
115
|
+
it { is_expected.to eq([]) }
|
116
116
|
end
|
117
117
|
|
118
118
|
context 'repeat argument', args: {repeat: '0'} do
|
119
|
-
it {
|
119
|
+
it { is_expected.to eq([]) }
|
120
120
|
end
|
121
121
|
|
122
122
|
context 'start_date argument', args: {start_date: '2000-06-06'} do
|
123
|
-
it {
|
123
|
+
it { is_expected.to eq([]) }
|
124
124
|
end
|
125
125
|
|
126
126
|
context 'repeat, date and start_date arguments', args: {repeat: '0', date: '2000-06-06', start_date: '2000-02-03'} do
|
127
|
-
it {
|
127
|
+
it { is_expected.to eq([Time.new(2000,6,6)]) }
|
128
128
|
end
|
129
129
|
|
130
130
|
context 'dates array argument', args: {dates: ['2000-01-02','2000-02-03']} do
|
131
|
-
it {
|
131
|
+
it { is_expected.to eq([Time.new(2000,1,2), Time.new(2000,2,3)]) }
|
132
132
|
end
|
133
133
|
|
134
134
|
context 'repeat, date, start_date and start_time arguments', args: {repeat: '0', date: '2000-06-06', start_date: '2000-06-06', start_time: '12:00'} do
|
135
|
-
it {
|
135
|
+
it { is_expected.to eq([Time.new(2000,6,6,12,0)]) }
|
136
136
|
end
|
137
137
|
end
|
138
138
|
|
@@ -140,7 +140,7 @@ describe ScheduleAttributes::Input do
|
|
140
140
|
subject(:ends) { input.ends? }
|
141
141
|
|
142
142
|
context 'repeat and end_date arguments', args: {repeat: '1', end_date: ''} do
|
143
|
-
it {
|
143
|
+
it { is_expected.to be_falsey }
|
144
144
|
end
|
145
145
|
end
|
146
146
|
|
@@ -148,15 +148,15 @@ describe ScheduleAttributes::Input do
|
|
148
148
|
subject(:yearly_start_month_day) { input.yearly_start_month_day? }
|
149
149
|
|
150
150
|
context 'repeat and yearly_start_month_day arguments', args: {repeat: '1', yearly_start_month_day: '2'} do
|
151
|
-
it {
|
151
|
+
it { is_expected.to be_falsey }
|
152
152
|
end
|
153
153
|
|
154
154
|
context 'repeat, yearly_start_month and yearly_start_month_day arguments', args: {repeat: '1', yearly_start_month: '12', yearly_start_month_day: '2'} do
|
155
|
-
it {
|
155
|
+
it { is_expected.to be_truthy }
|
156
156
|
end
|
157
157
|
|
158
158
|
context 'repeat, yearly_start_month and yearly_start_month_day arguments', args: {repeat: '1', yearly_start_month: '12', yearly_start_month_day: '1'} do
|
159
|
-
it {
|
159
|
+
it { is_expected.to be_falsey }
|
160
160
|
end
|
161
161
|
end
|
162
162
|
|
@@ -164,19 +164,19 @@ describe ScheduleAttributes::Input do
|
|
164
164
|
subject(:yearly_end_month_day) { input.yearly_end_month_day? }
|
165
165
|
|
166
166
|
context 'repeat and yearly_end_month_day arguments', args: {repeat: '1', yearly_end_month_day: '27'} do
|
167
|
-
it {
|
167
|
+
it { is_expected.to be_falsey }
|
168
168
|
end
|
169
169
|
|
170
170
|
context 'repeat, yearly_end_month and yearly_end_month_day arguments', args: {repeat: '1', yearly_end_month: '12', yearly_end_month_day: '27'} do
|
171
|
-
it {
|
171
|
+
it { is_expected.to be_truthy }
|
172
172
|
end
|
173
173
|
|
174
174
|
context 'repeat, yearly_end_month and yearly_end_month_day arguments', args: {repeat: '1', yearly_end_month: '12', yearly_end_month_day: '31'} do
|
175
|
-
it {
|
175
|
+
it { is_expected.to be_falsey }
|
176
176
|
end
|
177
177
|
|
178
178
|
context 'repeat, yearly_end_month and yearly_end_month_day arguments', args: {repeat: '1', yearly_end_month: '11', yearly_end_month_day: '30'} do
|
179
|
-
it {
|
179
|
+
it { is_expected.to be_falsey }
|
180
180
|
end
|
181
181
|
end
|
182
182
|
end
|