bigbluebutton_rails 1.2.0 → 1.3.0.beta1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (123) hide show
  1. data/.ruby-version +1 -0
  2. data/.travis.yml +2 -2
  3. data/CHANGELOG.rdoc +15 -1
  4. data/Gemfile +15 -4
  5. data/Gemfile.lock +187 -125
  6. data/LICENSE +24 -0
  7. data/README.rdoc +96 -19
  8. data/Rakefile +32 -16
  9. data/TODO_08 +9 -10
  10. data/{spec/rails_app/public → app/assets}/stylesheets/bigbluebutton_rails.css +58 -79
  11. data/app/controllers/bigbluebutton/recordings_controller.rb +142 -0
  12. data/app/controllers/bigbluebutton/rooms_controller.rb +105 -50
  13. data/app/controllers/bigbluebutton/servers_controller.rb +78 -2
  14. data/app/helpers/bigbluebutton_rails_helper.rb +11 -4
  15. data/app/models/bigbluebutton_metadata.rb +43 -0
  16. data/app/models/bigbluebutton_playback_format.rb +9 -0
  17. data/app/models/bigbluebutton_recording.rb +191 -0
  18. data/app/models/bigbluebutton_room.rb +92 -66
  19. data/app/models/bigbluebutton_server.rb +49 -3
  20. data/app/views/bigbluebutton/recordings/_form.html.erb +67 -0
  21. data/app/views/bigbluebutton/recordings/_recordings.html.erb +56 -0
  22. data/app/views/bigbluebutton/recordings/edit.html.erb +5 -0
  23. data/app/views/bigbluebutton/recordings/index.html.erb +2 -0
  24. data/app/views/bigbluebutton/recordings/show.html.erb +84 -0
  25. data/app/views/bigbluebutton/rooms/_form.html.erb +28 -7
  26. data/app/views/bigbluebutton/rooms/_rooms.html.erb +19 -4
  27. data/app/views/bigbluebutton/rooms/edit.html.erb +0 -1
  28. data/app/views/bigbluebutton/rooms/invite.html.erb +2 -1
  29. data/app/views/bigbluebutton/rooms/join.html.erb +0 -2
  30. data/app/views/bigbluebutton/rooms/recordings.html.erb +2 -0
  31. data/app/views/bigbluebutton/rooms/show.html.erb +35 -15
  32. data/app/views/bigbluebutton/servers/_form.html.erb +4 -0
  33. data/app/views/bigbluebutton/servers/index.html.erb +8 -3
  34. data/app/views/bigbluebutton/servers/recordings.html.erb +2 -0
  35. data/app/views/bigbluebutton/servers/rooms.html.erb +1 -1
  36. data/app/views/bigbluebutton/servers/show.html.erb +54 -6
  37. data/bigbluebutton_rails.gemspec +1 -1
  38. data/config/locales/en.yml +105 -55
  39. data/config/schedule.rb +3 -0
  40. data/lib/bigbluebutton_rails.rb +52 -2
  41. data/lib/bigbluebutton_rails/controller_methods.rb +31 -0
  42. data/lib/bigbluebutton_rails/rails/routes.rb +50 -14
  43. data/lib/bigbluebutton_rails/version.rb +1 -1
  44. data/lib/generators/bigbluebutton_rails/install_generator.rb +8 -8
  45. data/lib/generators/bigbluebutton_rails/templates/migration.rb +37 -1
  46. data/lib/generators/bigbluebutton_rails/templates/migration_1_3_0.rb +55 -0
  47. data/lib/generators/bigbluebutton_rails/templates/migration_1_3_0_b.rb +13 -0
  48. data/lib/generators/bigbluebutton_rails/views_generator.rb +6 -2
  49. data/lib/tasks/bigbluebutton_rails/recordings.rake +18 -0
  50. data/spec/bigbluebutton_rails_spec.rb +2 -2
  51. data/spec/controllers/bigbluebutton/recordings_controller_json_responses_spec.rb +111 -0
  52. data/spec/controllers/bigbluebutton/recordings_controller_spec.rb +188 -0
  53. data/spec/controllers/bigbluebutton/rooms_controller_exception_handling_spec.rb +15 -10
  54. data/spec/controllers/bigbluebutton/rooms_controller_json_responses_spec.rb +14 -7
  55. data/spec/controllers/bigbluebutton/rooms_controller_spec.rb +327 -103
  56. data/spec/controllers/bigbluebutton/servers_controller_json_responses_spec.rb +12 -12
  57. data/spec/controllers/bigbluebutton/servers_controller_spec.rb +166 -28
  58. data/spec/factories/bigbluebutton_metadata.rb +11 -0
  59. data/spec/factories/bigbluebutton_playback_format.rb +8 -0
  60. data/spec/factories/bigbluebutton_recording.rb +13 -0
  61. data/spec/factories/bigbluebutton_room.rb +2 -1
  62. data/spec/factories/bigbluebutton_server.rb +1 -1
  63. data/spec/factories/user.rb +1 -0
  64. data/spec/generators/install_generator_spec.rb +21 -10
  65. data/spec/generators/views_generator_spec.rb +14 -4
  66. data/spec/models/bigbluebutton_metadata_db_spec.rb +13 -0
  67. data/spec/models/bigbluebutton_metadata_spec.rb +64 -0
  68. data/spec/models/bigbluebutton_playback_format_db_spec.rb +13 -0
  69. data/spec/models/bigbluebutton_playback_format_spec.rb +22 -0
  70. data/spec/models/bigbluebutton_recording_db_spec.rb +24 -0
  71. data/spec/models/bigbluebutton_recording_spec.rb +450 -0
  72. data/spec/models/bigbluebutton_room_db_spec.rb +3 -2
  73. data/spec/models/bigbluebutton_room_spec.rb +194 -166
  74. data/spec/models/bigbluebutton_server_spec.rb +107 -27
  75. data/spec/rails_app/.gitignore +2 -0
  76. data/spec/rails_app/app/assets/javascripts/application.js +2 -0
  77. data/spec/rails_app/app/controllers/application_controller.rb +2 -0
  78. data/spec/rails_app/app/controllers/custom_recordings_controller.rb +8 -0
  79. data/spec/rails_app/app/controllers/frontpage_controller.rb +7 -0
  80. data/spec/rails_app/app/views/frontpage/show.html.erb +5 -0
  81. data/spec/rails_app/app/views/layouts/application.html.erb +5 -2
  82. data/spec/rails_app/config/application.rb +13 -0
  83. data/spec/rails_app/config/environments/development.rb +7 -2
  84. data/spec/rails_app/config/environments/production.rb +9 -0
  85. data/spec/rails_app/config/environments/test.rb +10 -0
  86. data/spec/rails_app/config/routes.rb +20 -2
  87. data/spec/rails_app/features/edit_rooms.feature +2 -3
  88. data/spec/rails_app/features/edit_servers.feature +2 -3
  89. data/spec/rails_app/features/step_definitions/activity_monitor_servers_step.rb +2 -2
  90. data/spec/rails_app/features/step_definitions/common_steps.rb +5 -5
  91. data/spec/rails_app/features/step_definitions/create_rooms_steps.rb +2 -4
  92. data/spec/rails_app/features/step_definitions/create_servers_steps.rb +2 -2
  93. data/spec/rails_app/features/step_definitions/edit_rooms_steps.rb +2 -2
  94. data/spec/rails_app/features/step_definitions/edit_servers_steps.rb +2 -2
  95. data/spec/rails_app/features/step_definitions/join_rooms_steps.rb +2 -2
  96. data/spec/rails_app/features/step_definitions/list_and_show_rooms_steps.rb +2 -2
  97. data/spec/rails_app/features/support/templates.rb +2 -6
  98. data/spec/rails_app/lib/tasks/db/populate.rake +119 -0
  99. data/spec/routing/bigbluebutton/custom_controllers_routing_spec.rb +78 -1
  100. data/spec/routing/bigbluebutton/recordings_only_routing_spec.rb +43 -0
  101. data/spec/routing/bigbluebutton/recordings_routing_spec.rb +46 -0
  102. data/spec/routing/bigbluebutton/rooms_only_routing_spec.rb +67 -0
  103. data/spec/routing/bigbluebutton/rooms_routing_spec.rb +28 -2
  104. data/spec/routing/bigbluebutton/servers_only_routing_spec.rb +43 -0
  105. data/spec/routing/bigbluebutton/servers_routing_spec.rb +16 -1
  106. data/spec/support/matchers/have_same_attributes_as.rb +20 -3
  107. data/spec/support/matchers/shoulda/{be_boolean.rb → be_boolean_matcher.rb} +0 -0
  108. data/spec/support/mocked_server.rb +19 -3
  109. metadata +48 -28
  110. data/public/images/loading.gif +0 -0
  111. data/public/javascripts/jquery.min.js +0 -16
  112. data/public/stylesheets/bigbluebutton_rails.css +0 -148
  113. data/spec/rails_app/public/images/loading.gif +0 -0
  114. data/spec/rails_app/public/images/rails.png +0 -0
  115. data/spec/rails_app/public/index.html +0 -239
  116. data/spec/rails_app/public/javascripts/application.js +0 -2
  117. data/spec/rails_app/public/javascripts/controls.js +0 -965
  118. data/spec/rails_app/public/javascripts/dragdrop.js +0 -974
  119. data/spec/rails_app/public/javascripts/effects.js +0 -1123
  120. data/spec/rails_app/public/javascripts/jquery.min.js +0 -16
  121. data/spec/rails_app/public/javascripts/prototype.js +0 -6001
  122. data/spec/rails_app/public/javascripts/rails.js +0 -191
  123. data/spec/support/shared_examples/rooms_controller.rb +0 -37
