bigbluebutton_rails 0.1.1 → 1.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 (55) hide show
  1. data/CHANGELOG.rdoc +1 -12
  2. data/Gemfile.lock +1 -1
  3. data/README.rdoc +32 -46
  4. data/Rakefile +1 -0
  5. data/app/controllers/bigbluebutton/rooms_controller.rb +16 -17
  6. data/app/controllers/bigbluebutton/servers_controller.rb +2 -6
  7. data/app/models/bigbluebutton_room.rb +1 -35
  8. data/app/models/bigbluebutton_server.rb +1 -1
  9. data/app/views/bigbluebutton/rooms/_form.html.erb +3 -7
  10. data/app/views/bigbluebutton/rooms/edit.html.erb +2 -2
  11. data/app/views/bigbluebutton/rooms/external.html.erb +1 -2
  12. data/app/views/bigbluebutton/rooms/index.html.erb +37 -2
  13. data/app/views/bigbluebutton/rooms/invite.html.erb +2 -2
  14. data/app/views/bigbluebutton/rooms/join.html.erb +1 -1
  15. data/app/views/bigbluebutton/rooms/new.html.erb +1 -1
  16. data/app/views/bigbluebutton/rooms/show.html.erb +4 -10
  17. data/app/views/bigbluebutton/servers/_activity_list.html.erb +6 -6
  18. data/app/views/bigbluebutton/servers/index.html.erb +3 -4
  19. data/app/views/bigbluebutton/servers/show.html.erb +4 -3
  20. data/config/locales/en.yml +3 -7
  21. data/lib/bigbluebutton_rails/exceptions.rb +0 -4
  22. data/lib/bigbluebutton_rails/rails/routes.rb +35 -28
  23. data/lib/bigbluebutton_rails/version.rb +1 -1
  24. data/spec/controllers/bigbluebutton/rooms_controller_exception_handling_spec.rb +10 -13
  25. data/spec/controllers/bigbluebutton/rooms_controller_json_responses_spec.rb +13 -13
  26. data/spec/controllers/bigbluebutton/rooms_controller_spec.rb +115 -114
  27. data/spec/controllers/bigbluebutton/servers_controller_json_responses_spec.rb +1 -12
  28. data/spec/controllers/bigbluebutton/servers_controller_spec.rb +0 -11
  29. data/spec/generators/install_generator_spec.rb +1 -1
  30. data/spec/models/bigbluebutton_room_spec.rb +80 -166
  31. data/spec/models/bigbluebutton_server_spec.rb +4 -4
  32. data/spec/rails_app/features/activity_monitor_servers.feature +0 -6
  33. data/spec/rails_app/features/create_rooms.feature +0 -5
  34. data/spec/rails_app/features/create_servers.feature +2 -7
  35. data/spec/rails_app/features/edit_rooms.feature +0 -7
  36. data/spec/rails_app/features/edit_servers.feature +2 -8
  37. data/spec/rails_app/features/join_rooms.feature +0 -1
  38. data/spec/rails_app/features/list_and_show_rooms.feature +2 -10
  39. data/spec/rails_app/features/step_definitions/activity_monitor_servers_step.rb +10 -10
  40. data/spec/rails_app/features/step_definitions/common_steps.rb +4 -6
  41. data/spec/rails_app/features/step_definitions/create_rooms_steps.rb +0 -1
  42. data/spec/rails_app/features/step_definitions/join_mobile_steps.rb +3 -1
  43. data/spec/rails_app/features/step_definitions/join_rooms_steps.rb +7 -3
  44. data/spec/rails_app/features/step_definitions/list_and_show_rooms_steps.rb +5 -12
  45. data/spec/rails_app/features/step_definitions/list_and_show_servers_steps.rb +5 -1
  46. data/spec/rails_app/features/support/{patches/application_controller.rb → application_controller.rb} +0 -0
  47. data/spec/rails_app/features/support/paths.rb +10 -12
  48. data/spec/rails_app/features/support/templates.rb +46 -90
  49. data/spec/routing/bigbluebutton/custom_controllers_routing_spec.rb +22 -38
  50. data/spec/routing/bigbluebutton/rooms_routing_spec.rb +58 -142
  51. data/spec/routing/bigbluebutton/servers_routing_spec.rb +1 -9
  52. metadata +9 -12
  53. data/app/views/bigbluebutton/rooms/_rooms.html.erb +0 -37
  54. data/app/views/bigbluebutton/servers/rooms.html.erb +0 -2
  55. data/spec/rails_app/features/support/patches/bigbluebutton_room.rb +0 -9
@@ -10,48 +10,55 @@ describe Bigbluebutton::RoomsController do
10
10
  let(:room) { Factory.create(:bigbluebutton_room, :server => server) }
11
11
 
12
12
  describe "#index" do
13
- before(:each) { get :index }
13
+ before(:each) { get :index, :server_id => server.to_param }
14
14
  it { should respond_with(:success) }
15
+ it { should assign_to(:server).with(server) }
15
16
  it { should assign_to(:rooms).with(BigbluebuttonRoom.all) }
16
17
  it { should render_template(:index) }
17
18
  end
