bigbluebutton_rails 1.4.0 → 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (125) hide show
  1. checksums.yaml +7 -0
  2. data/.ruby-version +1 -1
  3. data/.travis.yml +10 -1
  4. data/CHANGELOG.md +259 -0
  5. data/Gemfile +14 -19
  6. data/Gemfile.lock +194 -188
  7. data/README.md +416 -0
  8. data/Rakefile +12 -12
  9. data/TODO.md +13 -0
  10. data/app/controllers/bigbluebutton/playback_types_controller.rb +44 -0
  11. data/app/controllers/bigbluebutton/recordings_controller.rb +17 -10
  12. data/app/controllers/bigbluebutton/rooms_controller.rb +65 -36
  13. data/app/controllers/bigbluebutton/servers_controller.rb +12 -8
  14. data/app/models/bigbluebutton_metadata.rb +1 -1
  15. data/app/models/bigbluebutton_playback_format.rb +22 -1
  16. data/app/models/bigbluebutton_playback_type.rb +29 -0
  17. data/app/models/bigbluebutton_recording.rb +38 -19
  18. data/app/models/bigbluebutton_room.rb +150 -73
  19. data/app/models/bigbluebutton_room_options.rb +10 -7
  20. data/app/models/bigbluebutton_server.rb +69 -13
  21. data/app/models/bigbluebutton_server_config.rb +49 -0
  22. data/app/views/bigbluebutton/recordings/_form.html.erb +4 -0
  23. data/app/views/bigbluebutton/recordings/_recordings.html.erb +10 -3
  24. data/app/views/bigbluebutton/rooms/_form.html.erb +18 -6
  25. data/app/views/bigbluebutton/rooms/_rooms.html.erb +6 -3
  26. data/app/views/bigbluebutton/rooms/invite.html.erb +5 -5
  27. data/app/views/bigbluebutton/rooms/show.html.erb +18 -6
  28. data/app/views/bigbluebutton/servers/_form.html.erb +1 -1
  29. data/app/views/bigbluebutton/servers/show.html.erb +5 -0
  30. data/app/workers/bigbluebutton_finish_meetings.rb +11 -0
  31. data/app/workers/bigbluebutton_update_recordings.rb +11 -0
  32. data/app/workers/bigbluebutton_update_server_configs.rb +18 -0
  33. data/bigbluebutton_rails.gemspec +8 -7
  34. data/config/locales/en.yml +52 -7
  35. data/config/locales/pt-br.yml +162 -0
  36. data/config/resque/resque.rake +27 -0
  37. data/config/resque/workers_schedule.yml +17 -0
  38. data/lib/bigbluebutton_rails.rb +30 -2
  39. data/lib/bigbluebutton_rails/background_tasks.rb +31 -0
  40. data/lib/bigbluebutton_rails/controller_methods.rb +12 -8
  41. data/lib/bigbluebutton_rails/dial_number.rb +48 -0
  42. data/lib/bigbluebutton_rails/rails/routes.rb +9 -2
  43. data/lib/bigbluebutton_rails/utils.rb +9 -2
  44. data/lib/bigbluebutton_rails/version.rb +1 -1
  45. data/lib/generators/bigbluebutton_rails/install_generator.rb +0 -8
  46. data/lib/generators/bigbluebutton_rails/templates/migration.rb +28 -6
  47. data/lib/generators/bigbluebutton_rails/templates/migration_2_0_0.rb +56 -0
  48. data/lib/tasks/bigbluebutton_rails/meetings.rake +1 -13
  49. data/lib/tasks/bigbluebutton_rails/recordings.rake +1 -12
  50. data/lib/tasks/bigbluebutton_rails/server_configs.rake +10 -0
  51. data/spec/bigbluebutton_rails_spec.rb +0 -13
  52. data/spec/controllers/bigbluebutton/playback_types_controller_spec.rb +76 -0
  53. data/spec/controllers/bigbluebutton/recordings_controller_spec.rb +109 -37
  54. data/spec/controllers/bigbluebutton/rooms_controller_exception_handling_spec.rb +1 -0
  55. data/spec/controllers/bigbluebutton/rooms_controller_json_responses_spec.rb +27 -3
  56. data/spec/controllers/bigbluebutton/rooms_controller_spec.rb +338 -77
  57. data/spec/controllers/bigbluebutton/servers_controller_json_responses_spec.rb +8 -0
  58. data/spec/controllers/bigbluebutton/servers_controller_spec.rb +182 -47
  59. data/spec/factories/bigbluebutton_meeting.rb +2 -2
  60. data/spec/factories/bigbluebutton_playback_format.rb +2 -2
  61. data/spec/factories/bigbluebutton_playback_type.rb +7 -0
  62. data/spec/factories/bigbluebutton_recording.rb +8 -0
  63. data/spec/factories/bigbluebutton_room.rb +10 -3
  64. data/spec/factories/bigbluebutton_server.rb +6 -1
  65. data/spec/factories/bigbluebutton_server_config.rb +6 -0
  66. data/spec/generators/install_generator_spec.rb +0 -16
  67. data/spec/lib/bigbluebutton_rails/background_tasks_spec.rb +61 -0
  68. data/spec/lib/bigbluebutton_rails/dial_number_spec.rb +78 -0
  69. data/spec/lib/bigbluebutton_rails/utils_spec.rb +56 -0
  70. data/spec/lib/tasks/meetings_rake_spec.rb +14 -1
  71. data/spec/lib/tasks/recordings_rake_spec.rb +14 -1
  72. data/spec/models/bigbluebutton_meeting_db_spec.rb +3 -3
  73. data/spec/models/bigbluebutton_meeting_spec.rb +4 -4
  74. data/spec/models/bigbluebutton_playback_format_db_spec.rb +0 -1
  75. data/spec/models/bigbluebutton_playback_format_spec.rb +75 -4
  76. data/spec/models/bigbluebutton_playback_type_db_spec.rb +14 -0
  77. data/spec/models/bigbluebutton_playback_type_spec.rb +76 -0
  78. data/spec/models/bigbluebutton_recording_db_spec.rb +3 -1
  79. data/spec/models/bigbluebutton_recording_spec.rb +234 -58
  80. data/spec/models/bigbluebutton_room_db_spec.rb +8 -6
  81. data/spec/models/bigbluebutton_room_options_db_spec.rb +1 -0
  82. data/spec/models/bigbluebutton_room_options_spec.rb +137 -38
  83. data/spec/models/bigbluebutton_room_spec.rb +540 -153
  84. data/spec/models/bigbluebutton_server_config_spec.rb +115 -0
  85. data/spec/models/bigbluebutton_server_spec.rb +180 -23
  86. data/spec/rails_app/app/controllers/my_playback_types_controller.rb +7 -0
  87. data/spec/rails_app/app/views/frontpage/show.html.erb +1 -0
  88. data/spec/rails_app/app/views/my_playback_types/index.html.erb +33 -0
  89. data/spec/rails_app/config/application.rb +0 -3
  90. data/spec/rails_app/config/database.yml.travis +10 -0
  91. data/spec/rails_app/config/environments/development.rb +1 -6
  92. data/spec/rails_app/config/environments/production.rb +2 -0
  93. data/spec/rails_app/config/environments/test.rb +2 -0
  94. data/spec/rails_app/config/routes.rb +5 -2
  95. data/spec/rails_app/db/seeds.rb +1 -1
  96. data/spec/rails_app/features/config.yml.example +3 -4
  97. data/spec/rails_app/features/join_rooms.feature +14 -14
  98. data/spec/rails_app/features/step_definitions/activity_monitor_servers_step.rb +2 -2
  99. data/spec/rails_app/features/step_definitions/create_rooms_steps.rb +4 -4
  100. data/spec/rails_app/features/step_definitions/destroy_rooms_steps.rb +2 -2
  101. data/spec/rails_app/features/step_definitions/join_rooms_steps.rb +10 -10
  102. data/spec/rails_app/features/step_definitions/web_steps.rb +2 -2
  103. data/spec/rails_app/features/support/configurations.rb +1 -1
  104. data/spec/rails_app/features/support/templates.rb +12 -12
  105. data/spec/rails_app/lib/tasks/db/populate.rake +19 -6
  106. data/spec/routing/bigbluebutton/custom_controllers_routing_spec.rb +1 -1
  107. data/spec/routing/bigbluebutton/recordings_only_routing_spec.rb +2 -2
  108. data/spec/routing/bigbluebutton/recordings_routing_spec.rb +2 -2
  109. data/spec/routing/bigbluebutton/rooms_only_routing_spec.rb +1 -1
  110. data/spec/routing/bigbluebutton/rooms_routing_spec.rb +15 -1
  111. data/spec/routing/bigbluebutton/servers_only_routing_spec.rb +1 -1
  112. data/spec/routing/bigbluebutton/servers_routing_spec.rb +1 -1
  113. data/spec/spec_helper.rb +23 -31
  114. data/spec/support/matchers/delegate_matcher.rb +8 -1
  115. data/spec/support/matchers/shoulda/respond_with_json_matcher.rb +2 -2
  116. data/spec/support/mocked_server.rb +2 -0
  117. data/spec/support/shared_contexts/rake.rb +23 -0
  118. data/spec/workers/bigbluebutton_finish_meetings_spec.rb +14 -0
  119. data/spec/workers/bigbluebutton_update_recordings_spec.rb +14 -0
  120. data/spec/workers/bigbluebutton_update_server_configs_spec.rb +47 -0
  121. metadata +70 -59
  122. data/CHANGELOG.rdoc +0 -111
  123. data/README.rdoc +0 -319
  124. data/TODO.rdoc +0 -16
  125. data/config/schedule.rb +0 -7