@@ -83,6 +83,37 @@ module BigbluebuttonRails
83
83
  end
84
84
  end
85
85
 
86
+ # Method used called right before a meeting is created to check
87
+ # whether the current user ('bigbluebutton_user') is allowed to create
88
+ # the meeting in the target room.
89
+ # By default any moderator can create meetings.
90
+ # The parameter 'room' is the BigbluebuttonRoom where the meeting is about
91
+ # to be created. And 'role' is the role already defined for the user
92
+ # (:moderator, :attendee, etc).
93
+ #
94
+ # This method can also be used to run anything you may need to run
95
+ # right before a meeting is created, such as adapting the metadata.
96
+ # You can also, for instance, check if the user has permissions to record
97
+ # the meeting and set the flag 'record' accordingly.
98
+ #
99
+ # You may want to do override this in your ApplicationController to
100
+ # implement your own logic, for example:
101
+ #
102
+ # def bigbluebutton_can_create?(room, role)
103
+ # if role == :moderator
104
+ # unless bigbluebutton_user.can_record_meeting?(room)
105
+ # room.update_attributes(:record => false)
106
+ # end
107
+ # true
108
+ # else
109
+ # false
110
+ # end
111
+ # end
112
+ #
113
+ def bigbluebutton_can_create?(room, role)
114
+ role == :moderator
115
+ end
116
+
86
117
  end