18
19
 
19
20
  describe "#show" do
20
- before(:each) { get :show, :id => room.to_param }
21
+ before(:each) { get :show, :server_id => server.to_param, :id => room.to_param }
21
22
  it { should respond_with(:success) }
23
+ it { should assign_to(:server).with(server) }
22
24
  it { should assign_to(:room).with(room) }
23
25
  it { should render_template(:show) }
24
26
  end
25
27
 
26
28
  describe "#new" do
27
- before(:each) { get :new }
29
+ before(:each) { get :new, :server_id => server.to_param }
28
30
  it { should respond_with(:success) }
31
+ it { should assign_to(:server).with(server) }
29
32
  it { should assign_to(:room).with_kind_of(BigbluebuttonRoom) }
30
33
  it { should render_template(:new) }
31
34
  end
32
35
 
33
36
  describe "#edit" do
34
- before(:each) { get :edit, :id => room.to_param }
37
+ before(:each) { get :edit, :server_id => server.to_param, :id => room.to_param }
35
38
  it { should respond_with(:success) }
39
+ it { should assign_to(:server).with(server) }
36
40
  it { should assign_to(:room).with(room) }
37
41
  it { should render_template(:edit) }
38
42
  end
39
43
 
40
44
  describe "#join_mobile" do
41
45
  let(:user) { Factory.build(:user) }
42
- let(:room) { Factory.create(:bigbluebutton_room) }
46
+ let(:server) { Factory.create(:bigbluebutton_server) }
47
+ let(:room) { Factory.create(:bigbluebutton_room, :server => server) }
43
48
  before {
44
49
  mock_server_and_api
45
- room.server = mocked_server
46
50
  controller.stub(:bigbluebutton_user) { user }
47
51
  controller.should_receive(:bigbluebutton_role).and_return(:moderator)
48
- controller.should_receive(:join_bigbluebutton_room_url).with(room, :mobile => '1').
52
+ controller.should_receive(:join_bigbluebutton_server_room_url).
53
+ with(mocked_server, room, :mobile => '1').
49
54
  and_return("http://test.com/join/url?mobile=1")
50
- mocked_api.should_receive(:join_meeting_url).with(room.meetingid, user.name, room.moderator_password).
55
+ mocked_api.should_receive(:join_meeting_url).
56
+ with(room.meetingid, user.name, room.moderator_password).
51
57
  and_return("bigbluebutton://test.com/open/url/for/qrcode")
52
58
  }
53
- before(:each) { get :join_mobile, :id => room.to_param }
59
+ before(:each) { get :join_mobile, :server_id => mocked_server.to_param, :id => room.to_param }
54
60
  it { should respond_with(:success) }
61
+ it { should assign_to(:server).with(mocked_server) }
55
62
  it { should assign_to(:room).with(room) }
56
63
  it { should assign_to(:join_url).with("bigbluebutton://test.com/join/url?mobile=1") }
57
64
  it { should assign_to(:qrcode_url).with("bigbluebutton://test.com/open/url/for/qrcode") }
@@ -64,14 +71,15 @@ describe Bigbluebutton::RoomsController do
64
71
  context "on success" do
65
72
  before :each do
66
73
  expect {
67
- post :create, :bigbluebutton_room => new_room.attributes
74
+ post :create, :server_id => server.to_param, :bigbluebutton_room => new_room.attributes
68
75
  }.to change{ BigbluebuttonRoom.count }.by(1)
69
76
  end
70
77
  it {
71
78
  should respond_with(:redirect)
72
- should redirect_to bigbluebutton_room_path(BigbluebuttonRoom.last)
79
+ should redirect_to bigbluebutton_server_room_path(server, BigbluebuttonRoom.last)
73
80
  }
74
81
  it { should set_the_flash.to(I18n.t('bigbluebutton_rails.rooms.notice.create.success')) }