@@ -0,0 +1,76 @@
1
+ require 'spec_helper'
2
+
3
+ describe Bigbluebutton::PlaybackTypesController do
4
+ render_views
5
+ let!(:playback_type) { FactoryGirl.create(:bigbluebutton_playback_type) }
6
+
7
+ describe "#update" do
8
+ let!(:new_playback_type) { FactoryGirl.build(:bigbluebutton_playback_type, visible: !playback_type.visible) }
9
+ let(:referer) { "/back" }
10
+ before { request.env["HTTP_REFERER"] = referer }
11
+
12
+ context "on success" do
13
+ before(:each) {
14
+ expect {
15
+ put :update, :id => playback_type.to_param, :bigbluebutton_playback_type => new_playback_type.attributes
16
+ }.not_to change{ BigbluebuttonPlaybackType.count }
17
+ }
18
+ it { should respond_with(:redirect) }
19
+ it { should redirect_to(referer) }
20
+ it {
21
+ saved = BigbluebuttonPlaybackType.find(playback_type)
22
+ saved.should have_same_attributes_as(new_playback_type, ['identifier'])
23
+ }
24
+ it { should set_the_flash.to(I18n.t('bigbluebutton_rails.playback_types.notice.update.success')) }
25
+ end
26
+
27
+ context "on failure" do
28
+ before(:each) {
29
+ BigbluebuttonPlaybackType.should_receive(:find).and_return(playback_type)
30
+ playback_type.should_receive(:update_attributes).and_return(false)
31
+ playback_type.errors.add :identifier, "first"
32
+ playback_type.errors.add :visible, "second"
33
+ put :update, :id => playback_type.to_param, :bigbluebutton_playback_type => new_playback_type.attributes
34
+ }
35
+ it { should respond_with(:redirect) }
36
+ it { should redirect_to(referer) }
37
+ it {
38
+ expected = "Identifier first, Visible second"
39
+ should set_the_flash.to(expected)
40
+ }
41
+ end
42
+
43
+ describe "params handling" do
44
+ let(:attrs) { FactoryGirl.attributes_for(:bigbluebutton_playback_type) }
45
+ let(:params) { { :bigbluebutton_playback_type => attrs } }
46
+ let(:allowed_params) {
47
+ [ :visible, :default ]
48
+ }
49
+ it {
50
+ # we just check that the rails method 'permit' is being called on the hash with the
51
+ # correct parameters
52
+ BigbluebuttonPlaybackType.stub(:find).and_return(playback_type)
53
+ playback_type.stub(:update_attributes).and_return(true)
54
+ attrs.stub(:permit).and_return(attrs)
55
+ controller.stub(:params).and_return(params)
56
+
57
+ put :update, :id => playback_type.to_param, :bigbluebutton_playback_type => new_playback_type.attributes
58
+ attrs.should have_received(:permit).with(*allowed_params)
59
+ }
60
+ end
61
+
62
+ context "doesn't override @playback_type" do
63
+ let!(:other_playback_type) { FactoryGirl.create(:bigbluebutton_playback_type) }
64
+ let(:format) { FactoryGirl.create(:bigbluebutton_playback_format, :playback_type => playback_type) }
65
+ before { controller.instance_variable_set(:@playback_type, other_playback_type) }
66
+ before(:each) {
67
+ put :update, :id => playback_type.to_param, :bigbluebutton_playback_type => new_playback_type.attributes
68
+ }
69
+ it { should assign_to(:playback_type).with(other_playback_type) }
70
+ end
71
+ end
72
+
73
+ # important because it might break custom actions on controllers that inherit from this
74
+ skip "doesn't call #find_playback_type for custom actions"
75
+
76
+ end
@@ -2,60 +2,89 @@ require 'spec_helper'
2
2
 
3
3
  describe Bigbluebutton::RecordingsController do
4
4
  render_views
5
- let(:recording) { FactoryGirl.create(:bigbluebutton_recording) }
5
+ let!(:recording) { FactoryGirl.create(:bigbluebutton_recording) }
6
6
 
7
7
  describe "#index" do
8
- before { 3.times { FactoryGirl.create(:bigbluebutton_recording) } }
9
- before(:each) { get :index }
10
- it { should respond_with(:success) }
11
- it { should assign_to(:recordings).with(BigbluebuttonRecording.all) }
12
- it { should render_template(:index) }
8
+ context "basic" do
9
+ before { 3.times { FactoryGirl.create(:bigbluebutton_recording) } }
10
+ before(:each) { get :index }
11
+ it { should respond_with(:success) }
12
+ it { should assign_to(:recordings).with(BigbluebuttonRecording.all) }
13
+ it { should render_template(:index) }
14
+ end
15
+
16
+ context "doesn't override @recordings" do
17
+ let!(:my_recordings) { [ FactoryGirl.create(:bigbluebutton_recording), FactoryGirl.create(:bigbluebutton_recording) ] }
18
+ before {
19
+ 3.times { FactoryGirl.create(:bigbluebutton_recording) }
20
+ controller.instance_variable_set(:@recordings, my_recordings)
21
+ }
22
+ before(:each) { get :index }
23
+ it { should assign_to(:recordings).with(my_recordings) }
24
+ end
13
25
  end
14
26
 
15
27
  describe "#show" do
16
- before(:each) { get :show, :id => recording.to_param }
17
- it { should respond_with(:success) }
18
- it { should assign_to(:recording).with(recording) }
19
- it { should render_template(:show) }
28
+ context "basic" do
29
+ before(:each) { get :show, :id => recording.to_param }
30
+ it { should respond_with(:success) }
31
+ it { should assign_to(:recording).with(recording) }
32
+ it { should render_template(:show) }
33
+ end
34
+
35
+ context "doesn't override @recording" do
36
+ let!(:other_recording) { FactoryGirl.create(:bigbluebutton_recording) }
37
+ before { controller.instance_variable_set(:@recording, other_recording) }
38
+ before(:each) { get :show, :id => recording.to_param }
39
+ it { should assign_to(:recording).with(other_recording) }
40
+ end
20
41
  end