87
118
  end
88
119
 
@@ -12,10 +12,10 @@ module ActionDispatch::Routing
12
12
  # ==== Default routes
13
13
  #
14
14
  # Passing the option :default, it will generate the default routes to access
15
- # bigbluebutton servers and rooms. These routes are the resourceful routes generated
15
+ # servers, rooms and recordings. The routes generated are the CRUD routes generated
16
16
  # by rails to a resource, plus the other available actions for servers and rooms.
17
17
  #
18
- # bigbluebutton_routes :default
18
+ # bigbluebutton_routes :default
19
19
  #
20
20
  # Examples of some routes generated:
21
21
  #
@@ -23,19 +23,27 @@ module ActionDispatch::Routing
23
23
  # { :action=>"show", :controller=>"bigbluebutton/servers" }
24
24
  # POST /bigbluebutton/servers/:id(.:format)
25
25
  # { :action=>"update", :controller=>"bigbluebutton/servers" }
26
+ #
26
27
  # join_bigbluebutton_room GET /bigbluebutton/rooms/:id/join(.:format)
27
28
  # { :action=>"join", :controller=>"bigbluebutton/rooms" }
29
+ #
28
30
  # running_bigbluebutton_room GET /bigbluebutton/rooms/:id/running(.:format)
29
31
  # { :action=>"running", :controller=>"bigbluebutton/rooms" }
30
32
  #
31
- # The routes point by default to the controllers Bigbluebutton::ServersController and Bigbluebutton::RoomsController
33
+ # play_bigbluebutton_recording GET /bigbluebutton/recordings/:id/play(.:format)
34
+ # { :action=>"play", :controller=>"bigbluebutton/recordings" }
35
+ #
36
+ # The routes point by default to the controllers provided by this gem
32
37
  # and they are scoped (namespaced) with 'bigbluebutton'. You can change the namespace with:
33
38
  #
34
- # bigbluebutton_routes :default, :scope => "webconference"
39
+ # bigbluebutton_routes :default, :scope => "webconference"
35
40
  #