82
+ it { should assign_to(:server).with(server) }
75
83
  it {
76
84
  saved = BigbluebuttonRoom.last
77
85
  saved.should have_same_attributes_as(new_room)
@@ -82,16 +90,18 @@ describe Bigbluebutton::RoomsController do
82
90
  before :each do
83
91
  new_room.name = nil # invalid
84
92
  expect {
85
- post :create, :bigbluebutton_room => new_room.attributes
93
+ post :create, :server_id => server.to_param, :bigbluebutton_room => new_room.attributes
86
94
  }.not_to change{ BigbluebuttonRoom.count }
87
95
  end
88
96
  it { should render_template(:new) }
97
+ it { should assign_to(:server).with(server) }
89
98
  end
90
99
 
91
100
  context "with :redir_url" do
92
101
  it "on success" do
93
102
  expect {
94
- post :create, :bigbluebutton_room => new_room.attributes, :redir_url => bigbluebutton_servers_path
103
+ post :create, :server_id => server.to_param, :bigbluebutton_room => new_room.attributes,
104
+ :redir_url => bigbluebutton_servers_path
95
105
  }.to change{ BigbluebuttonRoom.count }.by(1)
96
106
  should respond_with(:redirect)
97
107
  should redirect_to bigbluebutton_servers_path
@@ -99,7 +109,8 @@ describe Bigbluebutton::RoomsController do
99
109
  it "on failure" do
100
110
  new_room.name = nil # invalid
101
111
  expect {
102
- post :create, :bigbluebutton_room => new_room.attributes, :redir_url => bigbluebutton_servers_path
112
+ post :create, :server_id => server.to_param, :bigbluebutton_room => new_room.attributes,
113
+ :redir_url => bigbluebutton_servers_path
103
114
  }.not_to change{ BigbluebuttonRoom.count }
104
115
  should respond_with(:redirect)
105
116
  should redirect_to bigbluebutton_servers_path
@@ -110,7 +121,7 @@ describe Bigbluebutton::RoomsController do
110
121
  before :each do
111
122
  attr = new_room.attributes
112
123
  attr.delete("meetingid")
113
- post :create, :bigbluebutton_room => attr
124
+ post :create, :server_id => server.to_param, :bigbluebutton_room => attr
114
125
  end
115
126
  it {
116
127
  saved = BigbluebuttonRoom.last
@@ -127,40 +138,42 @@ describe Bigbluebutton::RoomsController do
127
138
  context "on success" do
128
139
  before :each do
129
140
  expect {
130
- put :update, :id => @room.to_param, :bigbluebutton_room => new_room.attributes
141
+ put :update, :server_id => server.to_param, :id => @room.to_param, :bigbluebutton_room => new_room.attributes
131
142
  }.not_to change{ BigbluebuttonRoom.count }
132
143
  end
133
144
  it {
134
145
  saved = BigbluebuttonRoom.find(@room)
135
146
  should respond_with(:redirect)
136
- should redirect_to bigbluebutton_room_path(saved)
147
+ should redirect_to bigbluebutton_server_room_path(server, saved)
137
148
  }
138
149
  it {
139
150
  saved = BigbluebuttonRoom.find(@room)
140
151
  saved.should have_same_attributes_as(new_room)
141
152
  }
142
153
  it { should set_the_flash.to(I18n.t('bigbluebutton_rails.rooms.notice.update.success')) }
154
+ it { should assign_to(:server).with(server) }
143
155
  end
144
156
 
145
157
  context "on failure" do
146
158
  before :each do
147
159
  new_room.name = nil # invalid
148
- put :update, :id => @room.to_param, :bigbluebutton_room => new_room.attributes
160
+ put :update, :server_id => server.to_param, :id => @room.to_param, :bigbluebutton_room => new_room.attributes
149
161
  end
150
162
  it { should render_template(:edit) }
163
+ it { should assign_to(:server).with(server) }
151
164
  it { should assign_to(:room).with(@room) }
152
165
  end
153
166
 
154
167
  context "with :redir_url" do
155
168
  it "on success" do
156
- put :update, :id => @room.to_param, :bigbluebutton_room => new_room.attributes,
169
+ put :update, :server_id => server.to_param, :id => @room.to_param, :bigbluebutton_room => new_room.attributes,
157
170
  :redir_url => bigbluebutton_servers_path
158
171
  should respond_with(:redirect)
159
172
  should redirect_to bigbluebutton_servers_path
160
173
  end
161
174
  it "on failure" do
162
175
  new_room.name = nil # invalid
163
- put :update, :id => @room.to_param, :bigbluebutton_room => new_room.attributes,
176
+ put :update, :server_id => server.to_param, :id => @room.to_param, :bigbluebutton_room => new_room.attributes,
164
177
  :redir_url => bigbluebutton_servers_path
165
178
  should respond_with(:redirect)
166
179
  should redirect_to bigbluebutton_servers_path
@@ -171,7 +184,7 @@ describe Bigbluebutton::RoomsController do
171
184
  before :each do
172
185
  attr = new_room.attributes
173
186
  attr.delete("meetingid")
174
- put :update, :id => @room.to_param, :bigbluebutton_room => attr
187
+ put :update, :server_id => server.to_param, :id => @room.to_param, :bigbluebutton_room => attr
175
188
  end
176
189
  it {
177
190
  saved = BigbluebuttonRoom.find(@room)
@@ -193,18 +206,20 @@ describe Bigbluebutton::RoomsController do
193
206
  context do
194
207
  before :each do
195
208
  expect {
196
- delete :destroy, :id => room.to_param
209
+ delete :destroy, :server_id => mocked_server.to_param, :id => room.to_param
197
210
  }.to change{ BigbluebuttonRoom.count }.by(-1)
198
211
  end
199
212
  it {
200
213
  should respond_with(:redirect)
201
- should redirect_to bigbluebutton_rooms_url
214
+ should redirect_to bigbluebutton_server_rooms_url
202
215
  }
216
+ it { should assign_to(:server).with(mocked_server) }
203
217
  end
204
218
 
205
219
  it "with :redir_url" do
206
220
  expect {
207
- delete :destroy, :id => room.to_param, :redir_url => bigbluebutton_servers_path
221
+ delete :destroy, :server_id => mocked_server.to_param, :id => room.to_param,
222
+ :redir_url => bigbluebutton_servers_path
208
223
  }.to change{ BigbluebuttonRoom.count }.by(-1)
209
224
  should respond_with(:redirect)
210
225
  should redirect_to bigbluebutton_servers_path
@@ -218,16 +233,17 @@ describe Bigbluebutton::RoomsController do
218
233
 
219
234
  context "room is running" do
220
235
  before { mocked_api.should_receive(:is_meeting_running?).and_return(true) }
221
- before(:each) { get :running, :id => room.to_param }
236
+ before(:each) { get :running, :server_id => mocked_server.to_param, :id => room.to_param }
222
237
  it { should respond_with(:success) }
223
238
  it { should respond_with_content_type(:json) }
239
+ it { should assign_to(:server).with(mocked_server) }
224
240
  it { should assign_to(:room).with(room) }
225
241
  it { response.body.should == build_running_json(true) }
226
242
  end
227
243
 
228
244
  context "room is not running" do
229
245
  before { mocked_api.should_receive(:is_meeting_running?).and_return(false) }
230
- before(:each) { get :running, :id => room.to_param }
246
+ before(:each) { get :running, :server_id => mocked_server.to_param, :id => room.to_param }
231
247
  it { response.body.should == build_running_json(false) }
232
248
  end
233
249
  end
@@ -239,10 +255,10 @@ describe Bigbluebutton::RoomsController do
239
255
  context "for an anonymous user" do
240
256
  before { controller.stub(:bigbluebutton_user) { nil } }
241
257
  before { controller.stub(:bigbluebutton_role) { :moderator } }
242
- before(:each) { get :join, :id => room.to_param }
258
+ before(:each) { get :join, :server_id => mocked_server.to_param, :id => room.to_param }
243
259
  it {
244
260
  should respond_with(:redirect)
245
- should redirect_to(invite_bigbluebutton_room_path(room))
261
+ should redirect_to(invite_bigbluebutton_server_room_path(mocked_server, room))
246
262
  }
247
263
  end
248
264
 
@@ -251,16 +267,16 @@ describe Bigbluebutton::RoomsController do
251
267
 
252
268
  context "should be defined with a password" do
253
269
  before { controller.stub(:bigbluebutton_role) { :password } }
254
- before(:each) { get :join, :id => room.to_param }
270
+ before(:each) { get :join, :server_id => mocked_server.to_param, :id => room.to_param }
255
271
  it { should respond_with(:redirect) }
256
- it { should redirect_to(invite_bigbluebutton_room_path(room)) }
272
+ it { should redirect_to(invite_bigbluebutton_server_room_path(mocked_server, room)) }
257
273
  end
258
274
 
259
275
  context "is undefined, the access should be blocked" do
260
276
  before { controller.stub(:bigbluebutton_role) { nil } }
261
277
  it {
262
278
  lambda {
263
- get :join, :id => room.to_param
279
+ get :join, :server_id => mocked_server.to_param, :id => room.to_param
264
280
  }.should raise_error(BigbluebuttonRails::RoomAccessDenied)
265
281
  }
266
282
  end
@@ -270,7 +286,7 @@ describe Bigbluebutton::RoomsController do
270
286
  # see support/shared_examples/rooms_controller.rb
271
287
  context "calling .join_internal" do
272
288
  let(:template) { :join }
273
- let(:request) { get :join, :id => room.to_param }
289
+ let(:request) { get :join, :server_id => mocked_server.to_param, :id => room.to_param }
274
290
  before { controller.stub(:bigbluebutton_user).and_return(user) }
275
291
  it_should_behave_like "internal join caller"
276
292
  end
@@ -283,7 +299,7 @@ describe Bigbluebutton::RoomsController do
283
299
  room.should_receive(:perform_join).and_return("http://test.com/join/url")
284
300
  }
285
301
  before(:each) {
286
- get :join, :id => room.to_param, :mobile => "1"
302
+ get :join, :server_id => mocked_server.to_param, :id => room.to_param, :mobile => "1"
287
303
  }
288
304
  it { should redirect_to("bigbluebutton://test.com/join/url") }
289
305
  end
@@ -298,16 +314,17 @@ describe Bigbluebutton::RoomsController do
298
314
  mocked_api.should_receive(:is_meeting_running?).and_return(true)
299
315
  mocked_api.should_receive(:end_meeting).with(room.meetingid, room.moderator_password)
300
316
  }
301
- before(:each) { get :end, :id => room.to_param }
317
+ before(:each) { get :end, :server_id => mocked_server.to_param, :id => room.to_param }
302
318
  it { should respond_with(:redirect) }
303
- it { should redirect_to(bigbluebutton_room_path(room)) }
319
+ it { should redirect_to(bigbluebutton_server_room_path(mocked_server, room)) }
320
+ it { should assign_to(:server).with(mocked_server) }
304
321
  it { should assign_to(:room).with(room) }
305
322
  it { should set_the_flash.to(I18n.t('bigbluebutton_rails.rooms.notice.end.success')) }
306
323
  end
307
324
 
308
325
  context "room is not running" do
309
326
  before { mocked_api.should_receive(:is_meeting_running?).and_return(false) }
310
- before(:each) { get :end, :id => room.to_param }
327
+ before(:each) { get :end, :server_id => mocked_server.to_param, :id => room.to_param }
311
328
  it { should respond_with(:redirect) }
312
329
  it { should set_the_flash.to(I18n.t('bigbluebutton_rails.rooms.notice.end.not_running')) }
313
330
  end
@@ -322,7 +339,7 @@ describe Bigbluebutton::RoomsController do
322
339
 
323
340
  context "with a role defined" do
324
341
  before { controller.stub(:bigbluebutton_role).and_return(:attendee) }
325
- before(:each) { get :invite, :id => room.to_param }
342
+ before(:each) { get :invite, :server_id => mocked_server.to_param, :id => room.to_param }
326
343
  it { should respond_with(:success) }
327
344
  it { should render_template(:invite) }
328
345
  it { should assign_to(:room).with(room) }
@@ -331,7 +348,7 @@ describe Bigbluebutton::RoomsController do
331
348
  context "when the user's role" do
332
349
  context "should be defined with a password" do
333
350
  before { controller.stub(:bigbluebutton_role) { :password } }
334
- before(:each) { get :invite, :id => room.to_param }
351
+ before(:each) { get :invite, :server_id => mocked_server.to_param, :id => room.to_param }
335
352
  it { should respond_with(:success) }
336
353
  it { should render_template(:invite) }
337
354
  it { should assign_to(:room).with(room) }
@@ -341,7 +358,7 @@ describe Bigbluebutton::RoomsController do
341
358
  before { controller.stub(:bigbluebutton_role) { nil } }
342
359
  it {
343
360
  lambda {
344
- get :invite, :id => room.to_param
361
+ get :invite, :server_id => mocked_server.to_param, :id => room.to_param
345
362
  }.should raise_error(BigbluebuttonRails::RoomAccessDenied)
346
363
  }
347
364
  end
@@ -353,15 +370,15 @@ describe Bigbluebutton::RoomsController do
353
370
 
354
371
  context "with a role defined" do
355
372
  before { controller.stub(:bigbluebutton_role).and_return(:attendee) }
356
- before(:each) { get :invite, :id => room.to_param }
373
+ before(:each) { get :invite, :server_id => mocked_server.to_param, :id => room.to_param }
357
374
  it { should respond_with(:redirect) }
358
- it { should redirect_to(join_bigbluebutton_room_path(room)) }
375
+ it { should redirect_to(join_bigbluebutton_server_room_path(mocked_server, room)) }
359
376
  end
360
377
 
361
378
  context "when the user's role" do
362
379
  context "should be defined with a password" do
363
380
  before { controller.stub(:bigbluebutton_role) { :password } }
364
- before(:each) { get :invite, :id => room.to_param }
381
+ before(:each) { get :invite, :server_id => mocked_server.to_param, :id => room.to_param }
365
382
  it { should respond_with(:success) }
366
383
  it { should render_template(:invite) }
367
384
  it { should assign_to(:room).with(room) }
@@ -371,7 +388,7 @@ describe Bigbluebutton::RoomsController do
371
388
  before { controller.stub(:bigbluebutton_role) { nil } }
372
389
  it {
373
390
  lambda {
374
- get :invite, :id => room.to_param
391
+ get :invite, :server_id => mocked_server.to_param, :id => room.to_param
375
392
  }.should raise_error(BigbluebuttonRails::RoomAccessDenied)
376
393
  }
377
394
  end
@@ -397,13 +414,13 @@ describe Bigbluebutton::RoomsController do
397
414
  }