21
42
 
22
43
  describe "#edit" do
23
- before(:each) { get :edit, :id => recording.to_param }
24
- it { should respond_with(:success) }
25
- it { should assign_to(:recording).with(recording) }
26
- it { should render_template(:edit) }
44
+ context "basic" do
45
+ before(:each) { get :edit, :id => recording.to_param }
46
+ it { should respond_with(:success) }
47
+ it { should assign_to(:recording).with(recording) }
48
+ it { should render_template(:edit) }
49
+ end
50
+
51
+ context "doesn't override @recording" do
52
+ let!(:other_recording) { FactoryGirl.create(:bigbluebutton_recording) }
53
+ before { controller.instance_variable_set(:@recording, other_recording) }
54
+ before(:each) { get :edit, :id => recording.to_param }
55
+ it { should assign_to(:recording).with(other_recording) }
56
+ end
27
57
  end
28
58
 
29
59
  describe "#update" do
30
- let(:new_recording) { FactoryGirl.build(:bigbluebutton_recording) }
31
- before { @recording = recording } # need this to trigger let(:recording) and actually create the object
60
+ let!(:new_recording) { FactoryGirl.build(:bigbluebutton_recording) }
32
61
 
33
62
  context "on success" do
34
63
  before(:each) {
35
64
  expect {
36
- put :update, :id => @recording.to_param, :bigbluebutton_recording => new_recording.attributes
65
+ put :update, :id => recording.to_param, :bigbluebutton_recording => new_recording.attributes
37
66
  }.not_to change{ BigbluebuttonRecording.count }
38
67
  }
39
68
  it { should respond_with(:redirect) }
40
69
  it {
41
- saved = BigbluebuttonRecording.find(@recording)
70
+ saved = BigbluebuttonRecording.find(recording)
42
71
  should redirect_to(bigbluebutton_recording_path(saved))
43
72
  }
44
73
  it {
45
- saved = BigbluebuttonRecording.find(@recording)
46
- saved.should have_same_attributes_as(new_recording, ['room_id', 'server_id', 'meeting_id'])
74
+ saved = BigbluebuttonRecording.find(recording)
75
+ saved.should have_same_attributes_as(new_recording, ['room_id', 'server_id', 'meeting_id', 'size'])
47
76
  }
48
77
  it { should set_the_flash.to(I18n.t('bigbluebutton_rails.recordings.notice.update.success')) }
49
78
  end
50
79
 
51
80
  context "on failure" do
52
81
  before(:each) {
53
- BigbluebuttonRecording.should_receive(:find_by_recordid).and_return(@recording)
54
- @recording.should_receive(:update_attributes).and_return(false)
55
- put :update, :id => @recording.to_param, :bigbluebutton_recording => new_recording.attributes
82
+ BigbluebuttonRecording.should_receive(:find_by_recordid).and_return(recording)
83
+ recording.should_receive(:update_attributes).and_return(false)
84
+ put :update, :id => recording.to_param, :bigbluebutton_recording => new_recording.attributes
56
85
  }
57
86
  it { should render_template(:edit) }
58
- it { should assign_to(:recording).with(@recording) }
87
+ it { should assign_to(:recording).with(recording) }
59
88
  end
60
89
 
61
90
  describe "params handling" do
@@ -67,12 +96,12 @@ describe Bigbluebutton::RecordingsController do
67
96
  it {
68
97
  # we just check that the rails method 'permit' is being called on the hash with the
69
98
  # correct parameters
70
- BigbluebuttonRecording.stub(:find_by_recordid).and_return(@recording)
71
- @recording.stub(:update_attributes).and_return(true)
99
+ BigbluebuttonRecording.stub(:find_by_recordid).and_return(recording)
100
+ recording.stub(:update_attributes).and_return(true)
72
101
  attrs.stub(:permit).and_return(attrs)
73
102
  controller.stub(:params).and_return(params)
74
103
 
75
- put :update, :id => @recording.to_param, :bigbluebutton_recording => attrs
104
+ put :update, :id => recording.to_param, :bigbluebutton_recording => attrs
76
105
  attrs.should have_received(:permit).with(*allowed_params)
77
106
  }
78
107
  end
@@ -80,15 +109,15 @@ describe Bigbluebutton::RecordingsController do
80
109
  # to make sure it doesn't break if the hash informed doesn't have the key :bigbluebutton_recording
81
110
  describe "if parameters are not informed" do
82
111
  it {
83
- put :update, :id => @recording.to_param
84
- should redirect_to(bigbluebutton_recording_path(@recording))
112
+ put :update, :id => recording.to_param
113
+ should redirect_to(bigbluebutton_recording_path(recording))
85
114
  }
86
115
  end
87
116
 
88
117
  context "with :redir_url" do
89
118
  context "on success" do
90
119
  before(:each) {
91
- put :update, :id => @recording.to_param, :bigbluebutton_recording => new_recording.attributes, :redir_url => '/any'
120
+ put :update, :id => recording.to_param, :bigbluebutton_recording => new_recording.attributes, :redir_url => '/any'
92
121
  }
93
122
  it { should respond_with(:redirect) }
94
123
  it { should redirect_to "/any" }
@@ -96,15 +125,21 @@ describe Bigbluebutton::RecordingsController do
96
125
 
97
126
  context "on failure" do
98
127
  before(:each) {
99
- BigbluebuttonRecording.should_receive(:find_by_recordid).and_return(@recording)
100
- @recording.should_receive(:update_attributes).and_return(false)
101
- put :update, :id => @recording.to_param, :bigbluebutton_recording => new_recording.attributes, :redir_url => '/any'
128
+ BigbluebuttonRecording.should_receive(:find_by_recordid).and_return(recording)
129
+ recording.should_receive(:update_attributes).and_return(false)
130
+ put :update, :id => recording.to_param, :bigbluebutton_recording => new_recording.attributes, :redir_url => '/any'
102
131
  }
103
132
  it { should respond_with(:redirect) }
104
133
  it { should redirect_to "/any" }
105
134
  end
106
135
  end
107
136
 
137
+ context "doesn't override @recording" do
138
+ let!(:other_recording) { FactoryGirl.create(:bigbluebutton_recording) }
139
+ before { controller.instance_variable_set(:@recording, other_recording) }
140
+ before(:each) { put :update, :id => recording.to_param, :bigbluebutton_recording => new_recording.attributes }
141
+ it { should assign_to(:recording).with(other_recording) }
142
+ end
108
143
  end
109
144
 
110
145
  describe "#destroy" do
@@ -172,6 +207,16 @@ describe Bigbluebutton::RecordingsController do
172
207
  it { should redirect_to bigbluebutton_recordings_url }
173
208
  it { should set_the_flash.to(I18n.t('bigbluebutton_rails.recordings.notice.destroy.success')) }
174
209
  end
210
+
211
+ context "doesn't override @recording" do
212
+ let!(:other_recording) { FactoryGirl.create(:bigbluebutton_recording) }
213
+ before {
214
+ controller.instance_variable_set(:@recording, other_recording)
215
+ other_recording.server.stub(:send_delete_recordings)
216
+ }
217
+ before(:each) { delete :destroy, :id => recording.to_param }
218
+ it { should assign_to(:recording).with(other_recording) }
219
+ end
175
220
  end
176
221
 
177
222
  describe "#play" do
@@ -188,9 +233,20 @@ describe Bigbluebutton::RecordingsController do
188
233
  end
189
234
 
190
235
  context "when params[:type] is not specified plays the first format" do
191
- before(:each) { get :play, :id => recording.to_param }
192
- it { should respond_with(:redirect) }
193
- it { should redirect_to @format1.url }
236
+ context "plays the default format" do
237
+ before {
238
+ @format2.playback_type.update_attributes(default: true)
239
+ }
240
+ before(:each) { get :play, :id => recording.to_param }
241
+ it { should respond_with(:redirect) }
242
+ it { should redirect_to @format2.url }
243
+ end
244
+
245
+ context "plays the first format if there's no default" do
246
+ before(:each) { get :play, :id => recording.to_param }
247
+ it { should respond_with(:redirect) }
248
+ it { should redirect_to @format1.url }
249
+ end
194
250
  end