36
41
  # You can also change the controllers with:
37
42
  #
38
- # bigbluebutton_routes :default, :controllers { :servers => "custom_servers", :rooms => "custom_rooms" }
43
+ # bigbluebutton_routes :default,
44
+ # :controllers => { :servers => "custom_servers",
45
+ # :rooms => "custom_rooms",
46
+ # :recordings => "custom_recordings" }
39
47
  #
40
48
  # ==== Room matchers
41
49
  #
@@ -43,7 +51,7 @@ module ActionDispatch::Routing
43
51
  # Rooms can belong to users, communities or any other type of "entity" in an aplication.
44
52
  # This helper creates routes to the all the actions available in Bigbluebutton::RoomsController.
45
53
  #
46
- # bigbluebutton_routes :room_matchers
54
+ # bigbluebutton_routes :room_matchers
47
55
  #
48
56
  # You can, for example, create routes associated with users:
49
57
  #
@@ -55,10 +63,13 @@ module ActionDispatch::Routing
55
63
  #
56
64
  # user_room GET /users/:user_id/room/:id(.:format)
57
65
  # { :controller=>"bigbluebutton/rooms", :action=>"show" }
66
+ #
58
67
  # user_join_room GET /users/:user_id/room/:id/join(.:format)
59
68
  # { :controller=>"bigbluebutton/rooms", :action=>"join" }
69
+ #
60
70
  # user_end_room GET /users/:user_id/room/:id/end(.:format)
61
71
  # { :controller=>"bigbluebutton/rooms", :action=>"end" }
72
+ #
62
73
  # user_invite_room GET /users/:user_id/room/:id/invite(.:format)
63
74
  # { :controller=>"bigbluebutton/rooms", :action=>"invite" }
64
75
  #
@@ -72,14 +83,14 @@ module ActionDispatch::Routing
72
83
  def bigbluebutton_routes_default(*params) #:nodoc:
73
84
  options = params.extract_options!
74
85
  options_scope = options.has_key?(:scope) ? options[:scope] : BigbluebuttonRails.routing_scope
86
+ options_as = options.has_key?(:as) ? options[:as] : options_scope
87
+ options_only = options.has_key?(:only) ? options[:only] : ["servers", "rooms", "recordings"]
75
88
  BigbluebuttonRails.set_controllers(options[:controllers])
76
89
 
77
- scope options_scope, :as => options_scope do
78
- resources :servers, :controller => BigbluebuttonRails.controllers[:servers] do
79
- get :activity, :on => :member
80
- get :rooms, :on => :member
81
- end
82
- add_routes_for_rooms
90
+ scope options_scope, :as => options_as do
91
+ add_routes_for_servers if options_only.include?("servers")
92
+ add_routes_for_rooms if options_only.include?("rooms")
93
+ add_routes_for_recordings if options_only.include?("recordings")
83
94
  end
84
95
  end
85
96
 
@@ -87,7 +98,7 @@ module ActionDispatch::Routing
87
98
  add_routes_for_rooms
88
99
  end
89
100
 
90
- def add_routes_for_rooms
101
+ def add_routes_for_rooms #:nodoc:
91
102
  resources :rooms, :controller => BigbluebuttonRails.controllers[:rooms] do
92
103
  collection do
93
104
  get :external
@@ -100,10 +111,35 @@ module ActionDispatch::Routing
100
111
  get :invite
101
112
  get :join_mobile
102
113
  post :join, :action => :auth
114
+ post :fetch_recordings
115
+ get :recordings
116
+ end
117
+ end
118
+ end
119
+
120
+ def add_routes_for_servers #:nodoc:
121
+ resources :servers, :controller => BigbluebuttonRails.controllers[:servers] do
122
+ member do
123
+ get :activity
124
+ get :rooms
125
+ get :recordings
126
+ post :publish_recordings
127
+ post :unpublish_recordings
128
+ post :fetch_recordings
129
+ end
130
+ end
131
+ end
132
+
133
+ def add_routes_for_recordings #:nodoc:
134
+ resources :recordings, :except => [:new, :create],
135
+ :controller => BigbluebuttonRails.controllers[:recordings] do
136
+ member do
137
+ get :play
138
+ post :publish
139
+ post :unpublish
103
140
  end
104
141
  end
105
142
  end
106
143
 
107
144
  end
108
145
  end
109
-
@@ -1,3 +1,3 @@
1
1
  module BigbluebuttonRails