398
415
 
399
416
  context "if params[:id]" do
400
- before(:each) { post :auth, :id => room.to_param, :user => user_hash }
417
+ before(:each) { post :auth, :server_id => mocked_server.to_param, :id => room.to_param, :user => user_hash }
401
418
  it { should assign_to(:room).with(room) }
402
419
  end
403
420
 
404
421
  context "if params[:id] doesn't exists" do
405
422
  let(:message) { I18n.t('bigbluebutton_rails.rooms.errors.auth.wrong_params') }
406
- before(:each) { post :auth, :id => "inexistent-room-id", :user => user_hash }
423
+ before(:each) { post :auth, :server_id => mocked_server.to_param, :id => "inexistent-room-id", :user => user_hash }
407
424
  it { should assign_to(:room).with(nil) }
408
425
  it { should respond_with(:redirect) }
409
426
  it { should redirect_to(http_referer) }
@@ -416,7 +433,7 @@ describe Bigbluebutton::RoomsController do
416
433
  before { controller.stub(:bigbluebutton_role) { nil } }
417
434
  it {
418
435
  lambda {
419
- post :auth, :id => room.to_param, :user => hash
436
+ post :auth, :server_id => mocked_server.to_param, :id => room.to_param, :user => hash
420
437
  }.should raise_error(BigbluebuttonRails::RoomAccessDenied)
421
438
  }
