bigbluebutton_rails 1.2.0 → 1.3.0.beta1
Sign up to get free protection for your applications and to get access to all the features.
- data/.ruby-version +1 -0
- data/.travis.yml +2 -2
- data/CHANGELOG.rdoc +15 -1
- data/Gemfile +15 -4
- data/Gemfile.lock +187 -125
- data/LICENSE +24 -0
- data/README.rdoc +96 -19
- data/Rakefile +32 -16
- data/TODO_08 +9 -10
- data/{spec/rails_app/public → app/assets}/stylesheets/bigbluebutton_rails.css +58 -79
- data/app/controllers/bigbluebutton/recordings_controller.rb +142 -0
- data/app/controllers/bigbluebutton/rooms_controller.rb +105 -50
- data/app/controllers/bigbluebutton/servers_controller.rb +78 -2
- data/app/helpers/bigbluebutton_rails_helper.rb +11 -4
- data/app/models/bigbluebutton_metadata.rb +43 -0
- data/app/models/bigbluebutton_playback_format.rb +9 -0
- data/app/models/bigbluebutton_recording.rb +191 -0
- data/app/models/bigbluebutton_room.rb +92 -66
- data/app/models/bigbluebutton_server.rb +49 -3
- data/app/views/bigbluebutton/recordings/_form.html.erb +67 -0
- data/app/views/bigbluebutton/recordings/_recordings.html.erb +56 -0
- data/app/views/bigbluebutton/recordings/edit.html.erb +5 -0
- data/app/views/bigbluebutton/recordings/index.html.erb +2 -0
- data/app/views/bigbluebutton/recordings/show.html.erb +84 -0
- data/app/views/bigbluebutton/rooms/_form.html.erb +28 -7
- data/app/views/bigbluebutton/rooms/_rooms.html.erb +19 -4
- data/app/views/bigbluebutton/rooms/edit.html.erb +0 -1
- data/app/views/bigbluebutton/rooms/invite.html.erb +2 -1
- data/app/views/bigbluebutton/rooms/join.html.erb +0 -2
- data/app/views/bigbluebutton/rooms/recordings.html.erb +2 -0
- data/app/views/bigbluebutton/rooms/show.html.erb +35 -15
- data/app/views/bigbluebutton/servers/_form.html.erb +4 -0
- data/app/views/bigbluebutton/servers/index.html.erb +8 -3
- data/app/views/bigbluebutton/servers/recordings.html.erb +2 -0
- data/app/views/bigbluebutton/servers/rooms.html.erb +1 -1
- data/app/views/bigbluebutton/servers/show.html.erb +54 -6
- data/bigbluebutton_rails.gemspec +1 -1
- data/config/locales/en.yml +105 -55
- data/config/schedule.rb +3 -0
- data/lib/bigbluebutton_rails.rb +52 -2
- data/lib/bigbluebutton_rails/controller_methods.rb +31 -0
- data/lib/bigbluebutton_rails/rails/routes.rb +50 -14
- data/lib/bigbluebutton_rails/version.rb +1 -1
- data/lib/generators/bigbluebutton_rails/install_generator.rb +8 -8
- data/lib/generators/bigbluebutton_rails/templates/migration.rb +37 -1
- data/lib/generators/bigbluebutton_rails/templates/migration_1_3_0.rb +55 -0
- data/lib/generators/bigbluebutton_rails/templates/migration_1_3_0_b.rb +13 -0
- data/lib/generators/bigbluebutton_rails/views_generator.rb +6 -2
- data/lib/tasks/bigbluebutton_rails/recordings.rake +18 -0
- data/spec/bigbluebutton_rails_spec.rb +2 -2
- data/spec/controllers/bigbluebutton/recordings_controller_json_responses_spec.rb +111 -0
- data/spec/controllers/bigbluebutton/recordings_controller_spec.rb +188 -0
- data/spec/controllers/bigbluebutton/rooms_controller_exception_handling_spec.rb +15 -10
- data/spec/controllers/bigbluebutton/rooms_controller_json_responses_spec.rb +14 -7
- data/spec/controllers/bigbluebutton/rooms_controller_spec.rb +327 -103
- data/spec/controllers/bigbluebutton/servers_controller_json_responses_spec.rb +12 -12
- data/spec/controllers/bigbluebutton/servers_controller_spec.rb +166 -28
- data/spec/factories/bigbluebutton_metadata.rb +11 -0
- data/spec/factories/bigbluebutton_playback_format.rb +8 -0
- data/spec/factories/bigbluebutton_recording.rb +13 -0
- data/spec/factories/bigbluebutton_room.rb +2 -1
- data/spec/factories/bigbluebutton_server.rb +1 -1
- data/spec/factories/user.rb +1 -0
- data/spec/generators/install_generator_spec.rb +21 -10
- data/spec/generators/views_generator_spec.rb +14 -4
- data/spec/models/bigbluebutton_metadata_db_spec.rb +13 -0
- data/spec/models/bigbluebutton_metadata_spec.rb +64 -0
- data/spec/models/bigbluebutton_playback_format_db_spec.rb +13 -0
- data/spec/models/bigbluebutton_playback_format_spec.rb +22 -0
- data/spec/models/bigbluebutton_recording_db_spec.rb +24 -0
- data/spec/models/bigbluebutton_recording_spec.rb +450 -0
- data/spec/models/bigbluebutton_room_db_spec.rb +3 -2
- data/spec/models/bigbluebutton_room_spec.rb +194 -166
- data/spec/models/bigbluebutton_server_spec.rb +107 -27
- data/spec/rails_app/.gitignore +2 -0
- data/spec/rails_app/app/assets/javascripts/application.js +2 -0
- data/spec/rails_app/app/controllers/application_controller.rb +2 -0
- data/spec/rails_app/app/controllers/custom_recordings_controller.rb +8 -0
- data/spec/rails_app/app/controllers/frontpage_controller.rb +7 -0
- data/spec/rails_app/app/views/frontpage/show.html.erb +5 -0
- data/spec/rails_app/app/views/layouts/application.html.erb +5 -2
- data/spec/rails_app/config/application.rb +13 -0
- data/spec/rails_app/config/environments/development.rb +7 -2
- data/spec/rails_app/config/environments/production.rb +9 -0
- data/spec/rails_app/config/environments/test.rb +10 -0
- data/spec/rails_app/config/routes.rb +20 -2
- data/spec/rails_app/features/edit_rooms.feature +2 -3
- data/spec/rails_app/features/edit_servers.feature +2 -3
- data/spec/rails_app/features/step_definitions/activity_monitor_servers_step.rb +2 -2
- data/spec/rails_app/features/step_definitions/common_steps.rb +5 -5
- data/spec/rails_app/features/step_definitions/create_rooms_steps.rb +2 -4
- data/spec/rails_app/features/step_definitions/create_servers_steps.rb +2 -2
- data/spec/rails_app/features/step_definitions/edit_rooms_steps.rb +2 -2
- data/spec/rails_app/features/step_definitions/edit_servers_steps.rb +2 -2
- data/spec/rails_app/features/step_definitions/join_rooms_steps.rb +2 -2
- data/spec/rails_app/features/step_definitions/list_and_show_rooms_steps.rb +2 -2
- data/spec/rails_app/features/support/templates.rb +2 -6
- data/spec/rails_app/lib/tasks/db/populate.rake +119 -0
- data/spec/routing/bigbluebutton/custom_controllers_routing_spec.rb +78 -1
- data/spec/routing/bigbluebutton/recordings_only_routing_spec.rb +43 -0
- data/spec/routing/bigbluebutton/recordings_routing_spec.rb +46 -0
- data/spec/routing/bigbluebutton/rooms_only_routing_spec.rb +67 -0
- data/spec/routing/bigbluebutton/rooms_routing_spec.rb +28 -2
- data/spec/routing/bigbluebutton/servers_only_routing_spec.rb +43 -0
- data/spec/routing/bigbluebutton/servers_routing_spec.rb +16 -1
- data/spec/support/matchers/have_same_attributes_as.rb +20 -3
- data/spec/support/matchers/shoulda/{be_boolean.rb → be_boolean_matcher.rb} +0 -0
- data/spec/support/mocked_server.rb +19 -3
- metadata +48 -28
- data/public/images/loading.gif +0 -0
- data/public/javascripts/jquery.min.js +0 -16
- data/public/stylesheets/bigbluebutton_rails.css +0 -148
- data/spec/rails_app/public/images/loading.gif +0 -0
- data/spec/rails_app/public/images/rails.png +0 -0
- data/spec/rails_app/public/index.html +0 -239
- data/spec/rails_app/public/javascripts/application.js +0 -2
- data/spec/rails_app/public/javascripts/controls.js +0 -965
- data/spec/rails_app/public/javascripts/dragdrop.js +0 -974
- data/spec/rails_app/public/javascripts/effects.js +0 -1123
- data/spec/rails_app/public/javascripts/jquery.min.js +0 -16
- data/spec/rails_app/public/javascripts/prototype.js +0 -6001
- data/spec/rails_app/public/javascripts/rails.js +0 -191
- data/spec/support/shared_examples/rooms_controller.rb +0 -37
@@ -17,17 +17,18 @@ describe BigbluebuttonRoom do
|
|
17
17
|
it { should have_db_column(:voice_bridge).of_type(:string) }
|
18
18
|
it { should have_db_column(:max_participants).of_type(:integer) }
|
19
19
|
it { should have_db_column(:private).of_type(:boolean) }
|
20
|
-
it { should have_db_column(:randomize_meetingid).of_type(:boolean) }
|
21
20
|
it { should have_db_column(:external).of_type(:boolean) }
|
22
21
|
it { should have_db_column(:param).of_type(:string) }
|
22
|
+
it { should have_db_column(:record).of_type(:boolean) }
|
23
|
+
it { should have_db_column(:duration).of_type(:integer) }
|
23
24
|
it { should have_db_index(:server_id) }
|
24
25
|
it { should have_db_index(:meetingid).unique(true) }
|
25
26
|
it { should have_db_index(:voice_bridge).unique(true) }
|
26
27
|
it "default values" do
|
27
28
|
room = BigbluebuttonRoom.new
|
28
29
|
room.private.should be_false
|
29
|
-
room.randomize_meetingid.should be_true
|
30
30
|
room.external.should be_false
|
31
|
+
room.meetingid.should_not be_nil
|
31
32
|
end
|
32
33
|
end
|
33
34
|
|
@@ -6,47 +6,65 @@ describe BigbluebuttonRoom do
|
|
6
6
|
BigbluebuttonRoom.new.should be_a_kind_of(ActiveRecord::Base)
|
7
7
|
end
|
8
8
|
|
9
|
-
before {
|
9
|
+
before { FactoryGirl.create(:bigbluebutton_room) }
|
10
10
|
|
11
11
|
it { should belong_to(:server) }
|
12
|
+
it { should_not validate_presence_of(:server_id) }
|
13
|
+
|
12
14
|
it { should belong_to(:owner) }
|
13
15
|
it { should_not validate_presence_of(:owner_id) }
|
14
16
|
it { should_not validate_presence_of(:owner_type) }
|
15
17
|
|
16
|
-
it {
|
18
|
+
it { should have_many(:recordings).dependent(:nullify) }
|
19
|
+
|
20
|
+
it { should have_many(:metadata).dependent(:destroy) }
|
21
|
+
|
17
22
|
it { should validate_presence_of(:meetingid) }
|
23
|
+
it { should validate_uniqueness_of(:meetingid) }
|
24
|
+
it { should ensure_length_of(:meetingid).is_at_least(1).is_at_most(100) }
|
25
|
+
|
18
26
|
it { should validate_presence_of(:voice_bridge) }
|
27
|
+
it { should validate_uniqueness_of(:voice_bridge) }
|
28
|
+
|
19
29
|
it { should validate_presence_of(:name) }
|
30
|
+
it { should validate_uniqueness_of(:name) }
|
31
|
+
it { should ensure_length_of(:name).is_at_least(1).is_at_most(150) }
|
32
|
+
|
20
33
|
it { should validate_presence_of(:param) }
|
34
|
+
it { should validate_uniqueness_of(:param) }
|
35
|
+
it { should ensure_length_of(:param).is_at_least(1) }
|
21
36
|
|
22
37
|
it { should be_boolean(:private) }
|
23
|
-
|
38
|
+
|
39
|
+
it { should be_boolean(:record) }
|
40
|
+
|
41
|
+
it { should validate_presence_of(:duration) }
|
42
|
+
it { should validate_numericality_of(:duration).only_integer }
|
43
|
+
it { should_not allow_value(-1).for(:duration) }
|
44
|
+
it { should allow_value(0).for(:duration) }
|
45
|
+
it { should allow_value(1).for(:duration) }
|
46
|
+
|
47
|
+
it { should ensure_length_of(:attendee_password).is_at_most(16) }
|
48
|
+
|
49
|
+
it { should ensure_length_of(:moderator_password).is_at_most(16) }
|
50
|
+
|
51
|
+
it { should ensure_length_of(:welcome_msg).is_at_most(250) }
|
52
|
+
|
53
|
+
it { should accept_nested_attributes_for(:metadata).allow_destroy(true) }
|
24
54
|
|
25
55
|
[:name, :server_id, :meetingid, :attendee_password,
|
26
56
|
:moderator_password, :welcome_msg, :owner, :private, :logout_url,
|
27
57
|
:dial_number, :voice_bridge, :max_participants, :owner_id,
|
28
|
-
:owner_type, :
|
58
|
+
:owner_type, :param, :metadata_attributes].
|
29
59
|
each do |attribute|
|
30
60
|
it { should allow_mass_assignment_of(attribute) }
|
31
61
|
end
|
32
62
|
it { should_not allow_mass_assignment_of(:id) }
|
33
63
|
|
34
|
-
it { should validate_uniqueness_of(:meetingid) }
|
35
|
-
it { should validate_uniqueness_of(:name) }
|
36
|
-
it { should validate_uniqueness_of(:voice_bridge) }
|
37
|
-
it { should validate_uniqueness_of(:param) }
|
38
|
-
|
39
|
-
it { should ensure_length_of(:meetingid).is_at_least(1).is_at_most(100) }
|
40
|
-
it { should ensure_length_of(:name).is_at_least(1).is_at_most(150) }
|
41
|
-
it { should ensure_length_of(:attendee_password).is_at_most(16) }
|
42
|
-
it { should ensure_length_of(:moderator_password).is_at_most(16) }
|
43
|
-
it { should ensure_length_of(:welcome_msg).is_at_most(250) }
|
44
|
-
it { should ensure_length_of(:param).is_at_least(3) }
|
45
|
-
|
46
64
|
# attr_accessors
|
47
65
|
[:running, :participant_count, :moderator_count, :attendees,
|
48
|
-
:has_been_forcibly_ended, :start_time, :end_time,
|
49
|
-
:
|
66
|
+
:has_been_forcibly_ended, :start_time, :end_time, :external,
|
67
|
+
:server, :request_headers, :record, :duration].each do |attr|
|
50
68
|
it { should respond_to(attr) }
|
51
69
|
it { should respond_to("#{attr}=") }
|
52
70
|
end
|
@@ -54,7 +72,7 @@ describe BigbluebuttonRoom do
|
|
54
72
|
context ".to_param" do
|
55
73
|
it { should respond_to(:to_param) }
|
56
74
|
it {
|
57
|
-
r =
|
75
|
+
r = FactoryGirl.create(:bigbluebutton_room)
|
58
76
|
r.to_param.should be(r.param)
|
59
77
|
}
|
60
78
|
end
|
@@ -62,7 +80,7 @@ describe BigbluebuttonRoom do
|
|
62
80
|
it { should respond_to(:is_running?) }
|
63
81
|
|
64
82
|
describe "#user_role" do
|
65
|
-
let(:room) {
|
83
|
+
let(:room) { FactoryGirl.build(:bigbluebutton_room, :moderator_password => "mod", :attendee_password => "att") }
|
66
84
|
it { should respond_to(:user_role) }
|
67
85
|
it { room.user_role({ :password => room.moderator_password }).should == :moderator }
|
68
86
|
it { room.user_role({ :password => room.attendee_password }).should == :attendee }
|
@@ -72,7 +90,7 @@ describe BigbluebuttonRoom do
|
|
72
90
|
end
|
73
91
|
|
74
92
|
describe "#instance_variables_compare" do
|
75
|
-
let(:room) {
|
93
|
+
let(:room) { FactoryGirl.create(:bigbluebutton_room) }
|
76
94
|
let(:room2) { BigbluebuttonRoom.last }
|
77
95
|
it { should respond_to(:instance_variables_compare) }
|
78
96
|
it { room.instance_variables_compare(room2).should be_empty }
|
@@ -88,21 +106,21 @@ describe BigbluebuttonRoom do
|
|
88
106
|
end
|
89
107
|
|
90
108
|
describe "#attr_equal?" do
|
91
|
-
before {
|
109
|
+
before { FactoryGirl.create(:bigbluebutton_room) }
|
92
110
|
let(:room) { BigbluebuttonRoom.last }
|
93
111
|
let(:room2) { BigbluebuttonRoom.last }
|
94
112
|
it { should respond_to(:attr_equal?) }
|
95
113
|
it { room.attr_equal?(room2).should be_true }
|
96
|
-
it "
|
114
|
+
it "differentiates instance variables" do
|
97
115
|
room2.running = !room.running
|
98
116
|
room.attr_equal?(room2).should be_false
|
99
117
|
end
|
100
|
-
it "
|
118
|
+
it "differentiates attributes" do
|
101
119
|
room2.private = !room.private
|
102
120
|
room.attr_equal?(room2).should be_false
|
103
121
|
end
|
104
|
-
it "
|
105
|
-
room2 = room.
|
122
|
+
it "differentiates objects" do
|
123
|
+
room2 = room.dup
|
106
124
|
room.attr_equal?(room2).should be_false
|
107
125
|
end
|
108
126
|
end
|
@@ -111,13 +129,14 @@ describe BigbluebuttonRoom do
|
|
111
129
|
let(:room) { BigbluebuttonRoom.new }
|
112
130
|
|
113
131
|
it "fetched attributes before they are fetched" do
|
114
|
-
room.participant_count.should
|
115
|
-
room.moderator_count.should
|
132
|
+
room.participant_count.should be(0)
|
133
|
+
room.moderator_count.should be(0)
|
116
134
|
room.running.should be_false
|
117
135
|
room.has_been_forcibly_ended.should be_false
|
118
136
|
room.start_time.should be_nil
|
119
137
|
room.end_time.should be_nil
|
120
|
-
room.attendees.should
|
138
|
+
room.attendees.should eql([])
|
139
|
+
room.request_headers.should == {}
|
121
140
|
end
|
122
141
|
|
123
142
|
context "meetingid" do
|
@@ -137,7 +156,7 @@ describe BigbluebuttonRoom do
|
|
137
156
|
it { room.voice_bridge.should_not be_nil }
|
138
157
|
it { room.voice_bridge.should =~ /7[0-9]{4}/ }
|
139
158
|
it "tries to randomize 10 times if voice_bridge already exists" do
|
140
|
-
room =
|
159
|
+
room = FactoryGirl.create(:bigbluebutton_room, :voice_bridge => "70000")
|
141
160
|
BigbluebuttonRoom.stub!(:find_by_voice_bridge).and_return(room)
|
142
161
|
SecureRandom.should_receive(:random_number).exactly(10).and_return(0000)
|
143
162
|
room2 = BigbluebuttonRoom.new # triggers the random_number calls
|
@@ -147,7 +166,7 @@ describe BigbluebuttonRoom do
|
|
147
166
|
end
|
148
167
|
end
|
149
168
|
|
150
|
-
context "param format" do
|
169
|
+
context "#param format" do
|
151
170
|
let(:msg) { I18n.t('bigbluebutton_rails.rooms.errors.param_format') }
|
152
171
|
it { should validate_format_of(:param).not_with("123 321").with_message(msg) }
|
153
172
|
it { should validate_format_of(:param).not_with("").with_message(msg) }
|
@@ -158,10 +177,14 @@ describe BigbluebuttonRoom do
|
|
158
177
|
it { should validate_format_of(:param).not_with("ábcd").with_message(msg) }
|
159
178
|
it { should validate_format_of(:param).not_with("-abc").with_message(msg) }
|
160
179
|
it { should validate_format_of(:param).not_with("abc-").with_message(msg) }
|
180
|
+
it { should validate_format_of(:param).not_with("-").with_message(msg) }
|
161
181
|
it { should validate_format_of(:param).with("_abc").with_message(msg) }
|
162
182
|
it { should validate_format_of(:param).with("abc_").with_message(msg) }
|
163
183
|
it { should validate_format_of(:param).with("abc") }
|
164
184
|
it { should validate_format_of(:param).with("123") }
|
185
|
+
it { should validate_format_of(:param).with("1") }
|
186
|
+
it { should validate_format_of(:param).with("a") }
|
187
|
+
it { should validate_format_of(:param).with("_") }
|
165
188
|
it { should validate_format_of(:param).with("abc-123_d5") }
|
166
189
|
end
|
167
190
|
|
@@ -171,18 +194,34 @@ describe BigbluebuttonRoom do
|
|
171
194
|
@room.param.should == @room.name.downcase.parameterize
|
172
195
|
end
|
173
196
|
it "nil" do
|
174
|
-
@room =
|
197
|
+
@room = FactoryGirl.build(:bigbluebutton_room, :param => nil,
|
175
198
|
:name => "-My Name@ _Is Odd_-")
|
176
199
|
end
|
177
200
|
it "empty" do
|
178
|
-
@room =
|
201
|
+
@room = FactoryGirl.build(:bigbluebutton_room, :param => "",
|
179
202
|
:name => "-My Name@ _Is Odd_-")
|
180
203
|
end
|
181
204
|
end
|
182
205
|
|
206
|
+
context "when room set to private" do
|
207
|
+
context "sets passwords that are not yet defined" do
|
208
|
+
let(:room) { FactoryGirl.create(:bigbluebutton_room, :private => false, :moderator_password => nil, :attendee_password => nil) }
|
209
|
+
before(:each) { room.update_attributes(:private => true) }
|
210
|
+
it { room.moderator_password.should_not be_nil }
|
211
|
+
it { room.attendee_password.should_not be_nil }
|
212
|
+
end
|
213
|
+
|
214
|
+
context "only sets the passwords if the room was public before" do
|
215
|
+
let(:room) { FactoryGirl.create(:bigbluebutton_room, :private => true, :moderator_password => "123", :attendee_password => "321") }
|
216
|
+
before(:each) { room.update_attributes(:private => true) }
|
217
|
+
it { room.moderator_password.should == "123" }
|
218
|
+
it { room.attendee_password.should == "321" }
|
219
|
+
end
|
220
|
+
end
|
221
|
+
|
183
222
|
context "using the api" do
|
184
223
|
before { mock_server_and_api }
|
185
|
-
let(:room) {
|
224
|
+
let(:room) { FactoryGirl.create(:bigbluebutton_room) }
|
186
225
|
|
187
226
|
describe "#fetch_is_running?" do
|
188
227
|
|
@@ -302,15 +341,21 @@ describe BigbluebuttonRoom do
|
|
302
341
|
:hasBeenForciblyEnded => "false", :messageKey => {}, :message => {}
|
303
342
|
}
|
304
343
|
}
|
305
|
-
before {
|
344
|
+
before {
|
345
|
+
room.update_attributes(:welcome_msg => "Anything")
|
346
|
+
FactoryGirl.create(:bigbluebutton_room_metadata, :owner => room)
|
347
|
+
FactoryGirl.create(:bigbluebutton_room_metadata, :owner => room)
|
348
|
+
|
349
|
+
mocked_api.should_receive(:"request_headers=").any_number_of_times.with({})
|
350
|
+
}
|
306
351
|
|
307
352
|
it { should respond_to(:send_create) }
|
308
353
|
|
309
354
|
context "calls #default_welcome_msg if welcome_msg is" do
|
310
355
|
before do
|
311
356
|
room.should_receive(:default_welcome_message).and_return("Hi!")
|
312
|
-
mocked_api.should_receive(:create_meeting)
|
313
|
-
with(anything, anything, hash_including(:welcome => "Hi!"))
|
357
|
+
mocked_api.should_receive(:create_meeting)
|
358
|
+
.with(anything, anything, hash_including(:welcome => "Hi!"))
|
314
359
|
room.stub(:select_server).and_return(mocked_server)
|
315
360
|
room.server = mocked_server
|
316
361
|
end
|
@@ -329,12 +374,9 @@ describe BigbluebuttonRoom do
|
|
329
374
|
|
330
375
|
context "for a stored room" do
|
331
376
|
before do
|
332
|
-
|
333
|
-
|
334
|
-
|
335
|
-
:voiceBridge => room.voice_bridge)
|
336
|
-
mocked_api.should_receive(:create_meeting).
|
337
|
-
with(room.name, room.meetingid, hash).and_return(hash_create)
|
377
|
+
mocked_api.should_receive(:create_meeting)
|
378
|
+
.with(room.name, room.meetingid, get_create_params(room))
|
379
|
+
.and_return(hash_create)
|
338
380
|
room.stub(:select_server).and_return(mocked_server)
|
339
381
|
room.server = mocked_server
|
340
382
|
room.send_create
|
@@ -345,14 +387,11 @@ describe BigbluebuttonRoom do
|
|
345
387
|
end
|
346
388
|
|
347
389
|
context "for a new record" do
|
348
|
-
let(:new_room) {
|
390
|
+
let(:new_room) { FactoryGirl.build(:bigbluebutton_room) }
|
349
391
|
before do
|
350
|
-
|
351
|
-
|
352
|
-
|
353
|
-
:voiceBridge => new_room.voice_bridge)
|
354
|
-
mocked_api.should_receive(:create_meeting).
|
355
|
-
with(new_room.name, new_room.meetingid, hash).and_return(hash_create)
|
392
|
+
mocked_api.should_receive(:create_meeting)
|
393
|
+
.with(new_room.name, new_room.meetingid, get_create_params(new_room))
|
394
|
+
.and_return(hash_create)
|
356
395
|
new_room.stub(:select_server).and_return(mocked_server)
|
357
396
|
new_room.server = mocked_server
|
358
397
|
new_room.send_create
|
@@ -362,50 +401,33 @@ describe BigbluebuttonRoom do
|
|
362
401
|
it("and do not save the record") { new_room.new_record?.should be_true }
|
363
402
|
end
|
364
403
|
|
404
|
+
context "passing the user's name and id" do
|
405
|
+
let(:user) { FactoryGirl.build(:user) }
|
406
|
+
before do
|
407
|
+
mocked_api.should_receive(:create_meeting)
|
408
|
+
.with(room.name, room.meetingid, get_create_params(room, user.name, user.id))
|
409
|
+
.and_return(hash_create)
|
410
|
+
room.stub(:select_server).and_return(mocked_server)
|
411
|
+
room.server = mocked_server
|
412
|
+
room.send_create(user.name, user.id)
|
413
|
+
end
|
414
|
+
it { room.attendee_password.should be(attendee_password) }
|
415
|
+
it { room.moderator_password.should be(moderator_password) }
|
416
|
+
it { room.changed?.should be_false }
|
417
|
+
end
|
365
418
|
end
|
366
419
|
|
367
|
-
context "
|
368
|
-
let(:fail_hash) { { :returncode => true, :meetingID => "new id", :messageKey => "duplicateWarning" } }
|
369
|
-
let(:success_hash) { { :returncode => true, :meetingID => "new id", :messageKey => "" } }
|
420
|
+
context "generates a meetingid if nil" do
|
370
421
|
let(:new_id) { "new id" }
|
371
422
|
before {
|
372
|
-
room.
|
423
|
+
room.meetingid = nil
|
373
424
|
room.stub(:select_server).and_return(mocked_server)
|
374
425
|
room.server = mocked_server
|
375
426
|
}
|
376
|
-
|
377
427
|
it "before calling create" do
|
378
|
-
room.should_receive(:
|
379
|
-
|
380
|
-
|
381
|
-
:logoutURL => room.logout_url, :maxParticipants => room.max_participants,
|
382
|
-
:voiceBridge => room.voice_bridge)
|
383
|
-
mocked_api.should_receive(:create_meeting).with(room.name, new_id, hash)
|
384
|
-
room.send_create
|
385
|
-
end
|
386
|
-
|
387
|
-
it "and tries again on error" do
|
388
|
-
# fails twice and then succeds
|
389
|
-
room.should_receive(:random_meetingid).exactly(3).times.and_return(new_id)
|
390
|
-
hash = hash_including(:moderatorPW => room.moderator_password, :attendeePW => room.attendee_password,
|
391
|
-
:welcome => room.welcome_msg, :dialNumber => room.dial_number,
|
392
|
-
:logoutURL => room.logout_url, :maxParticipants => room.max_participants,
|
393
|
-
:voiceBridge => room.voice_bridge)
|
394
|
-
mocked_api.should_receive(:create_meeting).
|
395
|
-
with(room.name, new_id, hash).twice.and_return(fail_hash)
|
396
|
-
mocked_api.should_receive(:create_meeting).
|
397
|
-
with(room.name, new_id, hash).once.and_return(success_hash)
|
398
|
-
room.send_create
|
399
|
-
end
|
400
|
-
|
401
|
-
it "and limits to 10 tries" do
|
402
|
-
room.should_receive(:random_meetingid).exactly(11).times.and_return(new_id)
|
403
|
-
hash = hash_including(:moderatorPW => room.moderator_password, :attendeePW => room.attendee_password,
|
404
|
-
:welcome => room.welcome_msg, :dialNumber => room.dial_number,
|
405
|
-
:logoutURL => room.logout_url, :maxParticipants => room.max_participants,
|
406
|
-
:voiceBridge => room.voice_bridge)
|
407
|
-
mocked_api.should_receive(:create_meeting).
|
408
|
-
with(room.name, new_id, hash).exactly(10).times.and_return(fail_hash)
|
428
|
+
room.should_receive(:unique_meetingid).and_return(new_id)
|
429
|
+
mocked_api.should_receive(:create_meeting)
|
430
|
+
.with(room.name, new_id, get_create_params(room))
|
409
431
|
room.send_create
|
410
432
|
end
|
411
433
|
end
|
@@ -413,10 +435,7 @@ describe BigbluebuttonRoom do
|
|
413
435
|
context "uses #full_logout_url when set" do
|
414
436
|
before do
|
415
437
|
room.full_logout_url = "full-version-of-logout-url"
|
416
|
-
hash =
|
417
|
-
:welcome => room.welcome_msg, :dialNumber => room.dial_number,
|
418
|
-
:logoutURL => "full-version-of-logout-url", :maxParticipants => room.max_participants,
|
419
|
-
:voiceBridge => room.voice_bridge)
|
438
|
+
hash = get_create_params(room).merge({ :logoutURL => "full-version-of-logout-url" })
|
420
439
|
mocked_api.should_receive(:create_meeting).
|
421
440
|
with(room.name, room.meetingid, hash).and_return(hash_create)
|
422
441
|
room.stub(:select_server).and_return(mocked_server)
|
@@ -426,11 +445,10 @@ describe BigbluebuttonRoom do
|
|
426
445
|
end
|
427
446
|
|
428
447
|
context "selects and requires a server" do
|
429
|
-
let(:another_server) {
|
448
|
+
let(:another_server) { FactoryGirl.create(:bigbluebutton_server) }
|
430
449
|
|
431
450
|
context "and saves the result" do
|
432
451
|
before do
|
433
|
-
room.randomize_meetingid = false # take the shortest path inside #send_create
|
434
452
|
room.should_receive(:select_server).and_return(another_server)
|
435
453
|
room.should_receive(:require_server)
|
436
454
|
room.should_receive(:do_create_meeting)
|
@@ -441,9 +459,8 @@ describe BigbluebuttonRoom do
|
|
441
459
|
end
|
442
460
|
|
443
461
|
context "and does not save when is a new record" do
|
444
|
-
let(:new_room) {
|
462
|
+
let(:new_room) { FactoryGirl.build(:bigbluebutton_room) }
|
445
463
|
before do
|
446
|
-
new_room.randomize_meetingid = false # take the shortest path inside #send_create
|
447
464
|
new_room.should_receive(:select_server).and_return(another_server)
|
448
465
|
new_room.should_receive(:require_server)
|
449
466
|
new_room.should_receive(:do_create_meeting).and_return(nil)
|
@@ -455,6 +472,17 @@ describe BigbluebuttonRoom do
|
|
455
472
|
end
|
456
473
|
end
|
457
474
|
|
475
|
+
context "sets the request headers in the server api" do
|
476
|
+
before do
|
477
|
+
mocked_api.should_receive(:create_meeting).with(anything, anything, anything)
|
478
|
+
room.stub(:select_server).and_return(mocked_server)
|
479
|
+
room.server = mocked_server
|
480
|
+
room.request_headers = { :anything => "anything" }
|
481
|
+
mocked_api.should_receive(:"request_headers=").once.with(room.request_headers)
|
482
|
+
end
|
483
|
+
it { room.send_create }
|
484
|
+
end
|
485
|
+
|
458
486
|
end # #send_create
|
459
487
|
|
460
488
|
describe "#join_url" do
|
@@ -492,13 +520,13 @@ describe BigbluebuttonRoom do
|
|
492
520
|
|
493
521
|
context "validates passwords" do
|
494
522
|
context "for private rooms" do
|
495
|
-
let
|
523
|
+
let(:room) { FactoryGirl.create(:bigbluebutton_room, :private => true) }
|
496
524
|
it { room.should_not allow_value('').for(:moderator_password) }
|
497
525
|
it { room.should_not allow_value('').for(:attendee_password) }
|
498
526
|
end
|
499
527
|
|
500
528
|
context "for public rooms" do
|
501
|
-
let
|
529
|
+
let(:room) { FactoryGirl.create(:bigbluebutton_room, :private => false) }
|
502
530
|
it { room.should allow_value('').for(:moderator_password) }
|
503
531
|
it { room.should allow_value('').for(:attendee_password) }
|
504
532
|
end
|
@@ -506,7 +534,7 @@ describe BigbluebuttonRoom do
|
|
506
534
|
|
507
535
|
describe "#add_domain_to_logout_url" do
|
508
536
|
context "when logout_url has a path only" do
|
509
|
-
let(:room) {
|
537
|
+
let(:room) { FactoryGirl.create(:bigbluebutton_room, :logout_url => '/only/path') }
|
510
538
|
before(:each) { room.add_domain_to_logout_url("HTTP://", "test.com:80") }
|
511
539
|
it { room.full_logout_url.should == "http://test.com:80/only/path" }
|
512
540
|
it { room.logout_url.should == "/only/path" }
|
@@ -514,7 +542,7 @@ describe BigbluebuttonRoom do
|
|
514
542
|
end
|
515
543
|
|
516
544
|
context "when logout_url has a path and domain" do
|
517
|
-
let(:room) {
|
545
|
+
let(:room) { FactoryGirl.create(:bigbluebutton_room, :logout_url => 'other.com/only/path') }
|
518
546
|
before(:each) { room.add_domain_to_logout_url("HTTP://", "test.com:80") }
|
519
547
|
it { room.full_logout_url.should == "http://other.com/only/path" }
|
520
548
|
it { room.logout_url.should == "other.com/only/path" }
|
@@ -522,7 +550,7 @@ describe BigbluebuttonRoom do
|
|
522
550
|
end
|
523
551
|
|
524
552
|
context "when logout_url has a path, domain and protocol" do
|
525
|
-
let(:room) {
|
553
|
+
let(:room) { FactoryGirl.create(:bigbluebutton_room, :logout_url => 'HTTPS://other.com/only/path') }
|
526
554
|
before(:each) { room.add_domain_to_logout_url("HTTP://", "test.com:80") }
|
527
555
|
it { room.full_logout_url.should == "https://other.com/only/path" }
|
528
556
|
it { room.logout_url.should == "HTTPS://other.com/only/path" }
|
@@ -530,7 +558,7 @@ describe BigbluebuttonRoom do
|
|
530
558
|
end
|
531
559
|
|
532
560
|
context "does nothing if logout_url is nil" do
|
533
|
-
let(:room) {
|
561
|
+
let(:room) { FactoryGirl.create(:bigbluebutton_room, :logout_url => nil) }
|
534
562
|
before(:each) { room.add_domain_to_logout_url("HTTP://", "test.com:80") }
|
535
563
|
it { room.full_logout_url.should be_nil }
|
536
564
|
it { room.logout_url.should be_nil }
|
@@ -538,70 +566,40 @@ describe BigbluebuttonRoom do
|
|
538
566
|
end
|
539
567
|
end
|
540
568
|
|
541
|
-
describe "#
|
542
|
-
let(:room) {
|
543
|
-
let(:user) {
|
544
|
-
|
545
|
-
context "for an attendee" do
|
546
|
-
before { room.should_receive(:fetch_is_running?) }
|
569
|
+
describe "#create_meeting" do
|
570
|
+
let(:room) { FactoryGirl.create(:bigbluebutton_room) }
|
571
|
+
let(:user) { FactoryGirl.build(:user) }
|
572
|
+
before { room.should_receive(:fetch_is_running?) }
|
547
573
|
|
548
|
-
|
549
|
-
|
550
|
-
|
551
|
-
|
552
|
-
|
553
|
-
|
554
|
-
subject { room.perform_join(user.name, :attendee) }
|
555
|
-
it { should == "http://test.com/attendee/join" }
|
556
|
-
end
|
557
|
-
|
558
|
-
context "when the conference is not running" do
|
559
|
-
before { room.should_receive(:is_running?).and_return(false) }
|
560
|
-
subject { room.perform_join(user.name, :attendee) }
|
561
|
-
it { should be_nil }
|
562
|
-
end
|
574
|
+
context "when the conference is running" do
|
575
|
+
before {
|
576
|
+
room.should_receive(:is_running?).and_return(true)
|
577
|
+
}
|
578
|
+
subject { room.create_meeting(user.name) }
|
579
|
+
it { should be_false }
|
563
580
|
end
|
564
581
|
|
565
|
-
context "
|
566
|
-
before {
|
567
|
-
|
568
|
-
|
569
|
-
|
570
|
-
|
571
|
-
|
572
|
-
and_return("http://test.com/moderator/join")
|
573
|
-
}
|
574
|
-
subject { room.perform_join(user.name, :moderator) }
|
575
|
-
it { should == "http://test.com/moderator/join" }
|
576
|
-
end
|
577
|
-
|
578
|
-
context "when the conference is not running" do
|
579
|
-
before {
|
580
|
-
room.should_receive(:is_running?).and_return(false)
|
581
|
-
room.should_receive(:send_create)
|
582
|
-
room.should_receive(:join_url).with(user.name, :moderator).
|
583
|
-
and_return("http://test.com/moderator/join")
|
584
|
-
}
|
585
|
-
subject { room.perform_join(user.name, :moderator) }
|
586
|
-
it { should == "http://test.com/moderator/join" }
|
587
|
-
end
|
588
|
-
|
589
|
-
context "when the arg 'request' is informed" do
|
590
|
-
let(:request) { stub(ActionController::Request) }
|
591
|
-
before {
|
592
|
-
request.stub!(:protocol).and_return("HTTP://")
|
593
|
-
request.stub!(:host_with_port).and_return("test.com:80")
|
594
|
-
room.should_receive(:add_domain_to_logout_url).with("HTTP://", "test.com:80")
|
595
|
-
room.should_receive(:is_running?).and_return(true)
|
596
|
-
room.should_receive(:join_url).with(user.name, :moderator).
|
597
|
-
and_return("http://test.com/moderator/join")
|
598
|
-
}
|
599
|
-
subject { room.perform_join(user.name, :moderator, request) }
|
600
|
-
it { should == "http://test.com/moderator/join" }
|
601
|
-
end
|
602
|
-
|
582
|
+
context "when the conference is not running" do
|
583
|
+
before {
|
584
|
+
room.should_receive(:is_running?).and_return(false)
|
585
|
+
room.should_receive(:send_create).with(user.name, user.id)
|
586
|
+
}
|
587
|
+
subject { room.create_meeting(user.name, user.id) }
|
588
|
+
it { should be_true }
|
603
589
|
end
|
604
590
|
|
591
|
+
context "when the arg 'request' is informed" do
|
592
|
+
let(:request) { stub(ActionDispatch::Request) }
|
593
|
+
before {
|
594
|
+
request.stub!(:protocol).and_return("HTTP://")
|
595
|
+
request.stub!(:host_with_port).and_return("test.com:80")
|
596
|
+
room.should_receive(:add_domain_to_logout_url).with("HTTP://", "test.com:80")
|
597
|
+
room.should_receive(:is_running?).and_return(false)
|
598
|
+
room.should_receive(:send_create)
|
599
|
+
}
|
600
|
+
subject { room.create_meeting(user.name, user.id, request) }
|
601
|
+
it { should be_true }
|
602
|
+
end
|
605
603
|
end
|
606
604
|
|
607
605
|
describe "#full_logout_url" do
|
@@ -611,7 +609,7 @@ describe BigbluebuttonRoom do
|
|
611
609
|
end
|
612
610
|
|
613
611
|
describe "#require_server" do
|
614
|
-
let(:room) {
|
612
|
+
let(:room) { FactoryGirl.create(:bigbluebutton_room) }
|
615
613
|
it { should respond_to(:require_server) }
|
616
614
|
|
617
615
|
context "throws exception when the room has no server associated" do
|
@@ -624,7 +622,7 @@ describe BigbluebuttonRoom do
|
|
624
622
|
end
|
625
623
|
|
626
624
|
context "does nothing if the room has a server associated" do
|
627
|
-
before { room.server =
|
625
|
+
before { room.server = FactoryGirl.create(:bigbluebutton_server) }
|
628
626
|
it {
|
629
627
|
lambda {
|
630
628
|
room.send(:require_server)
|
@@ -634,16 +632,16 @@ describe BigbluebuttonRoom do
|
|
634
632
|
end
|
635
633
|
|
636
634
|
describe "#select_server" do
|
637
|
-
let(:room) {
|
635
|
+
let(:room) { FactoryGirl.create(:bigbluebutton_room, :server => nil) }
|
638
636
|
it { should respond_to(:select_server) }
|
639
637
|
|
640
638
|
context "selects the server with less rooms" do
|
641
639
|
before {
|
642
640
|
BigbluebuttonServer.destroy_all
|
643
|
-
s1 =
|
644
|
-
@s2 =
|
645
|
-
3.times{
|
646
|
-
2.times{
|
641
|
+
s1 = FactoryGirl.create(:bigbluebutton_server)
|
642
|
+
@s2 = FactoryGirl.create(:bigbluebutton_server)
|
643
|
+
3.times{ FactoryGirl.create(:bigbluebutton_room, :server => s1) }
|
644
|
+
2.times{ FactoryGirl.create(:bigbluebutton_room, :server => @s2) }
|
647
645
|
}
|
648
646
|
it { room.send(:select_server).should == @s2 }
|
649
647
|
end
|
@@ -654,4 +652,34 @@ describe BigbluebuttonRoom do
|
|
654
652
|
end
|
655
653
|
end
|
656
654
|
|
655
|
+
describe "#get_metadata_for_create" do
|
656
|
+
let(:room) { FactoryGirl.create(:bigbluebutton_room, :server => nil) }
|
657
|
+
before {
|
658
|
+
@m1 = FactoryGirl.create(:bigbluebutton_room_metadata, :owner => room)
|
659
|
+
@m2 = FactoryGirl.create(:bigbluebutton_room_metadata, :owner => room)
|
660
|
+
}
|
661
|
+
it {
|
662
|
+
result = { "meta_#{@m1.name}" => @m1.content, "meta_#{@m2.name}" => @m2.content }
|
663
|
+
room.send(:get_metadata_for_create).should == result
|
664
|
+
}
|
665
|
+
end
|
666
|
+
|
667
|
+
end
|
668
|
+
|
669
|
+
def get_create_params(room, username=nil, userid=nil)
|
670
|
+
params = {
|
671
|
+
:moderatorPW => room.moderator_password,
|
672
|
+
:attendeePW => room.attendee_password,
|
673
|
+
:welcome => room.welcome_msg,
|
674
|
+
:dialNumber => room.dial_number,
|
675
|
+
:logoutURL => room.logout_url,
|
676
|
+
:maxParticipants => room.max_participants,
|
677
|
+
:voiceBridge => room.voice_bridge,
|
678
|
+
:record => room.record,
|
679
|
+
:duration => room.duration
|
680
|
+
}
|
681
|
+
room.metadata.each { |meta| params["meta_#{meta.name}"] = meta.content }
|
682
|
+
params.merge!({ "meta_bbbrails-user-id" => userid }) unless userid.nil?
|
683
|
+
params.merge!({ "meta_bbbrails-user-name" => username }) unless username.nil?
|
684
|
+
params
|
657
685
|
end
|