2
- VERSION = "1.2.0".freeze
2
+ VERSION = "1.3.0.beta1".freeze
3
3
  end
@@ -14,14 +14,6 @@ module BigbluebuttonRails
14
14
  copy_file "config/locales/en.yml", "config/locales/bigbluebutton_rails.en.yml" unless options.migration_only?
15
15
  end
16
16
 
17
- def copy_public_files
18
- unless options.migration_only?
19
- copy_file "public/javascripts/jquery.min.js", "public/javascripts/jquery.min.js"
20
- copy_file "public/images/loading.gif", "public/images/loading.gif"
21
- copy_file "public/stylesheets/bigbluebutton_rails.css", "public/stylesheets/bigbluebutton_rails.css"
22
- end
23
- end
24
-
25
17
  def self.next_migration_number(dirname)
26
18
  ActiveRecord::Generators::Base.next_migration_number(dirname)
27
19
  end
@@ -34,6 +26,14 @@ module BigbluebuttonRails
34
26
  end
35
27
  end
36
28
 
29
+ def create_schedule
30
+ unless options.migration_only?
31
+ create_file 'config/schedule.rb'
32
+ content = File.read(File.expand_path("../../../../config/schedule.rb", __FILE__))
33
+ append_file 'config/schedule.rb', "\n#{content}" unless behavior == :revoke
34
+ end
35
+ end
36
+
37
37
  protected
38
38
 
39
39
  def migration_path
@@ -9,6 +9,7 @@ class CreateBigbluebuttonRails < ActiveRecord::Migration
9
9
  t.string :param
10
10
  t.timestamps
11
11
  end
12
+
12
13
  create_table :bigbluebutton_rooms do |t|
13
14
  t.integer :server_id
14
15
  t.integer :owner_id
@@ -23,17 +24,52 @@ class CreateBigbluebuttonRails < ActiveRecord::Migration
23
24
  t.string :dial_number
24
25
  t.integer :max_participants
25
26
  t.boolean :private, :default => false
26
- t.boolean :randomize_meetingid, :default => true
27
27
  t.boolean :external, :default => false
28
28
  t.string :param
29
+ t.boolean :record, :default => false
30
+ t.integer :duration, :default => 0
29
31
  t.timestamps
30
32
  end
31
33
  add_index :bigbluebutton_rooms, :server_id
32
34
  add_index :bigbluebutton_rooms, :meetingid, :unique => true
33
35
  add_index :bigbluebutton_rooms, :voice_bridge, :unique => true
36
+
37
+ create_table :bigbluebutton_recordings do |t|
38
+ t.integer :server_id
39
+ t.integer :room_id
40
+ t.string :recordid
41
+ t.string :meetingid
42
+ t.string :name
43
+ t.boolean :published, :default => false
44
+ t.datetime :start_time
45
+ t.datetime :end_time
46
+ t.boolean :available, :default => true
47
+ t.timestamps
48
+ end
49
+ add_index :bigbluebutton_recordings, :room_id
50
+ add_index :bigbluebutton_recordings, :recordid, :unique => true
51
+
52
+ create_table :bigbluebutton_metadata do |t|
53
+ t.integer :owner_id
54
+ t.string :owner_type
55
+ t.string :name
56
+ t.text :content
57
+ t.timestamps
58
+ end
59
+
60
+ create_table :bigbluebutton_playback_formats do |t|
61
+ t.integer :recording_id
62
+ t.string :format_type
63
+ t.string :url
64
+ t.integer :length
65
+ t.timestamps
66
+ end
34
67
  end
35
68
 
36
69
  def self.down
70
+ drop_table :bigbluebutton_playback_formats
71
+ drop_table :bigbluebutton_metadata
72
+ drop_table :bigbluebutton_recordings
37
73
  drop_table :bigbluebutton_rooms
38
74
  drop_table :bigbluebutton_servers
39
75
  end