422
439
  end
@@ -429,14 +446,14 @@ describe Bigbluebutton::RoomsController do
429
446
  mocked_api.should_receive(:join_meeting_url).
430
447
  with(room.meetingid, user.name, room.attendee_password). # here's the validation
431
448
  and_return("http://test.com/attendee/join")
432
- post :auth, :id => room.to_param, :user => hash
449
+ post :auth, :server_id => mocked_server.to_param, :id => room.to_param, :user => hash
433
450
  end
434
451
 
435
452
  it "redirects to the correct join_url" do
436
453
  hash = { :name => "Elftor", :password => room.attendee_password }
437
454
  mocked_api.should_receive(:is_meeting_running?).and_return(true)
438
455
  mocked_api.should_receive(:join_meeting_url).and_return("http://test.com/attendee/join")
439
- post :auth, :id => room.to_param, :user => hash
456
+ post :auth, :server_id => mocked_server.to_param, :id => room.to_param, :user => hash
440
457
  should respond_with(:redirect)
441
458
  should redirect_to("http://test.com/attendee/join")
442
459
  end
@@ -448,14 +465,14 @@ describe Bigbluebutton::RoomsController do
448
465
  mocked_api.should_receive(:join_meeting_url).
449
466
  with(anything, anything, room.attendee_password).