195
251
  end
196
252
 
@@ -209,6 +265,13 @@ describe Bigbluebutton::RecordingsController do
209
265
  end
210
266
  end
211
267
 
268
+ context "doesn't override @recording" do
269
+ let!(:other_recording) { FactoryGirl.create(:bigbluebutton_recording) }
270
+ let(:format) { FactoryGirl.create(:bigbluebutton_playback_format, :recording => recording) }
271
+ before { controller.instance_variable_set(:@recording, other_recording) }
272
+ before(:each) { get :play, :id => recording.to_param, :type => format.format_type }
273
+ it { should assign_to(:recording).with(other_recording) }
274
+ end
212
275
  end
213
276
 
214
277
  # these actions are essentially the same
@@ -269,7 +332,16 @@ describe Bigbluebutton::RecordingsController do
269
332
  end
270
333
  end
271
334
 
335
+ context "doesn't override @recording" do
336
+ let!(:other_recording) { FactoryGirl.create(:bigbluebutton_recording) }
337
+ before {
338
+ controller.instance_variable_set(:@recording, other_recording)
339
+ other_recording.server.stub(:send_publish_recordings)
340
+ }
341
+ before(:each) { post action, :id => recording.to_param }
342
+ it { should assign_to(:recording).with(other_recording) }
343
+ end
344
+
272
345
  end
273
346
  end
274
-
275
347
  end
@@ -84,6 +84,7 @@ describe Bigbluebutton::RoomsController do
84
84
  it "catches exception on create_meeting" do
85
85
  mocked_api.should_receive(:"request_headers=").once
86
86
  mocked_api.should_receive(:is_meeting_running?).exactly(3).times.and_return(false)
87
+ mocked_api.should_receive(:end_meeting)
87
88
  mocked_api.should_receive(:create_meeting) { raise bbb_error }
88
89
  end
89
90
 
@@ -105,7 +105,7 @@ describe Bigbluebutton::RoomsController do
105
105
  context "room is running" do
106
106
  before {
107
107
  mocked_api.should_receive(:is_meeting_running?).and_return(true)
108
- mocked_api.should_receive(:end_meeting).with(room.meetingid, room.moderator_password)
108
+ mocked_api.should_receive(:end_meeting).with(room.meetingid, room.moderator_api_password)
109
109
  }
110
110
  before(:each) { get :end, :id => room.to_param, :format => 'json' }
111
111
  it { should respond_with(:success) }
@@ -124,7 +124,7 @@ describe Bigbluebutton::RoomsController do
124
124
  context "throwing an exception" do
125
125
  let(:msg) { "any error message" }
126
126
  before {
127
- mocked_api.should_receive(:is_meeting_running?).and_return{ raise BigBlueButton::BigBlueButtonException.new(msg) }
127
+ mocked_api.should_receive(:is_meeting_running?) { raise BigBlueButton::BigBlueButtonException.new(msg) }
128
128
  }
129
129
  before(:each) { get :end, :id => room.to_param, :format => 'json' }
130
130
  it { should respond_with(:error) }
@@ -156,7 +156,7 @@ describe Bigbluebutton::RoomsController do
156
156
  context "throwing error" do
157
157
  let(:msg) { "any error message" }
158
158
  before {
159
- mocked_api.should_receive(:is_meeting_running?).and_return{ raise BigBlueButton::BigBlueButtonException.new(msg) }
159
+ mocked_api.should_receive(:is_meeting_running?) { raise BigBlueButton::BigBlueButtonException.new(msg) }
160
160
  }
161
161
  before(:each) {
162
162
  delete :destroy, :id => room.to_param, :format => 'json'
@@ -175,5 +175,29 @@ describe Bigbluebutton::RoomsController do
175
175
  it "on error"
176
176
  end
177
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
+
178
202
  end
179
203
  end
@@ -8,34 +8,74 @@ describe Bigbluebutton::RoomsController do
8
8
  render_views
9
9
  let(:server) { FactoryGirl.create(:bigbluebutton_server) }
10
10
  let(:room) { FactoryGirl.create(:bigbluebutton_room, :server => server) }
11
+ let(:params_to_ignore) { ['moderator_api_password', 'attendee_api_password'] }
11
12
 
12
13
  describe "#index" do
13
- before { 3.times { FactoryGirl.create(:bigbluebutton_room) } }
14
- before(:each) { get :index }
15
- it { should respond_with(:success) }
16
- it { should assign_to(:rooms).with(BigbluebuttonRoom.all) }
17
- it { should render_template(:index) }
14
+ context "basic" do
15
+ before { 3.times { FactoryGirl.create(:bigbluebutton_room) } }
16
+ before(:each) { get :index }
17
+ it { should respond_with(:success) }
18
+ it { should assign_to(:rooms).with(BigbluebuttonRoom.all) }
19
+ it { should render_template(:index) }
20
+ end
21
+
22
+ context "doesn't override @rooms" do
23
+ let!(:my_rooms) { [ FactoryGirl.create(:bigbluebutton_room), FactoryGirl.create(:bigbluebutton_room) ] }
24
+ before {
25
+ 3.times { FactoryGirl.create(:bigbluebutton_room) }
26
+ controller.instance_variable_set(:@rooms, my_rooms)
27
+ }
28
+ before(:each) { get :index }
29
+ it { should assign_to(:rooms).with(my_rooms) }
30
+ end
18
31
  end
19
32
 
20
33
  describe "#show" do
21
- before(:each) { get :show, :id => room.to_param }
22
- it { should respond_with(:success) }
23
- it { should assign_to(:room).with(room) }
24
- it { should render_template(:show) }
34
+ context "basic" do
35
+ before(:each) { get :show, :id => room.to_param }
36
+ it { should respond_with(:success) }
37
+ it { should assign_to(:room).with(room) }
38
+ it { should render_template(:show) }
39
+ end
40
+
41
+ context "doesn't override @room" do
42
+ let!(:other_room) { FactoryGirl.create(:bigbluebutton_room) }
43
+ before { controller.instance_variable_set(:@room, other_room) }
44
+ before(:each) { get :show, :id => room.to_param }
45
+ it { should assign_to(:room).with(other_room) }
46
+ end
25
47
  end
26
48
 
27
49
  describe "#new" do
28
- before(:each) { get :new }
29
- it { should respond_with(:success) }
30
- it { should assign_to(:room).with_kind_of(BigbluebuttonRoom) }
31
- it { should render_template(:new) }
50
+ context "basic" do
51
+ before(:each) { get :new }
52
+ it { should respond_with(:success) }
53
+ it { should assign_to(:room).with_kind_of(BigbluebuttonRoom) }
54
+ it { should render_template(:new) }
55
+ end
56
+
57
+ context "doesn't override @room" do
58
+ let!(:other_room) { FactoryGirl.create(:bigbluebutton_room) }
59
+ before { controller.instance_variable_set(:@room, other_room) }
60
+ before(:each) { get :new }
61
+ it { should assign_to(:room).with(other_room) }
62
+ end
32
63
  end
33
64
 
34
65
  describe "#edit" do
35
- before(:each) { get :edit, :id => room.to_param }
36
- it { should respond_with(:success) }
37
- it { should assign_to(:room).with(room) }
38
- it { should render_template(:edit) }
66
+ context "basic" do
67
+ before(:each) { get :edit, :id => room.to_param }
68
+ it { should respond_with(:success) }
69
+ it { should assign_to(:room).with(room) }
70
+ it { should render_template(:edit) }
71
+ end
72
+
73
+ context "doesn't override @room" do
74
+ let!(:other_room) { FactoryGirl.create(:bigbluebutton_room) }
75
+ before { controller.instance_variable_set(:@room, other_room) }
76
+ before(:each) { get :edit, :id => room.to_param }
77
+ it { should assign_to(:room).with(other_room) }
78
+ end
39
79
  end
40
80
 
41
81
  describe "#join_mobile" do
@@ -87,6 +127,13 @@ describe Bigbluebutton::RoomsController do
87
127
  it("assigns join_desktop") { should assign_to(:join_desktop).with("http://test.com/join/url?desktop=1") }
88
128
  it { should render_template(:join_mobile) }
89
129
  end
130
+
131
+ context "doesn't override @room" do
132
+ let!(:other_room) { FactoryGirl.create(:bigbluebutton_room) }
133
+ before { controller.instance_variable_set(:@room, other_room) }
134
+ before(:each) { get :join_mobile, :id => room.to_param }
135
+ it { should assign_to(:room).with(other_room) }
136
+ end
90
137
  end
91
138
 
92
139
  describe "#create" do
@@ -105,7 +152,7 @@ describe Bigbluebutton::RoomsController do
105
152
  it { should set_the_flash.to(I18n.t('bigbluebutton_rails.rooms.notice.create.success')) }
106
153
  it {
107
154
  saved = BigbluebuttonRoom.last
108
- saved.should have_same_attributes_as(new_room)
155
+ saved.should have_same_attributes_as(new_room, params_to_ignore)
109
156
  }
110
157
  end
111
158
 
@@ -151,7 +198,7 @@ describe Bigbluebutton::RoomsController do
151
198
  it {
152
199
  saved = BigbluebuttonRoom.last
153
200
  new_room.meetingid = new_room.name
154
- saved.should have_same_attributes_as(new_room)
201
+ saved.should have_same_attributes_as(new_room, params_to_ignore)
155
202
  }
156
203
  end
157
204
 
@@ -159,10 +206,12 @@ describe Bigbluebutton::RoomsController do
159
206
  let(:attrs) { FactoryGirl.attributes_for(:bigbluebutton_room) }
160
207
  let(:params) { { :bigbluebutton_room => attrs } }
161
208
  let(:allowed_params) {
162
- [ :name, :server_id, :meetingid, :attendee_password, :moderator_password, :welcome_msg,
209
+ [ :name, :server_id, :meetingid, :attendee_key, :moderator_key, :welcome_msg,
163
210
  :private, :logout_url, :dial_number, :voice_bridge, :max_participants, :owner_id,
164
- :owner_type, :external, :param, :record, :duration, :default_layout, :presenter_share_only,
165
- :auto_start_video, :auto_start_audio, :metadata_attributes => [ :id, :name, :content, :_destroy, :owner_id ] ]
211
+ :owner_type, :external, :param, :record_meeting, :duration, :default_layout, :presenter_share_only,
212
+ :auto_start_video, :auto_start_audio, :background,
213
+ :moderator_only_message, :auto_start_recording, :allow_start_stop_recording,
214
+ :metadata_attributes => [ :id, :name, :content, :_destroy, :owner_id ] ]
166
215
  }
167
216
 
168
217
  it {
@@ -187,6 +236,13 @@ describe Bigbluebutton::RoomsController do
187
236
  should render_template(:new)
188
237
  }
189
238
  end
239
+
240
+ context "doesn't override @room" do
241
+ let!(:other_room) { FactoryGirl.create(:bigbluebutton_room) }
242
+ before { controller.instance_variable_set(:@room, other_room) }
243
+ before(:each) { post :create, :bigbluebutton_room => new_room.attributes }
244
+ it { should assign_to(:room).with(other_room) }
245
+ end
190
246
  end
191
247
 
192
248
  describe "#update" do
@@ -206,7 +262,7 @@ describe Bigbluebutton::RoomsController do
206
262
  }
