bigbluebutton_rails 0.0.4 → 0.0.5
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +2 -1
- data/CHANGELOG.rdoc +12 -0
- data/Gemfile.lock +53 -14
- data/README.rdoc +31 -29
- data/Rakefile +63 -11
- data/app/controllers/bigbluebutton/rooms_controller.rb +89 -26
- data/app/controllers/bigbluebutton/servers_controller.rb +38 -5
- data/app/helpers/bigbluebutton_rails_helper.rb +12 -0
- data/app/models/bigbluebutton_room.rb +44 -1
- data/app/models/bigbluebutton_server.rb +48 -12
- data/app/views/bigbluebutton/rooms/_form.html.erb +8 -0
- data/app/views/bigbluebutton/rooms/index.html.erb +34 -43
- data/app/views/bigbluebutton/rooms/join_mobile.html.erb +9 -0
- data/app/views/bigbluebutton/rooms/show.html.erb +8 -0
- data/app/views/bigbluebutton/servers/_activity_list.html.erb +48 -0
- data/app/views/bigbluebutton/servers/_form.html.erb +4 -0
- data/app/views/bigbluebutton/servers/activity.html.erb +51 -0
- data/app/views/bigbluebutton/servers/index.html.erb +21 -25
- data/app/views/bigbluebutton/servers/show.html.erb +5 -0
- data/bigbluebutton_rails.gemspec +9 -6
- data/config/locales/en.yml +11 -2
- data/lib/bigbluebutton_rails/controller_methods.rb +47 -14
- data/lib/bigbluebutton_rails/exceptions.rb +6 -0
- data/lib/bigbluebutton_rails/rails/routes.rb +17 -12
- data/lib/bigbluebutton_rails/rails.rb +4 -0
- data/lib/bigbluebutton_rails/version.rb +1 -1
- data/lib/bigbluebutton_rails.rb +1 -0
- data/lib/generators/bigbluebutton_rails/install_generator.rb +28 -5
- data/lib/generators/bigbluebutton_rails/templates/migration.rb +3 -0
- data/lib/generators/bigbluebutton_rails/templates/migration_0_0_4.rb +38 -0
- data/lib/generators/bigbluebutton_rails/templates/migration_0_0_5.rb +23 -0
- data/{lib/generators/bigbluebutton_rails/templates/public → public}/images/loading.gif +0 -0
- data/{lib/generators/bigbluebutton_rails/templates/public → public}/javascripts/jquery.min.js +0 -0
- data/public/stylesheets/bigbluebutton_rails.css +138 -0
- data/spec/controllers/bigbluebutton/rooms_controller_spec.rb +284 -25
- data/spec/controllers/bigbluebutton/servers_controller_spec.rb +93 -1
- data/spec/factories/bigbluebutton_room.rb +1 -0
- data/spec/factories/bigbluebutton_server.rb +1 -0
- data/spec/factories/integration/bigbluebutton_server_integration.rb +8 -0
- data/spec/generators/install_generator_spec.rb +53 -10
- data/spec/generators/views_generator_spec.rb +6 -2
- data/spec/helpers/bigbluebutton_rails_helper_spec.rb +19 -0
- data/spec/integration_conf.yml.example +5 -0
- data/spec/models/bigbluebutton_room_spec.rb +99 -72
- data/spec/models/bigbluebutton_server_spec.rb +81 -20
- data/spec/rails_app/.gitignore +2 -1
- data/spec/rails_app/app/views/layouts/application.html.erb +1 -1
- data/spec/rails_app/config/cucumber.yml +8 -0
- data/spec/rails_app/config/database.yml +4 -1
- data/spec/rails_app/db/seeds.rb +6 -5
- data/spec/rails_app/features/manage_bigbluebutton_rooms.feature +9 -0
- data/spec/rails_app/features/manage_bigbluebutton_servers.feature +9 -0
- data/spec/rails_app/features/step_definitions/bigbluebutton_room_steps.rb +38 -0
- data/spec/rails_app/features/step_definitions/bigbluebutton_server_steps.rb +23 -0
- data/spec/rails_app/features/step_definitions/common_steps.rb +3 -0
- data/spec/rails_app/features/step_definitions/web_steps.rb +211 -0
- data/spec/rails_app/features/support/content.rb +11 -0
- data/spec/rails_app/features/support/env.rb +50 -0
- data/spec/rails_app/features/support/env_gem.rb +9 -0
- data/spec/rails_app/features/support/paths.rb +38 -0
- data/spec/rails_app/features/support/selectors.rb +39 -0
- data/spec/rails_app/lib/tasks/cucumber.rake +65 -0
- data/spec/rails_app/public/images/loading.gif +0 -0
- data/spec/rails_app/public/javascripts/jquery.min.js +16 -0
- data/spec/rails_app/public/stylesheets/bigbluebutton_rails.css +138 -0
- data/spec/rails_app/script/cucumber +10 -0
- data/spec/routing/bigbluebutton/rooms_routing_spec.rb +12 -0
- data/spec/spec_helper.rb +0 -1
- data/spec/support/integration/integration_conf.rb +16 -0
- data/spec/support/matchers/shoulda/respond_with_json_matcher.rb +67 -0
- data/spec/support/mocked_server.rb +1 -0
- metadata +91 -29
- data/lib/generators/bigbluebutton_rails/public_generator.rb +0 -16
- data/spec/generators/public_generator_spec.rb +0 -31
@@ -21,6 +21,7 @@ describe Bigbluebutton::RoomsController do
|
|
21
21
|
it { should respond_with(:success) }
|
22
22
|
it { should assign_to(:server).with(server) }
|
23
23
|
it { should assign_to(:rooms).with(BigbluebuttonRoom.all) }
|
24
|
+
it { should render_template(:index) }
|
24
25
|
end
|
25
26
|
|
26
27
|
describe "#show" do
|
@@ -28,6 +29,7 @@ describe Bigbluebutton::RoomsController do
|
|
28
29
|
it { should respond_with(:success) }
|
29
30
|
it { should assign_to(:server).with(server) }
|
30
31
|
it { should assign_to(:room).with(room) }
|
32
|
+
it { should render_template(:show) }
|
31
33
|
end
|
32
34
|
|
33
35
|
describe "#new" do
|
@@ -35,6 +37,7 @@ describe Bigbluebutton::RoomsController do
|
|
35
37
|
it { should respond_with(:success) }
|
36
38
|
it { should assign_to(:server).with(server) }
|
37
39
|
it { should assign_to(:room).with_kind_of(BigbluebuttonRoom) }
|
40
|
+
it { should render_template(:new) }
|
38
41
|
end
|
39
42
|
|
40
43
|
describe "#edit" do
|
@@ -42,6 +45,25 @@ describe Bigbluebutton::RoomsController do
|
|
42
45
|
it { should respond_with(:success) }
|
43
46
|
it { should assign_to(:server).with(server) }
|
44
47
|
it { should assign_to(:room).with(room) }
|
48
|
+
it { should render_template(:edit) }
|
49
|
+
end
|
50
|
+
|
51
|
+
describe "#join_mobile" do
|
52
|
+
let(:user) { Factory.build(:user) }
|
53
|
+
before {
|
54
|
+
mock_server_and_api
|
55
|
+
controller.stub(:bigbluebutton_user) { user }
|
56
|
+
controller.should_receive(:bigbluebutton_role).and_return(:moderator)
|
57
|
+
mocked_api.should_receive(:join_meeting_url).
|
58
|
+
with(room.meetingid, user.name, room.moderator_password).
|
59
|
+
and_return("http://join_url")
|
60
|
+
}
|
61
|
+
before(:each) { get :join_mobile, :server_id => mocked_server.to_param, :id => room.to_param }
|
62
|
+
it { should respond_with(:success) }
|
63
|
+
it { should assign_to(:server).with(mocked_server) }
|
64
|
+
it { should assign_to(:room).with(room) }
|
65
|
+
it { should assign_to(:join_url).with("bigbluebutton://join_url") }
|
66
|
+
it { should render_template(:join_mobile) }
|
45
67
|
end
|
46
68
|
|
47
69
|
describe "#create" do
|
@@ -112,7 +134,7 @@ describe Bigbluebutton::RoomsController do
|
|
112
134
|
|
113
135
|
describe "#update" do
|
114
136
|
let(:new_room) { Factory.build(:bigbluebutton_room) }
|
115
|
-
before { @room = room }
|
137
|
+
before { @room = room } # need this to trigger let(:room) and actually create the room
|
116
138
|
|
117
139
|
context "on success" do
|
118
140
|
before :each do
|
@@ -121,8 +143,9 @@ describe Bigbluebutton::RoomsController do
|
|
121
143
|
}.not_to change{ BigbluebuttonRoom.count }
|
122
144
|
end
|
123
145
|
it {
|
146
|
+
saved = BigbluebuttonRoom.find(@room)
|
124
147
|
should respond_with(:redirect)
|
125
|
-
should redirect_to bigbluebutton_server_room_path(server,
|
148
|
+
should redirect_to bigbluebutton_server_room_path(server, saved)
|
126
149
|
}
|
127
150
|
it {
|
128
151
|
saved = BigbluebuttonRoom.find(@room)
|
@@ -240,14 +263,24 @@ describe Bigbluebutton::RoomsController do
|
|
240
263
|
}
|
241
264
|
end
|
242
265
|
|
243
|
-
context "
|
266
|
+
context "when the user's role" do
|
244
267
|
before { controller.stub(:bigbluebutton_user) { user } }
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
should
|
250
|
-
|
268
|
+
|
269
|
+
context "should be defined with a password" do
|
270
|
+
before { controller.stub(:bigbluebutton_role) { :password } }
|
271
|
+
before(:each) { get :join, :server_id => mocked_server.to_param, :id => room.to_param }
|
272
|
+
it { should respond_with(:redirect) }
|
273
|
+
it { should redirect_to(invite_bigbluebutton_server_room_path(mocked_server, room)) }
|
274
|
+
end
|
275
|
+
|
276
|
+
context "is undefined, the access should be blocked" do
|
277
|
+
before { controller.stub(:bigbluebutton_role) { nil } }
|
278
|
+
it {
|
279
|
+
lambda {
|
280
|
+
get :join, :server_id => mocked_server.to_param, :id => room.to_param
|
281
|
+
}.should raise_error(BigbluebuttonRails::RoomAccessDenied)
|
282
|
+
}
|
283
|
+
end
|
251
284
|
end
|
252
285
|
|
253
286
|
context do
|
@@ -289,6 +322,38 @@ describe Bigbluebutton::RoomsController do
|
|
289
322
|
room.logout_url, room.max_participants, room.voice_bridge)
|
290
323
|
get :join, :server_id => mocked_server.to_param, :id => room.to_param
|
291
324
|
end
|
325
|
+
|
326
|
+
context "adds the protocol/domain to logout_url" do
|
327
|
+
after :each do
|
328
|
+
get :join, :server_id => mocked_server.to_param, :id => room.to_param
|
329
|
+
end
|
330
|
+
|
331
|
+
it "when it doesn't have protocol neither domain" do
|
332
|
+
room.update_attributes(:logout_url => "/incomplete/url")
|
333
|
+
full_logout_url = "http://test.host" + room.logout_url
|
334
|
+
|
335
|
+
mocked_api.should_receive(:create_meeting).
|
336
|
+
with(anything, anything, anything, anything, anything, anything,
|
337
|
+
full_logout_url, anything, anything)
|
338
|
+
end
|
339
|
+
|
340
|
+
it "when it doesn't have protocol only" do
|
341
|
+
room.update_attributes(:logout_url => "www.host.com/incomplete/url")
|
342
|
+
full_logout_url = "http://" + room.logout_url
|
343
|
+
|
344
|
+
mocked_api.should_receive(:create_meeting).
|
345
|
+
with(anything, anything, anything, anything, anything, anything,
|
346
|
+
full_logout_url, anything, anything)
|
347
|
+
end
|
348
|
+
|
349
|
+
it "but not when it has a protocol defined" do
|
350
|
+
room.update_attributes(:logout_url => "http://with/protocol")
|
351
|
+
mocked_api.should_receive(:create_meeting).
|
352
|
+
with(anything, anything, anything, anything, anything, anything,
|
353
|
+
room.logout_url, anything, anything)
|
354
|
+
end
|
355
|
+
end
|
356
|
+
|
292
357
|
end
|
293
358
|
|
294
359
|
end
|
@@ -359,6 +424,7 @@ describe Bigbluebutton::RoomsController do
|
|
359
424
|
context "room is not running" do
|
360
425
|
before { mocked_api.should_receive(:is_meeting_running?).and_return(false) }
|
361
426
|
before(:each) { get :end, :server_id => mocked_server.to_param, :id => room.to_param }
|
427
|
+
it { should respond_with(:redirect) }
|
362
428
|
it { should set_the_flash.to(I18n.t('bigbluebutton_rails.rooms.notice.end.not_running')) }
|
363
429
|
end
|
364
430
|
end
|
@@ -369,7 +435,7 @@ describe Bigbluebutton::RoomsController do
|
|
369
435
|
|
370
436
|
context "for an anonymous user" do
|
371
437
|
before { controller.stub(:bigbluebutton_user).and_return(nil) }
|
372
|
-
|
438
|
+
|
373
439
|
context "with a role defined" do
|
374
440
|
before { controller.stub(:bigbluebutton_role).and_return(:attendee) }
|
375
441
|
before(:each) { get :invite, :server_id => mocked_server.to_param, :id => room.to_param }
|
@@ -378,12 +444,23 @@ describe Bigbluebutton::RoomsController do
|
|
378
444
|
it { should assign_to(:room).with(room) }
|
379
445
|
end
|
380
446
|
|
381
|
-
context "
|
382
|
-
|
383
|
-
|
384
|
-
|
385
|
-
|
386
|
-
|
447
|
+
context "when the user's role" do
|
448
|
+
context "should be defined with a password" do
|
449
|
+
before { controller.stub(:bigbluebutton_role) { :password } }
|
450
|
+
before(:each) { get :invite, :server_id => mocked_server.to_param, :id => room.to_param }
|
451
|
+
it { should respond_with(:success) }
|
452
|
+
it { should render_template(:invite) }
|
453
|
+
it { should assign_to(:room).with(room) }
|
454
|
+
end
|
455
|
+
|
456
|
+
context "is undefined, the access should be blocked" do
|
457
|
+
before { controller.stub(:bigbluebutton_role) { nil } }
|
458
|
+
it {
|
459
|
+
lambda {
|
460
|
+
get :invite, :server_id => mocked_server.to_param, :id => room.to_param
|
461
|
+
}.should raise_error(BigbluebuttonRails::RoomAccessDenied)
|
462
|
+
}
|
463
|
+
end
|
387
464
|
end
|
388
465
|
end
|
389
466
|
|
@@ -397,12 +474,23 @@ describe Bigbluebutton::RoomsController do
|
|
397
474
|
it { should redirect_to(join_bigbluebutton_server_room_path(mocked_server, room)) }
|
398
475
|
end
|
399
476
|
|
400
|
-
context "
|
401
|
-
|
402
|
-
|
403
|
-
|
404
|
-
|
405
|
-
|
477
|
+
context "when the user's role" do
|
478
|
+
context "should be defined with a password" do
|
479
|
+
before { controller.stub(:bigbluebutton_role) { :password } }
|
480
|
+
before(:each) { get :invite, :server_id => mocked_server.to_param, :id => room.to_param }
|
481
|
+
it { should respond_with(:success) }
|
482
|
+
it { should render_template(:invite) }
|
483
|
+
it { should assign_to(:room).with(room) }
|
484
|
+
end
|
485
|
+
|
486
|
+
context "is undefined, the access should be blocked" do
|
487
|
+
before { controller.stub(:bigbluebutton_role) { nil } }
|
488
|
+
it {
|
489
|
+
lambda {
|
490
|
+
get :invite, :server_id => mocked_server.to_param, :id => room.to_param
|
491
|
+
}.should raise_error(BigbluebuttonRails::RoomAccessDenied)
|
492
|
+
}
|
493
|
+
end
|
406
494
|
end
|
407
495
|
end
|
408
496
|
|
@@ -415,6 +503,16 @@ describe Bigbluebutton::RoomsController do
|
|
415
503
|
controller.stub(:bigbluebutton_user).and_return(nil)
|
416
504
|
}
|
417
505
|
|
506
|
+
context "block access if bigbluebutton_role returns nil" do
|
507
|
+
let(:hash) { { :name => "Elftor", :password => room.attendee_password } }
|
508
|
+
before { controller.stub(:bigbluebutton_role) { nil } }
|
509
|
+
it {
|
510
|
+
lambda {
|
511
|
+
post :auth, :server_id => mocked_server.to_param, :id => room.to_param, :user => hash
|
512
|
+
}.should raise_error(BigbluebuttonRails::RoomAccessDenied)
|
513
|
+
}
|
514
|
+
end
|
515
|
+
|
418
516
|
context "if there's a user logged, should use it's name" do
|
419
517
|
let(:hash) { { :name => "Elftor", :password => room.attendee_password } }
|
420
518
|
it do
|
@@ -437,7 +535,7 @@ describe Bigbluebutton::RoomsController do
|
|
437
535
|
it { should respond_with(:unauthorized) }
|
438
536
|
it { should assign_to(:room).with(room) }
|
439
537
|
it { should render_template(:invite) }
|
440
|
-
it { should set_the_flash.to(I18n.t('bigbluebutton_rails.rooms.
|
538
|
+
it { should set_the_flash.to(I18n.t('bigbluebutton_rails.rooms.errors.auth.failure')) }
|
441
539
|
end
|
442
540
|
|
443
541
|
context "the password is wrong" do
|
@@ -446,7 +544,7 @@ describe Bigbluebutton::RoomsController do
|
|
446
544
|
it { should respond_with(:unauthorized) }
|
447
545
|
it { should assign_to(:room).with(room) }
|
448
546
|
it { should render_template(:invite) }
|
449
|
-
it { should set_the_flash.to(I18n.t('bigbluebutton_rails.rooms.
|
547
|
+
it { should set_the_flash.to(I18n.t('bigbluebutton_rails.rooms.errors.auth.failure')) }
|
450
548
|
end
|
451
549
|
|
452
550
|
end
|
@@ -487,7 +585,7 @@ describe Bigbluebutton::RoomsController do
|
|
487
585
|
post :auth, :server_id => mocked_server.to_param, :id => room.to_param, :user => hash
|
488
586
|
should respond_with(:success)
|
489
587
|
should render_template(:invite)
|
490
|
-
should set_the_flash.to(I18n.t('bigbluebutton_rails.rooms.
|
588
|
+
should set_the_flash.to(I18n.t('bigbluebutton_rails.rooms.errors.auth.not_running'))
|
491
589
|
end
|
492
590
|
end
|
493
591
|
|
@@ -545,6 +643,7 @@ describe Bigbluebutton::RoomsController do
|
|
545
643
|
it { should assign_to(:server).with(server) }
|
546
644
|
end
|
547
645
|
|
646
|
+
# make sure that the exceptions thrown by bigbluebutton-api-ruby are treated by the controller
|
548
647
|
context "exception handling" do
|
549
648
|
let(:bbb_error_msg) { "err msg" }
|
550
649
|
let(:bbb_error) { BigBlueButton::BigBlueButtonException.new(bbb_error_msg) }
|
@@ -651,5 +750,165 @@ describe Bigbluebutton::RoomsController do
|
|
651
750
|
|
652
751
|
end # exception handling
|
653
752
|
|
753
|
+
# verify all JSON responses
|
754
|
+
context "json responses for " do
|
755
|
+
describe "#index" do
|
756
|
+
before do
|
757
|
+
@room1 = Factory.create(:bigbluebutton_room, :server => server)
|
758
|
+
@room2 = Factory.create(:bigbluebutton_room, :server => server)
|
759
|
+
end
|
760
|
+
before(:each) { get :index, :server_id => server.to_param, :format => 'json' }
|
761
|
+
it { should respond_with(:success) }
|
762
|
+
it { should respond_with_content_type(:json) }
|
763
|
+
it { should respond_with_json([@room1, @room2].to_json) }
|
764
|
+
end
|
765
|
+
|
766
|
+
describe "#new" do
|
767
|
+
before(:each) { get :new, :server_id => server.to_param, :format => 'json' }
|
768
|
+
it { should respond_with(:success) }
|
769
|
+
it { should respond_with_content_type(:json) }
|
770
|
+
it {
|
771
|
+
# we ignore all values bc a BigbluebuttonRoom is generated with some
|
772
|
+
# random values (meetingid, voice_bridge)
|
773
|
+
should respond_with_json(BigbluebuttonRoom.new.to_json).ignoring_values
|
774
|
+
}
|
775
|
+
end
|
776
|
+
|
777
|
+
describe "#show" do
|
778
|
+
before(:each) { get :show, :server_id => server.to_param, :id => room.to_param, :format => 'json' }
|
779
|
+
it { should respond_with(:success) }
|
780
|
+
it { should respond_with_content_type(:json) }
|
781
|
+
it { should respond_with_json(room.to_json) }
|
782
|
+
end
|
783
|
+
|
784
|
+
describe "#create" do
|
785
|
+
let(:new_room) { Factory.build(:bigbluebutton_room, :server => server) }
|
786
|
+
|
787
|
+
context "on success" do
|
788
|
+
before(:each) {
|
789
|
+
post :create, :server_id => server.to_param, :bigbluebutton_room => new_room.attributes, :format => 'json'
|
790
|
+
}
|
791
|
+
it { should respond_with(:created) }
|
792
|
+
it { should respond_with_content_type(:json) }
|
793
|
+
it {
|
794
|
+
json = { :message => I18n.t('bigbluebutton_rails.rooms.notice.create.success') }.to_json
|
795
|
+
should respond_with_json(json)
|
796
|
+
}
|
797
|
+
end
|
798
|
+
|
799
|
+
context "on failure" do
|
800
|
+
before(:each) {
|
801
|
+
new_room.name = nil # invalid
|
802
|
+
post :create, :server_id => server.to_param, :bigbluebutton_room => new_room.attributes, :format => 'json'
|
803
|
+
}
|
804
|
+
it { should respond_with(:unprocessable_entity) }
|
805
|
+
it { should respond_with_content_type(:json) }
|
806
|
+
it {
|
807
|
+
new_room.save # should fail
|
808
|
+
should respond_with_json(new_room.errors.full_messages.to_json)
|
809
|
+
}
|
810
|
+
end
|
811
|
+
end
|
812
|
+
|
813
|
+
describe "#update" do
|
814
|
+
let(:new_room) { Factory.build(:bigbluebutton_room) }
|
815
|
+
before { @room = room }
|
816
|
+
|
817
|
+
context "on success" do
|
818
|
+
before(:each) {
|
819
|
+
put :update, :server_id => server.to_param, :id => @room.to_param, :bigbluebutton_room => new_room.attributes, :format => 'json'
|
820
|
+
}
|
821
|
+
it { should respond_with(:success) }
|
822
|
+
it { should respond_with_content_type(:json) }
|
823
|
+
it {
|
824
|
+
json = { :message => I18n.t('bigbluebutton_rails.rooms.notice.update.success') }.to_json
|
825
|
+
should respond_with_json(json)
|
826
|
+
}
|
827
|
+
end
|
828
|
+
|
829
|
+
context "on failure" do
|
830
|
+
before(:each) {
|
831
|
+
new_room.name = nil # invalid
|
832
|
+
put :update, :server_id => server.to_param, :id => @room.to_param, :bigbluebutton_room => new_room.attributes, :format => 'json'
|
833
|
+
}
|
834
|
+
it { should respond_with(:unprocessable_entity) }
|
835
|
+
it { should respond_with_content_type(:json) }
|
836
|
+
it {
|
837
|
+
new_room.save # should fail
|
838
|
+
should respond_with_json(new_room.errors.full_messages.to_json)
|
839
|
+
}
|
840
|
+
end
|
841
|
+
end
|
842
|
+
|
843
|
+
describe "#end" do
|
844
|
+
before { mock_server_and_api }
|
845
|
+
|
846
|
+
context "room is running" do
|
847
|
+
before {
|
848
|
+
mocked_api.should_receive(:is_meeting_running?).and_return(true)
|
849
|
+
mocked_api.should_receive(:end_meeting).with(room.meetingid, room.moderator_password)
|
850
|
+
}
|
851
|
+
before(:each) { get :end, :server_id => mocked_server.to_param, :id => room.to_param, :format => 'json' }
|
852
|
+
it { should respond_with(:success) }
|
853
|
+
it { should respond_with_content_type(:json) }
|
854
|
+
it { should respond_with_json(I18n.t('bigbluebutton_rails.rooms.notice.end.success')) }
|
855
|
+
end
|
856
|
+
|
857
|
+
context "room is not running" do
|
858
|
+
before { mocked_api.should_receive(:is_meeting_running?).and_return(false) }
|
859
|
+
before(:each) { get :end, :server_id => mocked_server.to_param, :id => room.to_param, :format => 'json' }
|
860
|
+
it { should respond_with(:error) }
|
861
|
+
it { should respond_with_content_type(:json) }
|
862
|
+
it { should respond_with_json(I18n.t('bigbluebutton_rails.rooms.notice.end.not_running')) }
|
863
|
+
end
|
864
|
+
|
865
|
+
context "throwing an exception" do
|
866
|
+
let(:msg) { "any error message" }
|
867
|
+
before {
|
868
|
+
mocked_api.should_receive(:is_meeting_running?).and_return{ raise BigBlueButton::BigBlueButtonException.new(msg) }
|
869
|
+
}
|
870
|
+
before(:each) { get :end, :server_id => mocked_server.to_param, :id => room.to_param, :format => 'json' }
|
871
|
+
it { should respond_with(:error) }
|
872
|
+
it { should respond_with_content_type(:json) }
|
873
|
+
it { should respond_with_json(msg) }
|
874
|
+
end
|
875
|
+
|
876
|
+
end
|
877
|
+
|
878
|
+
describe "#destroy" do
|
879
|
+
before { mock_server_and_api }
|
880
|
+
|
881
|
+
context "on success" do
|
882
|
+
before {
|
883
|
+
mocked_api.should_receive(:is_meeting_running?).and_return(true)
|
884
|
+
mocked_api.should_receive(:end_meeting)
|
885
|
+
}
|
886
|
+
before(:each) {
|
887
|
+
delete :destroy, :server_id => mocked_server.to_param, :id => room.to_param, :format => 'json'
|
888
|
+
}
|
889
|
+
it { should respond_with(:success) }
|
890
|
+
it { should respond_with_content_type(:json) }
|
891
|
+
it {
|
892
|
+
json = { :message => I18n.t('bigbluebutton_rails.rooms.notice.destroy.success') }.to_json
|
893
|
+
should respond_with_json(json)
|
894
|
+
}
|
895
|
+
end
|
896
|
+
|
897
|
+
context "throwing error" do
|
898
|
+
let(:msg) { "any error message" }
|
899
|
+
before {
|
900
|
+
mocked_api.should_receive(:is_meeting_running?).and_return{ raise BigBlueButton::BigBlueButtonException.new(msg) }
|
901
|
+
}
|
902
|
+
before(:each) {
|
903
|
+
delete :destroy, :server_id => mocked_server.to_param, :id => room.to_param, :format => 'json'
|
904
|
+
}
|
905
|
+
it { should respond_with(:error) }
|
906
|
+
it { should respond_with_content_type(:json) }
|
907
|
+
it { should respond_with_json({ :message => msg }.to_json) }
|
908
|
+
end
|
909
|
+
end
|
910
|
+
|
911
|
+
end # json responses
|
912
|
+
|
654
913
|
end
|
655
914
|
|
@@ -51,8 +51,9 @@ describe Bigbluebutton::ServersController do
|
|
51
51
|
}.not_to change{ BigbluebuttonServer.count }
|
52
52
|
end
|
53
53
|
it {
|
54
|
+
saved = BigbluebuttonServer.find(@server)
|
54
55
|
should respond_with(:redirect)
|
55
|
-
should redirect_to(bigbluebutton_server_path(
|
56
|
+
should redirect_to(bigbluebutton_server_path(saved))
|
56
57
|
}
|
57
58
|
it {
|
58
59
|
saved = BigbluebuttonServer.find(@server)
|
@@ -74,5 +75,96 @@ describe Bigbluebutton::ServersController do
|
|
74
75
|
}
|
75
76
|
end
|
76
77
|
|
78
|
+
# verify all JSON responses
|
79
|
+
context "json responses for " do
|
80
|
+
|
81
|
+
describe "#index" do
|
82
|
+
before do
|
83
|
+
@server1 = Factory.create(:bigbluebutton_server)
|
84
|
+
@server2 = Factory.create(:bigbluebutton_server)
|
85
|
+
end
|
86
|
+
before(:each) { get :index, :format => 'json' }
|
87
|
+
it { should respond_with(:success) }
|
88
|
+
it { should respond_with_content_type(:json) }
|
89
|
+
it { should respond_with_json([@server1, @server2].to_json) }
|
90
|
+
end
|
91
|
+
|
92
|
+
describe "#new" do
|
93
|
+
before(:each) { get :new, :format => 'json' }
|
94
|
+
it { should respond_with(:success) }
|
95
|
+
it { should respond_with_content_type(:json) }
|
96
|
+
it { should respond_with_json(BigbluebuttonServer.new.to_json).ignoring_values }
|
97
|
+
end
|
98
|
+
|
99
|
+
describe "#show" do
|
100
|
+
before(:each) { get :show, :id => server.to_param, :format => 'json' }
|
101
|
+
it { should respond_with(:success) }
|
102
|
+
it { should respond_with_content_type(:json) }
|
103
|
+
it { should respond_with_json(server.to_json) }
|
104
|
+
end
|
105
|
+
|
106
|
+
describe "#create" do
|
107
|
+
let(:new_server) { Factory.build(:bigbluebutton_server) }
|
108
|
+
|
109
|
+
context "on success" do
|
110
|
+
before(:each) {
|
111
|
+
post :create, :bigbluebutton_server => new_server.attributes, :format => 'json'
|
112
|
+
}
|
113
|
+
it { should respond_with(:created) }
|
114
|
+
it { should respond_with_content_type(:json) }
|
115
|
+
it { should respond_with_json(new_server.to_json).ignoring_attributes }
|
116
|
+
end
|
117
|
+
|
118
|
+
context "on failure" do
|
119
|
+
before(:each) {
|
120
|
+
new_server.url = nil # invalid
|
121
|
+
post :create, :bigbluebutton_server => new_server.attributes, :format => 'json'
|
122
|
+
}
|
123
|
+
it { should respond_with(:unprocessable_entity) }
|
124
|
+
it { should respond_with_content_type(:json) }
|
125
|
+
it {
|
126
|
+
new_server.save # should fail
|
127
|
+
should respond_with_json(new_server.errors.full_messages.to_json)
|
128
|
+
}
|
129
|
+
end
|
130
|
+
end
|
131
|
+
|
132
|
+
describe "#update" do
|
133
|
+
let(:new_server) { Factory.build(:bigbluebutton_server) }
|
134
|
+
before { @server = server }
|
135
|
+
|
136
|
+
context "on success" do
|
137
|
+
before(:each) {
|
138
|
+
put :update, :id => @server.to_param, :bigbluebutton_server => new_server.attributes, :format => 'json'
|
139
|
+
}
|
140
|
+
it { should respond_with(:success) }
|
141
|
+
it { should respond_with_content_type(:json) }
|
142
|
+
end
|
143
|
+
|
144
|
+
context "on failure" do
|
145
|
+
before(:each) {
|
146
|
+
new_server.url = nil # invalid
|
147
|
+
put :update, :id => @server.to_param, :bigbluebutton_server => new_server.attributes, :format => 'json'
|
148
|
+
}
|
149
|
+
it { should respond_with(:unprocessable_entity) }
|
150
|
+
it { should respond_with_content_type(:json) }
|
151
|
+
it {
|
152
|
+
new_server.save # should fail
|
153
|
+
should respond_with_json(new_server.errors.full_messages.to_json)
|
154
|
+
}
|
155
|
+
end
|
156
|
+
end
|
157
|
+
|
158
|
+
describe "#destroy" do
|
159
|
+
before :each do
|
160
|
+
@server = server
|
161
|
+
delete :destroy, :id => @server.to_param, :format => 'json'
|
162
|
+
end
|
163
|
+
it { should respond_with(:success) }
|
164
|
+
it { should respond_with_content_type(:json) }
|
165
|
+
end
|
166
|
+
|
167
|
+
end # json responses
|
168
|
+
|
77
169
|
end
|
78
170
|
|
@@ -5,19 +5,62 @@ describe BigbluebuttonRails::Generators::InstallGenerator do
|
|
5
5
|
destination File.expand_path("../../../tmp", __FILE__)
|
6
6
|
tests BigbluebuttonRails::Generators::InstallGenerator
|
7
7
|
|
8
|
-
|
9
|
-
|
10
|
-
|
8
|
+
context "standard install" do
|
9
|
+
before(:all) do
|
10
|
+
prepare_destination
|
11
|
+
run_generator
|
12
|
+
end
|
13
|
+
|
14
|
+
it "all files are properly created" do
|
15
|
+
assert_migration "db/migrate/create_bigbluebutton_rails.rb"
|
16
|
+
assert_file "config/locales/bigbluebutton_rails.en.yml"
|
17
|
+
assert_file "public/stylesheets/bigbluebutton_rails.css"
|
18
|
+
assert_file "public/javascripts/jquery.min.js"
|
19
|
+
assert_file "public/images/loading.gif"
|
20
|
+
end
|
21
|
+
|
22
|
+
it "all files are properly destroyed" do
|
23
|
+
run_generator %w(), :behavior => :revoke
|
24
|
+
assert_no_file "config/locales/bigbluebutton_rails.en.yml"
|
25
|
+
assert_no_migration "db/migrate/create_bigbluebutton_rails.rb"
|
26
|
+
assert_no_file "public/stylesheets/bigbluebutton_rails.css"
|
27
|
+
assert_no_file "public/javascripts/jquery.min.js"
|
28
|
+
assert_no_file "public/images/loading.gif"
|
29
|
+
end
|
11
30
|
end
|
12
31
|
|
13
|
-
|
14
|
-
|
15
|
-
|
32
|
+
context "setting migration-only" do
|
33
|
+
before(:all) do
|
34
|
+
prepare_destination
|
35
|
+
run_generator %w{ --migration-only }
|
36
|
+
end
|
37
|
+
|
38
|
+
it "only the migration is created" do
|
39
|
+
assert_migration "db/migrate/create_bigbluebutton_rails.rb"
|
40
|
+
assert_no_file "config/locales/bigbluebutton_rails.en.yml"
|
41
|
+
assert_no_file "public/stylesheets/bigbluebutton_rails.css"
|
42
|
+
assert_no_file "public/javascripts/jquery.min.js"
|
43
|
+
assert_no_file "public/images/loading.gif"
|
44
|
+
end
|
16
45
|
end
|
17
46
|
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
47
|
+
context "migrating to version" do
|
48
|
+
before { prepare_destination }
|
49
|
+
|
50
|
+
["0.0.4", "0.0.5"].each do |version|
|
51
|
+
context "#{version}" do
|
52
|
+
before { run_generator [ version ] }
|
53
|
+
|
54
|
+
it "all files are properly created" do
|
55
|
+
assert_migration "db/migrate/bigbluebutton_rails_to_#{version.gsub(".", "_")}.rb"
|
56
|
+
end
|
57
|
+
|
58
|
+
it "all files are properly destroyed" do
|
59
|
+
run_generator [ version ], :behavior => :revoke
|
60
|
+
assert_no_migration "db/migrate/bigbluebutton_rails_to_#{version.gsub(".", "_")}.rb"
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
22
64
|
end
|
65
|
+
|
23
66
|
end
|
@@ -30,14 +30,18 @@ describe BigbluebuttonRails::Generators::ViewsGenerator do
|
|
30
30
|
|
31
31
|
def assert_files(assert_exists=true, scope="bigbluebutton")
|
32
32
|
files = [
|
33
|
-
"app/views/#{scope}/rooms/edit.html.erb",
|
34
33
|
"app/views/#{scope}/rooms/_form.html.erb",
|
34
|
+
"app/views/#{scope}/rooms/edit.html.erb",
|
35
35
|
"app/views/#{scope}/rooms/index.html.erb",
|
36
|
+
"app/views/#{scope}/rooms/invite.html.erb",
|
36
37
|
"app/views/#{scope}/rooms/join.html.erb",
|
38
|
+
"app/views/#{scope}/rooms/join_mobile.html.erb",
|
37
39
|
"app/views/#{scope}/rooms/new.html.erb",
|
38
40
|
"app/views/#{scope}/rooms/show.html.erb",
|
39
|
-
"app/views/#{scope}/servers/
|
41
|
+
"app/views/#{scope}/servers/_activity_list.html.erb",
|
40
42
|
"app/views/#{scope}/servers/_form.html.erb",
|
43
|
+
"app/views/#{scope}/servers/activity.html.erb",
|
44
|
+
"app/views/#{scope}/servers/edit.html.erb",
|
41
45
|
"app/views/#{scope}/servers/index.html.erb",
|
42
46
|
"app/views/#{scope}/servers/new.html.erb",
|
43
47
|
"app/views/#{scope}/servers/show.html.erb"
|
@@ -0,0 +1,19 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe BigbluebuttonRailsHelper do
|
4
|
+
|
5
|
+
describe "#qrcode_url" do
|
6
|
+
let(:url) { "http://www.google.com" }
|
7
|
+
let(:size) { "55x55" }
|
8
|
+
|
9
|
+
subject { qrcode_url(url, size) }
|
10
|
+
|
11
|
+
it("uses google charts api") { should match /https:\/\/chart.googleapis.com\/chart\?cht=qr/ }
|
12
|
+
it("uses encoded content") { should match /chl=#{CGI::escape(url)}/ }
|
13
|
+
it("uses size") { should match /chs=#{size}/ }
|
14
|
+
it("uses UTF-8") { should match /choe=UTF-8/ }
|
15
|
+
end
|
16
|
+
|
17
|
+
end
|
18
|
+
|
19
|
+
|