450
467
  and_return("http://test.com/attendee/join")
451
- post :auth, :id => room.to_param, :user => hash
468
+ post :auth, :server_id => mocked_server.to_param, :id => room.to_param, :user => hash
452
469
  should respond_with(:redirect)
453
470
  should redirect_to("http://test.com/attendee/join")
454
471
  end
455
472
 
456
473
  context "validates user input and shows error" do
457
474
  before { controller.should_receive(:bigbluebutton_role).once { :password } }
458
- before(:each) { post :auth, :id => room.to_param, :user => user_hash }
475
+ before(:each) { post :auth, :server_id => mocked_server.to_param, :id => room.to_param, :user => user_hash }
459
476
 
460
477
  context "when name is not set" do
461
478
  let(:user_hash) { { :password => room.moderator_password } }
@@ -487,57 +504,41 @@ describe Bigbluebutton::RoomsController do
487
504
  context "calling .join_internal" do
488
505
  let(:template) { :invite }
489
506
  let(:hash) { { :name => user.name, :password => room.attendee_password } }
490
- let(:request) { post :auth, :id => room.to_param, :user => hash }
507
+ let(:request) { post :auth, :server_id => mocked_server.to_param, :id => room.to_param, :user => hash }
491
508
  before { controller.stub(:bigbluebutton_user).and_return(nil) }
492
509
  it_should_behave_like "internal join caller"
493
510
  end
494
511
  end
495
512
 
496
513
  describe "#external" do
497
- let(:server) { Factory.create(:bigbluebutton_server) }
498
- let(:meetingid) { 'my-meeting-id' }
514
+ before { mock_server_and_api }
515
+ let(:new_room) { BigbluebuttonRoom.new(:meetingid => 'my-meeting-id') }
499
516
 
500
517
  context "on success" do
501
- before {
502
- controller.stub(:bigbluebutton_user).and_return(nil)
503
- BigbluebuttonServer.stub(:find).and_return(server)
504
- }
505
- before(:each) { get :external, :meeting => meetingid, :server_id => server.id }
518
+ before { controller.stub(:bigbluebutton_user).and_return(nil) }
519
+ before(:each) { get :external, :server_id => mocked_server.to_param, :meeting => new_room.meetingid }
520
+ it { should assign_to(:server).with(mocked_server) }
506
521
  it { should respond_with(:success) }
507
522
  it { should render_template(:external) }
508
- it { should assign_to(:server).with(server) }
509
523
  it { should assign_to(:room).with_kind_of(BigbluebuttonRoom) }
510
- it { assigns(:room).meetingid.should be(meetingid) }
511
- it { assigns(:room).server_id.should be(server.id) }
524
+ it { assigns(:room).meetingid.should be(new_room.meetingid) }
512
525
  end
513
526
 
514
527
  context "when params[:meeting].blank?" do
528
+ before { controller.stub(:bigbluebutton_user).and_return(nil) }
529
+
515
530
  context "without params[:redir_url]" do
516
- before(:each) { get :external, :server_id => server.id }
531
+ before(:each) { get :external, :server_id => mocked_server.to_param }
517
532
  it { should respond_with(:redirect) }
518
- it { should redirect_to bigbluebutton_rooms_path }
533
+ it { should redirect_to bigbluebutton_server_rooms_path(mocked_server) }
519
534
  it { should set_the_flash.to(I18n.t('bigbluebutton_rails.rooms.errors.external.blank_meetingid')) }
520
535
  end
521
536
 
522
537
  context "with params[:redir_url]" do
523
- before(:each) { get :external, :server_id => server.id, :redir_url => '/'}
538
+ before(:each) { get :external, :server_id => mocked_server.to_param, :redir_url => '/'}
524
539
  it { should redirect_to '/' }
525
540
  end
526
541
  end
527
-
528
- context "when params[:server_id]" do
529
- it "is blank" do
530
- lambda {
531
- get :external, :meeting => meetingid
532
- }.should raise_error(ActiveRecord::RecordNotFound)
533
- end
534
-
535
- it "is invalid" do
536
- lambda {
537
- get :external, :meeting => meetingid, :server_id => server.id + 10
538
- }.should raise_error(ActiveRecord::RecordNotFound)
539
- end
540
- end
541
542
  end # #external
