bigbluebutton_rails 0.0.2 → 0.0.3

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.
Files changed (43) hide show
  1. data/CHANGELOG.rdoc +9 -1
  2. data/Gemfile.lock +3 -3
  3. data/README.rdoc +56 -21
  4. data/Rakefile +1 -0
  5. data/app/controllers/bigbluebutton/rooms_controller.rb +92 -35
  6. data/app/models/bigbluebutton_room.rb +136 -27
  7. data/app/models/bigbluebutton_server.rb +22 -6
  8. data/app/views/bigbluebutton/rooms/_form.html.erb +31 -6
  9. data/app/views/bigbluebutton/rooms/edit.html.erb +1 -1
  10. data/app/views/bigbluebutton/rooms/index.html.erb +20 -8
  11. data/app/views/bigbluebutton/rooms/invite.html.erb +56 -0
  12. data/app/views/bigbluebutton/rooms/{join_wait.html.erb → join.html.erb} +16 -12
  13. data/app/views/bigbluebutton/rooms/new.html.erb +1 -1
  14. data/app/views/bigbluebutton/rooms/show.html.erb +33 -9
  15. data/app/views/bigbluebutton/servers/edit.html.erb +1 -1
  16. data/app/views/bigbluebutton/servers/index.html.erb +6 -4
  17. data/app/views/bigbluebutton/servers/new.html.erb +1 -1
  18. data/app/views/bigbluebutton/servers/show.html.erb +5 -5
  19. data/bigbluebutton_rails.gemspec +1 -1
  20. data/config/locales/en.yml +31 -0
  21. data/lib/bigbluebutton_rails/controller_methods.rb +7 -1
  22. data/lib/bigbluebutton_rails/rails/routes.rb +10 -1
  23. data/lib/bigbluebutton_rails/version.rb +1 -1
  24. data/lib/bigbluebutton_rails.rb +0 -1
  25. data/lib/classes/bigbluebutton_attendee.rb +2 -0
  26. data/lib/generators/bigbluebutton_rails/install_generator.rb +2 -1
  27. data/lib/generators/bigbluebutton_rails/public_generator.rb +0 -1
  28. data/lib/generators/bigbluebutton_rails/templates/migration.rb +8 -2
  29. data/spec/controllers/bigbluebutton/rooms_controller_spec.rb +339 -88
  30. data/spec/factories/bigbluebutton_room.rb +5 -3
  31. data/spec/factories/user.rb +3 -0
  32. data/spec/generators/public_generator_spec.rb +0 -1
  33. data/spec/generators/views_generator_spec.rb +1 -1
  34. data/spec/models/bigbluebutton_room_spec.rb +276 -177
  35. data/spec/models/bigbluebutton_server_spec.rb +117 -96
  36. data/spec/routing/bigbluebutton/rooms_routing_spec.rb +24 -0
  37. data/spec/support/matchers/shoulda/be_boolean.rb +38 -0
  38. data/spec/support/mocked_server.rb +14 -0
  39. metadata +26 -26
  40. data/config/routes.rb +0 -2
  41. data/lib/classes/bigbluebutton_meeting.rb +0 -18
  42. data/lib/generators/bigbluebutton_rails/templates/public/javascripts/heartbeat.js +0 -54
  43. data/spec/classes/bigbluebutton_meeting_spec.rb +0 -62
@@ -1,27 +1,15 @@
1
1
  require 'spec_helper'
2
2
  require 'bigbluebutton-api'
3
3
 
4
+ # Some tests mock the server and its API object
5
+ # We don't want to trigger real API calls here (this is done in the integration tests)
6
+
4
7
  def build_running_json(value, error=nil)
5
8
  hash = { :running => "#{value}" }
6
9
  hash[:error] = error unless error.nil?
7
10
  hash.to_json
8
11
  end
9
12
 