@@ -0,0 +1,55 @@
1
+ class BigbluebuttonRailsTo130 < ActiveRecord::Migration
2
+
3
+ def self.up
4
+ create_table :bigbluebutton_recordings do |t|
5
+ t.integer :server_id
6
+ t.integer :room_id
7
+ t.string :recordid
8
+ t.string :meetingid
9
+ t.string :name
10
+ t.boolean :published, :default => false
11
+ t.datetime :start_time
12
+ t.datetime :end_time
13
+ t.boolean :available, :default => true
14
+ t.timestamps
15
+ end
16
+ add_index :bigbluebutton_recordings, :room_id
17
+ add_index :bigbluebutton_recordings, :recordid, :unique => true
18
+
19
+ create_table :bigbluebutton_metadata do |t|
20
+ t.integer :owner_id
21
+ t.string :owner_type
22
+ t.string :name
23
+ t.text :content
24
+ t.timestamps
25
+ end
26
+
27
+ create_table :bigbluebutton_playback_formats do |t|
28
+ t.integer :recording_id
29
+ t.string :format_type
30
+ t.string :url
31
+ t.integer :length
32
+ t.timestamps
33
+ end
34
+
35
+ change_table(:bigbluebutton_rooms) do |t|
36
+ t.boolean :record, :default => false
37
+ t.integer :duration, :default => 0
38
+ end
39
+
40
+ remove_column :bigbluebutton_rooms, :randomize_meetingid
41
+ end
42
+
43
+ def self.down
44
+ add_column :bigbluebutton_rooms, :randomize_meetingid, :boolean, :default => true
45
+ change_table(:bigbluebutton_rooms) do |t|
46
+ t.remove :record
47
+ t.remove :duration
48
+ end
49
+ drop_table :bigbluebutton_playback_formats
50
+ drop_table :bigbluebutton_metadata
51
+ remove_index :bigbluebutton_recordings, :room_id
52
+ remove_index :bigbluebutton_recordings, :recordid
53
+ drop_table :bigbluebutton_recordings
54
+ end
55
+ end
@@ -0,0 +1,13 @@
1
+ class BigbluebuttonRailsTo130B < ActiveRecord::Migration
2
+
3
+ def self.up
4
+ # Generate a meetingID for every room
5
+ BigbluebuttonRoom.all.each do |room|
6
+ room.update_attributes(:meetingid => room.unique_meetingid)
7
+ end
8
+ end
9
+
10
+ def self.down
11
+ # Can't undo
12
+ end
13
+ end
@@ -3,14 +3,18 @@ require 'rails/generators/active_record'
3
3
  module BigbluebuttonRails
4
4
  module Generators
5
5
  class ViewsGenerator < Rails::Generators::Base
6
- source_root File.expand_path("../../../../app/views", __FILE__)
6
+ source_root File.expand_path("../../../../app", __FILE__)
7
7
  desc "Copies all bigbluebutton_rails views into your application folders."
8
8
 
9
9
  argument :scope, :required => false, :default => nil,
10
10
  :desc => "The scope to copy views to"
11
11
 
12
12
  def copy_views
13
- directory "bigbluebutton", "app/views/#{ scope || :bigbluebutton}"
13
+ directory "views/bigbluebutton", "app/views/#{ scope || :bigbluebutton}"
14
+ end
15
+
16
+ def copy_stylesheets
17
+ copy_file "assets/stylesheets/bigbluebutton_rails.css", "app/assets/stylesheets/bigbluebutton_rails.css"
14
18
  end
15
19
 
16
20
  end
@@ -0,0 +1,18 @@
1
+ namespace :bigbluebutton_rails do
2
+ namespace :recordings do
3
+
4
+ desc "Fetch recordings in all servers"
5
+ task :update => :environment do
6
+ BigbluebuttonServer.all.each do |server|
7
+ begin
8
+ server.fetch_recordings
9
+ rescue Exception => e
10
+ puts "Failure fetching recordings from #{server.inspect}"
11
+ puts e.inspect
12
+ puts e.backtrace.join "\n"
13
+ end
14
+ end
15
+ end
16
+
17
+ end
18
+ end
@@ -5,8 +5,8 @@ describe BigbluebuttonRails do
5
5
  BigbluebuttonRails.should be_a(Module)
6
6
  end
7
7
 
8
- it "should have an engine" do
9
- BigbluebuttonRails::Engine.new.should be_a_kind_of(Rails::Engine)
8
+ it "should have be an engine" do
9
+ BigbluebuttonRails::Engine.should be < Rails::Engine
10
10
  end
11
11
 
12
12
  describe "#value_to_boolean" do