542
543
 
543
544
  describe "#external_auth" do
@@ -548,36 +549,27 @@ describe Bigbluebutton::RoomsController do
548
549
  :moderator_password => Forgery(:basic).password,
549
550
  :server => mocked_server) }
550
551
  let(:meetings) { [ new_room ] }
551
- before { controller.stub(:bigbluebutton_user).and_return(nil) }
552
-
553
- context "assigns @server and @room if params[:meeting] and params[:user] and params[:server_id]" do
554
- before {
555
- mock_server_and_api
556
- mocked_server.should_receive(:fetch_meetings)
557
- mocked_server.should_receive(:meetings).and_return(meetings)
558
- new_room.should_receive(:perform_join)
559
- }
560
- before(:each) { post :external_auth, :meeting => new_room.meetingid, :server_id => mocked_server.id, :user => user_hash }
561
- it { should assign_to(:room).with(new_room) }
562
- it { should assign_to(:server).with(mocked_server) }
563
- end
564
-
565
- it "shows error when params[:server_id] is invalid" do
566
- lambda {
567
- post :external_auth, :meeting => new_room.meetingid, :server_id => nil, :user => user_hash
568
- }.should raise_error(ActiveRecord::RecordNotFound)
569
- end
552
+ let(:http_referer) { bigbluebutton_server_path(mocked_server) }
553
+ before {
554
+ mock_server_and_api
555
+ controller.stub(:bigbluebutton_user).and_return(nil)
556
+ request.env["HTTP_REFERER"] = http_referer
557
+ }
570
558
 
571
- context "shows error" do
572
- let(:http_referer) { bigbluebutton_server_path(mocked_server) }
573
- before {
574
- mock_server_and_api
575
- request.env["HTTP_REFERER"] = http_referer
576
- }
559
+ context "assigns @room" do
560
+ context "if params[:meeting] and params[:user]" do
561
+ before { # TODO: this block is being repeated several times, put it in a method or something
562
+ mocked_server.should_receive(:fetch_meetings)
563
+ mocked_server.should_receive(:meetings).and_return(meetings)
564
+ new_room.should_receive(:perform_join)
565
+ }
566
+ before(:each) { post :external_auth, :server_id => mocked_server.to_param, :meeting => new_room.meetingid, :user => user_hash }
567
+ it { should assign_to(:room).with(new_room) }
568
+ end
577
569
 
578
570
  context "if not params[:meeting]" do
579
- let(:message) { I18n.t('bigbluebutton_rails.rooms.errors.external.wrong_params') }
580
- before(:each) { post :external_auth, :meeting => nil, :server_id => mocked_server.id, :user => user_hash }
571
+ let(:message) { I18n.t('bigbluebutton_rails.rooms.errors.auth.wrong_params') }
572
+ before(:each) { post :external_auth, :server_id => mocked_server.to_param, :meeting => nil, :user => user_hash }
581
573
  it { should assign_to(:room).with(nil) }
582
574
  it { should respond_with(:redirect) }
583
575
  it { should redirect_to(http_referer) }
@@ -585,8 +577,8 @@ describe Bigbluebutton::RoomsController do
585
577
  end
586
578
 
587
579
  context "if not params[:user]" do
588
- let(:message) { I18n.t('bigbluebutton_rails.rooms.errors.external.wrong_params') }
589
- before(:each) { post :external_auth, :meeting => new_room.meetingid, :server_id => mocked_server.id, :user => nil }
580
+ let(:message) { I18n.t('bigbluebutton_rails.rooms.errors.auth.wrong_params') }
581
+ before(:each) { post :external_auth, :server_id => mocked_server.to_param, :meeting => new_room.meetingid, :user => nil }
590
582
  it { should assign_to(:room).with(nil) }
591
583
  it { should respond_with(:redirect) }
592
584
  it { should redirect_to(http_referer) }
@@ -594,9 +586,8 @@ describe Bigbluebutton::RoomsController do
594
586
  end
595
587
  end
596
588
 
597
- context "with @server and @room assigned" do
589
+ context "got the room" do
598
590
  before {
599
- mock_server_and_api
600
591
  mocked_server.should_receive(:fetch_meetings)
601
592
  mocked_server.should_receive(:meetings).and_return(meetings)
602
593
  }
@@ -604,12 +595,12 @@ describe Bigbluebutton::RoomsController do
604
595
  it "block access if bigbluebutton_role returns nil" do
605
596
  controller.stub(:bigbluebutton_role) { nil }
606
597
  lambda {
607
- post :external_auth, :meeting => new_room.meetingid, :server_id => mocked_server.id, :user => user_hash
598
+ post :external_auth, :server_id => mocked_server.to_param, :meeting => new_room.meetingid, :user => user_hash
608
599
  }.should raise_error(BigbluebuttonRails::RoomAccessDenied)
609
600
  end
610
601
 
611
602
  context "validates user input and shows error" do