207
263
  it {
208
264
  saved = BigbluebuttonRoom.find(@room)
209
- saved.should have_same_attributes_as(new_room)
265
+ saved.should have_same_attributes_as(new_room, params_to_ignore)
210
266
  }
211
267
  it { should set_the_flash.to(I18n.t('bigbluebutton_rails.rooms.notice.update.success')) }
212
268
  end
@@ -243,10 +299,12 @@ describe Bigbluebutton::RoomsController do
243
299
  let(:attrs) { FactoryGirl.attributes_for(:bigbluebutton_room) }
244
300
  let(:params) { { :bigbluebutton_room => attrs } }
245
301
  let(:allowed_params) {
246
- [ :name, :server_id, :meetingid, :attendee_password, :moderator_password, :welcome_msg,
302
+ [ :name, :server_id, :meetingid, :attendee_key, :moderator_key, :welcome_msg,
247
303
  :private, :logout_url, :dial_number, :voice_bridge, :max_participants, :owner_id,
248
- :owner_type, :external, :param, :record, :duration, :default_layout, :presenter_share_only,
249
- :auto_start_video, :auto_start_audio, :metadata_attributes => [ :id, :name, :content, :_destroy, :owner_id ] ]
304
+ :owner_type, :external, :param, :record_meeting, :duration, :default_layout, :presenter_share_only,
305
+ :auto_start_video, :auto_start_audio, :background,
306
+ :moderator_only_message, :auto_start_recording, :allow_start_stop_recording,
307
+ :metadata_attributes => [ :id, :name, :content, :_destroy, :owner_id ] ]
250
308
  }
251
309
  it {
252
310
  # we just check that the rails method 'permit' is being called on the hash with the
@@ -269,19 +327,25 @@ describe Bigbluebutton::RoomsController do
269
327
  should redirect_to(bigbluebutton_room_path(@room))
270
328
  }
271
329
  end
330
+
331
+ context "doesn't override @room" do
332
+ let!(:other_room) { FactoryGirl.create(:bigbluebutton_room) }
333
+ before { controller.instance_variable_set(:@room, other_room) }
334
+ before(:each) { put :update, :id => @room.to_param, :bigbluebutton_room => new_room.attributes }
335
+ it { should assign_to(:room).with(other_room) }
336
+ end
272
337
  end
273
338
 
274
339
  describe "#destroy" do
275
- before {
276
- controller.should_receive(:set_request_headers)
277
- mock_server_and_api
278
- # to make sure it calls end_meeting if the meeting is running
279
- mocked_api.should_receive(:is_meeting_running?).and_return(true)
280
- }
281
-
282
340
  context "on success" do