@@ -0,0 +1,111 @@
1
+ require 'spec_helper'
2
+
3
+ describe Bigbluebutton::RecordingsController do
4
+ render_views
5
+ let(:recording) { FactoryGirl.create(:bigbluebutton_recording) }
6
+
7
+ context "json responses for" do
8
+
9
+ describe "#index" do
10
+ before do
11
+ @recording1 = FactoryGirl.create(:bigbluebutton_recording)
12
+ @recording2 = FactoryGirl.create(:bigbluebutton_recording)
13
+ end
14
+ before(:each) { get :index, :format => 'json' }
15
+ it { should respond_with(:success) }
16
+ it { should respond_with_content_type(:json) }
17
+ it { should respond_with_json([@recording1, @recording2].to_json) }
18
+ end
19
+
20
+ describe "#show" do
21
+ before(:each) { get :show, :id => recording.to_param, :format => 'json' }
22
+ it { should respond_with(:success) }
23
+ it { should respond_with_content_type(:json) }
24
+ it { should respond_with_json(recording.to_json) }
25
+ end
26
+
27
+ describe "#show" do
28
+ before(:each) { get :show, :id => recording.to_param, :format => 'json' }
29
+ it { should respond_with(:success) }
30
+ it { should respond_with_content_type(:json) }
31
+ it { should respond_with_json(recording.to_json) }
32
+ end
33
+
34
+ describe "#update" do
35
+ let(:new_recording) { FactoryGirl.build(:bigbluebutton_recording) }
36
+ before { @recording = recording }
37
+
38
+ context "on success" do
39
+ before(:each) {
40
+ put :update, :id => @recording.to_param, :bigbluebutton_recording => new_recording.attributes, :format => 'json'
41
+ }
42
+ it { should respond_with(:success) }
43
+ it { should respond_with_content_type(:json) }
44
+ end
45
+
46
+ context "on failure" do
47
+ before(:each) {
48
+ new_recording.recordid = nil # invalid
49
+ put :update, :id => @recording.to_param, :bigbluebutton_recording => new_recording.attributes, :format => 'json'
50
+ }
51
+ it { should respond_with(:unprocessable_entity) }
52
+ it { should respond_with_content_type(:json) }
53
+ it {
54
+ new_recording.save # should fail
55
+ should respond_with_json(new_recording.errors.full_messages.to_json)
56
+ }
57
+ end
58
+ end
59
+
60
+ describe "#destroy" do
61
+ before :each do
62
+ @recording = recording
63
+ @recording.server = nil
64
+ BigbluebuttonRecording.stub(:find_by_recordid) { @recording }
65
+ delete :destroy, :id => @recording.to_param, :format => 'json'
66
+ end
67
+ it { should respond_with(:success) }
68
+ it { should respond_with_content_type(:json) }
69
+ end
70
+
71
+ # these actions are essentially the same
72
+ [:publish, :unpublish].each do |action|
73
+ describe "##{action.to_s}" do
74
+ before { mock_server_and_api }
75
+ let(:flag) { action == :publish ? true : false }
76
+
77
+ context "on success" do
78
+ before {
79
+ mocked_server.should_receive(:send_publish_recordings).with(recording.recordid, flag)
80
+ }
81
+ before(:each) { post action, :id => recording.to_param, :format => 'json' }
82
+ it { should respond_with(:success) }
83
+ it { should respond_with_content_type(:json) }
84
+ it { should respond_with_json(I18n.t("bigbluebutton_rails.recordings.notice.#{action.to_s}.success")) }
85
+ end
86
+
87
+ context "on failure" do
88
+ let(:bbb_error_msg) { SecureRandom.hex(250) }
89
+ let(:bbb_error) { BigBlueButton::BigBlueButtonException.new(bbb_error_msg) }
90
+ before {
91
+ request.env["HTTP_REFERER"] = "/any"
92
+ mocked_server.should_receive(:send_publish_recordings) { raise bbb_error }
93
+ }
94
+ before(:each) { post action, :id => recording.to_param, :format => 'json' }
95
+ it { should respond_with(:error) }
96
+ it { should respond_with_content_type(:json) }
97
+ it { should respond_with_json(bbb_error_msg[0..200]) }
98
+ end
99
+
100
+ context "returns error if there's no server associated" do
101
+ before { recording.stub(:server) { nil } }
102
+ before(:each) { post action, :id => recording.to_param, :format => 'json' }
103
+ it { should respond_with(:error) }
104
+ it { should respond_with_content_type(:json) }
105
+ it { should respond_with_json(I18n.t('bigbluebutton_rails.recordings.errors.check_for_server.no_server')) }
106
+ end
107
+ end
108
+ end
109
+
110
+ end
111
+ end