612
- before(:each) { post :external_auth, :meeting => new_room.meetingid, :server_id => mocked_server.id, :user => user_hash }
603
+ before(:each) { post :external_auth, :server_id => mocked_server.to_param, :meeting => new_room.meetingid, :user => user_hash }
613
604
 
614
605
  context "when name is not set" do
615
606
  let(:user_hash) { { :password => room.moderator_password } }
@@ -642,7 +633,7 @@ describe Bigbluebutton::RoomsController do
642
633
  new_room.should_receive(:perform_join).with(anything, :attendee, request).
643
634
  and_return("http://test.com/attendee/join")
644
635
  }
645
- before(:each) { post :external_auth, :meeting => new_room.meetingid, :server_id => mocked_server.id, :user => user_hash }
636
+ before(:each) { post :external_auth, :server_id => mocked_server.to_param, :meeting => new_room.meetingid, :user => user_hash }
646
637
  it { should respond_with(:redirect) }
647
638
  it { should redirect_to("http://test.com/attendee/join") }
648
639
  end
@@ -651,7 +642,7 @@ describe Bigbluebutton::RoomsController do
651
642
  before {
652
643
  new_room.should_receive(:perform_join).with(user_hash[:name], :attendee, request).and_return(nil)
653
644
  }
654
- before(:each) { post :external_auth, :meeting => new_room.meetingid, :server_id => mocked_server.id, :user => user_hash }
645
+ before(:each) { post :external_auth, :server_id => mocked_server.to_param, :meeting => new_room.meetingid, :user => user_hash }
655
646
  it { should respond_with(:success) }
656
647
  it { should render_template(:external) }
657
648
  it { should set_the_flash.to(I18n.t('bigbluebutton_rails.rooms.errors.auth.not_running')) }
@@ -663,12 +654,22 @@ describe Bigbluebutton::RoomsController do
663
654
  controller.stub(:bigbluebutton_user).and_return(user)
664
655
  new_room.should_receive(:perform_join).with(user.name, anything, anything). # here's the validation
665
656
  and_return("http://test.com/attendee/join")
666
- post :external_auth, :meeting => new_room.meetingid, :server_id => mocked_server.id, :user => user_hash
657
+ post :external_auth, :server_id => mocked_server.to_param, :meeting => new_room.meetingid, :user => user_hash
667
658
  end
668
659
 
669
660
  end
670
661
 
671
662
  end # #external_auth
672
663
 
664
+ # can be used when matching rooms inside some resource other than servers
665
+ context "selects the first server when the server_id is not defined in the url" do
666
+ let(:server2) { Factory.create(:bigbluebutton_server) }
667
+
668
+ # get /users/:user_id/room/:id(.:format)
669
+ before(:each) { get :show, :id => room.to_param, :user_id => "1" }
670
+ it { should respond_with(:success) }
671
+ it { should assign_to(:server).with(server) }
672
+ end
673
+
673
674
  end
674
675
 
@@ -4,7 +4,7 @@ describe Bigbluebutton::ServersController do
4
4
  render_views
5
5
  let(:server) { Factory.create(:bigbluebutton_server) }
6
6
 
7
- context "json responses for" do
7
+ context "json responses for " do
8
8
 
9
9
  describe "#index" do
10
10
  before do
@@ -144,16 +144,5 @@ describe Bigbluebutton::ServersController do
144
144
 
145
145
  end
146
146
 
147
- describe "#rooms" do
148
- before do
149
- @room1 = Factory.create(:bigbluebutton_room, :server => server)
150
- @room2 = Factory.create(:bigbluebutton_room, :server => server)
151
- end
152
- before(:each) { get :rooms, :id => server.to_param, :format => 'json' }
153
- it { should respond_with(:success) }
154
- it { should respond_with_content_type(:json) }
155
- it { should respond_with_json([@room1, @room2].to_json) }
156
- end
157
-
158
147
  end
159
148
  end
@@ -140,16 +140,5 @@ describe Bigbluebutton::ServersController do
140
140
 
141
141
  end # #activity
142
142
 
143
- describe "#rooms" do
144
- before do
145
- @room1 = Factory.create(:bigbluebutton_room, :server => server)
146
- @room2 = Factory.create(:bigbluebutton_room, :server => server)
147
- end
148
- before(:each) { get :rooms, :id => server.to_param }
149
- it { should respond_with(:success) }
150
- it { should render_template(:rooms) }
151
- it { should assign_to(:rooms).with([@room1, @room2]) }
152
- end
153
-
154
143
  end
155
144
 
@@ -21,8 +21,8 @@ describe BigbluebuttonRails::Generators::InstallGenerator do
21
21
 
22
22
  it "all files are properly destroyed" do
23
23
  run_generator %w(), :behavior => :revoke
24
- assert_no_migration "db/migrate/create_bigbluebutton_rails.rb"
25
24
  assert_no_file "config/locales/bigbluebutton_rails.en.yml"
25
+ assert_no_migration "db/migrate/create_bigbluebutton_rails.rb"
26
26
  assert_no_file "public/stylesheets/bigbluebutton_rails.css"
27
27
  assert_no_file "public/javascripts/jquery.min.js"
28
28
  assert_no_file "public/images/loading.gif"