bigbluebutton_rails 2.2.0 → 2.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (86) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +3 -3
  3. data/CHANGELOG.md +34 -0
  4. data/Dockerfile +23 -0
  5. data/Gemfile +3 -0
  6. data/Gemfile.lock +14 -5
  7. data/README.md +42 -59
  8. data/Rakefile +6 -3
  9. data/app/controllers/bigbluebutton/api/rooms_controller.rb +117 -0
  10. data/app/controllers/bigbluebutton/playback_types_controller.rb +0 -3
  11. data/app/controllers/bigbluebutton/recordings_controller.rb +37 -23
  12. data/app/controllers/bigbluebutton/rooms_controller.rb +6 -31
  13. data/app/controllers/bigbluebutton/servers_controller.rb +0 -14
  14. data/app/helpers/bigbluebutton_rails_helper.rb +4 -0
  15. data/app/models/bigbluebutton_attendee.rb +21 -0
  16. data/app/models/bigbluebutton_meeting.rb +5 -0
  17. data/app/models/bigbluebutton_playback_format.rb +3 -2
  18. data/app/models/bigbluebutton_recording.rb +164 -68
  19. data/app/models/bigbluebutton_room.rb +148 -59
  20. data/app/models/bigbluebutton_server.rb +1 -1
  21. data/app/views/bigbluebutton/api/error.rabl +10 -0
  22. data/app/views/bigbluebutton/api/rooms/index.rabl +45 -0
  23. data/app/views/bigbluebutton/api/rooms/join.rabl +6 -0
  24. data/app/views/bigbluebutton/api/rooms/running.rabl +10 -0
  25. data/app/views/bigbluebutton/recordings/play.html.erb +1 -0
  26. data/app/views/bigbluebutton/servers/_activity_list.html.erb +5 -5
  27. data/app/workers/{bigbluebutton_finish_meetings.rb → bigbluebutton_finish_meetings_worker.rb} +2 -2
  28. data/app/workers/{bigbluebutton_meeting_updater.rb → bigbluebutton_meeting_updater_worker.rb} +3 -3
  29. data/app/workers/bigbluebutton_recordings_for_room_worker.rb +27 -0
  30. data/app/workers/{bigbluebutton_update_recordings.rb → bigbluebutton_update_recordings_worker.rb} +2 -2
  31. data/app/workers/{bigbluebutton_update_server_configs.rb → bigbluebutton_update_server_configs_worker.rb} +3 -3
  32. data/bigbluebutton_rails.gemspec +1 -0
  33. data/config/locales/en.yml +21 -0
  34. data/config/locales/pt-br.yml +1 -0
  35. data/config/resque/resque.rake +7 -1
  36. data/config/resque/workers_schedule.yml +3 -3
  37. data/docker-compose.yml +68 -0
  38. data/dumb-init_1.2.0 +0 -0
  39. data/lib/bigbluebutton_rails.rb +1 -2
  40. data/lib/bigbluebutton_rails/api_controller_methods.rb +138 -0
  41. data/lib/bigbluebutton_rails/configuration.rb +33 -4
  42. data/lib/bigbluebutton_rails/controller_methods.rb +0 -31
  43. data/lib/bigbluebutton_rails/exceptions.rb +17 -0
  44. data/lib/bigbluebutton_rails/rails/routes.rb +14 -0
  45. data/lib/bigbluebutton_rails/version.rb +1 -1
  46. data/lib/generators/bigbluebutton_rails/templates/migration.rb +17 -3
  47. data/lib/generators/bigbluebutton_rails/templates/migration_2_2_0.rb +1 -1
  48. data/lib/generators/bigbluebutton_rails/templates/migration_2_2_0_b.rb +106 -0
  49. data/lib/generators/bigbluebutton_rails/templates/migration_2_3_0.rb +22 -0
  50. data/lib/tasks/bigbluebutton_rails/meetings.rake +1 -1
  51. data/spec/controllers/bigbluebutton/api/rooms_controller_spec.rb +498 -0
  52. data/spec/controllers/bigbluebutton/recordings_controller_spec.rb +84 -0
  53. data/spec/controllers/bigbluebutton/rooms_controller_exception_handling_spec.rb +2 -2
  54. data/spec/controllers/bigbluebutton/rooms_controller_spec.rb +24 -22
  55. data/spec/controllers/bigbluebutton/servers_controller_spec.rb +9 -0
  56. data/spec/factories/bigbluebutton_attendee.rb +7 -0
  57. data/spec/factories/bigbluebutton_meeting.rb +0 -1
  58. data/spec/factories/bigbluebutton_playback_type.rb +1 -0
  59. data/spec/factories/bigbluebutton_recording.rb +2 -4
  60. data/spec/helpers/bigbluebutton_rails_helper_spec.rb +10 -2
  61. data/spec/lib/bigbluebutton_rails/background_tasks_spec.rb +1 -0
  62. data/spec/lib/tasks/meetings_rake_spec.rb +1 -1
  63. data/spec/models/bigbluebutton_attendee_spec.rb +44 -0
  64. data/spec/models/bigbluebutton_meeting_db_spec.rb +0 -1
  65. data/spec/models/bigbluebutton_meeting_spec.rb +1 -0
  66. data/spec/models/bigbluebutton_playback_format_spec.rb +2 -0
  67. data/spec/models/bigbluebutton_playback_type_db_spec.rb +1 -0
  68. data/spec/models/bigbluebutton_recording_db_spec.rb +2 -2
  69. data/spec/models/bigbluebutton_recording_spec.rb +404 -72
  70. data/spec/models/bigbluebutton_room_spec.rb +435 -148
  71. data/spec/rails_app/config/database.yml.example +10 -11
  72. data/spec/rails_app/config/initializers/resque.rb +33 -0
  73. data/spec/rails_app/config/routes.rb +2 -0
  74. data/spec/rails_app/lib/tasks/db/populate.rake +73 -55
  75. data/spec/support/mocked_server.rb +1 -1
  76. data/spec/workers/{bigbluebutton_finish_meetings_spec.rb → bigbluebutton_finish_meetings_worker_spec.rb} +3 -3
  77. data/spec/workers/{bigbluebutton_meeting_updater_spec.rb → bigbluebutton_meeting_updater_worker_spec.rb} +8 -7
  78. data/spec/workers/bigbluebutton_recordings_for_room_worker_spec.rb +49 -0
  79. data/spec/workers/{bigbluebutton_update_recordings_spec.rb → bigbluebutton_update_recordings_worker_spec.rb} +3 -3
  80. data/spec/workers/{bigbluebutton_update_server_configs_spec.rb → bigbluebutton_update_server_configs_worker_spec.rb} +4 -4
  81. metadata +42 -14
  82. data/lib/classes/bigbluebutton_attendee.rb +0 -21
  83. data/spec/classes/bigbluebutton_attendee_spec.rb +0 -76
  84. data/spec/controllers/bigbluebutton/recordings_controller_json_responses_spec.rb +0 -111
  85. data/spec/controllers/bigbluebutton/rooms_controller_json_responses_spec.rb +0 -203
  86. data/spec/controllers/bigbluebutton/servers_controller_json_responses_spec.rb +0 -162