10
- def mock_server_and_api
11
- @api_mock = mock(BigBlueButton::BigBlueButtonApi)
12
- @server_mock = mock_model(BigbluebuttonServer)
13
- @server_mock.stub(:api).and_return(@api_mock)
14
- BigbluebuttonServer.stub(:find).and_return(@server_mock)
15
- end
16
-
17
- def mocked_server
18
- @server_mock
19
- end
20
-
21
- def mocked_api
22
- @api_mock
23
- end
24
-
25
13
  describe Bigbluebutton::RoomsController do
26
14
 
27
15
  render_views
@@ -59,7 +47,7 @@ describe Bigbluebutton::RoomsController do
59
47
  describe "#create" do
60
48
  let(:new_room) { Factory.build(:bigbluebutton_room, :server => server) }
61
49
 
62
- context do
50
+ context "on success" do
63
51
  before :each do
64
52
  expect {
65
53
  post :create, :server_id => server.to_param, :bigbluebutton_room => new_room.attributes
@@ -67,7 +55,7 @@ describe Bigbluebutton::RoomsController do
67
55
  end
68
56
  it {
69
57
  should respond_with(:redirect)
70
- should redirect_to(bigbluebutton_server_room_path(server, BigbluebuttonRoom.last))
58
+ should redirect_to bigbluebutton_server_room_path(server, BigbluebuttonRoom.last)
71
59
  }
72
60
  it { should set_the_flash.to(I18n.t('bigbluebutton_rails.rooms.notice.create.success')) }
73
61
  it { should assign_to(:server).with(server) }
@@ -77,15 +65,46 @@ describe Bigbluebutton::RoomsController do
77
65
  }
78
66
  end
79
67
 
80
- context "when meeting_id is not specified should copied from name" do
68
+ context "on failure" do
69
+ before :each do
70
+ new_room.name = nil # invalid
71
+ expect {
72
+ post :create, :server_id => server.to_param, :bigbluebutton_room => new_room.attributes
73
+ }.not_to change{ BigbluebuttonRoom.count }
74
+ end
75
+ it { should render_template(:new) }
76
+ it { should assign_to(:server).with(server) }
77
+ end
78
+
79
+ context "with :redir_url" do
80
+ it "on success" do
81
+ expect {
82
+ post :create, :server_id => server.to_param, :bigbluebutton_room => new_room.attributes,
83
+ :redir_url => bigbluebutton_servers_path
84
+ }.to change{ BigbluebuttonRoom.count }.by(1)
85
+ should respond_with(:redirect)
86
+ should redirect_to bigbluebutton_servers_path
87
+ end
88
+ it "on failure" do
89
+ new_room.name = nil # invalid
90
+ expect {
91
+ post :create, :server_id => server.to_param, :bigbluebutton_room => new_room.attributes,
92
+ :redir_url => bigbluebutton_servers_path
93
+ }.not_to change{ BigbluebuttonRoom.count }
94
+ should respond_with(:redirect)
95
+ should redirect_to bigbluebutton_servers_path
96
+ end
97
+ end
98
+
99
+ context "when meetingid is not specified it should be copied from name" do
81
100
  before :each do
82
101
  attr = new_room.attributes
83
- attr.delete("meeting_id")
102
+ attr.delete("meetingid")
84
103
  post :create, :server_id => server.to_param, :bigbluebutton_room => attr
85
104
  end
86
105
  it {
87
106
  saved = BigbluebuttonRoom.last
88
- new_room.meeting_id = new_room.name
107
+ new_room.meetingid = new_room.name
89
108
  saved.should have_same_attributes_as(new_room)
90
109
  }
91
110
  end
@@ -95,7 +114,7 @@ describe Bigbluebutton::RoomsController do
95
114
  let(:new_room) { Factory.build(:bigbluebutton_room) }
96
115
  before { @room = room }
97
116
 
98
- context do
117
+ context "on success" do
99
118
  before :each do
