simple_pvr 1.0.0 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +1 -0
- data/.ruby-version +1 -0
- data/.travis.yml +1 -4
- data/Gemfile.lock +72 -61
- data/README.md +51 -33
- data/bin/pvr_server +14 -6
- data/changelog.txt +11 -0
- data/development_server +14 -6
- data/features/channel_overview.feature +1 -1
- data/features/recordings.feature +30 -0
- data/features/step_definitions/pvr_steps.rb +34 -0
- data/features/support/env.rb +1 -2
- data/features/support/paths.rb +2 -0
- data/lib/simple_pvr.rb +2 -0
- data/lib/simple_pvr/model/database_initializer.rb +8 -0
- data/lib/simple_pvr/model/programme.rb +12 -2
- data/lib/simple_pvr/model/programme_actor.rb +14 -0
- data/lib/simple_pvr/model/programme_category.rb +14 -0
- data/lib/simple_pvr/model/programme_director.rb +13 -0
- data/lib/simple_pvr/model/programme_presenter.rb +13 -0
- data/lib/simple_pvr/model/recording.rb +12 -0
- data/lib/simple_pvr/programme_icon_fetcher.rb +15 -0
- data/lib/simple_pvr/pvr_initializer.rb +4 -4
- data/lib/simple_pvr/recorder.rb +4 -3
- data/lib/simple_pvr/recording_manager.rb +44 -24
- data/lib/simple_pvr/recording_planner.rb +3 -3
- data/lib/simple_pvr/scheduler.rb +12 -4
- data/lib/simple_pvr/server/base_controller.rb +12 -13
- data/lib/simple_pvr/server/channels_controller.rb +5 -5
- data/lib/simple_pvr/server/programmes_controller.rb +2 -2
- data/lib/simple_pvr/server/schedules_controller.rb +4 -4
- data/lib/simple_pvr/server/secured_controller.rb +71 -0
- data/lib/simple_pvr/server/shows_controller.rb +13 -8
- data/lib/simple_pvr/server/status_controller.rb +1 -1
- data/lib/simple_pvr/server/upcoming_recordings_controller.rb +1 -1
- data/lib/simple_pvr/version.rb +1 -1
- data/lib/simple_pvr/xmltv_reader.rb +37 -4
- data/public/css/typeahead.js-bootstrap.css +83 -0
- data/public/index.html +45 -37
- data/public/js/angular/http-auth-interceptor.js +122 -0
- data/public/js/app.js +4 -37
- data/public/js/controllers.js +22 -14
- data/public/js/directives.js +102 -0
- data/public/js/filters.js +0 -31
- data/public/js/services.js +64 -0
- data/public/js/typeahead/typeahead.min.js +7 -0
- data/public/partials/about.html +15 -13
- data/public/partials/channels.html +41 -36
- data/public/partials/programme.html +20 -4
- data/public/partials/programmeListing.html +14 -13
- data/public/partials/schedule.html +91 -86
- data/public/partials/schedules.html +28 -16
- data/public/partials/search.html +10 -11
- data/public/partials/show.html +26 -9
- data/public/partials/shows.html +5 -6
- data/public/partials/status.html +1 -1
- data/public/templates/loginDialog.html +30 -0
- data/public/templates/logoutLink.html +1 -0
- data/public/templates/titleSearch.html +5 -3
- data/simple_pvr.gemspec +6 -4
- data/spec/resources/dummyImage.png +1 -0
- data/spec/resources/programmes-with-categories.xmltv +27 -0
- data/spec/resources/programmes-with-credits.xmltv +24 -0
- data/spec/resources/programmes-with-icons.xmltv +25 -0
- data/spec/resources/programmes-with-presenters.xmltv +19 -0
- data/spec/resources/{programs-without-icon.xmltv → programmes-without-icon.xmltv} +0 -0
- data/spec/resources/{programs.xmltv → programmes.xmltv} +0 -4
- data/spec/simple_pvr/ffmpeg_spec.rb +24 -22
- data/spec/simple_pvr/hdhomerun_spec.rb +69 -67
- data/spec/simple_pvr/model/channel_spec.rb +101 -101
- data/spec/simple_pvr/model/programme_spec.rb +104 -104
- data/spec/simple_pvr/model/schedule_spec.rb +74 -74
- data/spec/simple_pvr/programme_icon_fetcher_spec.rb +25 -0
- data/spec/simple_pvr/pvr_initializer_spec.rb +40 -38
- data/spec/simple_pvr/recorder_spec.rb +37 -26
- data/spec/simple_pvr/recording_manager_spec.rb +160 -133
- data/spec/simple_pvr/recording_planner_spec.rb +213 -211
- data/spec/simple_pvr/scheduler_spec.rb +189 -172
- data/spec/simple_pvr/server/secured_controller_spec.rb +118 -0
- data/spec/simple_pvr/xmltv_reader_spec.rb +89 -41
- data/test/karma.conf.js +7 -4
- data/test/unit/filtersSpec.js +0 -36
- metadata +79 -63
- data/public/css/bootstrap-responsive.min.css +0 -9
- data/public/css/bootstrap.min.css +0 -9
- data/public/img/glyphicons-halflings-white.png +0 -0
- data/public/img/glyphicons-halflings.png +0 -0
- data/public/js/angular/angular-resource.min.js +0 -10
- data/public/js/angular/angular.min.js +0 -162
- data/public/js/bootstrap/bootstrap.min.js +0 -6
- data/public/js/jquery/jquery.min.js +0 -5
- data/test/lib/angular/angular-mocks.js +0 -1768
@@ -1,221 +1,223 @@
|
|
1
1
|
require 'simple_pvr'
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
Time.stub!(now: Time.local(@next_year, 7, 9, 20, 50))
|
18
|
-
end
|
19
|
-
|
20
|
-
it 'adjusts end time for single programme schedules' do
|
21
|
-
SimplePvr::Model::Programme.create(title: 'Borgias', channel: @dr_k, start_time: @start_time_1, duration: @programme_duration)
|
22
|
-
SimplePvr::Model::Schedule.create(type: :specification, title: 'Borgias', channel: @dr_k, start_time: @start_time_1)
|
23
|
-
@scheduler.should_receive(:recordings=)
|
24
|
-
|
25
|
-
SimplePvr::RecordingPlanner.reload
|
26
|
-
|
27
|
-
schedule = SimplePvr::Model::Schedule.all[0]
|
28
|
-
schedule.end_time.should == @start_time_1 + @programme_duration.seconds + 5.minutes
|
29
|
-
end
|
30
|
-
|
31
|
-
it 'adjusts end time for exceptions' do
|
32
|
-
SimplePvr::Model::Programme.create(title: 'Borgias', channel: @dr_k, start_time: @start_time_1, duration: @programme_duration)
|
33
|
-
SimplePvr::Model::Schedule.create(type: :specification, title: 'Borgias')
|
34
|
-
SimplePvr::Model::Schedule.create(type: :exception, title: 'Borgias', channel: @dr_k, start_time: @start_time_1)
|
35
|
-
@scheduler.should_receive(:recordings=)
|
36
|
-
|
37
|
-
SimplePvr::RecordingPlanner.reload
|
38
|
-
|
39
|
-
schedule = SimplePvr::Model::Schedule.all(type: :exception)[0]
|
40
|
-
schedule.end_time.should == @start_time_1 + @programme_duration.seconds + 5.minutes
|
41
|
-
end
|
42
|
-
|
43
|
-
it 'leaves end time alone for schedules' do
|
44
|
-
SimplePvr::Model::Programme.create(title: 'Borgias', channel: @dr_k, start_time: @start_time_1, duration: @programme_duration)
|
45
|
-
SimplePvr::Model::Schedule.create(type: :specification, title: 'Borgias', channel: @dr_k)
|
46
|
-
@scheduler.should_receive(:recordings=)
|
47
|
-
|
48
|
-
SimplePvr::RecordingPlanner.reload
|
49
|
-
|
50
|
-
schedule = SimplePvr::Model::Schedule.first
|
51
|
-
schedule.end_time.should be_nil
|
52
|
-
end
|
53
|
-
|
54
|
-
it 'cleans up outdated schedules' do
|
55
|
-
SimplePvr::Model::Schedule.should_receive(:cleanup)
|
56
|
-
@scheduler.should_receive(:recordings=).with([])
|
57
|
-
|
58
|
-
SimplePvr::RecordingPlanner.reload
|
59
|
-
end
|
3
|
+
module SimplePvr
|
4
|
+
describe RecordingPlanner do
|
5
|
+
before do
|
6
|
+
Model::DatabaseInitializer.prepare_for_test
|
7
|
+
Model::DatabaseInitializer.clear
|
8
|
+
@dr_1 = Model::Channel.create(name: 'DR 1')
|
9
|
+
@dr_k = Model::Channel.create(name: 'DR K')
|
10
|
+
@next_year = Time.now.year + 1
|
11
|
+
@start_time_1, @start_time_2 = Time.local(@next_year, 7, 10, 20, 50), Time.local(@next_year, 7, 17, 20, 50)
|
12
|
+
@old_start_time = Time.local(@next_year, 8, 10, 20, 50)
|
13
|
+
@programme_duration = 60.minutes.to_i
|
14
|
+
|
15
|
+
@scheduler = double('Scheduler')
|
16
|
+
PvrInitializer.stub(scheduler: @scheduler)
|
60
17
|
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
18
|
+
Time.stub(now: Time.local(@next_year, 7, 9, 20, 50))
|
19
|
+
end
|
20
|
+
|
21
|
+
it 'adjusts end time for single programme schedules' do
|
22
|
+
Model::Programme.create(title: 'Borgias', channel: @dr_k, start_time: @start_time_1, duration: @programme_duration)
|
23
|
+
Model::Schedule.create(type: :specification, title: 'Borgias', channel: @dr_k, start_time: @start_time_1)
|
24
|
+
@scheduler.should_receive(:recordings=)
|
25
|
+
|
26
|
+
RecordingPlanner.reload
|
27
|
+
|
28
|
+
schedule = Model::Schedule.all[0]
|
29
|
+
schedule.end_time.should == @start_time_1 + @programme_duration.seconds + 5.minutes
|
30
|
+
end
|
31
|
+
|
32
|
+
it 'adjusts end time for exceptions' do
|
33
|
+
Model::Programme.create(title: 'Borgias', channel: @dr_k, start_time: @start_time_1, duration: @programme_duration)
|
34
|
+
Model::Schedule.create(type: :specification, title: 'Borgias')
|
35
|
+
Model::Schedule.create(type: :exception, title: 'Borgias', channel: @dr_k, start_time: @start_time_1)
|
36
|
+
@scheduler.should_receive(:recordings=)
|
71
37
|
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
38
|
+
RecordingPlanner.reload
|
39
|
+
|
40
|
+
schedule = Model::Schedule.all(type: :exception)[0]
|
41
|
+
schedule.end_time.should == @start_time_1 + @programme_duration.seconds + 5.minutes
|
42
|
+
end
|
43
|
+
|
44
|
+
it 'leaves end time alone for schedules' do
|
45
|
+
Model::Programme.create(title: 'Borgias', channel: @dr_k, start_time: @start_time_1, duration: @programme_duration)
|
46
|
+
Model::Schedule.create(type: :specification, title: 'Borgias', channel: @dr_k)
|
47
|
+
@scheduler.should_receive(:recordings=)
|
48
|
+
|
49
|
+
RecordingPlanner.reload
|
50
|
+
|
51
|
+
schedule = Model::Schedule.first
|
52
|
+
schedule.end_time.should be_nil
|
53
|
+
end
|
54
|
+
|
55
|
+
it 'cleans up outdated schedules' do
|
56
|
+
Model::Schedule.should_receive(:cleanup)
|
57
|
+
@scheduler.should_receive(:recordings=).with([])
|
58
|
+
|
59
|
+
RecordingPlanner.reload
|
60
|
+
end
|
78
61
|
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
@programme_1 = SimplePvr::Model::Programme.create(title: 'Borgias', channel: @dr_k, start_time: @start_time_1, duration: @programme_duration)
|
62
|
+
it 'resets the recordings when no schedules exist' do
|
63
|
+
Model::Programme.create(title: 'Borgias', channel: @dr_k, start_time: @start_time_1, duration: @programme_duration)
|
64
|
+
Model::Programme.create(title: 'Borgias', channel: @dr_k, start_time: @start_time_2, duration: @programme_duration)
|
65
|
+
Model::Programme.create(title: 'Borgias', channel: @dr_1, start_time: @start_time_2, duration: @programme_duration)
|
66
|
+
Model::Programme.create(title: 'Borgias' + "-", channel: @dr_k, start_time: @start_time_2, duration: @programme_duration)
|
67
|
+
|
68
|
+
@scheduler.should_receive(:recordings=).with([])
|
69
|
+
|
70
|
+
RecordingPlanner.reload
|
71
|
+
end
|
90
72
|
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
@scheduler.should_receive(:recordings=).with([
|
104
|
-
SimplePvr::Model::Recording.new(@dr_k, 'Borgias', @start_time_2.advance(minutes: -2), 2.minutes + @programme_duration + 5.minutes, @programme_to_be_recorded)
|
105
|
-
])
|
106
|
-
|
107
|
-
SimplePvr::RecordingPlanner.reload
|
108
|
-
end
|
109
|
-
|
110
|
-
it 'can set up schedules from programme title only' do
|
111
|
-
SimplePvr::Model::Schedule.create(type: :specification, title: 'Borgias')
|
112
|
-
@programme_1 = SimplePvr::Model::Programme.create(title: 'Borgias', channel: @dr_1, start_time: @start_time_1, duration: @programme_duration)
|
113
|
-
@programme_2 = SimplePvr::Model::Programme.create(title: 'Borgias', channel: @dr_k, start_time: @start_time_2, duration: @programme_duration)
|
114
|
-
SimplePvr::Model::Programme.create(title: 'Irrelevant programme', channel: @dr_k, start_time: @start_time_2, duration: @programme_duration)
|
115
|
-
|
116
|
-
@scheduler.should_receive(:recordings=).with([
|
117
|
-
SimplePvr::Model::Recording.new(@dr_1, 'Borgias', Time.local(@next_year, 7, 10, 20, 48), 67.minutes, @programme_1),
|
118
|
-
SimplePvr::Model::Recording.new(@dr_k, 'Borgias', Time.local(@next_year, 7, 17, 20, 48), 67.minutes, @programme_2)
|
119
|
-
])
|
120
|
-
|
121
|
-
SimplePvr::RecordingPlanner.reload
|
122
|
-
end
|
73
|
+
it 'can set up schedules from channel and programme title' do
|
74
|
+
Model::Schedule.create(type: :specification, title: 'Borgias', channel: @dr_k)
|
75
|
+
@programme_1 = Model::Programme.create(title: 'Borgias', channel: @dr_k, start_time: @start_time_1, duration: @programme_duration)
|
76
|
+
@programme_2 = Model::Programme.create(title: 'Borgias', channel: @dr_k, start_time: @start_time_2, duration: @programme_duration)
|
77
|
+
Model::Programme.create(title: 'Borgias', channel: @dr_1, start_time: @start_time_2, duration: @programme_duration)
|
78
|
+
Model::Programme.create(title: 'Irrelevant programme', channel: @dr_k, start_time: @start_time_2, duration: @programme_duration)
|
79
|
+
|
80
|
+
@scheduler.should_receive(:recordings=).with([
|
81
|
+
Model::Recording.new(@dr_k, 'Borgias', Time.local(@next_year, 7, 10, 20, 48), 67.minutes, @programme_1),
|
82
|
+
Model::Recording.new(@dr_k, 'Borgias', Time.local(@next_year, 7, 17, 20, 48), 67.minutes, @programme_2)
|
83
|
+
])
|
123
84
|
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
85
|
+
RecordingPlanner.reload
|
86
|
+
end
|
87
|
+
|
88
|
+
it 'takes the start early and end late minutes from schedule' do
|
89
|
+
Model::Schedule.create(type: :specification, title: 'Borgias', channel: @dr_k, custom_start_early_minutes: 4, custom_end_late_minutes: 10)
|
90
|
+
@programme_1 = Model::Programme.create(title: 'Borgias', channel: @dr_k, start_time: @start_time_1, duration: @programme_duration)
|
91
|
+
|
92
|
+
@scheduler.should_receive(:recordings=).with([
|
93
|
+
Model::Recording.new(@dr_k, 'Borgias', Time.local(@next_year, 7, 10, 20, 46), 74.minutes, @programme_1),
|
94
|
+
])
|
95
|
+
|
96
|
+
RecordingPlanner.reload
|
97
|
+
end
|
98
|
+
|
99
|
+
it 'can set up schedules from channel, programme title, and start time' do
|
100
|
+
Model::Schedule.create(type: :specification, title: 'Borgias', channel: @dr_k, start_time: @start_time_2)
|
101
|
+
Model::Programme.create(title: 'Borgias', channel:@dr_k, start_time: @start_time_1, duration: @programme_duration)
|
102
|
+
@programme_to_be_recorded = Model::Programme.create(title: 'Borgias', channel:@dr_k, start_time: @start_time_2, duration: @programme_duration)
|
103
|
+
|
104
|
+
@scheduler.should_receive(:recordings=).with([
|
105
|
+
Model::Recording.new(@dr_k, 'Borgias', @start_time_2.advance(minutes: -2), 2.minutes + @programme_duration + 5.minutes, @programme_to_be_recorded)
|
106
|
+
])
|
107
|
+
|
108
|
+
RecordingPlanner.reload
|
109
|
+
end
|
110
|
+
|
111
|
+
it 'can set up schedules from programme title only' do
|
112
|
+
Model::Schedule.create(type: :specification, title: 'Borgias')
|
113
|
+
@programme_1 = Model::Programme.create(title: 'Borgias', channel: @dr_1, start_time: @start_time_1, duration: @programme_duration)
|
114
|
+
@programme_2 = Model::Programme.create(title: 'Borgias', channel: @dr_k, start_time: @start_time_2, duration: @programme_duration)
|
115
|
+
Model::Programme.create(title: 'Irrelevant programme', channel: @dr_k, start_time: @start_time_2, duration: @programme_duration)
|
116
|
+
|
117
|
+
@scheduler.should_receive(:recordings=).with([
|
118
|
+
Model::Recording.new(@dr_1, 'Borgias', Time.local(@next_year, 7, 10, 20, 48), 67.minutes, @programme_1),
|
119
|
+
Model::Recording.new(@dr_k, 'Borgias', Time.local(@next_year, 7, 17, 20, 48), 67.minutes, @programme_2)
|
120
|
+
])
|
121
|
+
|
122
|
+
RecordingPlanner.reload
|
123
|
+
end
|
143
124
|
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
125
|
+
it 'can set up schedules for specific days of the week' do
|
126
|
+
@monday = Time.local(2012, 12, 10, 20, 50)
|
127
|
+
@tuesday, @wednesday, @thursday, @friday, @saturday, @sunday = @monday + 1.day, @monday + 2.days, @monday + 3.days, @monday + 4.days, @monday + 5.days, @monday + 6.days
|
128
|
+
@monday_programme = Model::Programme.create(title: 'Borgias', channel: @dr_1, start_time: @monday, duration: @programme_duration)
|
129
|
+
@tuesday_programme = Model::Programme.create(title: 'Borgias', channel: @dr_1, start_time: @tuesday, duration: @programme_duration)
|
130
|
+
@wednesday_programme = Model::Programme.create(title: 'Borgias', channel: @dr_1, start_time: @wednesday, duration: @programme_duration)
|
131
|
+
@thursday_programme = Model::Programme.create(title: 'Borgias', channel: @dr_1, start_time: @thursday, duration: @programme_duration)
|
132
|
+
@friday_programme = Model::Programme.create(title: 'Borgias', channel: @dr_1, start_time: @friday, duration: @programme_duration)
|
133
|
+
@saturday_programme = Model::Programme.create(title: 'Borgias', channel: @dr_1, start_time: @saturday, duration: @programme_duration)
|
134
|
+
@sunday_programme = Model::Programme.create(title: 'Borgias', channel: @dr_1, start_time: @sunday, duration: @programme_duration)
|
135
|
+
|
136
|
+
Model::Schedule.create(type: :specification, title: 'Borgias', filter_by_weekday: true, monday: false, tuesday: true, wednesday: true, thursday: false, friday: false, saturday: true, sunday: true)
|
137
|
+
|
138
|
+
@scheduler.should_receive(:recordings=).with([
|
139
|
+
Model::Recording.new(@dr_1, 'Borgias', @tuesday - 2.minutes, 67.minutes, @tuesday_programme),
|
140
|
+
Model::Recording.new(@dr_1, 'Borgias', @wednesday - 2.minutes, 67.minutes, @wednesday_programme),
|
141
|
+
Model::Recording.new(@dr_1, 'Borgias', @saturday - 2.minutes, 67.minutes, @saturday_programme),
|
142
|
+
Model::Recording.new(@dr_1, 'Borgias', @sunday - 2.minutes, 67.minutes, @sunday_programme),
|
143
|
+
])
|
144
|
+
|
145
|
+
RecordingPlanner.reload
|
146
|
+
end
|
147
|
+
|
148
|
+
it 'can set up schedules for programmes starting before specific time of day' do
|
149
|
+
@early_programme = Model::Programme.create(title: 'Borgias', channel: @dr_1, start_time: Time.local(2012, 12, 12, 9, 30), duration: @programme_duration)
|
150
|
+
@late_programme = Model::Programme.create(title: 'Borgias', channel: @dr_1, start_time: Time.local(2012, 12, 12, 17, 0), duration: @programme_duration)
|
151
|
+
@too_late_programme = Model::Programme.create(title: 'Borgias', channel: @dr_1, start_time: Time.local(2012, 12, 12, 17, 01), duration: @programme_duration)
|
152
|
+
|
153
|
+
Model::Schedule.create(type: :specification, title: 'Borgias', filter_by_time_of_day: true, to_time_of_day: '17:00')
|
154
|
+
|
155
|
+
@scheduler.should_receive(:recordings=).with([
|
156
|
+
Model::Recording.new(@dr_1, 'Borgias', @early_programme.start_time - 2.minutes, 67.minutes, @early_programme),
|
157
|
+
Model::Recording.new(@dr_1, 'Borgias', @late_programme.start_time - 2.minutes, 67.minutes, @late_programme)
|
158
|
+
])
|
159
|
+
|
160
|
+
RecordingPlanner.reload
|
161
|
+
end
|
162
|
+
|
163
|
+
it 'can set up schedules for programmes starting after a specific time of day' do
|
164
|
+
@too_early_programme = Model::Programme.create(title: 'Borgias', channel: @dr_1, start_time: Time.local(2012, 12, 12, 16, 59), duration: @programme_duration)
|
165
|
+
@early_programme = Model::Programme.create(title: 'Borgias', channel: @dr_1, start_time: Time.local(2012, 12, 12, 17, 0), duration: @programme_duration)
|
166
|
+
@late_programme = Model::Programme.create(title: 'Borgias', channel: @dr_1, start_time: Time.local(2012, 12, 12, 19, 30), duration: @programme_duration)
|
167
|
+
|
168
|
+
Model::Schedule.create(type: :specification, title: 'Borgias', filter_by_time_of_day: true, from_time_of_day: '17:00')
|
169
|
+
|
170
|
+
@scheduler.should_receive(:recordings=).with([
|
171
|
+
Model::Recording.new(@dr_1, 'Borgias', @early_programme.start_time - 2.minutes, 67.minutes, @early_programme),
|
172
|
+
Model::Recording.new(@dr_1, 'Borgias', @late_programme.start_time - 2.minutes, 67.minutes, @late_programme)
|
173
|
+
])
|
174
|
+
|
175
|
+
RecordingPlanner.reload
|
176
|
+
end
|
177
|
+
|
178
|
+
it 'can set up schedules for programmes starting in certain interval during day' do
|
179
|
+
@too_early_programme = Model::Programme.create(title: 'Borgias', channel: @dr_1, start_time: Time.local(2012, 12, 12, 16, 59), duration: @programme_duration)
|
180
|
+
@early_programme = Model::Programme.create(title: 'Borgias', channel: @dr_1, start_time: Time.local(2012, 12, 12, 17, 0), duration: @programme_duration)
|
181
|
+
@late_programme = Model::Programme.create(title: 'Borgias', channel: @dr_1, start_time: Time.local(2012, 12, 12, 19, 0), duration: @programme_duration)
|
182
|
+
@too_late_programme = Model::Programme.create(title: 'Borgias', channel: @dr_1, start_time: Time.local(2012, 12, 12, 19, 1), duration: @programme_duration)
|
183
|
+
|
184
|
+
Model::Schedule.create(type: :specification, title: 'Borgias', filter_by_time_of_day: true, from_time_of_day: '17:00', to_time_of_day: '19:00')
|
185
|
+
|
186
|
+
@scheduler.should_receive(:recordings=).with([
|
187
|
+
Model::Recording.new(@dr_1, 'Borgias', @early_programme.start_time - 2.minutes, 67.minutes, @early_programme),
|
188
|
+
Model::Recording.new(@dr_1, 'Borgias', @late_programme.start_time - 2.minutes, 67.minutes, @late_programme)
|
189
|
+
])
|
190
|
+
|
191
|
+
RecordingPlanner.reload
|
192
|
+
end
|
193
|
+
|
194
|
+
it 'can set up schedules for programmes starting in certain intervals during day, stretching across midnight' do
|
195
|
+
@too_early_programme = Model::Programme.create(title: 'Borgias', channel: @dr_1, start_time: Time.local(2012, 12, 12, 16, 59), duration: @programme_duration)
|
196
|
+
@early_programme = Model::Programme.create(title: 'Borgias', channel: @dr_1, start_time: Time.local(2012, 12, 12, 17, 0), duration: @programme_duration)
|
197
|
+
@late_programme = Model::Programme.create(title: 'Borgias', channel: @dr_1, start_time: Time.local(2012, 12, 13, 5, 0), duration: @programme_duration)
|
198
|
+
@too_late_programme = Model::Programme.create(title: 'Borgias', channel: @dr_1, start_time: Time.local(2012, 12, 13, 5, 1), duration: @programme_duration)
|
199
|
+
|
200
|
+
Model::Schedule.create(type: :specification, title: 'Borgias', filter_by_time_of_day: true, from_time_of_day: '17:00', to_time_of_day: '5:00')
|
201
|
+
|
202
|
+
@scheduler.should_receive(:recordings=).with([
|
203
|
+
Model::Recording.new(@dr_1, 'Borgias', @early_programme.start_time - 2.minutes, 67.minutes, @early_programme),
|
204
|
+
Model::Recording.new(@dr_1, 'Borgias', @late_programme.start_time - 2.minutes, 67.minutes, @late_programme)
|
205
|
+
])
|
206
|
+
|
207
|
+
RecordingPlanner.reload
|
208
|
+
end
|
209
|
+
|
210
|
+
it 'ignores programmes for which exceptions exist' do
|
211
|
+
Model::Schedule.create(type: :specification, title: 'Borgias')
|
212
|
+
Model::Schedule.create(type: :exception, title: 'Borgias', channel: @dr_1, start_time: @start_time_1)
|
213
|
+
Model::Programme.create(title: 'Borgias', channel: @dr_1, start_time: @start_time_1, duration: @programme_duration)
|
214
|
+
@programme_to_be_recorded = Model::Programme.create(title: 'Borgias', channel: @dr_k, start_time: @start_time_2, duration: @programme_duration)
|
215
|
+
|
216
|
+
@scheduler.should_receive(:recordings=).with([
|
217
|
+
Model::Recording.new(@dr_k, 'Borgias', Time.local(@next_year, 7, 17, 20, 48), 67.minutes, @programme_to_be_recorded)
|
218
|
+
])
|
219
|
+
|
220
|
+
RecordingPlanner.reload
|
221
|
+
end
|
220
222
|
end
|
221
223
|
end
|
@@ -1,201 +1,218 @@
|
|
1
1
|
require 'simple_pvr'
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
3
|
+
module SimplePvr
|
4
|
+
describe Scheduler do
|
5
|
+
before do
|
6
|
+
@channel = double('Channel DR K', name: 'DR K', frequency: 282000000, channel_id: 1098)
|
7
|
+
@channel_dr1 = double('Channel DR 1', name: 'DR 1', frequency: 290000000, channel_id: 1099)
|
8
|
+
|
9
|
+
@scheduler = Scheduler.new
|
10
|
+
end
|
7
11
|
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
it 'leaves recordings that are in the future' do
|
12
|
-
start_time = Time.local(2012, 7, 15, 20, 15, 30)
|
13
|
-
Time.stub(:now => start_time.advance(hours: -1))
|
14
|
-
|
15
|
-
@scheduler.recordings = [SimplePvr::Model::Recording.new(@channel, 'Borgia', start_time, 60.minutes)]
|
16
|
-
@scheduler.process
|
17
|
-
end
|
12
|
+
it 'leaves recordings that are in the future' do
|
13
|
+
start_time = Time.local(2012, 7, 15, 20, 15, 30)
|
14
|
+
Time.stub(:now => start_time.advance(hours: -1))
|
18
15
|
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
third_start_time = Time.now.advance(days: 1, minutes: 20)
|
23
|
-
fourth_start_time = Time.now.advance(days: 2)
|
24
|
-
first_recording = SimplePvr::Model::Recording.new(@channel, 'Borgia', first_start_time, 60.minutes)
|
25
|
-
second_recording = SimplePvr::Model::Recording.new(@channel, 'Borgia', second_start_time, 60.minutes)
|
26
|
-
third_recording = SimplePvr::Model::Recording.new(@channel, 'Borgia', third_start_time, 60.minutes)
|
27
|
-
fourth_recording = SimplePvr::Model::Recording.new(@channel, 'Borgia', fourth_start_time, 60.minutes)
|
28
|
-
|
29
|
-
@scheduler.recordings = [first_recording, third_recording, second_recording]
|
16
|
+
@scheduler.recordings = [Model::Recording.new(@channel, 'Borgia', start_time, 60.minutes)]
|
17
|
+
@scheduler.process
|
18
|
+
end
|
30
19
|
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
Time.stub(:now => start_time)
|
41
|
-
SimplePvr::Recorder.stub(:new).with(0, starting_recording).and_return(@recorder = double('Recorder'))
|
42
|
-
@recorder.should_receive(:start!)
|
43
|
-
|
44
|
-
@scheduler.recordings = [starting_recording]
|
45
|
-
@scheduler.process
|
46
|
-
end
|
47
|
-
|
48
|
-
it 'starts recordings that are in progress' do
|
49
|
-
start_time = Time.local(2012, 7, 15, 20, 15, 30)
|
50
|
-
recording_in_progress = SimplePvr::Model::Recording.new(@channel, 'Borgia', start_time, 60.minutes)
|
51
|
-
Time.stub(:now => start_time.advance(minutes: 30))
|
52
|
-
SimplePvr::Recorder.stub(:new).with(0, recording_in_progress).and_return(@recorder = double('Recorder'))
|
53
|
-
@recorder.should_receive(:start!)
|
54
|
-
|
55
|
-
@scheduler.recordings = [recording_in_progress]
|
56
|
-
@scheduler.process
|
57
|
-
end
|
58
|
-
|
59
|
-
it 'can start two recordings at once' do
|
60
|
-
first_start_time = Time.local(2012, 7, 15, 19, 45, 30)
|
61
|
-
second_start_time = Time.local(2012, 7, 15, 20, 15, 30)
|
62
|
-
recording_in_progress = SimplePvr::Model::Recording.new(@channel, 'Borgia', first_start_time, 60.minutes)
|
63
|
-
starting_recording = SimplePvr::Model::Recording.new(@channel, 'Borgia', second_start_time, 60.minutes)
|
64
|
-
Time.stub(:now => second_start_time)
|
65
|
-
SimplePvr::Recorder.stub(:new).with(0, recording_in_progress).and_return(@recorder0 = double('Recorder'))
|
66
|
-
SimplePvr::Recorder.stub(:new).with(1, starting_recording).and_return(@recorder1 = double('Recorder'))
|
67
|
-
@recorder0.should_receive(:start!)
|
68
|
-
@recorder1.should_receive(:start!)
|
69
|
-
|
70
|
-
@scheduler.recordings = [recording_in_progress, starting_recording]
|
71
|
-
@scheduler.process
|
72
|
-
end
|
20
|
+
it 'marks conflicting future recordings' do
|
21
|
+
first_start_time = Time.now.advance(days: 1)
|
22
|
+
second_start_time = Time.now.advance(days: 1, minutes: 10)
|
23
|
+
third_start_time = Time.now.advance(days: 1, minutes: 20)
|
24
|
+
fourth_start_time = Time.now.advance(days: 2)
|
25
|
+
first_recording = Model::Recording.new(@channel, 'Borgia', first_start_time, 60.minutes)
|
26
|
+
second_recording = Model::Recording.new(@channel, 'Borgia', second_start_time, 60.minutes)
|
27
|
+
third_recording = Model::Recording.new(@channel, 'Borgia', third_start_time, 60.minutes)
|
28
|
+
fourth_recording = Model::Recording.new(@channel, 'Borgia', fourth_start_time, 60.minutes)
|
73
29
|
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
Time.stub(:now => second_start_time)
|
82
|
-
SimplePvr::Recorder.stub(:new).with(0, recording_in_progress).and_return(@recorder0 = double('Recorder'))
|
83
|
-
SimplePvr::Recorder.stub(:new).with(1, starting_recording).and_return(@recorder1 = double('Recorder'))
|
84
|
-
@recorder0.should_receive(:start!)
|
85
|
-
@recorder1.should_receive(:start!)
|
86
|
-
|
87
|
-
@scheduler.recordings = [recording_in_progress, starting_recording, rejected_recording]
|
88
|
-
@scheduler.process
|
30
|
+
@scheduler.recordings = [first_recording, third_recording, second_recording]
|
31
|
+
|
32
|
+
first_recording.should_not be_conflicting
|
33
|
+
second_recording.should_not be_conflicting
|
34
|
+
third_recording.should be_conflicting
|
35
|
+
fourth_recording.should_not be_conflicting
|
36
|
+
end
|
89
37
|
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
start_time = Time.local(2012, 7, 15, 20, 15, 30)
|
97
|
-
ending_recording = SimplePvr::Model::Recording.new(@channel, 'Borgia', start_time, 60.minutes)
|
98
|
-
SimplePvr::Recorder.stub(:new).with(0, ending_recording).and_return(@recorder = double('Recorder'))
|
99
|
-
@recorder.should_receive(:start!)
|
100
|
-
Time.stub(:now => start_time)
|
101
|
-
|
102
|
-
@scheduler.recordings = [ending_recording]
|
103
|
-
@scheduler.process
|
104
|
-
|
105
|
-
@recorder.should_receive(:stop!)
|
106
|
-
Time.stub(:now => start_time.advance(hours: 1, minutes: 1))
|
107
|
-
|
108
|
-
@scheduler.process
|
109
|
-
end
|
38
|
+
it 'starts recordings at start time' do
|
39
|
+
start_time = Time.local(2012, 7, 15, 20, 15, 30)
|
40
|
+
starting_recording = Model::Recording.new(@channel, 'Borgia', start_time, 60.minutes)
|
41
|
+
Time.stub(:now => start_time)
|
42
|
+
Recorder.stub(:new).with(0, starting_recording).and_return(@recorder = double('Recorder'))
|
43
|
+
@recorder.should_receive(:start!)
|
110
44
|
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
Time.stub(:now => start_time)
|
45
|
+
@scheduler.recordings = [starting_recording]
|
46
|
+
@scheduler.process
|
47
|
+
end
|
115
48
|
|
116
|
-
|
117
|
-
@scheduler.process
|
118
|
-
end
|
119
|
-
|
120
|
-
it 'knows which programmes are being recorded' do
|
121
|
-
start_time = Time.local(2012, 7, 15, 20, 15, 30)
|
122
|
-
Time.stub(:now => start_time.advance(hours: -1))
|
123
|
-
scheduled_programme = double(id: 2)
|
124
|
-
unscheduled_programme = double(id: 3)
|
125
|
-
|
126
|
-
@scheduler.recordings = [SimplePvr::Model::Recording.new(@channel, 'Borgia', start_time, 60.minutes, scheduled_programme)]
|
127
|
-
@scheduler.scheduled?(scheduled_programme).should be_true
|
128
|
-
@scheduler.scheduled?(unscheduled_programme).should be_false
|
129
|
-
end
|
130
|
-
|
131
|
-
it 'gives idle status when nothing is recording' do
|
132
|
-
@scheduler.recordings = []
|
133
|
-
@scheduler.process
|
134
|
-
|
135
|
-
@scheduler.status_text.should == 'Idle'
|
136
|
-
end
|
137
|
-
|
138
|
-
it 'gives recording status when recording' do
|
139
|
-
start_time = Time.local(2012, 7, 15, 20, 15, 30)
|
140
|
-
Time.stub(:now => start_time.advance(minutes: 30))
|
141
|
-
SimplePvr::Recorder.stub(new: (@recorder = double('Recorder')))
|
142
|
-
@recorder.stub(:start!)
|
143
|
-
|
144
|
-
@scheduler.recordings = [SimplePvr::Model::Recording.new(@channel, 'Borgia', start_time, 60.minutes)]
|
145
|
-
@scheduler.process
|
146
|
-
|
147
|
-
@scheduler.status_text.should == "Recording 'Borgia' on channel 'DR K'"
|
148
|
-
end
|
149
|
-
|
150
|
-
context 'when updating existing recordings' do
|
151
|
-
it 'leaves running recording if new recording is equal' do
|
49
|
+
it 'starts recordings that are in progress' do
|
152
50
|
start_time = Time.local(2012, 7, 15, 20, 15, 30)
|
153
|
-
|
154
|
-
Time.stub(:now => start_time)
|
155
|
-
|
51
|
+
recording_in_progress = Model::Recording.new(@channel, 'Borgia', start_time, 60.minutes)
|
52
|
+
Time.stub(:now => start_time.advance(minutes: 30))
|
53
|
+
Recorder.stub(:new).with(0, recording_in_progress).and_return(@recorder = double('Recorder'))
|
156
54
|
@recorder.should_receive(:start!)
|
157
|
-
|
158
|
-
@scheduler.recordings = [
|
55
|
+
|
56
|
+
@scheduler.recordings = [recording_in_progress]
|
159
57
|
@scheduler.process
|
160
|
-
|
161
|
-
|
58
|
+
end
|
59
|
+
|
60
|
+
it 'can start two recordings at once' do
|
61
|
+
first_start_time = Time.local(2012, 7, 15, 19, 45, 30)
|
62
|
+
second_start_time = Time.local(2012, 7, 15, 20, 15, 30)
|
63
|
+
recording_in_progress = Model::Recording.new(@channel, 'Borgia', first_start_time, 60.minutes)
|
64
|
+
starting_recording = Model::Recording.new(@channel, 'Borgia', second_start_time, 60.minutes)
|
65
|
+
Time.stub(:now => second_start_time)
|
66
|
+
Recorder.stub(:new).with(0, recording_in_progress).and_return(@recorder0 = double('Recorder'))
|
67
|
+
Recorder.stub(:new).with(1, starting_recording).and_return(@recorder1 = double('Recorder'))
|
68
|
+
@recorder0.should_receive(:start!)
|
69
|
+
@recorder1.should_receive(:start!)
|
70
|
+
|
71
|
+
@scheduler.recordings = [recording_in_progress, starting_recording]
|
72
|
+
@scheduler.process
|
73
|
+
end
|
74
|
+
|
75
|
+
it 'rejects third recording at once, and marks the third recording as conflicting' do
|
76
|
+
first_start_time = Time.local(2012, 7, 15, 19, 45, 30)
|
77
|
+
second_start_time = Time.local(2012, 7, 15, 20, 15, 30)
|
78
|
+
third_start_time = Time.local(2012, 7, 15, 20, 20, 0)
|
79
|
+
recording_in_progress = Model::Recording.new(@channel, 'Borgia', first_start_time, 60.minutes)
|
80
|
+
starting_recording = Model::Recording.new(@channel, 'Borgia', second_start_time, 60.minutes)
|
81
|
+
rejected_recording = Model::Recording.new(@channel, 'Borgia', third_start_time, 60.minutes)
|
82
|
+
Time.stub(:now => second_start_time)
|
83
|
+
Recorder.stub(:new).with(0, recording_in_progress).and_return(@recorder0 = double('Recorder'))
|
84
|
+
Recorder.stub(:new).with(1, starting_recording).and_return(@recorder1 = double('Recorder'))
|
85
|
+
@recorder0.should_receive(:start!)
|
86
|
+
@recorder1.should_receive(:start!)
|
87
|
+
|
88
|
+
@scheduler.recordings = [recording_in_progress, starting_recording, rejected_recording]
|
162
89
|
@scheduler.process
|
90
|
+
|
91
|
+
recording_in_progress.should_not be_conflicting
|
92
|
+
starting_recording.should_not be_conflicting
|
93
|
+
rejected_recording.should be_conflicting
|
163
94
|
end
|
164
95
|
|
165
|
-
it '
|
96
|
+
it 'ends recordings at end time' do
|
166
97
|
start_time = Time.local(2012, 7, 15, 20, 15, 30)
|
167
|
-
|
168
|
-
|
169
|
-
Time.stub(:now => start_time)
|
170
|
-
SimplePvr::Recorder.stub(:new).with(0, stopping_recording).and_return(@recorder = double('Recorder'))
|
98
|
+
ending_recording = Model::Recording.new(@channel, 'Borgia', start_time, 60.minutes)
|
99
|
+
Recorder.stub(:new).with(0, ending_recording).and_return(@recorder = double('Recorder'))
|
171
100
|
@recorder.should_receive(:start!)
|
172
|
-
|
173
|
-
|
101
|
+
Time.stub(:now => start_time)
|
102
|
+
|
103
|
+
@scheduler.recordings = [ending_recording]
|
174
104
|
@scheduler.process
|
175
|
-
|
105
|
+
|
176
106
|
@recorder.should_receive(:stop!)
|
177
|
-
|
178
|
-
|
107
|
+
Time.stub(:now => start_time.advance(hours: 1, minutes: 1))
|
108
|
+
|
179
109
|
@scheduler.process
|
180
110
|
end
|
181
111
|
|
182
|
-
it '
|
112
|
+
it 'skips recordings that have passed' do
|
183
113
|
start_time = Time.local(2012, 7, 15, 20, 15, 30)
|
184
|
-
|
185
|
-
starting_recording = SimplePvr::Model::Recording.new(@channel_dr1, 'Sports', start_time, 60.minutes)
|
114
|
+
passed_recording = Model::Recording.new(@channel, 'Borgia', start_time - 65.minutes, 60.minutes)
|
186
115
|
Time.stub(:now => start_time)
|
187
|
-
|
188
|
-
|
189
|
-
@old_recorder.should_receive(:start!)
|
190
|
-
|
191
|
-
@scheduler.recordings = [stopping_recording]
|
116
|
+
|
117
|
+
@scheduler.recordings = [passed_recording]
|
192
118
|
@scheduler.process
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
119
|
+
end
|
120
|
+
|
121
|
+
it 'knows which programmes are being recorded' do
|
122
|
+
start_time = Time.local(2012, 7, 15, 20, 15, 30)
|
123
|
+
Time.stub(:now => start_time.advance(hours: -1))
|
124
|
+
scheduled_programme = double(id: 2)
|
125
|
+
unscheduled_programme = double(id: 3)
|
126
|
+
|
127
|
+
@scheduler.recordings = [Model::Recording.new(@channel, 'Borgia', start_time, 60.minutes, scheduled_programme)]
|
128
|
+
@scheduler.scheduled?(scheduled_programme).should be_true
|
129
|
+
@scheduler.scheduled?(unscheduled_programme).should be_false
|
130
|
+
end
|
131
|
+
|
132
|
+
it 'gives idle status when nothing is recording' do
|
133
|
+
@scheduler.recordings = []
|
134
|
+
@scheduler.process
|
135
|
+
|
136
|
+
@scheduler.status_text.should == 'Idle'
|
137
|
+
end
|
138
|
+
|
139
|
+
it 'gives recording status when recording' do
|
140
|
+
start_time = Time.local(2012, 7, 15, 20, 15, 30)
|
141
|
+
Time.stub(:now => start_time.advance(minutes: 30))
|
142
|
+
Recorder.stub(new: (@recorder = double('Recorder')))
|
143
|
+
@recorder.stub(:start!)
|
144
|
+
|
145
|
+
@scheduler.recordings = [Model::Recording.new(@channel, 'Borgia', start_time, 60.minutes)]
|
198
146
|
@scheduler.process
|
147
|
+
|
148
|
+
@scheduler.status_text.should == "Recording 'Borgia' on channel 'DR K'"
|
149
|
+
end
|
150
|
+
|
151
|
+
context 'when updating existing recordings' do
|
152
|
+
it 'leaves running recording if new recording is equal' do
|
153
|
+
start_time = Time.local(2012, 7, 15, 20, 15, 30)
|
154
|
+
continuing_recording = Model::Recording.new(@channel, 'Borgia', start_time, 60.minutes)
|
155
|
+
Time.stub(:now => start_time)
|
156
|
+
Recorder.stub(:new).with(0, continuing_recording).and_return(@recorder = double('Recorder'))
|
157
|
+
@recorder.should_receive(:start!)
|
158
|
+
|
159
|
+
@scheduler.recordings = [continuing_recording]
|
160
|
+
@scheduler.process
|
161
|
+
|
162
|
+
@scheduler.recordings = [Model::Recording.new(@channel, 'Borgia', start_time, 60.minutes)]
|
163
|
+
@scheduler.process
|
164
|
+
end
|
165
|
+
|
166
|
+
it 'replaces underlying information for running recording if new recording has same name, channel, and start time' do
|
167
|
+
old_programme, new_programme = Model::Programme.new, Model::Programme.new
|
168
|
+
start_time = Time.local(2012, 7, 15, 20, 15, 30)
|
169
|
+
continuing_recording = Model::Recording.new(@channel, 'Borgia', start_time, 60.minutes, old_programme)
|
170
|
+
Time.stub(:now => start_time)
|
171
|
+
Recorder.should_receive(:new).with(0, continuing_recording).and_return(@recorder = double('Recorder 1'))
|
172
|
+
@recorder.should_receive(:start!)
|
173
|
+
|
174
|
+
@scheduler.recordings = [continuing_recording]
|
175
|
+
@scheduler.process
|
176
|
+
|
177
|
+
@scheduler.recordings = [Model::Recording.new(@channel, 'Borgia', start_time, 55.minutes, new_programme)]
|
178
|
+
@scheduler.process
|
179
|
+
end
|
180
|
+
|
181
|
+
it 'stops existing recording if not present in new recording list' do
|
182
|
+
start_time = Time.local(2012, 7, 15, 20, 15, 30)
|
183
|
+
stopping_recording = Model::Recording.new(@channel, 'Borgia', start_time, 60.minutes)
|
184
|
+
upcoming_recording = Model::Recording.new(@channel, 'Borgia', start_time + 10.minutes, 60.minutes)
|
185
|
+
Time.stub(:now => start_time)
|
186
|
+
Recorder.stub(:new).with(0, stopping_recording).and_return(@recorder = double('Recorder'))
|
187
|
+
@recorder.should_receive(:start!)
|
188
|
+
|
189
|
+
@scheduler.recordings = [stopping_recording]
|
190
|
+
@scheduler.process
|
191
|
+
|
192
|
+
@recorder.should_receive(:stop!)
|
193
|
+
|
194
|
+
@scheduler.recordings = [upcoming_recording]
|
195
|
+
@scheduler.process
|
196
|
+
end
|
197
|
+
|
198
|
+
it 'stops existing recording and starts new recording if new recording list has other current recording' do
|
199
|
+
start_time = Time.local(2012, 7, 15, 20, 15, 30)
|
200
|
+
stopping_recording = Model::Recording.new(@channel, 'Borgia', start_time, 60.minutes)
|
201
|
+
starting_recording = Model::Recording.new(@channel_dr1, 'Sports', start_time, 60.minutes)
|
202
|
+
Time.stub(:now => start_time)
|
203
|
+
Recorder.stub(:new).with(0, stopping_recording).and_return(@old_recorder = double('Recorder'))
|
204
|
+
Recorder.stub(:new).with(0, starting_recording).and_return(@new_recorder = double('New recorder'))
|
205
|
+
@old_recorder.should_receive(:start!)
|
206
|
+
|
207
|
+
@scheduler.recordings = [stopping_recording]
|
208
|
+
@scheduler.process
|
209
|
+
|
210
|
+
@old_recorder.should_receive(:stop!)
|
211
|
+
@new_recorder.should_receive(:start!)
|
212
|
+
|
213
|
+
@scheduler.recordings = [starting_recording]
|
214
|
+
@scheduler.process
|
215
|
+
end
|
199
216
|
end
|
200
217
|
end
|
201
218
|
end
|