bigbluebutton_rails 0.0.5 → 0.0.6

Sign up to get free protection for your applications and to get access to all the features.
Files changed (56) hide show
  1. data/.gitignore +2 -0
  2. data/.rvmrc +6 -0
  3. data/.travis.yml +4 -0
  4. data/CHANGELOG.rdoc +9 -0
  5. data/Gemfile +18 -0
  6. data/Gemfile.lock +85 -65
  7. data/README.rdoc +23 -0
  8. data/Rakefile +17 -6
  9. data/app/controllers/bigbluebutton/rooms_controller.rb +79 -58
  10. data/app/controllers/bigbluebutton/servers_controller.rb +41 -24
  11. data/app/models/bigbluebutton_room.rb +45 -5
  12. data/app/models/bigbluebutton_server.rb +5 -7
  13. data/app/views/bigbluebutton/rooms/external.html.erb +24 -0
  14. data/app/views/bigbluebutton/rooms/join_mobile.html.erb +1 -1
  15. data/app/views/bigbluebutton/servers/_activity_list.html.erb +7 -7
  16. data/app/views/bigbluebutton/servers/activity.html.erb +1 -1
  17. data/bigbluebutton_rails.gemspec +2 -12
  18. data/config/locales/en.yml +3 -0
  19. data/lib/bigbluebutton_rails/rails/routes.rb +12 -6
  20. data/lib/bigbluebutton_rails/utils.rb +8 -0
  21. data/lib/bigbluebutton_rails/version.rb +1 -1
  22. data/lib/bigbluebutton_rails.rb +1 -0
  23. data/spec/bigbluebutton_rails_spec.rb +13 -0
  24. data/spec/controllers/bigbluebutton/rooms_controller_exception_handling_spec.rb +114 -0
  25. data/spec/controllers/bigbluebutton/rooms_controller_json_responses_spec.rb +167 -0
  26. data/spec/controllers/bigbluebutton/rooms_controller_spec.rb +213 -457
  27. data/spec/controllers/bigbluebutton/servers_controller_json_responses_spec.rb +148 -0
  28. data/spec/controllers/bigbluebutton/servers_controller_spec.rb +50 -76
  29. data/spec/factories/bigbluebutton_room.rb +1 -0
  30. data/spec/models/bigbluebutton_room_spec.rb +141 -17
  31. data/spec/models/bigbluebutton_server_spec.rb +27 -36
  32. data/spec/rails_app/app/controllers/application_controller.rb +4 -3
  33. data/spec/rails_app/config/initializers/rack_hotfix.rb +13 -0
  34. data/spec/rails_app/features/join_external_bigbluebutton_rooms.feature +19 -0
  35. data/spec/rails_app/features/manage_bigbluebutton_rooms.feature +3 -3
  36. data/spec/rails_app/features/manage_bigbluebutton_servers.feature +2 -2
  37. data/spec/rails_app/features/step_definitions/bigbluebutton_room_steps.rb +29 -3
  38. data/spec/rails_app/features/step_definitions/bigbluebutton_server_steps.rb +2 -7
  39. data/spec/rails_app/features/step_definitions/common_steps.rb +15 -2
  40. data/spec/rails_app/features/step_definitions/web_steps.rb +7 -3
  41. data/spec/rails_app/features/support/application_controller.rb +12 -0
  42. data/spec/rails_app/features/support/content.rb +10 -0
  43. data/spec/rails_app/features/support/env.rb +4 -4
  44. data/spec/rails_app/features/support/env_gem.rb +2 -1
  45. data/spec/rails_app/features/support/forms.rb +12 -0
  46. data/spec/rails_app/features/support/paths.rb +17 -8
  47. data/spec/rails_app/features/support/selectors.rb +57 -0
  48. data/spec/rails_app/features/support/within.rb +7 -0
  49. data/spec/routing/bigbluebutton/rooms_routing_spec.rb +60 -52
  50. data/spec/routing/bigbluebutton/servers_routing_spec.rb +8 -8
  51. data/spec/spec_helper.rb +5 -0
  52. data/spec/support/controllers/bigbluebutton/rooms_controller.rb +7 -0
  53. data/spec/support/matchers/shoulda/be_boolean.rb +1 -1
  54. data/spec/support/shared_examples/rooms_controller.rb +37 -0
  55. metadata +24 -110
  56. data/spec/rails_app/app/helpers/application_helper.rb +0 -2