100
119
  expect {
101
120
  put :update, :server_id => server.to_param, :id => @room.to_param, :bigbluebutton_room => new_room.attributes
@@ -103,7 +122,7 @@ describe Bigbluebutton::RoomsController do
103
122
  end
104
123
  it {
105
124
  should respond_with(:redirect)
106
- should redirect_to(bigbluebutton_server_room_path(server, @room))
125
+ should redirect_to bigbluebutton_server_room_path(server, @room)
107
126
  }
108
127
  it {
109
128
  saved = BigbluebuttonRoom.find(@room)
@@ -113,15 +132,41 @@ describe Bigbluebutton::RoomsController do
113
132
  it { should assign_to(:server).with(server) }
114
133
  end
115
134
 
116
- context "when meeting_id is not specified should copied from name" do
135
+ context "on failure" do
136
+ before :each do
137
+ new_room.name = nil # invalid
138
+ put :update, :server_id => server.to_param, :id => @room.to_param, :bigbluebutton_room => new_room.attributes
139
+ end
140
+ it { should render_template(:edit) }
141
+ it { should assign_to(:server).with(server) }
142
+ it { should assign_to(:room).with(@room) }
143
+ end
144
+
145
+ context "with :redir_url" do
146
+ it "on success" do
147
+ put :update, :server_id => server.to_param, :id => @room.to_param, :bigbluebutton_room => new_room.attributes,
148
+ :redir_url => bigbluebutton_servers_path
149
+ should respond_with(:redirect)
150
+ should redirect_to bigbluebutton_servers_path
151
+ end
152
+ it "on failure" do
153
+ new_room.name = nil # invalid
154
+ put :update, :server_id => server.to_param, :id => @room.to_param, :bigbluebutton_room => new_room.attributes,
155
+ :redir_url => bigbluebutton_servers_path
156
+ should respond_with(:redirect)
157
+ should redirect_to bigbluebutton_servers_path
158
+ end
159
+ end
160
+
161
+ context "when meetingid is not specified should copied from name" do
117
162
  before :each do
118
163
  attr = new_room.attributes
119
- attr.delete("meeting_id")
164
+ attr.delete("meetingid")
120
165
  put :update, :server_id => server.to_param, :id => @room.to_param, :bigbluebutton_room => attr
121
166
  end
122
167
  it {
123
168
  saved = BigbluebuttonRoom.find(@room)
124
- new_room.meeting_id = new_room.name
169
+ new_room.meetingid = new_room.name
125
170
  saved.should have_same_attributes_as(new_room)
126
171
  }
127
172
  end
@@ -133,19 +178,31 @@ describe Bigbluebutton::RoomsController do
133
178
  mock_server_and_api
134
179
  # to make sure it calls end_meeting if the meeting is running
135
180
  mocked_api.should_receive(:is_meeting_running?).and_return(true)
136
- mocked_api.should_receive(:end_meeting).with(room.meeting_id, room.moderator_password)
181
+ mocked_api.should_receive(:end_meeting).with(room.meetingid, room.moderator_password)
137
182
  }
138
183
 
139
- before :each do
184
+ context do
185
+ before :each do
186
+ expect {
187
+ delete :destroy, :server_id => mocked_server.to_param, :id => room.to_param
188
+ }.to change{ BigbluebuttonRoom.count }.by(-1)
189
+ end
190
+ it {
191
+ should respond_with(:redirect)
192
+ should redirect_to bigbluebutton_server_rooms_url
193
+ }
194
+ it { should assign_to(:server).with(mocked_server) }
195
+ end
196
+
197
+ it "with :redir_url" do
140
198
  expect {
141
- delete :destroy, :server_id => mocked_server.to_param, :id => room.to_param
199
+ delete :destroy, :server_id => mocked_server.to_param, :id => room.to_param,
200
+ :redir_url => bigbluebutton_servers_path
142
201
  }.to change{ BigbluebuttonRoom.count }.by(-1)
143
- end
144
- it {
145
202
  should respond_with(:redirect)
146
- should redirect_to(bigbluebutton_server_rooms_path)
147
- }
148
- it { should assign_to(:server).with(mocked_server) }
203
+ should redirect_to bigbluebutton_servers_path
204
+ end
205
+
149
206
  end
150
207
 
151
208
  describe "#running" do
@@ -170,58 +227,234 @@ describe Bigbluebutton::RoomsController do
170
227
  end
171
228
 
172
229
  describe "#join" do
173
-
174
- before { controller.stub_chain(:bigbluebutton_user, :name).and_return("Test name") }
175
-
176
- # mock the server so we can mock the BBB API
177
- # we don't want to trigger real API calls here (this is done in the integration tests)
178
-
179
- # setup basic server and API mocks
230
+ let(:user) { Factory.build(:user) }
180
231
  before { mock_server_and_api }
181
232
 
182
- context "if the user is a moderator" do
183
- before {
184
- controller.should_receive(:bigbluebutton_role).with(room).and_return(:moderator)
185
- mocked_api.should_receive(:join_meeting_url).and_return("http://test.com/mod/join")
233
+ context "for an anonymous user" do
234
+ before { controller.stub(:bigbluebutton_user) { nil } }
235
+ before { controller.stub(:bigbluebutton_role) { :moderator } }
236
+ before(:each) { get :join, :server_id => mocked_server.to_param, :id => room.to_param }
237
+ it {
238
+ should respond_with(:redirect)
239
+ should redirect_to(invite_bigbluebutton_server_room_path(mocked_server, room))
186
240
  }
241
+ end
187
242
 
188
- context "and the conference is running" do
243
+ context "for a user without a role" do
244
+ before { controller.stub(:bigbluebutton_user) { user } }
245
+ before { controller.stub(:bigbluebutton_role) { nil } }
246
+ before(:each) { get :join, :server_id => mocked_server.to_param, :id => room.to_param }
247
+ it {
248
+ should respond_with(:redirect)
249
+ should redirect_to(invite_bigbluebutton_server_room_path(mocked_server, room))
250
+ }
251
+ end
252
+
253
+ context do
254
+ before { controller.stub(:bigbluebutton_user) { user } }
255
+
256
+ context "if the user is a moderator" do
189
257
  before {
190
- mocked_api.should_receive(:is_meeting_running?).and_return(true)
258
+ controller.should_receive(:bigbluebutton_role).with(room).and_return(:moderator)
259
+ mocked_api.should_receive(:join_meeting_url).with(room.meetingid, user.name, room.moderator_password).
260
+ and_return("http://test.com/mod/join")
191
261
  }
192
262
 
193
- it "assigns server" do
194
- get :join, :server_id => mocked_server.to_param, :id => room.to_param
195
- should assign_to(:server).with(mocked_server)
263
+ context "and the conference is running" do
264
+ before {
265
+ mocked_api.should_receive(:is_meeting_running?).and_return(true)
266
+ }
267
+
268
+ it "assigns server" do
269
+ get :join, :server_id => mocked_server.to_param, :id => room.to_param
270
+ should assign_to(:server).with(mocked_server)
271
+ end
272
+
273
+ it "redirects to the moderator join url" do
274
+ get :join, :server_id => mocked_server.to_param, :id => room.to_param
275
+ should respond_with(:redirect)
276
+ should redirect_to("http://test.com/mod/join")
277
+ end
196
278
  end
197
279
 
198
- it "redirects to the moderator join url" do
199
- get :join, :server_id => mocked_server.to_param, :id => room.to_param
200
- should respond_with(:redirect)
201
- should redirect_to("http://test.com/mod/join")
280
+ context "and the conference is NOT running" do
281
+ before {
282
+ mocked_api.should_receive(:is_meeting_running?).and_return(false)
283
+ }
284
+
285
+ it "creates the conference" do
286
+ mocked_api.should_receive(:create_meeting).
287
+ with(room.name, room.meetingid, room.moderator_password,
288
+ room.attendee_password, room.welcome_msg, room.dial_number,
289
+ room.logout_url, room.max_participants, room.voice_bridge)
290
+ get :join, :server_id => mocked_server.to_param, :id => room.to_param
291
+ end
202
292
  end
293
+
203
294
  end
204
295
 
205
- context "and the conference is NOT running" do
296
+ context "if the user is an attendee" do
206
297
  before {
207
- mocked_api.should_receive(:is_meeting_running?).and_return(false)
298
+ controller.should_receive(:bigbluebutton_role).with(room).and_return(:attendee)
208
299
  }
209
300
 
210
- it "creates the conference" do
211
- mocked_api.should_receive(:create_meeting).
212
- with(room.name, room.meeting_id, room.moderator_password,
213
- room.attendee_password, room.welcome_msg)
214
- get :join, :server_id => mocked_server.to_param, :id => room.to_param
301
+ context "and the conference is running" do
302
+ before {
303
+ mocked_api.should_receive(:is_meeting_running?).and_return(true)
304
+ mocked_api.should_receive(:join_meeting_url).with(room.meetingid, user.name, room.attendee_password).
305
+ and_return("http://test.com/attendee/join")
306
+ }
307
+
308
+ it "assigns server" do
309
+ get :join, :server_id => mocked_server.to_param, :id => room.to_param
310
+ should assign_to(:server).with(mocked_server)
311
+ end
312
+
313
+ it "redirects to the attendee join url" do
314
+ get :join, :server_id => mocked_server.to_param, :id => room.to_param
315
+ should respond_with(:redirect)
316
+ should redirect_to("http://test.com/attendee/join")
317
+ end
318
+ end
319
+
320
+ context "and the conference is NOT running" do
321
+ before {
322
+ mocked_api.should_receive(:is_meeting_running?).and_return(false)
323
+ }
324
+
325
+ it "do not try to create the conference" do
326
+ mocked_api.should_not_receive(:create_meeting)
327
+ get :join, :server_id => mocked_server.to_param, :id => room.to_param
328
+ end
329
+
330
+ it "renders #join to wait for a moderator" do
331
+ get :join, :server_id => mocked_server.to_param, :id => room.to_param
332
+ should respond_with(:success)
333
+ should render_template(:join)
334
+ end
215
335
  end
336
+
216
337
  end
217
338
 
218
339
  end
219
340
 
220
- context "if the user is an attendee" do
341
+ end
342
+
343
+ describe "#end" do
344
+ before { mock_server_and_api }
345
+
346
+ context "room is running" do
221
347
  before {
222
- controller.should_receive(:bigbluebutton_role).with(room).and_return(:attendee)
348
+ mocked_api.should_receive(:is_meeting_running?).and_return(true)
349
+ mocked_api.should_receive(:end_meeting).with(room.meetingid, room.moderator_password)
223
350
  }
351
+ before(:each) { get :end, :server_id => mocked_server.to_param, :id => room.to_param }
352
+ it { should respond_with(:redirect) }
353
+ it { should redirect_to(bigbluebutton_server_room_path(mocked_server, room)) }
354
+ it { should assign_to(:server).with(mocked_server) }
355
+ it { should assign_to(:room).with(room) }
356
+ it { should set_the_flash.to(I18n.t('bigbluebutton_rails.rooms.notice.end.success')) }
357
+ end
358
+
359
+ context "room is not running" do
360
+ before { mocked_api.should_receive(:is_meeting_running?).and_return(false) }
361
+ before(:each) { get :end, :server_id => mocked_server.to_param, :id => room.to_param }
362
+ it { should set_the_flash.to(I18n.t('bigbluebutton_rails.rooms.notice.end.not_running')) }
363
+ end
364
+ end
365
+
366
+ describe "#invite" do
367
+ before { mock_server_and_api }
368
+ let(:user) { Factory.build(:user) }
369
+
370
+ context "for an anonymous user" do
371
+ before { controller.stub(:bigbluebutton_user).and_return(nil) }
372
+
373
+ context "with a role defined" do
374
+ before { controller.stub(:bigbluebutton_role).and_return(:attendee) }
375
+ before(:each) { get :invite, :server_id => mocked_server.to_param, :id => room.to_param }
376
+ it { should respond_with(:success) }
377
+ it { should render_template(:invite) }
378
+ it { should assign_to(:room).with(room) }
379
+ end
380
+
381
+ context "without a role" do
382
+ before { controller.stub(:bigbluebutton_role).and_return(nil) }
383
+ before(:each) { get :invite, :server_id => mocked_server.to_param, :id => room.to_param }
384
+ it { should respond_with(:success) }
385
+ it { should render_template(:invite) }
386
+ it { should assign_to(:room).with(room) }
387
+ end
388
+ end
389
+
390
+ context "for a logged user" do
391
+ before { controller.stub(:bigbluebutton_user).and_return(user) }
392
+
393
+ context "with a role defined" do
394
+ before { controller.stub(:bigbluebutton_role).and_return(:attendee) }
395
+ before(:each) { get :invite, :server_id => mocked_server.to_param, :id => room.to_param }
396
+ it { should respond_with(:redirect) }
397
+ it { should redirect_to(join_bigbluebutton_server_room_path(mocked_server, room)) }
398
+ end
224
399
 
400
+ context "without a role" do
401
+ before { controller.stub(:bigbluebutton_role).and_return(nil) }
402
+ before(:each) { get :invite, :server_id => mocked_server.to_param, :id => room.to_param }
403
+ it { should respond_with(:success) }
404
+ it { should render_template(:invite) }
405
+ it { should assign_to(:room).with(room) }
406
+ end
407
+ end
408
+
409
+ end
410
+
411
+ describe "#auth" do
412
+ let(:user) { Factory.build(:user) }
413
+ before {
414
+ mock_server_and_api
415
+ controller.stub(:bigbluebutton_user).and_return(nil)
416
+ }
417
+
418
+ context "if there's a user logged, should use it's name" do
419
+ let(:hash) { { :name => "Elftor", :password => room.attendee_password } }
420
+ it do
421
+ controller.stub(:bigbluebutton_user).and_return(user)
422
+ mocked_api.should_receive(:is_meeting_running?).and_return(true)
423
+ mocked_api.should_receive(:join_meeting_url).
424
+ with(room.meetingid, user.name, room.attendee_password).
425
+ and_return("http://test.com/attendee/join")
426
+ post :auth, :server_id => mocked_server.to_param, :id => room.to_param, :user => hash
427
+ should respond_with(:redirect)
428
+ should redirect_to("http://test.com/attendee/join")
429
+ end
430
+ end
431
+
432
+ context "shows error when" do
433
+
434
+ context "name is not set" do
435
+ let(:hash) { { :password => room.moderator_password } }
436
+ before(:each) { post :auth, :server_id => mocked_server.to_param, :id => room.to_param, :user => hash }
437
+ it { should respond_with(:unauthorized) }
438
+ it { should assign_to(:room).with(room) }
439
+ it { should render_template(:invite) }
440
+ it { should set_the_flash.to(I18n.t('bigbluebutton_rails.rooms.error.auth.failure')) }
441
+ end
442
+
443
+ context "the password is wrong" do
444
+ let(:hash) { { :name => "Elftor", :password => nil } }
445
+ before(:each) { post :auth, :server_id => mocked_server.to_param, :id => room.to_param, :user => hash }
446
+ it { should respond_with(:unauthorized) }
447
+ it { should assign_to(:room).with(room) }
448
+ it { should render_template(:invite) }
449
+ it { should set_the_flash.to(I18n.t('bigbluebutton_rails.rooms.error.auth.failure')) }
450
+ end
451
+
452
+ end
453
+
454
+ context "entering the attendee password" do
455
+ let(:hash) { { :name => "Elftor", :password => room.attendee_password } }
456
+
457
+ # OPTMIZE Almost the same tests as in #join. Can they be integrated somehow?
225
458
  context "and the conference is running" do
226
459
  before {
227
460
  mocked_api.should_receive(:is_meeting_running?).and_return(true)
@@ -229,12 +462,12 @@ describe Bigbluebutton::RoomsController do
229
462
  }
230
463
 
231
464
  it "assigns server" do
232
- get :join, :server_id => mocked_server.to_param, :id => room.to_param
465
+ post :auth, :server_id => mocked_server.to_param, :id => room.to_param, :user => hash
233
466
  should assign_to(:server).with(mocked_server)
234
467
  end
235
468
 
236
469
  it "redirects to the attendee join url" do
237
- get :join, :server_id => mocked_server.to_param, :id => room.to_param
470
+ post :auth, :server_id => mocked_server.to_param, :id => room.to_param, :user => hash
238
471
  should respond_with(:redirect)
239
472
  should redirect_to("http://test.com/attendee/join")
240
473
  end
@@ -247,40 +480,58 @@ describe Bigbluebutton::RoomsController do
247
480
 
248
481
  it "do not try to create the conference" do
249
482
  mocked_api.should_not_receive(:create_meeting)
250
- get :join, :server_id => mocked_server.to_param, :id => room.to_param
483
+ post :auth, :server_id => mocked_server.to_param, :id => room.to_param, :user => hash
251
484
  end
252
485
 
253
- it "render the join_wait view to wait for a moderator" do
254
- get :join, :server_id => mocked_server.to_param, :id => room.to_param
486
+ it "renders #invite" do
487
+ post :auth, :server_id => mocked_server.to_param, :id => room.to_param, :user => hash
255
488
  should respond_with(:success)
256
- should render_template(:join_wait)
489
+ should render_template(:invite)
490
+ should set_the_flash.to(I18n.t('bigbluebutton_rails.rooms.error.not_running'))
257
491
  end
258
492
  end
259
493
 
260
494
  end
261
495
 
262
- end
263
-
264
- describe "#end" do
265
- before { mock_server_and_api }
496
+ context "entering the moderator password" do
497
+ let(:hash) { { :name => "Elftor", :password => room.moderator_password } }
266
498
 
267
- context "room is running" do
499
+ # OPTMIZE Almost the same tests as in #join. Can they be integrated somehow?
268
500
  before {
269
- mocked_api.should_receive(:is_meeting_running?).and_return(true)
270
- mocked_api.should_receive(:end_meeting).with(room.meeting_id, room.moderator_password)
501
+ mocked_api.should_receive(:join_meeting_url).and_return("http://test.com/mod/join")
271
502
  }
272
- before(:each) { get :end, :server_id => mocked_server.to_param, :id => room.to_param }
273
- it { should respond_with(:redirect) }
274
- it { should redirect_to(bigbluebutton_server_room_path(mocked_server, room)) }
275
- it { should assign_to(:server).with(mocked_server) }
276
- it { should assign_to(:room).with(room) }
277
- it { should set_the_flash.to(I18n.t('bigbluebutton_rails.rooms.notice.end.success')) }
278
- end
279
503
 
280
- context "room is not running" do
281
- before { mocked_api.should_receive(:is_meeting_running?).and_return(false) }
282
- before(:each) { get :end, :server_id => mocked_server.to_param, :id => room.to_param }
283
- it { should set_the_flash.to(I18n.t('bigbluebutton_rails.rooms.notice.end.not_running')) }
504
+ context "and the conference is running" do
505
+ before {
506
+ mocked_api.should_receive(:is_meeting_running?).and_return(true)
507
+ }
508
+
509
+ it "assigns server" do
510
+ post :auth, :server_id => mocked_server.to_param, :id => room.to_param, :user => hash
511
+ should assign_to(:server).with(mocked_server)
512
+ end
513
+
514
+ it "redirects to the moderator join url" do
515
+ post :auth, :server_id => mocked_server.to_param, :id => room.to_param, :user => hash
516
+ should respond_with(:redirect)
517
+ should redirect_to("http://test.com/mod/join")
518
+ end
519
+ end
520
+
521
+ context "and the conference is NOT running" do
522
+ before {
523
+ mocked_api.should_receive(:is_meeting_running?).and_return(false)
524
+ }
525
+
526
+ it "creates the conference" do
527
+ mocked_api.should_receive(:create_meeting).
528
+ with(room.name, room.meetingid, room.moderator_password,
529
+ room.attendee_password, room.welcome_msg, room.dial_number,
530
+ room.logout_url, room.max_participants, room.voice_bridge)
531
+ post :auth, :server_id => mocked_server.to_param, :id => room.to_param, :user => hash
532
+ end
533
+ end
534
+
284
535
  end
285
536
  end
286
537
 
@@ -316,7 +567,7 @@ describe Bigbluebutton::RoomsController do
316
567
  after :each do
317
568
  delete :destroy, :server_id => mocked_server.to_param, :id => room.to_param
318
569
  should respond_with(:redirect)
319
- should redirect_to(bigbluebutton_server_rooms_path)
570
+ should redirect_to bigbluebutton_server_rooms_url
320
571
  should set_the_flash.to(bbb_error_msg)
321
572
  end
322
573
  end
@@ -348,7 +599,7 @@ describe Bigbluebutton::RoomsController do
348
599
  end
349
600
 
350
601
  describe "#join" do
351
- before { controller.stub_chain(:bigbluebutton_user, :name).and_return("Test name") }
602
+ before { controller.stub(:bigbluebutton_user) { Factory.build(:user) } }
352
603
 
353
604
  context "as moderator" do
354
605
  before { controller.should_receive(:bigbluebutton_role).with(room).and_return(:moderator) }
@@ -1,8 +1,10 @@
1
1
  Factory.define :bigbluebutton_room do |r|
2
2
  r.association :server, :factory => :bigbluebutton_server
3
- r.sequence(:meeting_id) { |n| "MeetingID#{n}" }
3
+ r.sequence(:meetingid) { |n| "MeetingID#{n}" }
4
4
  r.sequence(:name) { |n| "Name#{n}" }
5
- r.attendee_password { Forgery(:basic).password :at_least => 10, :at_most => 20 }
6
- r.moderator_password { Forgery(:basic).password :at_least => 10, :at_most => 20 }
5
+ r.attendee_password { Forgery(:basic).password :at_least => 10, :at_most => 16 }
6
+ r.moderator_password { Forgery(:basic).password :at_least => 10, :at_most => 16 }
7
7
  r.welcome_msg { Forgery(:lorem_ipsum).sentences(2) }
8
+ r.private false
9
+ r.randomize_meetingid false
8
10
  end
@@ -0,0 +1,3 @@
1
+ Factory.define :user do |u|
2
+ u.name { Forgery(:name).full_name }
3
+ end
@@ -19,7 +19,6 @@ describe BigbluebuttonRails::Generators::PublicGenerator do
19
19
  def assert_files(assert_exists=true)
20
20
  files = [
21
21
  "public/images/loading.gif",
22
- "public/javascripts/heartbeat.js",
23
22
  "public/javascripts/jquery.min.js"
24
23
  ]
25
24
  if assert_exists
@@ -33,7 +33,7 @@ describe BigbluebuttonRails::Generators::ViewsGenerator do
33
33
  "app/views/#{scope}/rooms/edit.html.erb",
34
34
  "app/views/#{scope}/rooms/_form.html.erb",
35
35
  "app/views/#{scope}/rooms/index.html.erb",
36
- "app/views/#{scope}/rooms/join_wait.html.erb",
36
+ "app/views/#{scope}/rooms/join.html.erb",
37
37
  "app/views/#{scope}/rooms/new.html.erb",
38
38
  "app/views/#{scope}/rooms/show.html.erb",
39
39
  "app/views/#{scope}/servers/edit.html.erb",