341
+ before {
342
+ controller.should_receive(:set_request_headers)
343
+ mock_server_and_api
344
+ # to make sure it calls end_meeting if the meeting is running
345
+ mocked_api.should_receive(:is_meeting_running?).and_return(true)
346
+ mocked_api.should_receive(:end_meeting).with(room.meetingid, room.moderator_api_password)
347
+ }
283
348
  before(:each) {
284
- mocked_api.should_receive(:end_meeting).with(room.meetingid, room.moderator_password)
285
349
  expect {
286
350
  delete :destroy, :id => room.to_param
287
351
  }.to change{ BigbluebuttonRoom.count }.by(-1)
@@ -294,6 +358,10 @@ describe Bigbluebutton::RoomsController do
294
358
  let(:bbb_error_msg) { SecureRandom.hex(250) }
295
359
  let(:bbb_error) { BigBlueButton::BigBlueButtonException.new(bbb_error_msg) }
296
360
  before {
361
+ controller.should_receive(:set_request_headers)
362
+ mock_server_and_api
363
+ # to make sure it calls end_meeting if the meeting is running
364
+ mocked_api.should_receive(:is_meeting_running?).and_return(true)
297
365
  mocked_api.should_receive(:end_meeting) { raise bbb_error }
298
366
  }
299
367
  before(:each) {
@@ -310,9 +378,15 @@ describe Bigbluebutton::RoomsController do
310
378
  end
311
379
 
312
380
  context "with :redir_url" do
381
+ before {
382
+ controller.should_receive(:set_request_headers)
383
+ mock_server_and_api
384
+ # to make sure it calls end_meeting if the meeting is running
385
+ mocked_api.should_receive(:is_meeting_running?).and_return(true)
386
+ mocked_api.should_receive(:end_meeting)
387
+ }
313
388
  before(:each) {
314
389
  expect {
315
- mocked_api.should_receive(:end_meeting)
316
390
  delete :destroy, :id => room.to_param, :redir_url => "/any"
317
391
  }.to change{ BigbluebuttonRoom.count }.by(-1)
318
392
  }
@@ -320,6 +394,12 @@ describe Bigbluebutton::RoomsController do
320
394
  it { should redirect_to "/any" }
321
395
  end
322
396
 
397
+ context "doesn't override @room" do
398
+ let!(:other_room) { FactoryGirl.create(:bigbluebutton_room) }
399
+ before { controller.instance_variable_set(:@room, other_room) }
400
+ before(:each) { delete :destroy, :id => room.to_param }
401
+ it { should assign_to(:room).with(other_room) }
402
+ end
323
403
  end
324
404
 
325
405
  describe "#running" do
@@ -352,8 +432,22 @@ describe Bigbluebutton::RoomsController do
352
432
  it { should respond_with(:success) }
353
433
  it { should set_the_flash.to(bbb_error_msg[0..200]) }
354
434
  end
355
- end
356
435
 
436
+ context "doesn't override @room" do
437
+ let!(:other_room) { FactoryGirl.create(:bigbluebutton_room) }
438
+ before {
439
+ controller.stub(:running)
440
+ controller.instance_variable_set(:@room, other_room)
441
+ }
442
+ before(:each) {
443
+ begin
444
+ get :running, :id => room.to_param
445
+ rescue ActionView::MissingTemplate
446
+ end
447
+ }
448
+ it { should assign_to(:room).with(other_room) }
449
+ end
450
+ end
357
451
 
358
452
  describe "#join" do
359
453
  let(:user) { FactoryGirl.build(:user) }
@@ -368,7 +462,7 @@ describe Bigbluebutton::RoomsController do
368
462
  context "via #{method}" do
369
463
 
370
464
  context "before filter #join_check_room" do
371
- let(:user_hash) { { :name => "Elftor", :password => room.attendee_password } }
465
+ let(:user_hash) { { :name => "Elftor", :key => room.attendee_key } }
372
466
  let(:meetingid) { "my-meeting-id" }
373
467
 
374
468
  context "if params[:id]" do
@@ -392,12 +486,24 @@ describe Bigbluebutton::RoomsController do
392
486
  it { should redirect_to(http_referer) }
393
487
  it { should set_the_flash.to(message) }
394
488
  end
489
+
490
+ context "doesn't override @room" do
491
+ let!(:other_room) { FactoryGirl.create(:bigbluebutton_room) }
492
+ before {
493
+ controller.instance_variable_set(:@room, other_room)
494
+ other_room.stub(:fetch_is_running?).and_return(true)
495
+ }
496
+ before(:each) {
497
+ send(method, :join, :id => room.to_param, :user => user_hash)
498
+ }
499
+ it { should assign_to(:room).with(other_room) }
500
+ end
395
501
  end
396
502
 
397
503
  context "before filter #join_user_params" do
398
504
 
399
505
  context "block access if bigbluebutton_role returns nil" do
400
- let(:hash) { { :name => "Elftor", :password => room.attendee_password } }
506
+ let(:hash) { { :name => "Elftor", :key => room.attendee_key } }
401
507
  before { controller.stub(:bigbluebutton_role) { nil } }
402
508
  it {
403
509
  lambda {
@@ -407,24 +513,24 @@ describe Bigbluebutton::RoomsController do
407
513
  end
408
514
 
409
515
  it "if there's a user logged, should use his name" do
410
- controller.stub(:bigbluebutton_role) { :password }
411
- hash = { :name => "Elftor", :password => room.attendee_password }
516
+ controller.stub(:bigbluebutton_role) { :key }
517
+ hash = { :name => "Elftor", :key => room.attendee_key }
412
518
  controller.stub(:bigbluebutton_user).and_return(user)
413
519
  mocked_api.should_receive(:is_meeting_running?).at_least(:once).and_return(true)
414
520
  mocked_api.should_receive(:join_meeting_url)
415
- .with(room.meetingid, user.name, room.attendee_password, anything) # here's the validation
521
+ .with(room.meetingid, user.name, room.attendee_api_password, anything) # here's the validation
416
522
  .and_return("http://test.com/attendee/join")
417
523
  send(method, :join, :id => room.to_param, :user => hash)
418
524
  end
419
525
 
420
- context "uses bigbluebutton_role when the return is not :password" do
421
- let(:hash) { { :name => "Elftor", :password => nil } }
526
+ context "uses bigbluebutton_role when the return is not :key" do
527
+ let(:hash) { { :name => "Elftor", :key => nil } }
422
528
  before {
423
529
  controller.stub(:bigbluebutton_user).and_return(nil)
424
530
  controller.stub(:bigbluebutton_role) { :attendee }
425
531
  mocked_api.should_receive(:is_meeting_running?).at_least(:once).and_return(true)
426
532
  mocked_api.should_receive(:join_meeting_url)
427
- .with(anything, anything, room.attendee_password, anything)
533
+ .with(anything, anything, room.attendee_api_password, anything)
428
534
  .and_return("http://test.com/attendee/join")
429
535
  }
430
536
  before(:each) { send(method, :join, :id => room.to_param, :user => hash) }
@@ -438,12 +544,12 @@ describe Bigbluebutton::RoomsController do
438
544
  context "validates user input and shows error" do
439
545
  before {
440
546
  controller.stub(:bigbluebutton_user).and_return(nil)
441
- controller.should_receive(:bigbluebutton_role).once { :password }
547
+ controller.should_receive(:bigbluebutton_role).once { :key }
442
548
  }
443
549
  before(:each) { send(method, :join, :id => room.to_param, :user => user_hash) }
444
550
 
445
551
  context "when name is not set" do
446
- let(:user_hash) { { :password => room.moderator_password } }
552
+ let(:user_hash) { { :key => room.moderator_key } }
447
553
  it { should respond_with(:redirect) }
448
554
  it { should redirect_to(http_referer) }
449
555
  it { should assign_to(:room).with(room) }
@@ -454,7 +560,7 @@ describe Bigbluebutton::RoomsController do
454
560
  end
455
561
 
456
562
  context "when name is set but empty" do
457
- let(:user_hash) { { :password => room.moderator_password, :name => "" } }
563
+ let(:user_hash) { { :key => room.moderator_key, :name => "" } }
458
564
  it { should respond_with(:redirect) }
459
565
  it { should redirect_to(http_referer) }
460
566
  it { should assign_to(:room).with(room) }
@@ -464,8 +570,8 @@ describe Bigbluebutton::RoomsController do
464
570
  it { should set_the_flash.to(I18n.t('bigbluebutton_rails.rooms.errors.join.failure')) }
465
571
  end
466
572
 
467
- context "when the password is wrong" do
468
- let(:user_hash) { { :name => "Elftor", :password => nil } }
573
+ context "when the key is wrong" do
574
+ let(:user_hash) { { :name => "Elftor", :key => nil } }
469
575
  it { should respond_with(:redirect) }
470
576
  it { should redirect_to(http_referer) }
471
577
  it { should assign_to(:user_role).with(nil) }
@@ -479,7 +585,7 @@ describe Bigbluebutton::RoomsController do
479
585
  end
480
586
 
481
587
  context "before filter #join_check_can_create" do
482
- let(:user_hash) { { :password => room.moderator_password, :name => "Elftor" } }
588
+ let(:user_hash) { { :key => room.moderator_key, :name => "Elftor" } }
483
589
  before {
484
590
  controller.stub(:bigbluebutton_user).and_return(nil)
485
591
  controller.should_receive(:bigbluebutton_role).once { :moderator }
@@ -507,9 +613,8 @@ describe Bigbluebutton::RoomsController do
507
613
  context "in a mobile device with no flags set" do
508
614
  before {
509
615
  controller.stub(:bigbluebutton_role) { :moderator }
510
- browser = double()
511
- browser.should_receive(:mobile?).and_return(true)
512
- controller.stub(:browser).and_return(browser)
616
+ controller.stub(:browser).and_return('my-browser')
617
+ BigbluebuttonRails.should_receive(:use_mobile_client?).with('my-browser').and_return(true)
513
618
  }
514
619
 
515
620
  context "with no parameters in the url" do
@@ -536,11 +641,8 @@ describe Bigbluebutton::RoomsController do
536
641
  before {
537
642
  controller.stub(:bigbluebutton_user) { user }
538
643
  controller.stub(:bigbluebutton_role) { :moderator }
539
-
540
- # make sure it's in a mobile device
541
- browser = double()
542
- browser.should_receive(:mobile?).and_return(true)
543
- controller.stub(:browser).and_return(browser)
644
+ controller.stub(:browser).and_return('my-browser')
645
+ BigbluebuttonRails.should_receive(:use_mobile_client?).with('my-browser').and_return(true)
544
646
 
545
647
  # here's the real verification
546
648
  controller.should_receive(:join_internal).with(user.name, :moderator, user.id)
@@ -552,11 +654,8 @@ describe Bigbluebutton::RoomsController do
552
654
  before {
553
655
  controller.stub(:bigbluebutton_user) { user }
554
656
  controller.stub(:bigbluebutton_role) { :moderator }
555
-
556
- # make sure it's in a mobile device
557
- browser = double()
558
- browser.should_receive(:mobile?).and_return(true)
559
- controller.stub(:browser).and_return(browser)
657
+ controller.stub(:browser).and_return('my-browser')
658
+ BigbluebuttonRails.should_receive(:use_mobile_client?).with('my-browser').and_return(true)
560
659
 
561
660
  # here's the real verification
562
661
  controller.should_receive(:join_internal).with(user.name, :moderator, user.id)
@@ -593,7 +692,7 @@ describe Bigbluebutton::RoomsController do
593
692
  context "room is running" do
594
693
  before {
595
694
  mocked_api.should_receive(:is_meeting_running?).and_return(true)
596
- mocked_api.should_receive(:end_meeting).with(room.meetingid, room.moderator_password)
695
+ mocked_api.should_receive(:end_meeting).with(room.meetingid, room.moderator_api_password)
597
696
  }
598
697
  before(:each) { get :end, :id => room.to_param }
599
698
  it { should respond_with(:redirect) }
@@ -606,7 +705,7 @@ describe Bigbluebutton::RoomsController do
606
705
  context "with :redir_url" do
607
706
  before {
608
707
  mocked_api.should_receive(:is_meeting_running?).and_return(true)
609
- mocked_api.should_receive(:end_meeting).with(room.meetingid, room.moderator_password)
708
+ mocked_api.should_receive(:end_meeting).with(room.meetingid, room.moderator_api_password)
610
709
  }
611
710
  before(:each) { get :end, :id => room.to_param, :redir_url => '/any' }
612
711
  it { should respond_with(:redirect) }
@@ -631,6 +730,16 @@ describe Bigbluebutton::RoomsController do
631
730
  it { should respond_with(:redirect) }
632
731
  it { should set_the_flash.to(bbb_error_msg[0..200]) }
633
732
  end
733
+
734
+ context "doesn't override @room" do
735
+ let!(:other_room) { FactoryGirl.create(:bigbluebutton_room) }
736
+ before {
737
+ controller.instance_variable_set(:@room, other_room)
738
+ other_room.stub(:fetch_is_running?).and_return(true)
739
+ }
740
+ before(:each) { get :end, :id => room.to_param }
741
+ it { should assign_to(:room).with(other_room) }
742
+ end
634
743
  end
635
744
 
636
745
  describe "#invite" do
@@ -648,13 +757,13 @@ describe Bigbluebutton::RoomsController do
648
757
  end
649
758
 
650
759
  context "when the user's role" do
651
- context "should be defined with a password" do
652
- before { controller.stub(:bigbluebutton_role) { :password } }
760
+ context "should be defined with a key" do
761
+ before { controller.stub(:bigbluebutton_role) { :key } }
653
762
  before(:each) { get :invite, :id => room.to_param }
654
763
  it { should respond_with(:success) }
655
764
  it { should render_template(:invite) }
656
765
  it { should assign_to(:room).with(room) }
657
- it { should assign_to(:user_role).with(:password) }
766
+ it { should assign_to(:user_role).with(:key) }
658
767
  end
659
768
 
660
769
  context "is undefined, the access should be blocked" do
@@ -666,12 +775,18 @@ describe Bigbluebutton::RoomsController do
666
775
  }
667
776
  end
668
777
  end
778
+
779
+ context "doesn't override @room" do
780
+ let!(:other_room) { FactoryGirl.create(:bigbluebutton_room) }
781
+ before { controller.instance_variable_set(:@room, other_room) }
782
+ before(:each) { get :invite, :id => room.to_param }
783
+ it { should assign_to(:room).with(other_room) }
784
+ end
669
785
  end
670
786
 
671
787
  describe "#fetch_recordings" do
672
788
  # setup basic server and API mocks
673
789
  before do
674
- #controller.should_receive(:set_request_headers)
675
790
  mock_server_and_api
676
791
  end
677
792
  let(:filter) {
@@ -729,6 +844,15 @@ describe Bigbluebutton::RoomsController do
729
844
  end
730
845
  end
731
846
 
847
+ context "doesn't override @room" do
848
+ let!(:other_room) { FactoryGirl.create(:bigbluebutton_room) }
849
+ before {
850
+ controller.instance_variable_set(:@room, other_room)
851
+ other_room.server = nil
852
+ }
853
+ before(:each) { post :fetch_recordings, :id => room.to_param }
854
+ it { should assign_to(:room).with(other_room) }
855
+ end
732
856
  end
733
857
 
734
858
  describe "#recordings" do
@@ -747,6 +871,51 @@ describe Bigbluebutton::RoomsController do
747
871
  it { should assign_to(:recordings).with([@recording1, @recording2]) }
748
872
  end
749
873
 
874
+ describe "#generate_dial_number" do
875
+ let(:http_referer) { bigbluebutton_room_path(room) }
876
+ before {
877
+ request.env["HTTP_REFERER"] = http_referer
878
+ }
879
+
880
+ context "on success" do
881
+ before(:each) {
882
+ BigbluebuttonRoom.any_instance.stub(:generate_dial_number!).and_return(true)
883
+ post :generate_dial_number, id: room.to_param
884
+ }
885
+ it { should respond_with(:redirect) }
886
+ it { should redirect_to(http_referer) }
887
+ it { should set_the_flash.to(I18n.t('bigbluebutton_rails.rooms.notice.generate_dial_number.success')) }
888
+ end
889
+
890
+ context "on error" do
891
+ before(:each) {
892
+ BigbluebuttonRoom.any_instance.stub(:generate_dial_number!).and_return(nil)
893
+ post :generate_dial_number, id: room.to_param
894
+ }
895
+ it { should respond_with(:redirect) }
896
+ it { should redirect_to(http_referer) }
897
+ it { should set_the_flash.to(I18n.t('bigbluebutton_rails.rooms.errors.generate_dial_number.not_unique')) }
898
+ end
899
+
900
+ context "uses params[:pattern]" do
901
+ before(:each) {
902
+ BigbluebuttonRoom.any_instance.stub(:generate_dial_number!).with("xxx-xxx").and_return(true)
903
+ post :generate_dial_number, id: room.to_param, pattern: "xxx-xxx"
904
+ }
905
+ it { should respond_with(:redirect) }
906
+ it { should redirect_to(http_referer) }
907
+ end
908
+
909
+ context "doesn't use params[:pattern] if it's blank" do
910
+ before(:each) {
911
+ BigbluebuttonRoom.any_instance.stub(:generate_dial_number!).with(nil).and_return(true)
912
+ post :generate_dial_number, id: room.to_param, pattern: ""
913
+ }
914
+ it { should respond_with(:redirect) }
915
+ it { should redirect_to(http_referer) }
916
+ end
917
+ end
918
+
750
919
  describe "before filter :set_request_headers" do
751
920
  let(:headers) { {"x-forwarded-for" => "0.0.0.0"} }
752
921
  let(:make_request) { }
@@ -771,6 +940,26 @@ describe Bigbluebutton::RoomsController do
771
940
  room.request_headers.should == headers
772
941
  }
773
942
  end
943
+
944
+ context "doesn't override @room" do
945
+ let!(:other_room) { FactoryGirl.create(:bigbluebutton_room) }
946
+ before { controller.instance_variable_set(:@room, other_room) }
947
+ before(:each) { get :recordings, :id => room.to_param }
948
+ it { should assign_to(:room).with(other_room) }
949
+ end
950
+
951
+ context "doesn't override @recordings" do
952
+ let!(:my_recordings) {
953
+ [ FactoryGirl.create(:bigbluebutton_recording, room: room),
954
+ FactoryGirl.create(:bigbluebutton_recording, room: room) ]
955
+ }
956
+ before {
957
+ 3.times { FactoryGirl.create(:bigbluebutton_recording, room: room) }
958
+ controller.instance_variable_set(:@recordings, my_recordings)
959
+ }
960
+ before(:each) { get :recordings, :id => room.to_param }
961
+ it { should assign_to(:recordings).with(my_recordings) }
962
+ end
774
963
  end
775
964
 
776
965
  # Test #join_internal using #join because it's easier and cleaner than the other
@@ -796,11 +985,11 @@ describe Bigbluebutton::RoomsController do
796
985
  room.should_receive(:create_meeting)
797
986
  .with(user, controller.request, { custom: true })
798
987
  room.should_receive(:fetch_new_token).and_return(nil)
799
- room.should_receive(:join_url).and_return("http://test.com/join/url")
988
+ room.should_receive(:join_url).and_return("http://test.com/join/url/")
800
989
  }
801
990
  before(:each) { get :join, :id => room.to_param }
802
991
  it { should respond_with(:redirect) }
803
- it { should redirect_to("http://test.com/join/url") }
992
+ it { should redirect_to("http://test.com/join/url/") }
804
993
  end
805
994
 
806
995
  context "when the user doesn't have permission to create the meeting" do
@@ -856,7 +1045,7 @@ describe Bigbluebutton::RoomsController do
856
1045
  room.should_receive(:fetch_new_token).and_return('fake-token')
857
1046
  room.should_receive(:join_url)
858
1047
  .with(user.name, :attendee, nil, hash_including(:configToken => 'fake-token'))
859
- .and_return("http://test.com/join/url")
1048
+ .and_return("http://test.com/join/url/")
860
1049
  }
861
1050
  it("uses the token") { get :join, :id => room.to_param }
862
1051
  end
@@ -865,13 +1054,87 @@ describe Bigbluebutton::RoomsController do
865
1054
  before(:each) {
866
1055
  room.should_receive(:fetch_new_token).and_return(nil)
867
1056
  room.should_receive(:join_url)
868
- .with(user.name, :attendee, nil, {})
869
- .and_return("http://test.com/join/url")
1057
+ .with(user.name, :attendee, nil, hash_not_including(:configToken))
1058
+ .and_return("http://test.com/join/url/")
870
1059
  }
871
1060
  it("does not use the token") { get :join, :id => room.to_param }
872
1061
  end
873
1062
  end
874
1063
 
1064
+ context "pass createTime parameter to join_url" do
1065
+ let(:time) { DateTime.now }
1066
+ before {
1067
+ room.should_receive(:fetch_is_running?).at_least(:once).and_return(true)
1068
+ room.should_not_receive(:create_meeting)
1069
+ }
1070
+
1071
+ context "if the createTime is not blank" do
1072
+ before(:each) {
1073
+ room.stub(:create_time).and_return(time)
1074
+ room.should_receive(:fetch_new_token).and_return(anything)
1075
+ room.should_receive(:join_url)
1076
+ .with(user.name, :attendee, nil, hash_including(:createTime => time))
1077
+ }
1078
+ it ("uses the createTime") { get :join, :id => room.to_param }
1079
+ end
1080
+
1081
+ context "if the createTime is blank" do
1082
+ before(:each) {
1083
+ room.stub(:create_time).and_return("")
1084
+ room.should_receive(:fetch_new_token).and_return(anything)
1085
+ room.should_receive(:join_url)
1086
+ .with(user.name, :attendee, nil, hash_not_including(:createTime))
1087
+ }
1088
+ it ("does not use the createTime") { get :join, :id => room.to_param }
1089
+ end
1090
+
1091
+ context "if the createTime is nil" do
1092
+ before(:each) {
1093
+ room.stub(:create_time).and_return(nil)
1094
+ room.should_receive(:fetch_new_token).and_return(anything)
1095
+ room.should_receive(:join_url)
1096
+ .with(user.name, :attendee, nil, hash_not_including(:createTime))
1097
+ }
1098
+ it ("does not use the createTime") { get :join, :id => room.to_param }
1099
+ end
1100
+ end
1101
+
1102
+ context "pass userID to join url" do
1103
+ before {
1104
+ room.should_receive(:fetch_is_running?).at_least(:once).and_return(true)
1105
+ room.should_not_receive(:create_meeting)
1106
+ }
1107
+
1108
+ context "userID is nil" do
1109
+ before(:each) {
1110
+ user.id = nil
1111
+ room.should_receive(:fetch_new_token).and_return(anything)
1112
+ room.should_receive(:join_url)
1113
+ .with(user.name, :attendee, nil, hash_not_including(:userID))
1114
+ }
1115
+ it("does not use the userID") { get :join, :id => room.to_param }
1116
+ end
1117
+
1118
+ context "userID is blank" do
1119
+ before(:each) {
1120
+ user.id = ""
1121
+ room.should_receive(:fetch_new_token).and_return(anything)
1122
+ room.should_receive(:join_url)
1123
+ .with(user.name, :attendee, nil, hash_not_including(:userID))
1124
+ }
1125
+ it("does not use the userID") { get :join, :id => room.to_param }
1126
+ end
1127
+
1128
+ context "userID is not blank" do
1129
+ before(:each) {
1130
+ room.should_receive(:fetch_new_token).and_return(anything)
1131
+ room.should_receive(:join_url)
1132
+ .with(user.name, :attendee, nil, hash_including(:userID => user.id))
1133
+ }
1134
+ it("uses the userID") { get :join, :id => room.to_param }
1135
+ end
1136
+ end
1137
+
875
1138
  context "when the user doesn't have permission to join the meeting" do
876
1139
  before {
877
1140
  room.should_receive(:fetch_is_running?).at_least(:once).and_return(true)
@@ -892,9 +1155,7 @@ describe Bigbluebutton::RoomsController do
892
1155
  room.should_receive(:fetch_is_running?).at_least(:once).and_return(true)
893
1156
  room.should_not_receive(:create_meeting)
894
1157
  room.should_receive(:fetch_new_token).and_return(nil)
895
- browser = double()
896
- browser.should_receive(:mobile?).twice.and_return(true)
897
- controller.stub(:browser).and_return(browser)
1158
+ BigbluebuttonRails.stub(:use_mobile_client?).and_return(true)
898
1159
  }
899
1160
 
900
1161
  context "and the url uses 'http'" do