@@ -0,0 +1,167 @@
1
+ require 'spec_helper'
2
+
3
+ describe Bigbluebutton::RoomsController do
4
+ render_views
5
+ let(:server) { Factory.create(:bigbluebutton_server) }
6
+ let(:room) { Factory.create(:bigbluebutton_room, :server => server) }
7
+
8
+ context "json responses for " do
9
+
10
+ describe "#index" do
11
+ before do
12
+ @room1 = Factory.create(:bigbluebutton_room, :server => server)
13
+ @room2 = Factory.create(:bigbluebutton_room, :server => server)
14
+ end
15
+ before(:each) { get :index, :server_id => server.to_param, :format => 'json' }
16
+ it { should respond_with(:success) }
17
+ it { should respond_with_content_type(:json) }
18
+ it { should respond_with_json([@room1, @room2].to_json) }
19
+ end
20
+
21
+ describe "#new" do
22
+ before(:each) { get :new, :server_id => server.to_param, :format => 'json' }
23
+ it { should respond_with(:success) }
24
+ it { should respond_with_content_type(:json) }
25
+ it {
26
+ # we ignore all values bc a BigbluebuttonRoom is generated with some
27
+ # random values (meetingid, voice_bridge)
28
+ should respond_with_json(BigbluebuttonRoom.new.to_json).ignoring_values
29
+ }
30
+ end
31
+
32
+ describe "#show" do
33
+ before(:each) { get :show, :server_id => server.to_param, :id => room.to_param, :format => 'json' }
34
+ it { should respond_with(:success) }
35
+ it { should respond_with_content_type(:json) }
36
+ it { should respond_with_json(room.to_json) }
37
+ end
38
+
39
+ describe "#create" do
40
+ let(:new_room) { Factory.build(:bigbluebutton_room, :server => server) }
41
+
42
+ context "on success" do
43
+ before(:each) {
44
+ post :create, :server_id => server.to_param, :bigbluebutton_room => new_room.attributes, :format => 'json'
45
+ }
46
+ it { should respond_with(:created) }
47
+ it { should respond_with_content_type(:json) }
48
+ it {
49
+ json = { :message => I18n.t('bigbluebutton_rails.rooms.notice.create.success') }.to_json
50
+ should respond_with_json(json)
51
+ }
52
+ end
53
+
54
+ context "on failure" do
55
+ before(:each) {
56
+ new_room.name = nil # invalid
57
+ post :create, :server_id => server.to_param, :bigbluebutton_room => new_room.attributes, :format => 'json'
58
+ }
59
+ it { should respond_with(:unprocessable_entity) }
60
+ it { should respond_with_content_type(:json) }
61
+ it {
62
+ new_room.save # should fail
63
+ should respond_with_json(new_room.errors.full_messages.to_json)
64
+ }
65
+ end
66
+ end
67
+
68
+ describe "#update" do
69
+ let(:new_room) { Factory.build(:bigbluebutton_room) }
70
+ before { @room = room }
71
+
72
+ context "on success" do
73
+ before(:each) {
74
+ put :update, :server_id => server.to_param, :id => @room.to_param, :bigbluebutton_room => new_room.attributes, :format => 'json'
75
+ }
76
+ it { should respond_with(:success) }
77
+ it { should respond_with_content_type(:json) }
78
+ it {
79
+ json = { :message => I18n.t('bigbluebutton_rails.rooms.notice.update.success') }.to_json
80
+ should respond_with_json(json)
81
+ }
82
+ end
83
+
84
+ context "on failure" do
85
+ before(:each) {
86
+ new_room.name = nil # invalid
87
+ put :update, :server_id => server.to_param, :id => @room.to_param, :bigbluebutton_room => new_room.attributes, :format => 'json'
88
+ }
89
+ it { should respond_with(:unprocessable_entity) }
90
+ it { should respond_with_content_type(:json) }
91
+ it {
92
+ new_room.save # should fail
93
+ should respond_with_json(new_room.errors.full_messages.to_json)
94
+ }
95
+ end
96
+ end
97
+
98
+ describe "#end" do
99
+ before { mock_server_and_api }
100
+
101
+ context "room is running" do
102
+ before {
103
+ mocked_api.should_receive(:is_meeting_running?).and_return(true)
104
+ mocked_api.should_receive(:end_meeting).with(room.meetingid, room.moderator_password)
105
+ }
106
+ before(:each) { get :end, :server_id => mocked_server.to_param, :id => room.to_param, :format => 'json' }
107
+ it { should respond_with(:success) }
108
+ it { should respond_with_content_type(:json) }
109
+ it { should respond_with_json(I18n.t('bigbluebutton_rails.rooms.notice.end.success')) }
110
+ end
111
+
112
+ context "room is not running" do
113
+ before { mocked_api.should_receive(:is_meeting_running?).and_return(false) }
114
+ before(:each) { get :end, :server_id => mocked_server.to_param, :id => room.to_param, :format => 'json' }
115
+ it { should respond_with(:error) }
116
+ it { should respond_with_content_type(:json) }
117
+ it { should respond_with_json(I18n.t('bigbluebutton_rails.rooms.notice.end.not_running')) }
118
+ end
119
+
120
+ context "throwing an exception" do
121
+ let(:msg) { "any error message" }
122
+ before {
123
+ mocked_api.should_receive(:is_meeting_running?).and_return{ raise BigBlueButton::BigBlueButtonException.new(msg) }
124
+ }
125
+ before(:each) { get :end, :server_id => mocked_server.to_param, :id => room.to_param, :format => 'json' }
126
+ it { should respond_with(:error) }
127
+ it { should respond_with_content_type(:json) }
128
+ it { should respond_with_json(msg) }
129
+ end
130
+
131
+ end
132
+
133
+ describe "#destroy" do
134
+ before { mock_server_and_api }
135
+
136
+ context "on success" do
137
+ before {
138
+ mocked_api.should_receive(:is_meeting_running?).and_return(true)
139
+ mocked_api.should_receive(:end_meeting)
140
+ }
141
+ before(:each) {
142
+ delete :destroy, :server_id => mocked_server.to_param, :id => room.to_param, :format => 'json'
143
+ }
144
+ it { should respond_with(:success) }
145
+ it { should respond_with_content_type(:json) }
146
+ it {
147
+ json = { :message => I18n.t('bigbluebutton_rails.rooms.notice.destroy.success') }.to_json
148
+ should respond_with_json(json)
149
+ }
150
+ end
151
+
152
+ context "throwing error" do
153
+ let(:msg) { "any error message" }
154
+ before {
155
+ mocked_api.should_receive(:is_meeting_running?).and_return{ raise BigBlueButton::BigBlueButtonException.new(msg) }
156
+ }
157
+ before(:each) {
158
+ delete :destroy, :server_id => mocked_server.to_param, :id => room.to_param, :format => 'json'
159
+ }
160
+ it { should respond_with(:error) }
161
+ it { should respond_with_content_type(:json) }
162
+ it { should respond_with_json({ :message => msg }.to_json) }
163
+ end
164
+ end
165
+
166
+ end
167
+ end