bigbluebutton_rails 1.4.0 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.ruby-version +1 -1
- data/.travis.yml +10 -1
- data/CHANGELOG.md +259 -0
- data/Gemfile +14 -19
- data/Gemfile.lock +194 -188
- data/README.md +416 -0
- data/Rakefile +12 -12
- data/TODO.md +13 -0
- data/app/controllers/bigbluebutton/playback_types_controller.rb +44 -0
- data/app/controllers/bigbluebutton/recordings_controller.rb +17 -10
- data/app/controllers/bigbluebutton/rooms_controller.rb +65 -36
- data/app/controllers/bigbluebutton/servers_controller.rb +12 -8
- data/app/models/bigbluebutton_metadata.rb +1 -1
- data/app/models/bigbluebutton_playback_format.rb +22 -1
- data/app/models/bigbluebutton_playback_type.rb +29 -0
- data/app/models/bigbluebutton_recording.rb +38 -19
- data/app/models/bigbluebutton_room.rb +150 -73
- data/app/models/bigbluebutton_room_options.rb +10 -7
- data/app/models/bigbluebutton_server.rb +69 -13
- data/app/models/bigbluebutton_server_config.rb +49 -0
- data/app/views/bigbluebutton/recordings/_form.html.erb +4 -0
- data/app/views/bigbluebutton/recordings/_recordings.html.erb +10 -3
- data/app/views/bigbluebutton/rooms/_form.html.erb +18 -6
- data/app/views/bigbluebutton/rooms/_rooms.html.erb +6 -3
- data/app/views/bigbluebutton/rooms/invite.html.erb +5 -5
- data/app/views/bigbluebutton/rooms/show.html.erb +18 -6
- data/app/views/bigbluebutton/servers/_form.html.erb +1 -1
- data/app/views/bigbluebutton/servers/show.html.erb +5 -0
- data/app/workers/bigbluebutton_finish_meetings.rb +11 -0
- data/app/workers/bigbluebutton_update_recordings.rb +11 -0
- data/app/workers/bigbluebutton_update_server_configs.rb +18 -0
- data/bigbluebutton_rails.gemspec +8 -7
- data/config/locales/en.yml +52 -7
- data/config/locales/pt-br.yml +162 -0
- data/config/resque/resque.rake +27 -0
- data/config/resque/workers_schedule.yml +17 -0
- data/lib/bigbluebutton_rails.rb +30 -2
- data/lib/bigbluebutton_rails/background_tasks.rb +31 -0
- data/lib/bigbluebutton_rails/controller_methods.rb +12 -8
- data/lib/bigbluebutton_rails/dial_number.rb +48 -0
- data/lib/bigbluebutton_rails/rails/routes.rb +9 -2
- data/lib/bigbluebutton_rails/utils.rb +9 -2
- data/lib/bigbluebutton_rails/version.rb +1 -1
- data/lib/generators/bigbluebutton_rails/install_generator.rb +0 -8
- data/lib/generators/bigbluebutton_rails/templates/migration.rb +28 -6
- data/lib/generators/bigbluebutton_rails/templates/migration_2_0_0.rb +56 -0
- data/lib/tasks/bigbluebutton_rails/meetings.rake +1 -13
- data/lib/tasks/bigbluebutton_rails/recordings.rake +1 -12
- data/lib/tasks/bigbluebutton_rails/server_configs.rake +10 -0
- data/spec/bigbluebutton_rails_spec.rb +0 -13
- data/spec/controllers/bigbluebutton/playback_types_controller_spec.rb +76 -0
- data/spec/controllers/bigbluebutton/recordings_controller_spec.rb +109 -37
- data/spec/controllers/bigbluebutton/rooms_controller_exception_handling_spec.rb +1 -0
- data/spec/controllers/bigbluebutton/rooms_controller_json_responses_spec.rb +27 -3
- data/spec/controllers/bigbluebutton/rooms_controller_spec.rb +338 -77
- data/spec/controllers/bigbluebutton/servers_controller_json_responses_spec.rb +8 -0
- data/spec/controllers/bigbluebutton/servers_controller_spec.rb +182 -47
- data/spec/factories/bigbluebutton_meeting.rb +2 -2
- data/spec/factories/bigbluebutton_playback_format.rb +2 -2
- data/spec/factories/bigbluebutton_playback_type.rb +7 -0
- data/spec/factories/bigbluebutton_recording.rb +8 -0
- data/spec/factories/bigbluebutton_room.rb +10 -3
- data/spec/factories/bigbluebutton_server.rb +6 -1
- data/spec/factories/bigbluebutton_server_config.rb +6 -0
- data/spec/generators/install_generator_spec.rb +0 -16
- data/spec/lib/bigbluebutton_rails/background_tasks_spec.rb +61 -0
- data/spec/lib/bigbluebutton_rails/dial_number_spec.rb +78 -0
- data/spec/lib/bigbluebutton_rails/utils_spec.rb +56 -0
- data/spec/lib/tasks/meetings_rake_spec.rb +14 -1
- data/spec/lib/tasks/recordings_rake_spec.rb +14 -1
- data/spec/models/bigbluebutton_meeting_db_spec.rb +3 -3
- data/spec/models/bigbluebutton_meeting_spec.rb +4 -4
- data/spec/models/bigbluebutton_playback_format_db_spec.rb +0 -1
- data/spec/models/bigbluebutton_playback_format_spec.rb +75 -4
- data/spec/models/bigbluebutton_playback_type_db_spec.rb +14 -0
- data/spec/models/bigbluebutton_playback_type_spec.rb +76 -0
- data/spec/models/bigbluebutton_recording_db_spec.rb +3 -1
- data/spec/models/bigbluebutton_recording_spec.rb +234 -58
- data/spec/models/bigbluebutton_room_db_spec.rb +8 -6
- data/spec/models/bigbluebutton_room_options_db_spec.rb +1 -0
- data/spec/models/bigbluebutton_room_options_spec.rb +137 -38
- data/spec/models/bigbluebutton_room_spec.rb +540 -153
- data/spec/models/bigbluebutton_server_config_spec.rb +115 -0
- data/spec/models/bigbluebutton_server_spec.rb +180 -23
- data/spec/rails_app/app/controllers/my_playback_types_controller.rb +7 -0
- data/spec/rails_app/app/views/frontpage/show.html.erb +1 -0
- data/spec/rails_app/app/views/my_playback_types/index.html.erb +33 -0
- data/spec/rails_app/config/application.rb +0 -3
- data/spec/rails_app/config/database.yml.travis +10 -0
- data/spec/rails_app/config/environments/development.rb +1 -6
- data/spec/rails_app/config/environments/production.rb +2 -0
- data/spec/rails_app/config/environments/test.rb +2 -0
- data/spec/rails_app/config/routes.rb +5 -2
- data/spec/rails_app/db/seeds.rb +1 -1
- data/spec/rails_app/features/config.yml.example +3 -4
- data/spec/rails_app/features/join_rooms.feature +14 -14
- data/spec/rails_app/features/step_definitions/activity_monitor_servers_step.rb +2 -2
- data/spec/rails_app/features/step_definitions/create_rooms_steps.rb +4 -4
- data/spec/rails_app/features/step_definitions/destroy_rooms_steps.rb +2 -2
- data/spec/rails_app/features/step_definitions/join_rooms_steps.rb +10 -10
- data/spec/rails_app/features/step_definitions/web_steps.rb +2 -2
- data/spec/rails_app/features/support/configurations.rb +1 -1
- data/spec/rails_app/features/support/templates.rb +12 -12
- data/spec/rails_app/lib/tasks/db/populate.rake +19 -6
- data/spec/routing/bigbluebutton/custom_controllers_routing_spec.rb +1 -1
- data/spec/routing/bigbluebutton/recordings_only_routing_spec.rb +2 -2
- data/spec/routing/bigbluebutton/recordings_routing_spec.rb +2 -2
- data/spec/routing/bigbluebutton/rooms_only_routing_spec.rb +1 -1
- data/spec/routing/bigbluebutton/rooms_routing_spec.rb +15 -1
- data/spec/routing/bigbluebutton/servers_only_routing_spec.rb +1 -1
- data/spec/routing/bigbluebutton/servers_routing_spec.rb +1 -1
- data/spec/spec_helper.rb +23 -31
- data/spec/support/matchers/delegate_matcher.rb +8 -1
- data/spec/support/matchers/shoulda/respond_with_json_matcher.rb +2 -2
- data/spec/support/mocked_server.rb +2 -0
- data/spec/support/shared_contexts/rake.rb +23 -0
- data/spec/workers/bigbluebutton_finish_meetings_spec.rb +14 -0
- data/spec/workers/bigbluebutton_update_recordings_spec.rb +14 -0
- data/spec/workers/bigbluebutton_update_server_configs_spec.rb +47 -0
- metadata +70 -59
- data/CHANGELOG.rdoc +0 -111
- data/README.rdoc +0 -319
- data/TODO.rdoc +0 -16
- data/config/schedule.rb +0 -7
@@ -0,0 +1,76 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
require 'spec_helper'
|
3
|
+
|
4
|
+
describe BigbluebuttonPlaybackType do
|
5
|
+
it "loaded correctly" do
|
6
|
+
BigbluebuttonPlaybackType.new.should be_a_kind_of(ActiveRecord::Base)
|
7
|
+
end
|
8
|
+
|
9
|
+
before { FactoryGirl.create(:bigbluebutton_playback_type) }
|
10
|
+
|
11
|
+
it { should validate_presence_of(:identifier) }
|
12
|
+
|
13
|
+
it { should_not validate_presence_of(:visible) }
|
14
|
+
|
15
|
+
it { should have_many(:playback_formats).dependent(:nullify) }
|
16
|
+
|
17
|
+
context "ensures only 0 or 1 records with default=true" do
|
18
|
+
context "automatically sets new records as default=false if setting the current as default=true" do
|
19
|
+
let!(:first) { FactoryGirl.create(:bigbluebutton_playback_type, default: true) }
|
20
|
+
let!(:target) { FactoryGirl.create(:bigbluebutton_playback_type, default: false) }
|
21
|
+
before(:each) {
|
22
|
+
target.update_attributes(default: true)
|
23
|
+
}
|
24
|
+
it { target.reload.default.should be(true) }
|
25
|
+
it { first.reload.default.should be(false) }
|
26
|
+
end
|
27
|
+
|
28
|
+
context "doesn't change other records to default=false if not setting the current as default=true" do
|
29
|
+
let!(:first) { FactoryGirl.create(:bigbluebutton_playback_type, default: true) }
|
30
|
+
let!(:target) { FactoryGirl.create(:bigbluebutton_playback_type, default: false) }
|
31
|
+
before(:each) {
|
32
|
+
target.update_attributes(identifier: "any")
|
33
|
+
}
|
34
|
+
it { target.reload.default.should be(false) }
|
35
|
+
it { first.reload.default.should be(true) }
|
36
|
+
end
|
37
|
+
|
38
|
+
context "allows all records to have default=false" do
|
39
|
+
let!(:first) { FactoryGirl.create(:bigbluebutton_playback_type, default: false) }
|
40
|
+
let!(:target) { FactoryGirl.create(:bigbluebutton_playback_type, default: true) }
|
41
|
+
before(:each) {
|
42
|
+
target.update_attributes(default: false)
|
43
|
+
}
|
44
|
+
it { target.reload.default.should be(false) }
|
45
|
+
it { first.reload.default.should be(false) }
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
describe "#name" do
|
50
|
+
let(:subject) { FactoryGirl.create(:bigbluebutton_playback_type) }
|
51
|
+
|
52
|
+
it {
|
53
|
+
subject.identifier = "presentation"
|
54
|
+
subject.name.should eql(I18n.t("bigbluebutton_rails.playback_types.presentation.name"))
|
55
|
+
}
|
56
|
+
|
57
|
+
it {
|
58
|
+
subject.identifier = "any_other"
|
59
|
+
subject.name.should eql("Any Other")
|
60
|
+
}
|
61
|
+
end
|
62
|
+
|
63
|
+
describe "#description" do
|
64
|
+
let(:subject) { FactoryGirl.create(:bigbluebutton_playback_type) }
|
65
|
+
|
66
|
+
it {
|
67
|
+
subject.identifier = "presentation"
|
68
|
+
subject.description.should eql(I18n.t("bigbluebutton_rails.playback_types.presentation.tip"))
|
69
|
+
}
|
70
|
+
|
71
|
+
it {
|
72
|
+
subject.identifier = "any_other"
|
73
|
+
subject.description.should eql("Any Other")
|
74
|
+
}
|
75
|
+
end
|
76
|
+
end
|
@@ -16,11 +16,13 @@ describe BigbluebuttonRecording do
|
|
16
16
|
it { should have_db_column(:description).of_type(:string) }
|
17
17
|
it { should have_db_column(:created_at).of_type(:datetime) }
|
18
18
|
it { should have_db_column(:updated_at).of_type(:datetime) }
|
19
|
+
it { should have_db_column(:size).of_type(:integer) }
|
19
20
|
it { should have_db_index(:room_id) }
|
20
21
|
it { should have_db_index(:recordid).unique(true) }
|
21
22
|
it "default values" do
|
22
23
|
room = BigbluebuttonRecording.new
|
23
|
-
room.published.should
|
24
|
+
room.published.should be(false)
|
25
|
+
room.size.should be(0)
|
24
26
|
end
|
25
27
|
end
|
26
28
|
|
@@ -16,15 +16,17 @@ describe BigbluebuttonRecording do
|
|
16
16
|
it { should validate_presence_of(:recordid) }
|
17
17
|
it { should validate_uniqueness_of(:recordid) }
|
18
18
|
|
19
|
-
[:recordid, :meetingid, :name, :published, :start_time,
|
20
|
-
:end_time, :available].each do |attribute|
|
21
|
-
it { should allow_mass_assignment_of(attribute) }
|
22
|
-
end
|
23
|
-
|
24
19
|
it { should have_many(:metadata).dependent(:destroy) }
|
25
20
|
|
26
21
|
it { should have_many(:playback_formats).dependent(:destroy) }
|
27
22
|
|
23
|
+
describe "#size" do
|
24
|
+
# make sure it's a bigint
|
25
|
+
it { should allow_value(-9223372036854775808).for(:size) }
|
26
|
+
it { should allow_value(0).for(:size) }
|
27
|
+
it { should allow_value(9223372036854775807).for(:size) }
|
28
|
+
end
|
29
|
+
|
28
30
|
context "scopes" do
|
29
31
|
|
30
32
|
describe "#published" do
|
@@ -46,6 +48,24 @@ describe BigbluebuttonRecording do
|
|
46
48
|
}
|
47
49
|
end
|
48
50
|
|
51
|
+
describe "#default_playback_format" do
|
52
|
+
let!(:recording) { FactoryGirl.create(:bigbluebutton_recording) }
|
53
|
+
let!(:type_default) { FactoryGirl.create(:bigbluebutton_playback_type, default: true) }
|
54
|
+
let!(:type_other) { FactoryGirl.create(:bigbluebutton_playback_type, default: false) }
|
55
|
+
let!(:format1) { FactoryGirl.create(:bigbluebutton_playback_format, recording: recording, playback_type: type_other) }
|
56
|
+
let!(:format2) { FactoryGirl.create(:bigbluebutton_playback_format, recording: recording, playback_type: type_default) }
|
57
|
+
let!(:format3) { FactoryGirl.create(:bigbluebutton_playback_format, recording: recording, playback_type: type_other) }
|
58
|
+
|
59
|
+
context "in a normal situation" do
|
60
|
+
it { recording.default_playback_format.should eql(format2) }
|
61
|
+
end
|
62
|
+
|
63
|
+
context "when there's more than one format of the default type" do
|
64
|
+
let!(:format4) { FactoryGirl.create(:bigbluebutton_playback_format, recording: recording, playback_type: type_default) }
|
65
|
+
it { recording.default_playback_format.should eql(format2) }
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
49
69
|
describe ".sync" do
|
50
70
|
let(:data) {
|
51
71
|
[
|
@@ -56,6 +76,7 @@ describe BigbluebuttonRecording do
|
|
56
76
|
:published => true,
|
57
77
|
:startTime => DateTime.now,
|
58
78
|
:endTime => DateTime.now + 2.hours,
|
79
|
+
:size => 100,
|
59
80
|
:metadata => {
|
60
81
|
:course => "Fundamentals of JAVA",
|
61
82
|
:description => "List of recordings",
|
@@ -96,6 +117,7 @@ describe BigbluebuttonRecording do
|
|
96
117
|
it { @recording.server.should == new_server }
|
97
118
|
it { @recording.room.should == @room }
|
98
119
|
it { @recording.available.should == true }
|
120
|
+
it { @recording.size.should == 100 }
|
99
121
|
it { @recording.metadata.count.should == 3 }
|
100
122
|
3.times do |i|
|
101
123
|
it { @recording.metadata[i].name.should == data[0][:metadata].keys[i].to_s }
|
@@ -103,6 +125,7 @@ describe BigbluebuttonRecording do
|
|
103
125
|
end
|
104
126
|
it { @recording.playback_formats.count.should == 2 }
|
105
127
|
2.times do |i|
|
128
|
+
it { @recording.playback_formats[i].playback_type.identifier.should == data[0][:playback][:format][i][:type] }
|
106
129
|
it { @recording.playback_formats[i].format_type.should == data[0][:playback][:format][i][:type] }
|
107
130
|
it { @recording.playback_formats[i].url.should == data[0][:playback][:format][i][:url] }
|
108
131
|
it { @recording.playback_formats[i].length.should == data[0][:playback][:format][i][:length] }
|
@@ -126,6 +149,7 @@ describe BigbluebuttonRecording do
|
|
126
149
|
it { @recording.server.should == new_server }
|
127
150
|
it { @recording.room.should == @room }
|
128
151
|
it { @recording.available.should == true }
|
152
|
+
it { @recording.size.should == 100 }
|
129
153
|
it { @recording.metadata.count.should == 3 }
|
130
154
|
3.times do |i|
|
131
155
|
it { @recording.metadata[i].name.should == data[0][:metadata].keys[i].to_s }
|
@@ -133,6 +157,7 @@ describe BigbluebuttonRecording do
|
|
133
157
|
end
|
134
158
|
it { @recording.playback_formats.count.should == 2 }
|
135
159
|
2.times do |i|
|
160
|
+
it { @recording.playback_formats[i].playback_type.identifier.should == data[0][:playback][:format][i][:type] }
|
136
161
|
it { @recording.playback_formats[i].format_type.should == data[0][:playback][:format][i][:type] }
|
137
162
|
it { @recording.playback_formats[i].url.should == data[0][:playback][:format][i][:url] }
|
138
163
|
it { @recording.playback_formats[i].length.should == data[0][:playback][:format][i][:length] }
|
@@ -149,17 +174,46 @@ describe BigbluebuttonRecording do
|
|
149
174
|
end
|
150
175
|
|
151
176
|
context "sets recording that are not in the parameters as unavailable" do
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
177
|
+
|
178
|
+
context "for recordings in multiple servers" do
|
179
|
+
before {
|
180
|
+
BigbluebuttonRecording.delete_all
|
181
|
+
@r1 = FactoryGirl.create(:bigbluebutton_recording, :available => true, :server => new_server)
|
182
|
+
@r2 = FactoryGirl.create(:bigbluebutton_recording, :available => true, :server => new_server)
|
183
|
+
@r3 = FactoryGirl.create(:bigbluebutton_recording, :available => true, :server => FactoryGirl.create(:bigbluebutton_server))
|
184
|
+
@r4 = FactoryGirl.create(:bigbluebutton_recording, :available => true, :server => FactoryGirl.create(:bigbluebutton_server))
|
185
|
+
BigbluebuttonRecording.sync(new_server, data)
|
186
|
+
}
|
187
|
+
it { BigbluebuttonRecording.count.should == 5 }
|
188
|
+
it ("recording from the target server") { @r1.reload.available.should == false }
|
189
|
+
it ("recording from the target server") { @r2.reload.available.should == false }
|
190
|
+
it ("recording from another server") { @r3.reload.available.should == true }
|
191
|
+
it ("recording from another server") { @r4.reload.available.should == true }
|
192
|
+
end
|
193
|
+
|
194
|
+
context "when there are no recordings in the target server" do
|
195
|
+
before {
|
196
|
+
new_server.recordings.delete_all
|
197
|
+
@r1 = FactoryGirl.create(:bigbluebutton_recording, :available => true, :server => FactoryGirl.create(:bigbluebutton_server))
|
198
|
+
@r2 = FactoryGirl.create(:bigbluebutton_recording, :available => true, :server => FactoryGirl.create(:bigbluebutton_server))
|
199
|
+
BigbluebuttonRecording.sync(new_server, data)
|
200
|
+
}
|
201
|
+
it { new_server.recordings.should be_empty }
|
202
|
+
it ("recording from another server") { @r1.reload.available.should == true }
|
203
|
+
it ("recording from another server") { @r2.reload.available.should == true }
|
204
|
+
end
|
205
|
+
|
206
|
+
context "when there are no recordings in other servers" do
|
207
|
+
before {
|
208
|
+
BigbluebuttonRecording.delete_all
|
209
|
+
@r1 = FactoryGirl.create(:bigbluebutton_recording, :available => true, :server => new_server)
|
210
|
+
@r2 = FactoryGirl.create(:bigbluebutton_recording, :available => true, :server => new_server)
|
211
|
+
BigbluebuttonRecording.sync(new_server, data)
|
212
|
+
}
|
213
|
+
it { BigbluebuttonRecording.count.should == 3 }
|
214
|
+
it ("recording from another server") { @r1.reload.available.should == false }
|
215
|
+
it ("recording from another server") { @r2.reload.available.should == false }
|
216
|
+
end
|
163
217
|
end
|
164
218
|
|
165
219
|
context "works for multiple recordings" do
|
@@ -206,26 +260,39 @@ describe BigbluebuttonRecording do
|
|
206
260
|
:published => !old_attrs[:published],
|
207
261
|
:start_time => attrs[:start_time],
|
208
262
|
:end_time => attrs[:end_time],
|
263
|
+
:size => attrs[:size],
|
209
264
|
:metadata => { :any => "any" },
|
210
265
|
:playback => { :format => [ { :type => "any1" }, { :type => "any2" } ] }
|
211
266
|
}
|
212
267
|
}
|
213
268
|
let(:new_server) { FactoryGirl.create(:bigbluebutton_server) }
|
214
269
|
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
.
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
270
|
+
context "default behavior" do
|
271
|
+
before {
|
272
|
+
@room = FactoryGirl.create(:bigbluebutton_room, :meetingid => attrs[:meetingid])
|
273
|
+
BigbluebuttonRecording.should_receive(:sync_additional_data)
|
274
|
+
.with(recording, data)
|
275
|
+
BigbluebuttonRecording.send(:update_recording, new_server, recording, data)
|
276
|
+
}
|
277
|
+
it { recording.recordid.should == old_attrs[:recordid] } # not updated
|
278
|
+
it { recording.meetingid.should == attrs[:meetingid] }
|
279
|
+
it { recording.name.should == attrs[:name] }
|
280
|
+
it { recording.published.should == !old_attrs[:published] }
|
281
|
+
it { recording.end_time.utc.to_i.should == attrs[:end_time].utc.to_i }
|
282
|
+
it { recording.start_time.utc.to_i.should == attrs[:start_time].utc.to_i }
|
283
|
+
it { recording.size.should == attrs[:size] }
|
284
|
+
it { recording.server.should == new_server }
|
285
|
+
it { recording.room.should == @room }
|
286
|
+
end
|
287
|
+
|
288
|
+
context "works if the recording returned has no :size attribute" do
|
289
|
+
before {
|
290
|
+
data.delete(:size)
|
291
|
+
recording.update_attributes(size: 0)
|
292
|
+
BigbluebuttonRecording.send(:update_recording, new_server, recording, data)
|
293
|
+
}
|
294
|
+
it { recording.size.should == 0 }
|
295
|
+
end
|
229
296
|
end
|
230
297
|
|
231
298
|
describe ".create_recording" do
|
@@ -309,7 +376,7 @@ describe BigbluebuttonRecording do
|
|
309
376
|
}
|
310
377
|
}
|
311
378
|
|
312
|
-
it "
|
379
|
+
it "succeeds" do
|
313
380
|
BigbluebuttonRecording.should_receive(:sync_metadata)
|
314
381
|
.with(recording, data[:metadata])
|
315
382
|
BigbluebuttonRecording.should_receive(:sync_playback_formats)
|
@@ -400,45 +467,87 @@ describe BigbluebuttonRecording do
|
|
400
467
|
describe ".sync_playback_formats" do
|
401
468
|
let(:recording) { FactoryGirl.create(:bigbluebutton_recording) }
|
402
469
|
|
403
|
-
context "with
|
470
|
+
context "with a single format" do
|
404
471
|
let(:data) {
|
405
|
-
|
406
|
-
{ :type => "any2", :url => "url2", :length => 2 } ]
|
472
|
+
{ :type => "any1", :url => "url1", :length => 1 }
|
407
473
|
}
|
408
|
-
before {
|
409
|
-
# one playback format to be updated
|
410
|
-
FactoryGirl.create(:bigbluebutton_playback_format,
|
411
|
-
:recording => recording, :format_type => "any1")
|
412
|
-
# one to be deleted
|
413
|
-
FactoryGirl.create(:bigbluebutton_playback_format, :recording => recording)
|
414
474
|
|
415
|
-
|
416
|
-
|
417
|
-
|
418
|
-
|
419
|
-
|
420
|
-
|
421
|
-
|
422
|
-
|
475
|
+
context "and it's not in the database yet" do
|
476
|
+
before {
|
477
|
+
BigbluebuttonRecording.send(:sync_playback_formats, recording, data)
|
478
|
+
}
|
479
|
+
it { BigbluebuttonPlaybackFormat.count.should == 1 }
|
480
|
+
it { BigbluebuttonPlaybackFormat.where(:recording_id => recording.id).count.should == 1 }
|
481
|
+
it { BigbluebuttonPlaybackFormat.where(:recording_id => recording.id).last.url.should == "url1" }
|
482
|
+
it { BigbluebuttonPlaybackFormat.where(:recording_id => recording.id).last.length.should == 1 }
|
483
|
+
it { BigbluebuttonPlaybackFormat.where(:recording_id => recording.id).last.visible.should be(true) }
|
484
|
+
end
|
485
|
+
|
486
|
+
context "and it's already in the database" do
|
487
|
+
before {
|
488
|
+
# one playback format to be updated
|
489
|
+
playback_type = FactoryGirl.create(:bigbluebutton_playback_type, identifier: "any1", visible: false)
|
490
|
+
FactoryGirl.create(:bigbluebutton_playback_format,
|
491
|
+
:recording => recording, :playback_type => playback_type)
|
492
|
+
|
493
|
+
BigbluebuttonRecording.send(:sync_playback_formats, recording, data)
|
494
|
+
}
|
495
|
+
it { BigbluebuttonPlaybackFormat.count.should == 1 }
|
496
|
+
it { BigbluebuttonPlaybackFormat.where(:recording_id => recording.id).count.should == 1 }
|
497
|
+
it { BigbluebuttonPlaybackFormat.where(:recording_id => recording.id).last.url.should == "url1" }
|
498
|
+
it { BigbluebuttonPlaybackFormat.where(:recording_id => recording.id).last.length.should == 1 }
|
499
|
+
it { BigbluebuttonPlaybackFormat.where(:recording_id => recording.id).last.visible.should be(false) }
|
500
|
+
end
|
501
|
+
|
502
|
+
context "and there are unused formats in the database" do
|
503
|
+
before {
|
504
|
+
# formats to be deleted
|
505
|
+
FactoryGirl.create(:bigbluebutton_playback_format, :recording => recording)
|
506
|
+
FactoryGirl.create(:bigbluebutton_playback_format, :recording => recording)
|
507
|
+
|
508
|
+
BigbluebuttonRecording.send(:sync_playback_formats, recording, data)
|
509
|
+
}
|
510
|
+
it { BigbluebuttonPlaybackFormat.count.should == 1 }
|
511
|
+
it { BigbluebuttonPlaybackFormat.where(:recording_id => recording.id).count.should == 1 }
|
512
|
+
it { BigbluebuttonPlaybackFormat.where(:recording_id => recording.id).last.url.should == "url1" }
|
513
|
+
it { BigbluebuttonPlaybackFormat.where(:recording_id => recording.id).last.length.should == 1 }
|
514
|
+
end
|
423
515
|
end
|
424
516
|
|
425
|
-
context "with
|
517
|
+
context "with several formats" do
|
426
518
|
let(:data) {
|
427
|
-
{ :type => "any1", :url => "url1", :length => 1 }
|
519
|
+
[ { :type => "any1", :url => "url1", :length => 1 },
|
520
|
+
{ :type => "any2", :url => "url2", :length => 2 },
|
521
|
+
{ :type => "any3", :url => "url3", :length => 3 } ]
|
522
|
+
}
|
523
|
+
let(:playback_type) {
|
524
|
+
FactoryGirl.create(:bigbluebutton_playback_type, identifier: "any1", visible: true)
|
525
|
+
}
|
526
|
+
let(:playback_type_hidden) {
|
527
|
+
FactoryGirl.create(:bigbluebutton_playback_type, identifier: "any2", visible: false)
|
428
528
|
}
|
429
529
|
before {
|
430
|
-
#
|
530
|
+
# two playback formats to be updated
|
531
|
+
FactoryGirl.create(:bigbluebutton_playback_format,
|
532
|
+
:recording => recording, :playback_type => playback_type)
|
431
533
|
FactoryGirl.create(:bigbluebutton_playback_format,
|
432
|
-
:recording => recording, :
|
534
|
+
:recording => recording, :playback_type => playback_type_hidden)
|
433
535
|
# one to be deleted
|
434
536
|
FactoryGirl.create(:bigbluebutton_playback_format, :recording => recording)
|
435
537
|
|
436
538
|
BigbluebuttonRecording.send(:sync_playback_formats, recording, data)
|
437
539
|
}
|
438
|
-
it {
|
439
|
-
it { BigbluebuttonPlaybackFormat.
|
440
|
-
it { BigbluebuttonPlaybackFormat.
|
441
|
-
it { BigbluebuttonPlaybackFormat.
|
540
|
+
it { BigbluebuttonPlaybackType.count.should == 3 }
|
541
|
+
it { BigbluebuttonPlaybackFormat.count.should == 3 }
|
542
|
+
it { BigbluebuttonPlaybackFormat.where(:recording_id => recording.id).count.should == 3 }
|
543
|
+
it { BigbluebuttonPlaybackFormat.where(:recording_id => recording.id, :playback_type_id => playback_type.id).first.url.should == "url1" }
|
544
|
+
it { BigbluebuttonPlaybackFormat.where(:recording_id => recording.id, :playback_type_id => playback_type.id).first.length.should == 1 }
|
545
|
+
it { BigbluebuttonPlaybackFormat.where(:recording_id => recording.id, :playback_type_id => playback_type.id).first.visible.should be(true) }
|
546
|
+
it { BigbluebuttonPlaybackFormat.where(:recording_id => recording.id, :playback_type_id => playback_type_hidden.id).first.url.should == "url2" }
|
547
|
+
it { BigbluebuttonPlaybackFormat.where(:recording_id => recording.id, :playback_type_id => playback_type_hidden.id).first.length.should == 2 }
|
548
|
+
it { BigbluebuttonPlaybackFormat.where(:recording_id => recording.id, :playback_type_id => playback_type_hidden.id).first.visible.should be(false) }
|
549
|
+
it { BigbluebuttonPlaybackFormat.where(:recording_id => recording.id, :playback_type_id => BigbluebuttonPlaybackType.last.id).first.url.should == "url3" }
|
550
|
+
it { BigbluebuttonPlaybackFormat.where(:recording_id => recording.id, :playback_type_id => BigbluebuttonPlaybackType.last.id).first.length.should == 3 }
|
442
551
|
end
|
443
552
|
|
444
553
|
context "ignores formats with blank type" do
|
@@ -450,12 +559,79 @@ describe BigbluebuttonRecording do
|
|
450
559
|
before {
|
451
560
|
BigbluebuttonRecording.send(:sync_playback_formats, recording, data)
|
452
561
|
}
|
562
|
+
it { BigbluebuttonPlaybackType.count.should == 1 }
|
453
563
|
it { BigbluebuttonPlaybackFormat.count.should == 1 }
|
454
564
|
it { BigbluebuttonPlaybackFormat.where(:recording_id => recording.id).count.should == 1 }
|
455
|
-
it { BigbluebuttonPlaybackFormat.
|
456
|
-
it { BigbluebuttonPlaybackFormat.
|
565
|
+
it { BigbluebuttonPlaybackFormat.where(:recording_id => recording.id, :playback_type_id => BigbluebuttonPlaybackType.last.id).first.url.should == "url2" }
|
566
|
+
it { BigbluebuttonPlaybackFormat.where(:recording_id => recording.id, :playback_type_id => BigbluebuttonPlaybackType.last.id).first.length.should == 1 }
|
567
|
+
end
|
568
|
+
|
569
|
+
context "manages the playback types" do
|
570
|
+
let(:data) {
|
571
|
+
{ :type => "any1", :url => "url1", :length => 1 }
|
572
|
+
}
|
573
|
+
|
574
|
+
context "when the playback type is already on the database" do
|
575
|
+
let!(:playback_type) {
|
576
|
+
FactoryGirl.create(:bigbluebutton_playback_type, :identifier => "any1")
|
577
|
+
}
|
578
|
+
before {
|
579
|
+
BigbluebuttonRecording.send(:sync_playback_formats, recording, data)
|
580
|
+
}
|
581
|
+
it { BigbluebuttonPlaybackType.count.should == 1 }
|
582
|
+
it { BigbluebuttonPlaybackType.last.should == playback_type }
|
583
|
+
end
|
584
|
+
|
585
|
+
context "when the playback type is not on the database" do
|
586
|
+
before {
|
587
|
+
BigbluebuttonRecording.send(:sync_playback_formats, recording, data)
|
588
|
+
}
|
589
|
+
it { BigbluebuttonPlaybackType.count.should == 1 }
|
590
|
+
it { BigbluebuttonPlaybackType.last.identifier.should == "any1" }
|
591
|
+
it { BigbluebuttonPlaybackType.last.playback_formats.should include(BigbluebuttonPlaybackFormat.last) }
|
592
|
+
end
|
593
|
+
|
594
|
+
context "when there are unused playback types on the database" do
|
595
|
+
before {
|
596
|
+
FactoryGirl.create(:bigbluebutton_playback_type, :identifier => "any2")
|
597
|
+
FactoryGirl.create(:bigbluebutton_playback_type, :identifier => "any3")
|
598
|
+
BigbluebuttonRecording.send(:sync_playback_formats, recording, data)
|
599
|
+
}
|
600
|
+
it { BigbluebuttonPlaybackType.count.should == 1 }
|
601
|
+
it { BigbluebuttonPlaybackType.last.identifier.should == "any1" }
|
602
|
+
end
|
457
603
|
end
|
604
|
+
end
|
605
|
+
|
606
|
+
describe ".cleanup_playback_types" do
|
607
|
+
let(:recording) { FactoryGirl.create(:bigbluebutton_recording) }
|
458
608
|
|
609
|
+
context "when all playback types are in use" do
|
610
|
+
before {
|
611
|
+
@kept1 = FactoryGirl.create(:bigbluebutton_playback_format, :recording => recording).playback_type
|
612
|
+
@kept2 = FactoryGirl.create(:bigbluebutton_playback_format, :recording => recording).playback_type
|
613
|
+
|
614
|
+
BigbluebuttonRecording.send(:cleanup_playback_types)
|
615
|
+
}
|
616
|
+
it { BigbluebuttonPlaybackType.count.should == 2 }
|
617
|
+
it { BigbluebuttonPlaybackType.all.should include(@kept1) }
|
618
|
+
it { BigbluebuttonPlaybackType.all.should include(@kept2) }
|
619
|
+
end
|
620
|
+
|
621
|
+
context "when there are unused playback types" do
|
622
|
+
before {
|
623
|
+
@removed1 = FactoryGirl.create(:bigbluebutton_playback_type)
|
624
|
+
@removed2 = FactoryGirl.create(:bigbluebutton_playback_type)
|
625
|
+
@kept1 = FactoryGirl.create(:bigbluebutton_playback_format, :recording => recording).playback_type
|
626
|
+
|
627
|
+
BigbluebuttonRecording.send(:cleanup_playback_types)
|
628
|
+
}
|
629
|
+
|
630
|
+
it { BigbluebuttonPlaybackType.count.should == 1 }
|
631
|
+
it { BigbluebuttonPlaybackType.all.should include(@kept1) }
|
632
|
+
it { BigbluebuttonPlaybackType.all.should_not include(@removed1) }
|
633
|
+
it { BigbluebuttonPlaybackType.all.should_not include(@removed2) }
|
634
|
+
end
|
459
635
|
end
|
460
636
|
|
461
637
|
describe ".find_matching_meeting" do
|