@@ -1,21 +0,0 @@
1
- # Used to store the attendees of a meeting as returned by BigBlueButton in
2
- # <tt>get_meeting_info</tt>.
3
- class BigbluebuttonAttendee
4
-
5
- attr_accessor :user_id, :full_name, :role
6
-
7
- def from_hash(hash)
8
- self.user_id = hash[:userID].to_s
9
- self.full_name = hash[:fullName].to_s
10
- self.role = hash[:role].to_s.downcase == "moderator" ? :moderator : :attendee
11
- end
12
-
13
- def ==(other)
14
- r = true
15
- [:user_id, :full_name, :role].each do |param|
16
- r = r && self.send(param) == other.send(param)
17
- end
18
- r
19
- end
20
-
21
- end
@@ -1,76 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe BigbluebuttonAttendee do
4
-
5
- it "should be recognized" do
6
- lambda { BigbluebuttonAttendee.new }.should_not raise_error
7
- end
8
-
9
- [:user_id, :full_name, :role].each do |attr|
10
- it { should respond_to(attr) }
11
- it { should respond_to(:"#{attr}=") }
12
- end
13
-
14
- context "equality" do
15
- let(:attendee1) {
16
- attendee = BigbluebuttonAttendee.new
17
- attendee.user_id = Forgery(:basic).password
18
- attendee.full_name = Forgery(:name).full_name
19
- attendee.role = :attendee
20
- attendee
21
- }
22
- let(:attendee2) {
23
- attendee = BigbluebuttonAttendee.new
24
- attendee.user_id = Forgery(:basic).password
25
- attendee.full_name = Forgery(:name).full_name
26
- attendee.role = :moderator
27
- attendee
28
- }
29
- let(:attendee3) {
30
- attendee = BigbluebuttonAttendee.new
31
- attendee.user_id = attendee1.user_id
32
- attendee.full_name = attendee1.full_name
33
- attendee.role = attendee1.role
34
- attendee
35
- }
36
-
37
- it { attendee1.should == attendee3 }
38
- it { attendee1.should_not == attendee2 }
39
- it { attendee2.should_not == attendee3 }
40
- end
41
-
42
- context "gets params from hash" do
43
- let(:hash) { {:userID=>"user_id", :fullName=>"House M.D.", :role=>"MODERATOR"} }
44
- let(:attendee) { BigbluebuttonAttendee.new }
45
-
46
- it "standard case" do
47
- attendee.from_hash(hash)
48
- attendee.user_id.should == "user_id"
49
- attendee.full_name.should == "House M.D."
50
- attendee.role.should == :moderator
51
- end
52
-
53
- it "converts user_id to string" do
54
- hash[:userID] = 123
55
- attendee.from_hash(hash)
56
- attendee.user_id.should == "123"
57
- end
58
-
59
- it "role is not case sensitive" do
60
- hash[:role] = "mODErAtOR"
61
- attendee.from_hash(hash)
62
- attendee.role.should == :moderator
63
- end
64
-
65
- it "any role other than 'moderator' is attendee" do
66
- hash[:role] = "VIEWER"
67
- attendee.from_hash(hash)
68
- attendee.role.should == :attendee
69
-
70
- hash[:role] = "whatever"
71
- attendee.from_hash(hash)
72
- attendee.role.should == :attendee
73
- end
74
- end
75
-
76
- end
@@ -1,111 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe Bigbluebutton::RecordingsController do
4
- render_views
5
- let(:recording) { FactoryGirl.create(:bigbluebutton_recording) }
6
-
7
- context "json responses for" do
8
-
9
- describe "#index" do
10
- before do
11
- @recording1 = FactoryGirl.create(:bigbluebutton_recording)
12
- @recording2 = FactoryGirl.create(:bigbluebutton_recording)
13
- end
14
- before(:each) { get :index, :format => 'json' }
15
- it { should respond_with(:success) }
16
- it { should respond_with_content_type('application/json') }
17
- it { should respond_with_json([@recording1, @recording2].to_json) }
18
- end
19
-
20
- describe "#show" do
21
- before(:each) { get :show, :id => recording.to_param, :format => 'json' }
22
- it { should respond_with(:success) }
23
- it { should respond_with_content_type('application/json') }
24
- it { should respond_with_json(recording.to_json) }
25
- end
26
-
27
- describe "#show" do
28
- before(:each) { get :show, :id => recording.to_param, :format => 'json' }
29
- it { should respond_with(:success) }
30
- it { should respond_with_content_type('application/json') }
31
- it { should respond_with_json(recording.to_json) }
32
- end
33
-
34
- describe "#update" do
35
- let(:new_recording) { FactoryGirl.build(:bigbluebutton_recording) }
36
- before { @recording = recording }
37
-
38
- context "on success" do
39
- before(:each) {
40
- put :update, :id => @recording.to_param, :bigbluebutton_recording => new_recording.attributes, :format => 'json'
41
- }
42
- it { should respond_with(:success) }
43
- it { should respond_with_content_type('application/json') }
44
- it { response.body.should eq("true") }
45
- end
46
-
47
- context "on failure" do
48
- before {
49
- BigbluebuttonRecording.any_instance.should_receive(:update_attributes).and_return(false)
50
- }
51
- before(:each) {
52
- put :update, :id => @recording.to_param, :bigbluebutton_recording => new_recording.attributes, :format => 'json'
53
- }
54
- it { should respond_with(:unprocessable_entity) }
55
- it { should respond_with_content_type('application/json') }
56
- it { should respond_with_json([].to_json) }
57
- end
58
- end
59
-
60
- describe "#destroy" do
61
- before :each do
62
- @recording = recording
63
- @recording.server = nil
64
- BigbluebuttonRecording.stub(:find_by_recordid) { @recording }
65
- delete :destroy, :id => @recording.to_param, :format => 'json'
66
- end
67
- it { should respond_with(:success) }
68
- it { should respond_with_content_type('application/json') }
69
- end
70
-
71
- # these actions are essentially the same
72
- [:publish, :unpublish].each do |action|
73
- describe "##{action.to_s}" do
74
- before { mock_server_and_api }
75
- let(:flag) { action == :publish ? true : false }
76
-
77
- context "on success" do
78
- before {
79
- mocked_server.should_receive(:send_publish_recordings).with(recording.recordid, flag)
80
- }
81
- before(:each) { post action, :id => recording.to_param, :format => 'json' }
82
- it { should respond_with(:success) }
83
- it { should respond_with_content_type('application/json') }
84
- it { should respond_with_json(I18n.t("bigbluebutton_rails.recordings.notice.#{action.to_s}.success")) }
85
- end
86
-
87
- context "on failure" do
88
- let(:bbb_error_msg) { SecureRandom.hex(250) }
89
- let(:bbb_error) { BigBlueButton::BigBlueButtonException.new(bbb_error_msg) }
90
- before {
91
- request.env["HTTP_REFERER"] = "/any"
92
- mocked_server.should_receive(:send_publish_recordings) { raise bbb_error }
93
- }
94
- before(:each) { post action, :id => recording.to_param, :format => 'json' }
95
- it { should respond_with(:error) }
96
- it { should respond_with_content_type('application/json') }
97
- it { should respond_with_json(bbb_error_msg[0..200]) }
98
- end
99
-
100
- context "returns error if there's no server associated" do
101
- before { recording.stub(:server) { nil } }
102
- before(:each) { post action, :id => recording.to_param, :format => 'json' }
103
- it { should respond_with(:error) }
104
- it { should respond_with_content_type('application/json') }
105
- it { should respond_with_json(I18n.t('bigbluebutton_rails.recordings.errors.check_for_server.no_server')) }
106
- end
107
- end
108
- end
109
-
110
- end
111
- end
@@ -1,203 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe Bigbluebutton::RoomsController do
4
- render_views
5
- let(:server) { FactoryGirl.create(:bigbluebutton_server) }
6
- let(:room) { FactoryGirl.create(:bigbluebutton_room) }
7
- before do
8
- BigbluebuttonRoom.stub(:find_by_param) { room }
9
- BigbluebuttonRoom.stub(:find) { room }
10
- end
11
-
12
- context "json responses for" do
13
-
14
- describe "#index" do
15
- before do
16
- @room1 = FactoryGirl.create(:bigbluebutton_room)
17
- @room2 = FactoryGirl.create(:bigbluebutton_room)
18
- end
19
- before(:each) { get :index, :format => 'json' }
20
- it { should respond_with(:success) }
21
- it { should respond_with_content_type('application/json') }
22
- it { should respond_with_json([@room1, @room2].to_json) }
23
- end
24
-
25
- describe "#new" do
26
- before(:each) { get :new, :format => 'json' }
27
- it { should respond_with(:success) }
28
- it { should respond_with_content_type('application/json') }
29
- it {
30
- # we ignore all values bc a BigbluebuttonRoom is generated with some
31
- # random values (meetingid, voice_bridge)
32
- should respond_with_json(BigbluebuttonRoom.new.to_json).ignoring_values
33
- }
34
- end
35
-
36
- describe "#show" do
37
- before(:each) { get :show, :id => room.to_param, :format => 'json' }
38
- it { should respond_with(:success) }
39
- it { should respond_with_content_type('application/json') }
40
- it { should respond_with_json(room.to_json) }
41
- end
42
-
43
- describe "#create" do
44
- let(:new_room) { FactoryGirl.build(:bigbluebutton_room) }
45
-
46
- context "on success" do
47
- before(:each) {
48
- post :create, :bigbluebutton_room => new_room.attributes, :format => 'json'
49
- }
50
- it { should respond_with(:created) }
51
- it { should respond_with_content_type('application/json') }
52
- it {
53
- json = { :message => I18n.t('bigbluebutton_rails.rooms.notice.create.success') }.to_json
54
- should respond_with_json(json)
55
- }
56
- end
57
-
58
- context "on failure" do
59
- before(:each) {
60
- new_room.name = nil # invalid
61
- post :create, :bigbluebutton_room => new_room.attributes, :format => 'json'
62
- }
63
- it { should respond_with(:unprocessable_entity) }
64
- it { should respond_with_content_type('application/json') }
65
- it {
66
- new_room.save # should fail
67
- should respond_with_json(new_room.errors.full_messages.to_json)
68
- }
69
- end
70
- end
71
-
72
- describe "#update" do
73
- let(:new_room) { FactoryGirl.build(:bigbluebutton_room) }
74
- before { @room = room }
75
-
76
- context "on success" do
77
- before(:each) {
78
- put :update, :id => @room.to_param, :bigbluebutton_room => new_room.attributes, :format => 'json'
79
- }
80
- it { should respond_with(:success) }
81
- it { should respond_with_content_type('application/json') }
82
- it {
83
- json = { :message => I18n.t('bigbluebutton_rails.rooms.notice.update.success') }.to_json
84
- should respond_with_json(json)
85
- }
86
- end
87
-
88
- context "on failure" do
89
- before(:each) {
90
- new_room.name = nil # invalid
91
- put :update, :id => @room.to_param, :bigbluebutton_room => new_room.attributes, :format => 'json'
92
- }
93
- it { should respond_with(:unprocessable_entity) }
94
- it { should respond_with_content_type('application/json') }
95
- it {
96
- new_room.save # should fail
97
- should respond_with_json(new_room.errors.full_messages.to_json)
98
- }
99
- end
100
- end
101
-
102
- describe "#end" do
103
- before { mock_server_and_api }
104
-
105
- context "room is running" do
106
- before {
107
- mocked_api.should_receive(:is_meeting_running?).and_return(true)
108
- mocked_api.should_receive(:end_meeting).with(room.meetingid, room.moderator_api_password)
109
- }
110
- before(:each) { get :end, :id => room.to_param, :format => 'json' }
111
- it { should respond_with(:success) }
112
- it { should respond_with_content_type('application/json') }
113
- it { should respond_with_json(I18n.t('bigbluebutton_rails.rooms.notice.end.success')) }
114
- end
115
-
116
- context "room is not running" do
117
- before { mocked_api.should_receive(:is_meeting_running?).and_return(false) }
118
- before(:each) { get :end, :id => room.to_param, :format => 'json' }
119
- it { should respond_with(:error) }
120
- it { should respond_with_content_type('application/json') }
121
- it { should respond_with_json(I18n.t('bigbluebutton_rails.rooms.notice.end.not_running')) }
122
- end
123
-
124
- context "throwing an exception" do
125
- let(:msg) { "any error message" }
126
- before {
127
- mocked_api.should_receive(:is_meeting_running?) { raise BigBlueButton::BigBlueButtonException.new(msg) }
128
- }
129
- before(:each) { get :end, :id => room.to_param, :format => 'json' }
130
- it { should respond_with(:error) }
131
- it { should respond_with_content_type('application/json') }
132
- it { should respond_with_json(msg) }
133
- end
134
-
135
- end
136
-
137
- describe "#destroy" do
138
- before { mock_server_and_api }
139
-
140
- context "on success" do
141
- before {
142
- mocked_api.should_receive(:is_meeting_running?).and_return(true)
143
- mocked_api.should_receive(:end_meeting)
144
- }
145
- before(:each) {
146
- delete :destroy, :id => room.to_param, :format => 'json'
147
- }
148
- it { should respond_with(:success) }
149
- it { should respond_with_content_type('application/json') }
150
- it {
151
- json = { :message => I18n.t('bigbluebutton_rails.rooms.notice.destroy.success') }.to_json
152
- should respond_with_json(json)
153
- }
154
- end
155
-
156
- context "throwing error" do
157
- let(:msg) { "any error message" }
158
- before {
159
- mocked_api.should_receive(:is_meeting_running?) { raise BigBlueButton::BigBlueButtonException.new(msg) }
160
- }
161
- before(:each) {
162
- delete :destroy, :id => room.to_param, :format => 'json'
163
- }
164
- it { should respond_with(:error) }
165
- it { should respond_with_content_type('application/json') }
166
- it {
167
- error_msg = I18n.t('bigbluebutton_rails.rooms.notice.destroy.success_with_bbb_error', :error => msg)
168
- should respond_with_json({ :message => error_msg }.to_json)
169
- }
170
- end
171
- end
172
-
173
- describe "#fetch_recordings" do
174
- it "on success"
175
- it "on error"
176
- end
177
-
178
- describe "#generate_dial_number" do
179
- context "on success" do
180
- before(:each) {
181
- BigbluebuttonRoom.any_instance.stub(:generate_dial_number!).and_return(true)
182
- post :generate_dial_number, id: room.to_param, format: 'json'
183
- }
184
- it { should respond_with(:success) }
185
- it { should respond_with_content_type('application/json') }
186
- end
187
-
188
- context "on error" do
189
- before(:each) {
190
- BigbluebuttonRoom.any_instance.stub(:generate_dial_number!).and_return(nil)
191
- post :generate_dial_number, id: room.to_param, format: 'json'
192
- }
193
- it { should respond_with(:error) }
194
- it { should respond_with_content_type('application/json') }
195
- it {
196
- error_msg = I18n.t('bigbluebutton_rails.rooms.errors.generate_dial_number.not_unique')
197
- should respond_with_json({ :message => error_msg }.to_json)
198
- }
199
- end
200
- end
201
-
202
- end
203
- end
@@ -1,162 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe Bigbluebutton::ServersController do
4
- render_views
5
- let!(:server) { FactoryGirl.create(:bigbluebutton_server) }
6
-
7
- context "json responses for" do
8
-
9
- describe "#index" do
10
- before do
11
- BigbluebuttonServer.destroy_all
12
- @server1 = FactoryGirl.create(:bigbluebutton_server)
13
- @server2 = FactoryGirl.create(:bigbluebutton_server)
14
- end
15
- before(:each) { get :index, :format => 'json' }
16
- it { should respond_with(:success) }
17
- it { should respond_with_content_type('application/json') }
18
- it { should respond_with_json([@server1, @server2].to_json) }
19
- end
20
-
21
- describe "#new" do
22
- before(:each) { get :new, :format => 'json' }
23
- it { should respond_with(:success) }
24
- it { should respond_with_content_type('application/json') }
25
- it { should respond_with_json(BigbluebuttonServer.new.to_json).ignoring_values }
26
- end
27
-
28
- describe "#show" do
29
- before(:each) { get :show, :id => server.to_param, :format => 'json' }
30
- it { should respond_with(:success) }
31
- it { should respond_with_content_type('application/json') }
32
- it { should respond_with_json(server.to_json) }
33
- end
34
-
35
- describe "#create" do
36
- let(:new_server) { FactoryGirl.build(:bigbluebutton_server) }
37
-
38
- context "on success" do
39
- before {
40
- api_mock = double(BigBlueButton::BigBlueButtonApi)
41
- api_mock.stub(:version).and_return("0.9")
42
- api_mock.stub(:get_default_config_xml)
43
- api_mock.stub(:get_available_layouts)
44
- BigBlueButton::BigBlueButtonApi.stub(:new).and_return(api_mock)
45
- }
46
- before(:each) {
47
- post :create, :bigbluebutton_server => new_server.attributes, :format => 'json'
48
- }
49
- it { should respond_with(:created) }
50
- it { should respond_with_content_type('application/json') }
51
- it { should respond_with_json(new_server.to_json).ignoring_attributes }
52
- end
53
-
54
- context "on failure" do
55
- before(:each) {
56
- new_server.url = nil # invalid
57
- post :create, :bigbluebutton_server => new_server.attributes, :format => 'json'
58
- }
59
- it { should respond_with(:unprocessable_entity) }
60
- it { should respond_with_content_type('application/json') }
61
- it {
62
- new_server.save # should fail
63
- should respond_with_json(new_server.errors.full_messages.to_json)
64
- }
65
- end
66
- end
67
-
68
- describe "#update" do
69
- let(:new_server) { FactoryGirl.build(:bigbluebutton_server) }
70
-
71
- context "on success" do
72
- before(:each) {
73
- BigbluebuttonServer.any_instance.stub(:set_api_version_from_server)
74
- put :update, :id => server.to_param, :bigbluebutton_server => new_server.attributes, :format => 'json'
75
- }
76
- it { should respond_with(:success) }
77
- it { should respond_with_content_type('application/json') }
78
- it { response.body.should eq("true") }
79
- end
80
-
81
- context "on failure" do
82
- before(:each) {
83
- new_server.url = nil # invalid
84
- put :update, :id => server.to_param, :bigbluebutton_server => new_server.attributes, :format => 'json'
85
- }
86
- it { should respond_with(:unprocessable_entity) }
87
- it { should respond_with_content_type('application/json') }
88
- it {
89
- new_server.save # should fail
90
- should respond_with_json(new_server.errors.full_messages.to_json)
91
- }
92
- end
93
- end
94
-
95
- describe "#destroy" do
96
- before :each do
97
- delete :destroy, :id => server.to_param, :format => 'json'
98
- end
99
- it { should respond_with(:success) }
100
- it { should respond_with_content_type('application/json') }
101
- it { response.body.should eq("true") }
102
- end
103
-
104
- describe "#activity" do
105
- let(:room1) { FactoryGirl.create(:bigbluebutton_room) }
106
- let(:room2) { FactoryGirl.create(:bigbluebutton_room) }
107
- before do
108
- # so we return our mocked server
109
- BigbluebuttonServer.stub(:find_by_param).with(server.to_param).
110
- and_return(server)
111
- end
112
-
113
- context "on success" do
114
- before do
115
- server.should_receive(:fetch_meetings).and_return({ })
116
- server.should_receive(:meetings).twice.and_return([room1, room2])
117
- room1.should_receive(:fetch_meeting_info)
118
- room2.should_receive(:fetch_meeting_info)
119
- end
120
- before(:each) { get :activity, :id => server.to_param, :format => 'json' }
121
- it { should respond_with(:success) }
122
- it { should respond_with_content_type('application/json') }
123
- it { should respond_with_json([room1, room2].to_json) }
124
- end
125
-
126
- context "on failure" do
127
- let(:bbb_error_msg) { SecureRandom.hex(250) }
128
- let(:bbb_error) { BigBlueButton::BigBlueButtonException.new(bbb_error_msg) }
129
- before do
130
- server.should_receive(:fetch_meetings).and_return({ })
131
- server.should_receive(:meetings).at_least(:once).and_return([room1, room2])
132
- room1.should_receive(:fetch_meeting_info) { raise bbb_error }
133
- end
134
- before(:each) { get :activity, :id => server.to_param, :format => 'json' }
135
- it { should respond_with(:error) }
136
- it { should respond_with_content_type('application/json') }
137
- it { should respond_with_json([{ :message => bbb_error_msg[0..200] }, room1, room2].to_json) }
138
- it { should set_the_flash.to(bbb_error_msg[0..200]) }
139
- end
140
-
141
- context "ignores params[:update_list]" do
142
- before do
143
- server.should_receive(:fetch_meetings).and_return({ })
144
- server.should_receive(:meetings).twice.and_return([room1, room2])
145
- room1.should_receive(:fetch_meeting_info)
146
- room2.should_receive(:fetch_meeting_info)
147
- end
148
- before(:each) { get :activity, :id => server.to_param, :update_list => true, :format => 'json' }
149
- it { should respond_with(:success) }
150
- it { should respond_with_content_type('application/json') }
151
- it { should respond_with_json([room1, room2].to_json) }
152
- end
153
-
154
- end
155
-
156
- describe "#fetch_recordings" do
157
- it "on success"
158
- it "on error"
159
- end
160
-
161
- end
162
- end