bigbluebutton_rails 2.1.0 → 2.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.travis.yml +3 -0
- data/CHANGELOG.md +21 -0
- data/Gemfile +2 -1
- data/Gemfile.lock +4 -11
- data/Rakefile +15 -15
- data/app/controllers/bigbluebutton/recordings_controller.rb +1 -1
- data/app/controllers/bigbluebutton/rooms_controller.rb +10 -12
- data/app/controllers/bigbluebutton/servers_controller.rb +4 -5
- data/app/models/bigbluebutton_meeting.rb +1 -2
- data/app/models/bigbluebutton_metadata.rb +2 -2
- data/app/models/bigbluebutton_recording.rb +20 -5
- data/app/models/bigbluebutton_room.rb +80 -102
- data/app/models/bigbluebutton_server.rb +31 -17
- data/app/views/bigbluebutton/recordings/_form.html.erb +13 -13
- data/app/views/bigbluebutton/rooms/_form.html.erb +0 -4
- data/app/views/bigbluebutton/rooms/_rooms.html.erb +0 -4
- data/app/views/bigbluebutton/rooms/show.html.erb +0 -4
- data/app/workers/bigbluebutton_update_recordings.rb +2 -2
- data/config/locales/en.yml +1 -2
- data/config/locales/pt-br.yml +1 -2
- data/lib/bigbluebutton_rails.rb +22 -108
- data/lib/bigbluebutton_rails/background_tasks.rb +7 -3
- data/lib/bigbluebutton_rails/configuration.rb +80 -0
- data/lib/bigbluebutton_rails/rails/routes.rb +7 -6
- data/lib/bigbluebutton_rails/version.rb +1 -1
- data/lib/generators/bigbluebutton_rails/install_generator.rb +10 -1
- data/lib/generators/bigbluebutton_rails/templates/migration.rb +0 -3
- data/lib/generators/bigbluebutton_rails/templates/migration_2_2_0.rb +13 -0
- data/spec/controllers/bigbluebutton/recordings_controller_json_responses_spec.rb +4 -5
- data/spec/controllers/bigbluebutton/recordings_controller_spec.rb +3 -2
- data/spec/controllers/bigbluebutton/rooms_controller_exception_handling_spec.rb +1 -1
- data/spec/controllers/bigbluebutton/rooms_controller_json_responses_spec.rb +4 -4
- data/spec/controllers/bigbluebutton/rooms_controller_spec.rb +53 -38
- data/spec/controllers/bigbluebutton/servers_controller_json_responses_spec.rb +7 -19
- data/spec/controllers/bigbluebutton/servers_controller_spec.rb +32 -51
- data/spec/factories/bigbluebutton_meeting.rb +0 -1
- data/spec/factories/bigbluebutton_recording.rb +1 -0
- data/spec/factories/bigbluebutton_room.rb +0 -1
- data/spec/models/bigbluebutton_meeting_db_spec.rb +0 -1
- data/spec/models/bigbluebutton_meeting_spec.rb +0 -3
- data/spec/models/bigbluebutton_metadata_spec.rb +4 -4
- data/spec/models/bigbluebutton_recording_spec.rb +32 -0
- data/spec/models/bigbluebutton_room_db_spec.rb +0 -2
- data/spec/models/bigbluebutton_room_spec.rb +138 -244
- data/spec/models/bigbluebutton_server_spec.rb +40 -21
- data/spec/rails_app/db/seeds.rb +1 -1
- data/spec/rails_app/features/config.yml.example +4 -4
- data/spec/rails_app/features/step_definitions/create_rooms_steps.rb +0 -1
- data/spec/rails_app/features/support/templates.rb +0 -4
- data/spec/rails_app/lib/tasks/db/populate.rake +2 -2
- data/spec/routing/bigbluebutton/servers_only_routing_spec.rb +4 -1
- data/spec/routing/bigbluebutton/servers_routing_spec.rb +4 -0
- data/spec/spec_helper.rb +4 -0
- data/spec/support/mocked_server.rb +1 -1
- data/spec/workers/bigbluebutton_meeting_updater_spec.rb +3 -3
- metadata +4 -2
@@ -142,7 +142,6 @@ describe Bigbluebutton::ServersController do
|
|
142
142
|
|
143
143
|
describe "#update" do
|
144
144
|
let(:new_server) { FactoryGirl.build(:bigbluebutton_server) }
|
145
|
-
before { @server = server } # need this to trigger let(:server) and actually create the object
|
146
145
|
|
147
146
|
context "on success" do
|
148
147
|
let(:new_server) { FactoryGirl.build(:bigbluebutton_server, version: "") }
|
@@ -150,16 +149,16 @@ describe Bigbluebutton::ServersController do
|
|
150
149
|
before {
|
151
150
|
BigBlueButton::BigBlueButtonApi.any_instance.should_receive(:get_api_version).and_return("0.9")
|
152
151
|
expect {
|
153
|
-
put :update, id:
|
152
|
+
put :update, id: server.to_param, bigbluebutton_server: new_server.attributes
|
154
153
|
}.not_to change { BigbluebuttonServer.count }
|
155
154
|
}
|
156
155
|
it {
|
157
|
-
saved = BigbluebuttonServer.find(
|
156
|
+
saved = BigbluebuttonServer.find(server)
|
158
157
|
should respond_with(:redirect)
|
159
158
|
should redirect_to(bigbluebutton_server_path(saved))
|
160
159
|
}
|
161
160
|
it {
|
162
|
-
saved = BigbluebuttonServer.find(
|
161
|
+
saved = BigbluebuttonServer.find(server)
|
163
162
|
saved.should_not have_same_attributes_as(new_server)
|
164
163
|
saved.version.should == "0.9"
|
165
164
|
}
|
@@ -169,10 +168,10 @@ describe Bigbluebutton::ServersController do
|
|
169
168
|
context "on failure" do
|
170
169
|
before :each do
|
171
170
|
new_server.url = nil # invalid
|
172
|
-
put :update, :id =>
|
171
|
+
put :update, :id => server.to_param, :bigbluebutton_server => new_server.attributes
|
173
172
|
end
|
174
173
|
it { should render_template(:edit) }
|
175
|
-
it { should assign_to(:server).with(
|
174
|
+
it { should assign_to(:server).with(server) }
|
176
175
|
end
|
177
176
|
|
178
177
|
describe "params handling" do
|
@@ -185,12 +184,12 @@ describe Bigbluebutton::ServersController do
|
|
185
184
|
it {
|
186
185
|
# we just check that the rails method 'permit' is being called on the hash with the
|
187
186
|
# correct parameters
|
188
|
-
BigbluebuttonServer.stub(:find_by_param).and_return(
|
189
|
-
|
187
|
+
BigbluebuttonServer.stub(:find_by_param).and_return(server)
|
188
|
+
server.stub(:update_attributes).and_return(true)
|
190
189
|
attrs.stub(:permit).and_return(attrs)
|
191
190
|
controller.stub(:params).and_return(params)
|
192
191
|
|
193
|
-
put :update, :id =>
|
192
|
+
put :update, :id => server.to_param, :bigbluebutton_server => attrs
|
194
193
|
attrs.should have_received(:permit).with(*allowed_params)
|
195
194
|
}
|
196
195
|
end
|
@@ -198,8 +197,8 @@ describe Bigbluebutton::ServersController do
|
|
198
197
|
# to make sure it doesn't break if the hash informed doesn't have the key :bigbluebutton_server
|
199
198
|
describe "if parameters are not informed" do
|
200
199
|
it {
|
201
|
-
put :update, :id =>
|
202
|
-
should redirect_to(bigbluebutton_server_path(
|
200
|
+
put :update, :id => server.to_param
|
201
|
+
should redirect_to(bigbluebutton_server_path(server))
|
203
202
|
}
|
204
203
|
end
|
205
204
|
|
@@ -207,7 +206,7 @@ describe Bigbluebutton::ServersController do
|
|
207
206
|
context "on success" do
|
208
207
|
before(:each) {
|
209
208
|
BigbluebuttonServer.any_instance.should_receive(:set_api_version_from_server).and_return(anything)
|
210
|
-
put :update, :id =>
|
209
|
+
put :update, :id => server.to_param, :bigbluebutton_server => new_server.attributes, :redir_url => '/any'
|
211
210
|
}
|
212
211
|
it { should respond_with(:redirect) }
|
213
212
|
it { should redirect_to "/any" }
|
@@ -216,7 +215,7 @@ describe Bigbluebutton::ServersController do
|
|
216
215
|
context "on failure" do
|
217
216
|
before(:each) {
|
218
217
|
new_server.url = nil # invalid
|
219
|
-
put :update, :id =>
|
218
|
+
put :update, :id => server.to_param, :bigbluebutton_server => new_server.attributes, :redir_url => '/any'
|
220
219
|
}
|
221
220
|
it { should respond_with(:redirect) }
|
222
221
|
it { should redirect_to "/any" }
|
@@ -228,7 +227,7 @@ describe Bigbluebutton::ServersController do
|
|
228
227
|
before { controller.instance_variable_set(:@server, other_server) }
|
229
228
|
before(:each) {
|
230
229
|
BigbluebuttonServer.any_instance.should_receive(:set_api_version_from_server).and_return(anything)
|
231
|
-
put :update, :id =>
|
230
|
+
put :update, :id => server.to_param, :bigbluebutton_server => new_server.attributes
|
232
231
|
}
|
233
232
|
it { should assign_to(:server).with(other_server) }
|
234
233
|
end
|
@@ -266,8 +265,8 @@ describe Bigbluebutton::ServersController do
|
|
266
265
|
end
|
267
266
|
|
268
267
|
describe "#activity" do
|
269
|
-
let(:room1) { FactoryGirl.create(:bigbluebutton_room
|
270
|
-
let(:room2) { FactoryGirl.create(:bigbluebutton_room
|
268
|
+
let(:room1) { FactoryGirl.create(:bigbluebutton_room) }
|
269
|
+
let(:room2) { FactoryGirl.create(:bigbluebutton_room) }
|
271
270
|
before do
|
272
271
|
# return our mocked server
|
273
272
|
BigbluebuttonServer.stub(:find_by_param).with(server.to_param).
|
@@ -335,40 +334,6 @@ describe Bigbluebutton::ServersController do
|
|
335
334
|
end
|
336
335
|
end # #activity
|
337
336
|
|
338
|
-
describe "#rooms" do
|
339
|
-
context "basic" do
|
340
|
-
before do
|
341
|
-
@room1 = FactoryGirl.create(:bigbluebutton_room, :server => server)
|
342
|
-
@room2 = FactoryGirl.create(:bigbluebutton_room, :server => server)
|
343
|
-
FactoryGirl.create(:bigbluebutton_room)
|
344
|
-
end
|
345
|
-
before(:each) { get :rooms, :id => server.to_param }
|
346
|
-
it { should respond_with(:success) }
|
347
|
-
it { should render_template(:rooms) }
|
348
|
-
it { should assign_to(:rooms).with([@room1, @room2]) }
|
349
|
-
end
|
350
|
-
|
351
|
-
context "doesn't override @server" do
|
352
|
-
let!(:other_server) { FactoryGirl.create(:bigbluebutton_server) }
|
353
|
-
before { controller.instance_variable_set(:@server, other_server) }
|
354
|
-
before(:each) { get :rooms, :id => server.to_param }
|
355
|
-
it { should assign_to(:server).with(other_server) }
|
356
|
-
end
|
357
|
-
|
358
|
-
context "doesn't override @rooms" do
|
359
|
-
let!(:my_rooms) {
|
360
|
-
[ FactoryGirl.create(:bigbluebutton_room, server: server),
|
361
|
-
FactoryGirl.create(:bigbluebutton_room, server: server) ]
|
362
|
-
}
|
363
|
-
before {
|
364
|
-
3.times { FactoryGirl.create(:bigbluebutton_room, server: server) }
|
365
|
-
controller.instance_variable_set(:@rooms, my_rooms)
|
366
|
-
}
|
367
|
-
before(:each) { get :rooms, :id => server.to_param }
|
368
|
-
it { should assign_to(:rooms).with(my_rooms) }
|
369
|
-
end
|
370
|
-
end
|
371
|
-
|
372
337
|
describe "#publish_recordings" do
|
373
338
|
let(:recording_ids) { "id1,id2,id3" }
|
374
339
|
before do
|
@@ -553,7 +518,7 @@ describe Bigbluebutton::ServersController do
|
|
553
518
|
FactoryGirl.create(:bigbluebutton_recording)
|
554
519
|
|
555
520
|
# one that belongs to another server but to a room that's in the target server
|
556
|
-
room = FactoryGirl.create(:bigbluebutton_room
|
521
|
+
room = FactoryGirl.create(:bigbluebutton_room)
|
557
522
|
FactoryGirl.create(:bigbluebutton_recording, :room => room)
|
558
523
|
end
|
559
524
|
before(:each) { get :recordings, :id => server.to_param }
|
@@ -583,4 +548,20 @@ describe Bigbluebutton::ServersController do
|
|
583
548
|
end
|
584
549
|
end
|
585
550
|
|
551
|
+
describe "#check" do
|
552
|
+
before do
|
553
|
+
# return our mocked server
|
554
|
+
BigbluebuttonServer.stub(:find_by_param).with(server.to_param).and_return(server)
|
555
|
+
end
|
556
|
+
|
557
|
+
context "on success" do
|
558
|
+
before(:each) {
|
559
|
+
server.should_receive(:check_url).and_return('http://test-server.com/check')
|
560
|
+
post :check, :id => server.to_param
|
561
|
+
}
|
562
|
+
it { should respond_with(:redirect) }
|
563
|
+
it { should redirect_to 'http://test-server.com/check' }
|
564
|
+
end
|
565
|
+
end
|
566
|
+
|
586
567
|
end
|
@@ -1,7 +1,6 @@
|
|
1
1
|
FactoryGirl.define do
|
2
2
|
factory :bigbluebutton_meeting do |m|
|
3
3
|
m.sequence(:meetingid) { |n| "meeting-#{n}-" + SecureRandom.hex(4) }
|
4
|
-
m.association :server, :factory => :bigbluebutton_server
|
5
4
|
m.association :room, :factory => :bigbluebutton_room
|
6
5
|
m.sequence(:name) { |n| "Name#{n}" }
|
7
6
|
m.recorded false
|
@@ -12,6 +12,7 @@ FactoryGirl.define do
|
|
12
12
|
r.sequence(:recordid) { |n| "rec#{n}-#{SecureRandom.uuid}-#{DateTime.now.to_i}" }
|
13
13
|
r.size { rand((20*1024**2)..(500*1024**2)) } # size ranging from 20Mb to 500Mb
|
14
14
|
r.available true
|
15
|
+
r.description { Forgery(:lorem_ipsum).words(10) }
|
15
16
|
|
16
17
|
after(:create) do |r|
|
17
18
|
r.updated_at = r.updated_at.change(:usec => 0)
|
@@ -3,7 +3,6 @@ FactoryGirl.define do
|
|
3
3
|
# meetingid with a random factor to avoid duplicated ids in consecutive test runs
|
4
4
|
r.sequence(:meetingid) { |n| "meeting-#{n}-" + SecureRandom.hex(4) }
|
5
5
|
|
6
|
-
r.association :server, :factory => :bigbluebutton_server
|
7
6
|
r.sequence(:name) { |n| "Name#{n}" }
|
8
7
|
r.attendee_key { Forgery(:basic).password :at_least => 10, :at_most => 16 }
|
9
8
|
r.moderator_key { Forgery(:basic).password :at_least => 10, :at_most => 16 }
|
@@ -4,7 +4,6 @@ describe BigbluebuttonMeeting do
|
|
4
4
|
|
5
5
|
# to ensure that the migration is correct
|
6
6
|
context "db" do
|
7
|
-
it { should have_db_column(:server_id).of_type(:integer) }
|
8
7
|
it { should have_db_column(:room_id).of_type(:integer) }
|
9
8
|
it { should have_db_column(:meetingid).of_type(:string) }
|
10
9
|
it { should have_db_column(:name).of_type(:string) }
|
@@ -8,9 +8,6 @@ describe BigbluebuttonMeeting do
|
|
8
8
|
|
9
9
|
before { FactoryGirl.create(:bigbluebutton_meeting) }
|
10
10
|
|
11
|
-
it { should belong_to(:server) }
|
12
|
-
it { should_not validate_presence_of(:server_id) }
|
13
|
-
|
14
11
|
it { should belong_to(:room) }
|
15
12
|
it { should validate_presence_of(:room) }
|
16
13
|
|
@@ -42,11 +42,11 @@ describe BigbluebuttonMetadata do
|
|
42
42
|
before(:each) { subject.owner = FactoryGirl.create(:bigbluebutton_room) }
|
43
43
|
|
44
44
|
it { should ensure_exclusion_of(:name)
|
45
|
-
.in_array(BigbluebuttonRails.metadata_invalid_keys.map(&:to_s)) }
|
45
|
+
.in_array(BigbluebuttonRails.configuration.metadata_invalid_keys.map(&:to_s)) }
|
46
46
|
|
47
47
|
it "allows values to be added to the list of invalid metadata keys" do
|
48
|
-
old = BigbluebuttonRails.metadata_invalid_keys.clone
|
49
|
-
BigbluebuttonRails.metadata_invalid_keys.push("1")
|
48
|
+
old = BigbluebuttonRails.configuration.metadata_invalid_keys.clone
|
49
|
+
BigbluebuttonRails.configuration.metadata_invalid_keys.push("1")
|
50
50
|
old.push("1")
|
51
51
|
should ensure_exclusion_of(:name).in_array(old.map(&:to_s))
|
52
52
|
end
|
@@ -54,7 +54,7 @@ describe BigbluebuttonMetadata do
|
|
54
54
|
it "only invalidates if the metadata belongs to a room" do
|
55
55
|
subject.owner = FactoryGirl.create(:bigbluebutton_recording)
|
56
56
|
should_not ensure_exclusion_of(:name)
|
57
|
-
.in_array(BigbluebuttonRails.metadata_invalid_keys.map(&:to_s))
|
57
|
+
.in_array(BigbluebuttonRails.configuration.metadata_invalid_keys.map(&:to_s))
|
58
58
|
end
|
59
59
|
end
|
60
60
|
end
|
@@ -66,6 +66,38 @@ describe BigbluebuttonRecording do
|
|
66
66
|
end
|
67
67
|
end
|
68
68
|
|
69
|
+
describe ".overall_average_length" do
|
70
|
+
context "when there's no recording" do
|
71
|
+
it { BigbluebuttonRecording.overall_average_length.should eql(0) }
|
72
|
+
end
|
73
|
+
|
74
|
+
context "when there are a few recordings" do
|
75
|
+
let!(:recording1) { FactoryGirl.create(:bigbluebutton_recording) }
|
76
|
+
let!(:recording2) { FactoryGirl.create(:bigbluebutton_recording) }
|
77
|
+
let!(:type_default) { FactoryGirl.create(:bigbluebutton_playback_type, default: true) }
|
78
|
+
let!(:type_other) { FactoryGirl.create(:bigbluebutton_playback_type, default: false) }
|
79
|
+
let!(:format_other_rec1) { FactoryGirl.create(:bigbluebutton_playback_format, recording: recording1, playback_type: type_other, length: 50) }
|
80
|
+
let!(:format_default_rec1) { FactoryGirl.create(:bigbluebutton_playback_format, recording: recording1, playback_type: type_default, length: 100) }
|
81
|
+
let!(:format_other_rec2) { FactoryGirl.create(:bigbluebutton_playback_format, recording: recording2, playback_type: type_other, length: 50) }
|
82
|
+
let!(:format_default_rec2) { FactoryGirl.create(:bigbluebutton_playback_format, recording: recording2, playback_type: type_default, length: 100) }
|
83
|
+
|
84
|
+
it { BigbluebuttonRecording.overall_average_length.should eql(6000.0) }
|
85
|
+
end
|
86
|
+
end
|
87
|
+
|
88
|
+
describe ".overall_average_size" do
|
89
|
+
context "when there's no recording" do
|
90
|
+
it { BigbluebuttonRecording.overall_average_size.should eql(0) }
|
91
|
+
end
|
92
|
+
|
93
|
+
context "when there are a few recordings" do
|
94
|
+
let!(:recording1) { FactoryGirl.create(:bigbluebutton_recording, size: 100000000) } # 100 MB
|
95
|
+
let!(:recording2) { FactoryGirl.create(:bigbluebutton_recording, size: 200000000) } # 200 MB
|
96
|
+
|
97
|
+
it { BigbluebuttonRecording.overall_average_size.should eql(150000000) }
|
98
|
+
end
|
99
|
+
end
|
100
|
+
|
69
101
|
describe ".sync" do
|
70
102
|
let(:data) {
|
71
103
|
[
|
@@ -4,7 +4,6 @@ describe BigbluebuttonRoom do
|
|
4
4
|
|
5
5
|
# to ensure that the migration is correct
|
6
6
|
context "db" do
|
7
|
-
it { should have_db_column(:server_id).of_type(:integer) }
|
8
7
|
it { should have_db_column(:owner_id).of_type(:integer) }
|
9
8
|
it { should have_db_column(:owner_type).of_type(:string) }
|
10
9
|
it { should have_db_column(:meetingid).of_type(:string) }
|
@@ -26,7 +25,6 @@ describe BigbluebuttonRoom do
|
|
26
25
|
it { should have_db_column(:created_at).of_type(:datetime) }
|
27
26
|
it { should have_db_column(:updated_at).of_type(:datetime) }
|
28
27
|
it { should have_db_column(:create_time).of_type(:integer) }
|
29
|
-
it { should have_db_index(:server_id) }
|
30
28
|
it { should have_db_index(:meetingid).unique(true) }
|
31
29
|
it "default values" do
|
32
30
|
room = BigbluebuttonRoom.new
|
@@ -1,4 +1,4 @@
|
|
1
|
-
#
|
1
|
+
# coding: utf-8
|
2
2
|
require 'spec_helper'
|
3
3
|
|
4
4
|
describe BigbluebuttonRoom do
|
@@ -8,9 +8,6 @@ describe BigbluebuttonRoom do
|
|
8
8
|
|
9
9
|
before { FactoryGirl.create(:bigbluebutton_room) }
|
10
10
|
|
11
|
-
it { should belong_to(:server) }
|
12
|
-
it { should_not validate_presence_of(:server_id) }
|
13
|
-
|
14
11
|
it { should belong_to(:owner) }
|
15
12
|
it { should_not validate_presence_of(:owner_id) }
|
16
13
|
it { should_not validate_presence_of(:owner_type) }
|
@@ -68,7 +65,7 @@ describe BigbluebuttonRoom do
|
|
68
65
|
# attr_accessors
|
69
66
|
[:running, :participant_count, :moderator_count, :attendees,
|
70
67
|
:has_been_forcibly_ended, :start_time, :end_time, :external,
|
71
|
-
:
|
68
|
+
:request_headers, :record_meeting, :duration].each do |attr|
|
72
69
|
it { should respond_to(attr) }
|
73
70
|
it { should respond_to("#{attr}=") }
|
74
71
|
end
|
@@ -152,7 +149,7 @@ describe BigbluebuttonRoom do
|
|
152
149
|
b.meetingid.should == "user defined"
|
153
150
|
}
|
154
151
|
end
|
155
|
-
|
152
|
+
end
|
156
153
|
|
157
154
|
describe "#room_options" do
|
158
155
|
it "is created when the room is created" do
|
@@ -245,8 +242,7 @@ describe BigbluebuttonRoom do
|
|
245
242
|
context "fetches 'running' when not running" do
|
246
243
|
before {
|
247
244
|
mocked_api.should_receive(:is_meeting_running?).with(room.meetingid).and_return(false)
|
248
|
-
room.should_receive(:
|
249
|
-
room.server = mocked_server
|
245
|
+
room.should_receive(:select_server).and_return(mocked_server)
|
250
246
|
}
|
251
247
|
before(:each) { @response = room.fetch_is_running? }
|
252
248
|
it { room.running.should be(false) }
|
@@ -257,8 +253,7 @@ describe BigbluebuttonRoom do
|
|
257
253
|
context "fetches 'running' when running" do
|
258
254
|
before {
|
259
255
|
mocked_api.should_receive(:is_meeting_running?).with(room.meetingid).and_return(true)
|
260
|
-
room.should_receive(:
|
261
|
-
room.server = mocked_server
|
256
|
+
room.should_receive(:select_server).and_return(mocked_server)
|
262
257
|
}
|
263
258
|
before(:each) { @response = room.fetch_is_running? }
|
264
259
|
it { room.running.should be_truthy }
|
@@ -288,8 +283,8 @@ describe BigbluebuttonRoom do
|
|
288
283
|
}
|
289
284
|
let(:metadata) {
|
290
285
|
m = {}
|
291
|
-
m[BigbluebuttonRails.metadata_user_id] = user.id
|
292
|
-
m[BigbluebuttonRails.metadata_user_name] = user.name
|
286
|
+
m[BigbluebuttonRails.configuration.metadata_user_id] = user.id
|
287
|
+
m[BigbluebuttonRails.configuration.metadata_user_name] = user.name
|
293
288
|
m
|
294
289
|
}
|
295
290
|
let(:hash_info2) {
|
@@ -306,8 +301,7 @@ describe BigbluebuttonRoom do
|
|
306
301
|
before {
|
307
302
|
mocked_api.should_receive(:get_meeting_info).
|
308
303
|
with(room.meetingid, room.moderator_api_password).and_return(hash_info)
|
309
|
-
room.should_receive(:
|
310
|
-
room.server = mocked_server
|
304
|
+
room.should_receive(:select_server).and_return(mocked_server)
|
311
305
|
}
|
312
306
|
before(:each) { room.fetch_meeting_info }
|
313
307
|
it { room.running.should == false }
|
@@ -324,8 +318,7 @@ describe BigbluebuttonRoom do
|
|
324
318
|
before {
|
325
319
|
mocked_api.should_receive(:get_meeting_info).
|
326
320
|
with(room.meetingid, room.moderator_api_password).and_return(hash_info2)
|
327
|
-
room.should_receive(:
|
328
|
-
room.server = mocked_server
|
321
|
+
room.should_receive(:select_server).and_return(mocked_server)
|
329
322
|
}
|
330
323
|
before(:each) { room.fetch_meeting_info }
|
331
324
|
it { room.running.should == true }
|
@@ -348,8 +341,7 @@ describe BigbluebuttonRoom do
|
|
348
341
|
before {
|
349
342
|
mocked_api.should_receive(:get_meeting_info).
|
350
343
|
with(room.meetingid, room.moderator_api_password).and_return(hash_info2)
|
351
|
-
room.should_receive(:
|
352
|
-
room.server = mocked_server
|
344
|
+
room.should_receive(:select_server).and_return(mocked_server)
|
353
345
|
|
354
346
|
# here's the validation
|
355
347
|
room.should_receive(:update_current_meeting_record).with(metadata, true)
|
@@ -364,6 +356,7 @@ describe BigbluebuttonRoom do
|
|
364
356
|
e
|
365
357
|
}
|
366
358
|
before {
|
359
|
+
room.should_receive(:select_server).and_return(mocked_server)
|
367
360
|
expect(mocked_api).to receive(:get_meeting_info) { raise exception }
|
368
361
|
expect(room).not_to receive(:update_current_meeting_record)
|
369
362
|
expect(room).to receive(:finish_meetings)
|
@@ -382,6 +375,7 @@ describe BigbluebuttonRoom do
|
|
382
375
|
e
|
383
376
|
}
|
384
377
|
before {
|
378
|
+
room.should_receive(:select_server).and_return(mocked_server)
|
385
379
|
expect(mocked_api).to receive(:get_meeting_info) { raise exception }
|
386
380
|
expect(room).not_to receive(:update_current_meeting_record)
|
387
381
|
expect(room).to receive(:finish_meetings)
|
@@ -400,6 +394,7 @@ describe BigbluebuttonRoom do
|
|
400
394
|
e
|
401
395
|
}
|
402
396
|
before {
|
397
|
+
room.should_receive(:select_server).and_return(mocked_server)
|
403
398
|
expect(mocked_api).to receive(:get_meeting_info) { raise exception }
|
404
399
|
expect(room).not_to receive(:update_current_meeting_record)
|
405
400
|
expect(room).to receive(:finish_meetings)
|
@@ -414,6 +409,7 @@ describe BigbluebuttonRoom do
|
|
414
409
|
context "raises any exception other than a BigBlueButtonException" do
|
415
410
|
let!(:exception) { NoMethodError.new('Test error') }
|
416
411
|
before {
|
412
|
+
room.should_receive(:select_server).and_return(mocked_server)
|
417
413
|
expect(mocked_api).to receive(:get_meeting_info) { raise exception }
|
418
414
|
expect(room).not_to receive(:update_current_meeting_record)
|
419
415
|
expect(room).not_to receive(:finish_meetings)
|
@@ -431,19 +427,20 @@ describe BigbluebuttonRoom do
|
|
431
427
|
context "calls end_meeting" do
|
432
428
|
before {
|
433
429
|
mocked_api.should_receive(:end_meeting).with(room.meetingid, room.moderator_api_password)
|
434
|
-
room.should_receive(:
|
435
|
-
room.server = mocked_server
|
430
|
+
room.should_receive(:select_server).and_return(mocked_server)
|
436
431
|
}
|
437
432
|
it { room.send_end }
|
438
433
|
end
|
439
434
|
|
440
435
|
context "schedules a BigbluebuttonMeetingUpdater" do
|
441
|
-
before {
|
442
|
-
|
436
|
+
before {
|
437
|
+
room.should_receive(:select_server).and_return(mocked_server)
|
438
|
+
mocked_api.should_receive(:end_meeting)
|
443
439
|
expect {
|
444
440
|
room.send_end
|
445
441
|
}.to change{ Resque.info[:pending] }.by(1)
|
446
442
|
}
|
443
|
+
|
447
444
|
subject { Resque.peek(:bigbluebutton_rails) }
|
448
445
|
it("should have a job schedule") { subject.should_not be_nil }
|
449
446
|
it("the job should be the right one") { subject['class'].should eq('BigbluebuttonMeetingUpdater') }
|
@@ -480,7 +477,6 @@ describe BigbluebuttonRoom do
|
|
480
477
|
mocked_api.should_receive(:create_meeting)
|
481
478
|
.with(anything, anything, hash_including(:welcome => "Hi!"))
|
482
479
|
room.stub(:select_server).and_return(mocked_server)
|
483
|
-
room.server = mocked_server
|
484
480
|
end
|
485
481
|
|
486
482
|
context "nil" do
|
@@ -499,7 +495,6 @@ describe BigbluebuttonRoom do
|
|
499
495
|
.with(room.name, room.meetingid, get_create_params(room))
|
500
496
|
.and_return(hash_create)
|
501
497
|
room.stub(:select_server).and_return(mocked_server)
|
502
|
-
room.server = mocked_server
|
503
498
|
room.send_create
|
504
499
|
end
|
505
500
|
|
@@ -514,8 +509,6 @@ describe BigbluebuttonRoom do
|
|
514
509
|
.with(room.name, room.meetingid, expected_params)
|
515
510
|
.and_return(hash_create)
|
516
511
|
room.stub(:select_server).and_return(mocked_server)
|
517
|
-
|
518
|
-
room.server = mocked_server
|
519
512
|
room.send_create
|
520
513
|
end
|
521
514
|
it { room.attendee_api_password.should be(new_attendee_api_password) }
|
@@ -532,7 +525,6 @@ describe BigbluebuttonRoom do
|
|
532
525
|
.with(new_room.name, new_room.meetingid, params)
|
533
526
|
.and_return(hash_create)
|
534
527
|
new_room.stub(:select_server).and_return(mocked_server)
|
535
|
-
new_room.server = mocked_server
|
536
528
|
new_room.send_create
|
537
529
|
end
|
538
530
|
it { new_room.attendee_api_password.should be(new_attendee_api_password) }
|
@@ -553,7 +545,6 @@ describe BigbluebuttonRoom do
|
|
553
545
|
.with(room.name, room.meetingid, params)
|
554
546
|
.and_return(hash_create)
|
555
547
|
room.stub(:select_server).and_return(mocked_server)
|
556
|
-
room.server = mocked_server
|
557
548
|
room.send_create(user)
|
558
549
|
end
|
559
550
|
it { room.attendee_api_password.should be(new_attendee_api_password) }
|
@@ -570,7 +561,6 @@ describe BigbluebuttonRoom do
|
|
570
561
|
.with(room.name, room.meetingid, params)
|
571
562
|
.and_return(hash_create)
|
572
563
|
room.stub(:select_server).and_return(mocked_server)
|
573
|
-
room.server = mocked_server
|
574
564
|
room.send_create(user, user_opts)
|
575
565
|
end
|
576
566
|
it { room.attendee_api_password.should be(new_attendee_api_password) }
|
@@ -587,7 +577,6 @@ describe BigbluebuttonRoom do
|
|
587
577
|
.with(room.name, room.meetingid, get_create_params(room))
|
588
578
|
.and_return(hash_create)
|
589
579
|
room.stub(:select_server).and_return(mocked_server)
|
590
|
-
room.server = mocked_server
|
591
580
|
room.send_create
|
592
581
|
end
|
593
582
|
it { room.voice_bridge.should be_nil }
|
@@ -596,11 +585,11 @@ describe BigbluebuttonRoom do
|
|
596
585
|
|
597
586
|
context "when it's set to use local voice bridges" do
|
598
587
|
before {
|
599
|
-
@use_local_voice_bridges = BigbluebuttonRails.use_local_voice_bridges
|
600
|
-
BigbluebuttonRails.use_local_voice_bridges = true
|
588
|
+
@use_local_voice_bridges = BigbluebuttonRails.configuration.use_local_voice_bridges
|
589
|
+
BigbluebuttonRails.configuration.use_local_voice_bridges = true
|
601
590
|
}
|
602
591
|
after {
|
603
|
-
BigbluebuttonRails.use_local_voice_bridges = @use_local_voice_bridges
|
592
|
+
BigbluebuttonRails.configuration.use_local_voice_bridges = @use_local_voice_bridges
|
604
593
|
}
|
605
594
|
|
606
595
|
context "sets the voice bridge in the params if there's a voice bridge" do
|
@@ -614,7 +603,6 @@ describe BigbluebuttonRoom do
|
|
614
603
|
.with(room.name, room.meetingid, create_params)
|
615
604
|
.and_return(hash_create)
|
616
605
|
room.stub(:select_server).and_return(mocked_server)
|
617
|
-
room.server = mocked_server
|
618
606
|
room.send_create
|
619
607
|
end
|
620
608
|
it { room.changed?.should be(false) }
|
@@ -629,7 +617,6 @@ describe BigbluebuttonRoom do
|
|
629
617
|
.with(room.name, room.meetingid, get_create_params(room))
|
630
618
|
.and_return(hash_create)
|
631
619
|
room.stub(:select_server).and_return(mocked_server)
|
632
|
-
room.server = mocked_server
|
633
620
|
room.send_create
|
634
621
|
end
|
635
622
|
it { room.changed?.should be(false) }
|
@@ -643,16 +630,14 @@ describe BigbluebuttonRoom do
|
|
643
630
|
.and_return(hash_create)
|
644
631
|
room.stub(:select_server).and_return(mocked_server)
|
645
632
|
|
646
|
-
room.server = mocked_server
|
647
633
|
expect {
|
648
634
|
room.send_create
|
649
635
|
}.to change{ BigbluebuttonMeeting.count }.by(1)
|
650
636
|
end
|
651
637
|
subject { BigbluebuttonMeeting.last }
|
652
638
|
it { subject.room.should eql(room) }
|
653
|
-
it { subject.
|
654
|
-
it { subject.
|
655
|
-
it { subject.server_secret.should eql(room.server.secret) }
|
639
|
+
it { subject.server_url.should eql(mocked_server.url) }
|
640
|
+
it { subject.server_secret.should eql(mocked_server.secret) }
|
656
641
|
it { subject.meetingid.should eql(room.meetingid) }
|
657
642
|
it { subject.name.should eql(room.name) }
|
658
643
|
it { subject.recorded.should eql(room.record_meeting) }
|
@@ -669,7 +654,6 @@ describe BigbluebuttonRoom do
|
|
669
654
|
.and_return(hash_create)
|
670
655
|
room.stub(:select_server).and_return(mocked_server)
|
671
656
|
|
672
|
-
room.server = mocked_server
|
673
657
|
expect {
|
674
658
|
room.send_create
|
675
659
|
}.to change{ Resque.info[:pending] }.by(1)
|
@@ -688,7 +672,6 @@ describe BigbluebuttonRoom do
|
|
688
672
|
it "generates a new one if it's empty or nil" do
|
689
673
|
room.meetingid = value
|
690
674
|
room.stub(:select_server).and_return(mocked_server)
|
691
|
-
room.server = mocked_server
|
692
675
|
room.should_receive(:unique_meetingid).and_return(new_id)
|
693
676
|
mocked_api.should_receive(:create_meeting)
|
694
677
|
.with(room.name, new_id, anything)
|
@@ -700,7 +683,6 @@ describe BigbluebuttonRoom do
|
|
700
683
|
old_id = "old id"
|
701
684
|
room.meetingid = old_id
|
702
685
|
room.stub(:select_server).and_return(mocked_server)
|
703
|
-
room.server = mocked_server
|
704
686
|
room.should_not_receive(:unique_meetingid)
|
705
687
|
mocked_api.should_receive(:create_meeting)
|
706
688
|
.with(room.name, old_id, anything)
|
@@ -715,7 +697,6 @@ describe BigbluebuttonRoom do
|
|
715
697
|
it "generates a new one if it's empty or nil" do
|
716
698
|
room.moderator_api_password = value
|
717
699
|
room.stub(:select_server).and_return(mocked_server)
|
718
|
-
room.server = mocked_server
|
719
700
|
room.should_receive(:internal_password).and_return(new_pass)
|
720
701
|
mocked_api.should_receive(:create_meeting)
|
721
702
|
.with(room.name, anything, hash_including(moderatorPW: new_pass))
|
@@ -727,7 +708,6 @@ describe BigbluebuttonRoom do
|
|
727
708
|
old_pass = "old pass"
|
728
709
|
room.moderator_api_password = old_pass
|
729
710
|
room.stub(:select_server).and_return(mocked_server)
|
730
|
-
room.server = mocked_server
|
731
711
|
room.should_not_receive(:internal_password)
|
732
712
|
mocked_api.should_receive(:create_meeting)
|
733
713
|
.with(room.name, anything, hash_including(moderatorPW: old_pass))
|
@@ -742,7 +722,6 @@ describe BigbluebuttonRoom do
|
|
742
722
|
it "generates a new one if it's empty or nil" do
|
743
723
|
room.attendee_api_password = value
|
744
724
|
room.stub(:select_server).and_return(mocked_server)
|
745
|
-
room.server = mocked_server
|
746
725
|
room.should_receive(:internal_password).and_return(new_pass)
|
747
726
|
mocked_api.should_receive(:create_meeting)
|
748
727
|
.with(room.name, anything, hash_including(attendeePW: new_pass))
|
@@ -754,7 +733,6 @@ describe BigbluebuttonRoom do
|
|
754
733
|
old_pass = "old pass"
|
755
734
|
room.attendee_api_password = old_pass
|
756
735
|
room.stub(:select_server).and_return(mocked_server)
|
757
|
-
room.server = mocked_server
|
758
736
|
room.should_not_receive(:internal_password)
|
759
737
|
mocked_api.should_receive(:create_meeting)
|
760
738
|
.with(room.name, anything, hash_including(attendeePW: old_pass))
|
@@ -769,34 +747,23 @@ describe BigbluebuttonRoom do
|
|
769
747
|
mocked_api.should_receive(:create_meeting).
|
770
748
|
with(room.name, room.meetingid, hash).and_return(hash_create)
|
771
749
|
room.stub(:select_server).and_return(mocked_server)
|
772
|
-
room.server = mocked_server
|
773
750
|
end
|
774
751
|
it { room.send_create }
|
775
752
|
end
|
776
753
|
|
777
|
-
context "selects
|
754
|
+
context "selects a server" do
|
778
755
|
let(:another_server) { FactoryGirl.create(:bigbluebutton_server) }
|
779
|
-
let(:room2) { FactoryGirl.create(:bigbluebutton_room
|
780
|
-
|
781
|
-
before do
|
782
|
-
room2.should_receive(:internal_create_meeting)
|
783
|
-
room2.send_create
|
784
|
-
end
|
785
|
-
# send_create will call require_server, so a server will be assigned
|
786
|
-
# to this room
|
787
|
-
it { BigbluebuttonRoom.find(room2.id).server_id.should_not be_nil }
|
788
|
-
end
|
756
|
+
let(:room2) { FactoryGirl.create(:bigbluebutton_room) }
|
757
|
+
let(:api) { double(BigBlueButton::BigBlueButtonApi) }
|
789
758
|
|
790
|
-
context "and
|
791
|
-
let(:new_room) { FactoryGirl.build(:bigbluebutton_room) }
|
759
|
+
context "and saves the result" do
|
792
760
|
before do
|
793
|
-
|
794
|
-
|
795
|
-
|
796
|
-
|
797
|
-
new_room.send_create
|
761
|
+
room2.should_receive(:select_server).with(:create).and_return(another_server)
|
762
|
+
another_server.stub(:api).and_return(api)
|
763
|
+
api.should_receive(:request_headers=)
|
764
|
+
api.should_receive(:create_meeting)
|
798
765
|
end
|
799
|
-
it {
|
766
|
+
it { room2.send_create }
|
800
767
|
end
|
801
768
|
end
|
802
769
|
|
@@ -804,7 +771,6 @@ describe BigbluebuttonRoom do
|
|
804
771
|
before do
|
805
772
|
mocked_api.should_receive(:create_meeting).with(anything, anything, anything)
|
806
773
|
room.stub(:select_server).and_return(mocked_server)
|
807
|
-
room.server = mocked_server
|
808
774
|
room.request_headers = { :anything => "anything" }
|
809
775
|
mocked_api.should_receive(:"request_headers=").once.with(room.request_headers)
|
810
776
|
end
|
@@ -821,11 +787,10 @@ describe BigbluebuttonRoom do
|
|
821
787
|
context "with moderator role" do
|
822
788
|
let(:expected) { 'expected-url' }
|
823
789
|
before {
|
824
|
-
room.should_receive(:
|
790
|
+
room.should_receive(:select_server).and_return(mocked_server)
|
825
791
|
mocked_api.should_receive(:join_meeting_url)
|
826
792
|
.with(room.meetingid, username, room.moderator_api_password, join_options)
|
827
793
|
.and_return(expected)
|
828
|
-
room.server = mocked_server
|
829
794
|
}
|
830
795
|
subject { room.join_url(username, :moderator, nil, join_options) }
|
831
796
|
it("returns the correct url") { subject.should eq(expected) }
|
@@ -834,25 +799,56 @@ describe BigbluebuttonRoom do
|
|
834
799
|
context "with attendee role" do
|
835
800
|
let(:expected) { 'expected-url' }
|
836
801
|
before {
|
837
|
-
room.should_receive(:
|
802
|
+
room.should_receive(:select_server).and_return(mocked_server)
|
838
803
|
mocked_api.should_receive(:join_meeting_url)
|
839
804
|
.with(room.meetingid, username, room.attendee_api_password, join_options)
|
840
805
|
.and_return(expected)
|
841
|
-
room.server = mocked_server
|
842
806
|
}
|
843
807
|
subject { room.join_url(username, :attendee, nil, join_options) }
|
844
808
|
it("returns the correct url") { subject.should eq(expected) }
|
845
809
|
end
|
846
810
|
|
811
|
+
context "with guest role" do
|
812
|
+
let(:expected) { 'expected-url' }
|
813
|
+
|
814
|
+
context "when guest support is disabled" do
|
815
|
+
before {
|
816
|
+
room.should_receive(:select_server).and_return(mocked_server)
|
817
|
+
mocked_api.should_receive(:join_meeting_url)
|
818
|
+
.with(room.meetingid, username, room.attendee_api_password, join_options)
|
819
|
+
.and_return(expected)
|
820
|
+
}
|
821
|
+
subject { room.join_url(username, :guest, nil, join_options) }
|
822
|
+
it("returns the correct url") { subject.should eq(expected) }
|
823
|
+
end
|
824
|
+
|
825
|
+
context "when guest support is enabled" do
|
826
|
+
before {
|
827
|
+
@guest_support_before = BigbluebuttonRails.configuration.guest_support
|
828
|
+
BigbluebuttonRails.configuration.guest_support = true
|
829
|
+
|
830
|
+
room.should_receive(:select_server).and_return(mocked_server)
|
831
|
+
params = { guest: true }.merge(join_options)
|
832
|
+
mocked_api.should_receive(:join_meeting_url)
|
833
|
+
.with(room.meetingid, username, room.attendee_api_password, params)
|
834
|
+
.and_return(expected)
|
835
|
+
}
|
836
|
+
after {
|
837
|
+
BigbluebuttonRails.configuration.guest_support = @guest_support_before
|
838
|
+
}
|
839
|
+
subject { room.join_url(username, :guest, nil, join_options) }
|
840
|
+
it("returns the correct url") { subject.should eq(expected) }
|
841
|
+
end
|
842
|
+
end
|
843
|
+
|
847
844
|
context "without a role" do
|
848
845
|
context "passing the moderator key" do
|
849
846
|
let(:expected) { 'expected-url' }
|
850
847
|
before {
|
851
|
-
room.should_receive(:
|
848
|
+
room.should_receive(:select_server).and_return(mocked_server)
|
852
849
|
mocked_api.should_receive(:join_meeting_url)
|
853
850
|
.with(room.meetingid, username, room.moderator_api_password, join_options)
|
854
851
|
.and_return(expected)
|
855
|
-
room.server = mocked_server
|
856
852
|
}
|
857
853
|
subject { room.join_url(username, nil, room.moderator_key, join_options) }
|
858
854
|
it("returns the correct url") { subject.should eq(expected) }
|
@@ -861,11 +857,10 @@ describe BigbluebuttonRoom do
|
|
861
857
|
context "passing the attendee key" do
|
862
858
|
let(:expected) { 'expected-url' }
|
863
859
|
before {
|
864
|
-
room.should_receive(:
|
860
|
+
room.should_receive(:select_server).and_return(mocked_server)
|
865
861
|
mocked_api.should_receive(:join_meeting_url)
|
866
862
|
.with(room.meetingid, username, room.attendee_api_password, join_options)
|
867
863
|
.and_return(expected)
|
868
|
-
room.server = mocked_server
|
869
864
|
}
|
870
865
|
subject { room.join_url(username, nil, room.attendee_key, join_options) }
|
871
866
|
it("returns the correct url") { subject.should eq(expected) }
|
@@ -874,11 +869,10 @@ describe BigbluebuttonRoom do
|
|
874
869
|
context "passing an unmatching key" do
|
875
870
|
let(:expected) { 'expected-url' }
|
876
871
|
before {
|
877
|
-
room.should_receive(:
|
872
|
+
room.should_receive(:select_server).and_return(mocked_server)
|
878
873
|
mocked_api.should_receive(:join_meeting_url)
|
879
874
|
.with(room.meetingid, username, nil, join_options)
|
880
875
|
.and_return(expected)
|
881
|
-
room.server = mocked_server
|
882
876
|
}
|
883
877
|
subject { room.join_url(username, nil, "wrong key", join_options) }
|
884
878
|
it("returns the correct url") { subject.should eq(expected) }
|
@@ -887,10 +881,9 @@ describe BigbluebuttonRoom do
|
|
887
881
|
|
888
882
|
context "strips the url before returning it" do
|
889
883
|
before {
|
890
|
-
room.should_receive(:
|
884
|
+
room.should_receive(:select_server).and_return(mocked_server)
|
891
885
|
mocked_api.should_receive(:join_meeting_url)
|
892
886
|
.and_return(" my.url/with/spaces \t ")
|
893
|
-
room.server = mocked_server
|
894
887
|
}
|
895
888
|
subject { room.join_url(username, :moderator) }
|
896
889
|
it("returns the url stripped") { subject.should eq('my.url/with/spaces') }
|
@@ -918,6 +911,7 @@ describe BigbluebuttonRoom do
|
|
918
911
|
|
919
912
|
context "and the xml generated is not equal the default one" do
|
920
913
|
before {
|
914
|
+
room.should_receive(:select_server).and_return(mocked_server)
|
921
915
|
room.room_options.should_receive(:set_on_config_xml)
|
922
916
|
.with(config_xml).and_return('fake-config-xml')
|
923
917
|
mocked_api.should_receive(:set_config_xml)
|
@@ -930,6 +924,7 @@ describe BigbluebuttonRoom do
|
|
930
924
|
|
931
925
|
context "and the xml generated is equal the default one" do
|
932
926
|
before {
|
927
|
+
room.should_receive(:select_server).and_return(mocked_server)
|
933
928
|
room.room_options.should_receive(:set_on_config_xml)
|
934
929
|
.with(config_xml).and_return(false)
|
935
930
|
mocked_api.should_not_receive(:set_config_xml)
|
@@ -953,52 +948,70 @@ describe BigbluebuttonRoom do
|
|
953
948
|
|
954
949
|
context "#available_layouts" do
|
955
950
|
context "delegates to server" do
|
951
|
+
let(:server) { FactoryGirl.build(:bigbluebutton_server) }
|
956
952
|
let(:room) { FactoryGirl.build(:bigbluebutton_room) }
|
957
953
|
let(:layouts) { [ 'layout-1', 'another layout' ] }
|
954
|
+
|
958
955
|
before {
|
959
|
-
room.
|
956
|
+
room.should_receive(:select_server).and_return(server)
|
957
|
+
server.should_receive(:available_layouts)
|
960
958
|
.and_return(layouts)
|
961
959
|
}
|
962
960
|
it { room.available_layouts.should eql(layouts) }
|
963
961
|
end
|
964
962
|
|
965
963
|
context "returns and empty array if the server is nil" do
|
966
|
-
let(:room) { FactoryGirl.build(:bigbluebutton_room
|
967
|
-
it {
|
964
|
+
let(:room) { FactoryGirl.build(:bigbluebutton_room) }
|
965
|
+
it {
|
966
|
+
room.should_receive(:select_server).and_return(nil)
|
967
|
+
room.available_layouts.should eql([])
|
968
|
+
}
|
968
969
|
end
|
969
970
|
end
|
970
971
|
|
971
972
|
context "#available_layouts_names" do
|
972
973
|
context "delegates to server" do
|
974
|
+
let(:server) { FactoryGirl.build(:bigbluebutton_server) }
|
973
975
|
let(:room) { FactoryGirl.build(:bigbluebutton_room) }
|
974
976
|
let(:layouts) { [ 'layout-1', 'another layout' ] }
|
977
|
+
|
975
978
|
before {
|
976
|
-
room.
|
979
|
+
room.should_receive(:select_server).and_return(server)
|
980
|
+
server.should_receive(:available_layouts_names)
|
977
981
|
.and_return(layouts)
|
978
982
|
}
|
979
983
|
it { room.available_layouts_names.should eql(layouts) }
|
980
984
|
end
|
981
985
|
|
982
986
|
context "returns and empty array if the server is nil" do
|
983
|
-
let(:room) { FactoryGirl.build(:bigbluebutton_room
|
984
|
-
it {
|
987
|
+
let(:room) { FactoryGirl.build(:bigbluebutton_room) }
|
988
|
+
it {
|
989
|
+
room.should_receive(:select_server).and_return(nil)
|
990
|
+
room.available_layouts_names.should eql([])
|
991
|
+
}
|
985
992
|
end
|
986
993
|
end
|
987
994
|
|
988
995
|
context "#available_layouts_for_select" do
|
989
996
|
context "delegates to server" do
|
997
|
+
let(:server) { FactoryGirl.build(:bigbluebutton_server) }
|
990
998
|
let(:room) { FactoryGirl.build(:bigbluebutton_room) }
|
991
999
|
let(:layouts) { [ 'layout-1', 'another layout' ] }
|
1000
|
+
|
992
1001
|
before {
|
993
|
-
room.
|
1002
|
+
room.should_receive(:select_server).and_return(server)
|
1003
|
+
server.should_receive(:available_layouts_for_select)
|
994
1004
|
.and_return(layouts)
|
995
1005
|
}
|
996
1006
|
it { room.available_layouts_for_select.should eql(layouts) }
|
997
1007
|
end
|
998
1008
|
|
999
1009
|
context "returns and empty array if the server is nil" do
|
1000
|
-
let(:room) { FactoryGirl.build(:bigbluebutton_room
|
1001
|
-
it {
|
1010
|
+
let(:room) { FactoryGirl.build(:bigbluebutton_room) }
|
1011
|
+
it {
|
1012
|
+
room.should_receive(:select_server).and_return(nil)
|
1013
|
+
room.available_layouts_for_select.should eql([])
|
1014
|
+
}
|
1002
1015
|
end
|
1003
1016
|
end
|
1004
1017
|
|
@@ -1157,107 +1170,30 @@ describe BigbluebuttonRoom do
|
|
1157
1170
|
it { should respond_to(:"full_logout_url=") }
|
1158
1171
|
end
|
1159
1172
|
|
1160
|
-
describe "#
|
1173
|
+
describe "#select_server" do
|
1174
|
+
let(:server) { FactoryGirl.create(:bigbluebutton_server) }
|
1161
1175
|
let(:room) { FactoryGirl.create(:bigbluebutton_room) }
|
1162
|
-
it { room.respond_to?(:require_server, true).should be(true) }
|
1163
|
-
|
1164
|
-
context "if the room has no server associated" do
|
1165
|
-
let(:server) { FactoryGirl.create(:bigbluebutton_server) }
|
1166
|
-
before {
|
1167
|
-
room.server = nil
|
1168
|
-
}
|
1169
|
-
|
1170
|
-
context "assigns server to room if there is one" do
|
1171
|
-
before {
|
1172
|
-
room.send(:require_server)
|
1173
|
-
}
|
1174
|
-
it { room.reload.server.should_not be_nil }
|
1175
|
-
end
|
1176
|
-
|
1177
|
-
context "raises exception if there are no servers to assign" do
|
1178
|
-
before {
|
1179
|
-
room.should_receive(:select_server).and_return(nil)
|
1180
|
-
}
|
1181
|
-
it {
|
1182
|
-
expect {
|
1183
|
-
room.send(:require_server)
|
1184
|
-
}.to raise_error(BigbluebuttonRails::ServerRequired)
|
1185
|
-
}
|
1186
|
-
end
|
1187
|
-
|
1188
|
-
context "doesn't save the room if no server is selected" do
|
1189
|
-
before {
|
1190
|
-
@updated_at = room.updated_at
|
1191
|
-
room.should_receive(:select_server).and_return(nil)
|
1192
|
-
expect {
|
1193
|
-
room.send(:require_server)
|
1194
|
-
}.to raise_error(BigbluebuttonRails::ServerRequired)
|
1195
|
-
}
|
1196
|
-
it { room.updated_at.should eql(@updated_at) }
|
1197
|
-
end
|
1198
1176
|
|
1199
|
-
|
1200
|
-
let(:room) { FactoryGirl.build(:bigbluebutton_room) }
|
1201
|
-
before {
|
1202
|
-
room.should_receive(:select_server).and_return(server)
|
1203
|
-
room.send(:require_server)
|
1204
|
-
}
|
1205
|
-
it { room.new_record?.should be(true) }
|
1206
|
-
it { room.server.should eql(server) }
|
1207
|
-
end
|
1208
|
-
|
1209
|
-
context "passes the api_method parameter to #select_server" do
|
1210
|
-
let(:method) { :my_api_method }
|
1211
|
-
before {
|
1212
|
-
room.should_receive(:select_server).with(method).and_return(server)
|
1213
|
-
}
|
1214
|
-
it { room.send(:require_server, method) }
|
1215
|
-
end
|
1216
|
-
end
|
1177
|
+
it { room.respond_to?(:select_server, true).should be(true) }
|
1217
1178
|
|
1218
|
-
context "
|
1219
|
-
|
1220
|
-
before {
|
1221
|
-
room.server = server
|
1222
|
-
expect {
|
1223
|
-
room.send(:require_server)
|
1224
|
-
}.not_to raise_error
|
1225
|
-
}
|
1226
|
-
it { room.server.should eql(server) }
|
1179
|
+
context "assigns server to room if there is one" do
|
1180
|
+
it { room.select_server.should eql(BigbluebuttonServer.first) }
|
1227
1181
|
end
|
1228
|
-
end
|
1229
1182
|
|
1230
|
-
|
1231
|
-
let(:room) { FactoryGirl.create(:bigbluebutton_room, :server => nil) }
|
1232
|
-
it { room.respond_to?(:select_server, true).should be(true) }
|
1233
|
-
|
1234
|
-
context "selects the server with less rooms" do
|
1183
|
+
context "raises exception if there are no servers to assign" do
|
1235
1184
|
before {
|
1236
1185
|
BigbluebuttonServer.destroy_all
|
1237
|
-
s1 = FactoryGirl.create(:bigbluebutton_server)
|
1238
|
-
@s2 = FactoryGirl.create(:bigbluebutton_server)
|
1239
|
-
3.times{ FactoryGirl.create(:bigbluebutton_room, :server => s1) }
|
1240
|
-
2.times{ FactoryGirl.create(:bigbluebutton_room, :server => @s2) }
|
1241
1186
|
}
|
1242
|
-
it {
|
1243
|
-
|
1244
|
-
|
1245
|
-
|
1246
|
-
before { BigbluebuttonServer.destroy_all }
|
1247
|
-
it { room.send(:select_server).should == nil }
|
1248
|
-
end
|
1249
|
-
|
1250
|
-
context "returns nil if the room already has a server" do
|
1251
|
-
before {
|
1252
|
-
2.times{ FactoryGirl.create(:bigbluebutton_server) }
|
1253
|
-
room.update_attributes(server: FactoryGirl.create(:bigbluebutton_server))
|
1187
|
+
it {
|
1188
|
+
expect {
|
1189
|
+
room.select_server
|
1190
|
+
}.to raise_error(BigbluebuttonRails::ServerRequired)
|
1254
1191
|
}
|
1255
|
-
it { room.send(:select_server).should == nil }
|
1256
1192
|
end
|
1257
1193
|
end
|
1258
1194
|
|
1259
1195
|
describe "#get_metadata_for_create" do
|
1260
|
-
let(:room) { FactoryGirl.create(:bigbluebutton_room
|
1196
|
+
let(:room) { FactoryGirl.create(:bigbluebutton_room) }
|
1261
1197
|
|
1262
1198
|
context "returns the metadata from the database" do
|
1263
1199
|
before {
|
@@ -1272,20 +1208,12 @@ describe BigbluebuttonRoom do
|
|
1272
1208
|
|
1273
1209
|
context "returns the dynamic metadata, if any" do
|
1274
1210
|
before {
|
1275
|
-
|
1276
|
-
|
1277
|
-
{
|
1278
|
-
"test1" => "value1",
|
1279
|
-
"test2" => "value2"
|
1280
|
-
}
|
1211
|
+
BigbluebuttonRails.configure do |config|
|
1212
|
+
config.get_dynamic_metadata = Proc.new do |room|
|
1213
|
+
{ "test1" => "value1", "test2" => "value2" }
|
1281
1214
|
end
|
1282
1215
|
end
|
1283
1216
|
}
|
1284
|
-
after {
|
1285
|
-
BigbluebuttonRoom.class_eval do
|
1286
|
-
undef_method :dynamic_metadata
|
1287
|
-
end
|
1288
|
-
}
|
1289
1217
|
|
1290
1218
|
it {
|
1291
1219
|
result = { "meta_test1" => "value1", "meta_test2" => "value2" }
|
@@ -1295,23 +1223,15 @@ describe BigbluebuttonRoom do
|
|
1295
1223
|
|
1296
1224
|
context "gives priority to the dynamic metadata" do
|
1297
1225
|
before {
|
1298
|
-
|
1299
|
-
|
1300
|
-
{
|
1301
|
-
"test1" => "value1",
|
1302
|
-
"test2" => "value2"
|
1303
|
-
}
|
1226
|
+
BigbluebuttonRails.configure do |config|
|
1227
|
+
config.get_dynamic_metadata = Proc.new do |room|
|
1228
|
+
{ "test1" => "value1", "test2" => "value2" }
|
1304
1229
|
end
|
1305
1230
|
end
|
1306
1231
|
|
1307
1232
|
@m1 = FactoryGirl.create(:bigbluebutton_room_metadata, owner: room, name: "test1", content: "content overwritten")
|
1308
1233
|
@m2 = FactoryGirl.create(:bigbluebutton_room_metadata, owner: room, name: "other", content: "other content")
|
1309
1234
|
}
|
1310
|
-
after {
|
1311
|
-
BigbluebuttonRoom.class_eval do
|
1312
|
-
undef_method :dynamic_metadata
|
1313
|
-
end
|
1314
|
-
}
|
1315
1235
|
|
1316
1236
|
it {
|
1317
1237
|
result = { "meta_test1" => "value1", "meta_test2" => "value2", "meta_other" => "other content" }
|
@@ -1321,7 +1241,7 @@ describe BigbluebuttonRoom do
|
|
1321
1241
|
end
|
1322
1242
|
|
1323
1243
|
describe "#get_current_meeting" do
|
1324
|
-
let(:room) { FactoryGirl.create(:bigbluebutton_room
|
1244
|
+
let(:room) { FactoryGirl.create(:bigbluebutton_room) }
|
1325
1245
|
|
1326
1246
|
context "if there's no start_time set in the room" do
|
1327
1247
|
before { room.start_time = nil }
|
@@ -1353,8 +1273,8 @@ describe BigbluebuttonRoom do
|
|
1353
1273
|
let(:user) { FactoryGirl.build(:user) }
|
1354
1274
|
let(:metadata) {
|
1355
1275
|
m = {}
|
1356
|
-
m[BigbluebuttonRails.metadata_user_id] = user.id
|
1357
|
-
m[BigbluebuttonRails.metadata_user_name] = user.name
|
1276
|
+
m[BigbluebuttonRails.configuration.metadata_user_id] = user.id
|
1277
|
+
m[BigbluebuttonRails.configuration.metadata_user_name] = user.name
|
1358
1278
|
m
|
1359
1279
|
}
|
1360
1280
|
before {
|
@@ -1413,6 +1333,7 @@ describe BigbluebuttonRoom do
|
|
1413
1333
|
end
|
1414
1334
|
|
1415
1335
|
describe "#create_meeting_record" do
|
1336
|
+
let(:server) { FactoryGirl.create(:bigbluebutton_server) }
|
1416
1337
|
let(:room) { FactoryGirl.create(:bigbluebutton_room) }
|
1417
1338
|
|
1418
1339
|
context "if there is already a current meeting" do
|
@@ -1439,8 +1360,8 @@ describe BigbluebuttonRoom do
|
|
1439
1360
|
let(:user) { FactoryGirl.build(:user) }
|
1440
1361
|
let(:metadata) {
|
1441
1362
|
m = {}
|
1442
|
-
m[BigbluebuttonRails.metadata_user_id] = user.id
|
1443
|
-
m[BigbluebuttonRails.metadata_user_name] = user.name
|
1363
|
+
m[BigbluebuttonRails.configuration.metadata_user_id] = user.id
|
1364
|
+
m[BigbluebuttonRails.configuration.metadata_user_name] = user.name
|
1444
1365
|
m
|
1445
1366
|
}
|
1446
1367
|
before {
|
@@ -1454,13 +1375,13 @@ describe BigbluebuttonRoom do
|
|
1454
1375
|
context "and no metadata was passed" do
|
1455
1376
|
before(:each) {
|
1456
1377
|
expect {
|
1378
|
+
room.should_receive(:select_server).and_return(server)
|
1457
1379
|
room.create_meeting_record
|
1458
1380
|
}.to change{ BigbluebuttonMeeting.count }.by(1)
|
1459
1381
|
}
|
1460
1382
|
subject { BigbluebuttonMeeting.last }
|
1461
|
-
it("sets
|
1462
|
-
it("sets
|
1463
|
-
it("sets server_secret") { subject.server_secret.should eq(room.server.secret) }
|
1383
|
+
it("sets server_url") { subject.server_url.should eq(server.url) }
|
1384
|
+
it("sets server_secret") { subject.server_secret.should eq(server.secret) }
|
1464
1385
|
it("sets room") { subject.room.should eq(room) }
|
1465
1386
|
it("sets meetingid") { subject.meetingid.should eq(room.meetingid) }
|
1466
1387
|
it("sets name") { subject.name.should eq(room.name) }
|
@@ -1549,8 +1470,8 @@ describe BigbluebuttonRoom do
|
|
1549
1470
|
let(:room) { FactoryGirl.create(:bigbluebutton_room) }
|
1550
1471
|
|
1551
1472
|
before {
|
1473
|
+
room.stub(:select_server).and_return(mocked_server)
|
1552
1474
|
mocked_api.stub(:"request_headers=")
|
1553
|
-
room.server = mocked_server
|
1554
1475
|
}
|
1555
1476
|
|
1556
1477
|
it { room.should_not respond_to(:invitation_url) }
|
@@ -1567,45 +1488,33 @@ describe BigbluebuttonRoom do
|
|
1567
1488
|
|
1568
1489
|
context "doesn't add the invitation URL if BigbluebuttonRoom#invitation_url returns nil" do
|
1569
1490
|
before {
|
1570
|
-
|
1571
|
-
|
1491
|
+
BigbluebuttonRails.configure do |config|
|
1492
|
+
config.get_invitation_url = Proc.new do |room|
|
1572
1493
|
nil
|
1573
1494
|
end
|
1574
1495
|
end
|
1575
1496
|
|
1576
|
-
room.should respond_to(:invitation_url)
|
1577
1497
|
mocked_api.should_receive(:create_meeting) do |name, meetingid, opts|
|
1578
1498
|
opts.should_not have_key('meta_invitation-url')
|
1579
1499
|
opts.should_not have_key(:'meta_invitation-url')
|
1580
1500
|
end
|
1581
1501
|
}
|
1582
|
-
after {
|
1583
|
-
BigbluebuttonRoom.class_eval do
|
1584
|
-
undef_method :invitation_url
|
1585
|
-
end
|
1586
|
-
}
|
1587
1502
|
|
1588
1503
|
it { room.send(:internal_create_meeting) }
|
1589
1504
|
end
|
1590
1505
|
|
1591
1506
|
context "adds the value returned by BigbluebuttonRoom#invitation_url" do
|
1592
1507
|
before {
|
1593
|
-
|
1594
|
-
|
1508
|
+
BigbluebuttonRails.configure do |config|
|
1509
|
+
config.get_invitation_url = Proc.new do |room|
|
1595
1510
|
'http://my-invitation.url'
|
1596
1511
|
end
|
1597
1512
|
end
|
1598
1513
|
|
1599
|
-
room.should respond_to(:invitation_url)
|
1600
1514
|
mocked_api.should_receive(:create_meeting) do |name, meetingid, opts|
|
1601
1515
|
opts.should include('meta_invitation-url' => 'http://my-invitation.url')
|
1602
1516
|
end
|
1603
1517
|
}
|
1604
|
-
after {
|
1605
|
-
BigbluebuttonRoom.class_eval do
|
1606
|
-
undef_method :invitation_url
|
1607
|
-
end
|
1608
|
-
}
|
1609
1518
|
|
1610
1519
|
it { room.send(:internal_create_meeting) }
|
1611
1520
|
end
|
@@ -1616,8 +1525,8 @@ describe BigbluebuttonRoom do
|
|
1616
1525
|
let(:room) { FactoryGirl.create(:bigbluebutton_room) }
|
1617
1526
|
|
1618
1527
|
before {
|
1528
|
+
room.stub(:select_server).and_return(mocked_server)
|
1619
1529
|
mocked_api.stub(:"request_headers=")
|
1620
|
-
room.server = mocked_server
|
1621
1530
|
}
|
1622
1531
|
|
1623
1532
|
it { room.should_not respond_to(:dynamic_metadata) }
|
@@ -1635,50 +1544,35 @@ describe BigbluebuttonRoom do
|
|
1635
1544
|
|
1636
1545
|
context "doesn't add the dynamic metadata if it returns nil" do
|
1637
1546
|
before {
|
1638
|
-
|
1639
|
-
|
1547
|
+
BigbluebuttonRails.configure do |config|
|
1548
|
+
config.get_dynamic_metadata = Proc.new do |room|
|
1640
1549
|
nil
|
1641
1550
|
end
|
1642
1551
|
end
|
1643
1552
|
|
1644
|
-
room.should respond_to(:dynamic_metadata)
|
1645
1553
|
mocked_api.should_receive(:create_meeting) do |name, meetingid, opts|
|
1646
1554
|
opts.each do |key, value|
|
1647
1555
|
key.should_not match(/meta_/)
|
1648
1556
|
end
|
1649
1557
|
end
|
1650
1558
|
}
|
1651
|
-
after {
|
1652
|
-
BigbluebuttonRoom.class_eval do
|
1653
|
-
undef_method :dynamic_metadata
|
1654
|
-
end
|
1655
|
-
}
|
1656
1559
|
|
1657
1560
|
it { room.send(:internal_create_meeting) }
|
1658
1561
|
end
|
1659
1562
|
|
1660
1563
|
context "adds the value returned by BigbluebuttonRoom#invitation_url" do
|
1661
1564
|
before {
|
1662
|
-
|
1663
|
-
|
1664
|
-
{
|
1665
|
-
"test1" => "value1",
|
1666
|
-
"test2" => "value2"
|
1667
|
-
}
|
1565
|
+
BigbluebuttonRails.configure do |config|
|
1566
|
+
config.get_dynamic_metadata = Proc.new do |room|
|
1567
|
+
{ "test1" => "value1", "test2" => "value2" }
|
1668
1568
|
end
|
1669
1569
|
end
|
1670
1570
|
|
1671
|
-
room.should respond_to(:dynamic_metadata)
|
1672
1571
|
mocked_api.should_receive(:create_meeting) do |name, meetingid, opts|
|
1673
1572
|
opts.should include('meta_test1' => 'value1')
|
1674
1573
|
opts.should include('meta_test2' => 'value2')
|
1675
1574
|
end
|
1676
1575
|
}
|
1677
|
-
after {
|
1678
|
-
BigbluebuttonRoom.class_eval do
|
1679
|
-
undef_method :dynamic_metadata
|
1680
|
-
end
|
1681
|
-
}
|
1682
1576
|
|
1683
1577
|
it { room.send(:internal_create_meeting) }
|
1684
1578
|
end
|