bigbluebutton_rails 0.0.5 → 0.0.6

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 (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
@@ -3,7 +3,7 @@ Feature: Manage BigBlueButton rooms
3
3
  One needs to be able to create and manage BigBlueButton rooms
4
4
 
5
5
  Scenario: Register a new BigBlueButton room
6
- Given a BigBlueButton server
7
- When the user goes to the new BigBlueButton room page
8
- And registers a new BigBlueButton room
6
+ Given a server
7
+ When the user goes to the new room page
8
+ And registers a new room
9
9
  Then he should see the information about this room
@@ -4,6 +4,6 @@ Feature: Manage BigBlueButton servers
4
4
 
5
5
  Scenario: Register a new BigBlueButton server
6
6
  Given a user named "test user"
7
- When he goes to the new BigBlueButton server page
8
- And registers a new BigBlueButton server
7
+ When he goes to the new server page
8
+ And registers a new server
9
9
  Then he should see the information about this server
@@ -1,8 +1,8 @@
1
- Given /a BigBlueButton server/i do
1
+ When /a server/i do
2
2
  @server = Factory.create(:bigbluebutton_server_integration)
3
3
  end
4
4
 
5
- And /^registers a new BigBlueButton room$/i do
5
+ When /^registers a new room$/i do
6
6
  attrs = Factory.attributes_for(:bigbluebutton_room, :server => @server)
7
7
  fill_in("bigbluebutton_room[name]", :with => attrs[:name])
8
8
  fill_in("bigbluebutton_room[meetingid]", :with => attrs[:meetingid])
@@ -20,7 +20,7 @@ And /^registers a new BigBlueButton room$/i do
20
20
  click_button("Create")
21
21
  end
22
22
 
23
- Then /(?:|I ) should see the information about this room/ do
23
+ When /(?:|I ) should see the information about this room/i do
24
24
  room = BigbluebuttonRoom.last
25
25
  page_has_content(room.name)
26
26
  page_has_content(room.meetingid)
@@ -36,3 +36,29 @@ Then /(?:|I ) should see the information about this room/ do
36
36
  page_has_content(room.external)
37
37
  page_has_content(room.param)
38
38
  end
39
+
40
+ When /^an external room$/i do
41
+ @room = Factory.build(:bigbluebutton_room, :server => @server, :external => true)
42
+ @room.send_create
43
+ end
44
+
45
+ When /(?:|I ) should see a form to join the external room$/i do
46
+ within(form_selector(external_bigbluebutton_server_rooms_path(@server), 'post')) do
47
+ has_element("input", { :name => 'meeting', :type => 'hidden', :value => @room.meetingid })
48
+ has_element("input", { :name => 'user[name]', :type => 'text' })
49
+ has_element("input", { :name => 'user[password]', :type => 'password' })
50
+ end
51
+ end
52
+
53
+ When /his name should be in the appropriate input$/i do
54
+ within(form_selector(external_bigbluebutton_server_rooms_path(@server), 'post')) do
55
+ has_element("input", { :name => 'user[name]', :type => 'text', :value => @user.name })
56
+ end
57
+ end
58
+
59
+ When /^be able to join the room$/i do
60
+ fill_in("user[name]", :with => @user.name)
61
+ fill_in("user[password]", :with => @room.moderator_password)
62
+ click_button("Submit")
63
+ # TODO: check current_url to ensure it is inside the conference
64
+ end
@@ -1,9 +1,4 @@
1
- Given /a user named "(.+)"/i do |username|
2
- @username = username
3
- # TODO useless for now
4
- end
5
-
6
- And /^registers a new BigBlueButton server$/i do
1
+ When /^registers a new server$/i do
7
2
  attrs = Factory.attributes_for(:bigbluebutton_server_integration)
8
3
  fill_in("bigbluebutton_server[name]", :with => attrs[:name])
9
4
  fill_in("bigbluebutton_server[url]", :with => attrs[:url])
@@ -13,7 +8,7 @@ And /^registers a new BigBlueButton server$/i do
13
8
  click_button("Create")
14
9
  end
15
10
 
16
- Then /(?:|I ) should see the information about this server/ do
11
+ When /(?:|I ) should see the information about this server/ do
17
12
  server = BigbluebuttonServer.last
18
13
  page_has_content(server.name)
19
14
  page_has_content(server.url)
@@ -1,3 +1,16 @@
1
- When /(?:|I ) go(es)? to (.+) page$/i do |_, page_name|
2
- visit path_to(page_name)
1
+ When /(?:|I ) go(es)? to the (.+) page$/i do |_, page_name|
2
+ visit path_to(page_name, @params)
3
+ end
4
+
5
+ When /(?:|I ) go(es)? to the (.+) page for (.+)$/i do |_, page_name, param|
6
+ case page_name
7
+ when /join external room/i
8
+ @params = { :meeting => @room.meetingid }
9
+ end
10
+ visit path_to(page_name, @params)
11
+ end
12
+
13
+ When /a user named "(.+)"/i do |username|
14
+ @user = Factory.build(:user, :name => username)
15
+ ApplicationController.set_user(@user) # This is now the logged user
3
16
  end
@@ -24,6 +24,7 @@ require 'cgi'
24
24
  require File.expand_path(File.join(File.dirname(__FILE__), "..", "support", "paths"))
25
25
  require File.expand_path(File.join(File.dirname(__FILE__), "..", "support", "selectors"))
26
26
 
27
+ =begin
27
28
  module WithinHelpers
28
29
  def with_scope(locator)
29
30
  locator ? within(*selector_for(locator)) { yield } : yield
@@ -48,6 +49,7 @@ end
48
49
  When /^(?:|I )go to (.+)$/ do |page_name|
49
50
  visit path_to(page_name)
50
51
  end
52
+ =end
51
53
 
52
54
  When /^(?:|I )press "([^"]*)"$/ do |button|
53
55
  click_button(button)
@@ -102,6 +104,7 @@ When /^(?:|I )attach the file "([^"]*)" to "([^"]*)"$/ do |path, field|
102
104
  attach_file(field, File.expand_path(path))
103
105
  end
104
106
 
107
+ =begin
105
108
  Then /^(?:|I )should see "([^"]*)"$/ do |text|
106
109
  if page.respond_to? :should
107
110
  page.should have_content(text)
@@ -137,6 +140,7 @@ Then /^(?:|I )should not see \/([^\/]*)\/$/ do |regexp|
137
140
  assert page.has_no_xpath?('//*', :text => regexp)
138
141
  end
139
142
  end
143
+ =end
140
144
 
141
145
  Then /^the "([^"]*)" field(?: within (.*))? should contain "([^"]*)"$/ do |field, parent, value|
142
146
  with_scope(parent) do
@@ -183,7 +187,7 @@ Then /^the "([^"]*)" checkbox(?: within (.*))? should not be checked$/ do |label
183
187
  end
184
188
  end
185
189
  end
186
-
190
+
187
191
  Then /^(?:|I )should be on (.+)$/ do |page_name|
188
192
  current_path = URI.parse(current_url).path
189
193
  if current_path.respond_to? :should
@@ -197,8 +201,8 @@ Then /^(?:|I )should have the following query string:$/ do |expected_pairs|
197
201
  query = URI.parse(current_url).query
198
202
  actual_params = query ? CGI.parse(query) : {}
199
203
  expected_params = {}
200
- expected_pairs.rows_hash.each_pair{|k,v| expected_params[k] = v.split(',')}
201
-
204
+ expected_pairs.rows_hash.each_pair{|k,v| expected_params[k] = v.split(',')}
205
+
202
206
  if actual_params.respond_to? :should
203
207
  actual_params.should == expected_params
204
208
  else
@@ -0,0 +1,12 @@
1
+ # "Mock" the application controller so we can set the logged user from our features
2
+ class ApplicationController < ActionController::Base
3
+
4
+ def self.set_user(user)
5
+ @@user = user
6
+ end
7
+
8
+ def bigbluebutton_user
9
+ @@user
10
+ end
11
+
12
+ end
@@ -1,4 +1,13 @@
1
1
  module ContentHelpers
2
+
3
+ def page_has_content(text)
4
+ if page.respond_to? :should
5
+ page.should have_content(text)
6
+ else
7
+ assert page.has_content?(text)
8
+ end
9
+ end
10
+
2
11
  def page_has_content(text)
3
12
  if page.respond_to? :should
4
13
  page.should have_content(text)
@@ -6,6 +15,7 @@ module ContentHelpers
6
15
  assert page.has_content?(text)
7
16
  end
8
17
  end
18
+
9
19
  end
10
20
 
11
21
  World(ContentHelpers)
@@ -1,6 +1,6 @@
1
1
  # IMPORTANT: This file is generated by cucumber-rails - edit at your own peril.
2
- # It is recommended to regenerate this file in the future when you upgrade to a
3
- # newer version of cucumber-rails. Consider adding your own code to a new file
2
+ # It is recommended to regenerate this file in the future when you upgrade to a
3
+ # newer version of cucumber-rails. Consider adding your own code to a new file
4
4
  # instead of editing this one. Cucumber will automatically load all features/**/*.rb
5
5
  # files.
6
6
 
@@ -13,8 +13,8 @@ require 'cucumber/rails'
13
13
  Capybara.default_selector = :css
14
14
 
15
15
  # By default, any exception happening in your Rails application will bubble up
16
- # to Cucumber so that your scenario will fail. This is a different from how
17
- # your application behaves in the production environment, where an error page will
16
+ # to Cucumber so that your scenario will fail. This is a different from how
17
+ # your application behaves in the production environment, where an error page will
18
18
  # be rendered instead.
19
19
  #
20
20
  # Sometimes we want to override this default behaviour and allow Rails to rescue
@@ -6,4 +6,5 @@ Dir["#{File.dirname(__FILE__)}/../../../support/integration/**/*.rb"].each { |f|
6
6
  # Load the factories in the gem spec/factories folder
7
7
  require 'factory_girl'
8
8
  require 'forgery'
9
- Dir["#{ File.dirname(__FILE__)}/../../../factories/**/*.rb"].each { |f| require f }
9
+ Dir["#{ File.dirname(__FILE__)}/../../../factories/*.rb"].each { |f| require f }
10
+ Dir["#{ File.dirname(__FILE__)}/../../../factories/integration/*.rb"].each { |f| require f }
@@ -0,0 +1,12 @@
1
+ module FormsHelpers
2
+
3
+ # Creates a css selector to match a form with certain action, method and possibly other attribues
4
+ def form_selector(action, method='post', attrs={})
5
+ attrs[:action] = action
6
+ attrs[:method] = method
7
+ make_selector("form", attrs)
8
+ end
9
+
10
+ end
11
+
12
+ World(FormsHelpers)
@@ -5,15 +5,19 @@ module NavigationHelpers
5
5
  #
6
6
  # step definition in web_steps.rb
7
7
  #
8
- def path_to(page_name)
8
+ def path_to(page_name, params=nil)
9
+ params = "?" + params.map{ |k,v| "#{k}=#{CGI::escape(v)}" }.join("&") if params
10
+
9
11
  case page_name
10
12
 
11
- when /^the home\s?$/
12
- '/'
13
- when /the new bigbluebutton server/i
14
- new_bigbluebutton_server_path
15
- when /the new bigbluebutton room/i
16
- new_bigbluebutton_server_room_path(@server)
13
+ when /^home\s?$/
14
+ p = '/'
15
+ when /new server/i
16
+ p = new_bigbluebutton_server_path
17
+ when /new room/i
18
+ p = new_bigbluebutton_server_room_path(@server)
19
+ when /join external room/i
20
+ p = external_bigbluebutton_server_rooms_path(@server)
17
21
 
18
22
 
19
23
  # Add more mappings here.
@@ -23,15 +27,20 @@ module NavigationHelpers
23
27
  # user_profile_path(User.find_by_login($1))
24
28
 
25
29
  else
30
+ =begin
26
31
  begin
27
32
  page_name =~ /^the (.*) page$/
28
33
  path_components = $1.split(/\s+/)
29
34
  self.send(path_components.push('path').join('_').to_sym)
30
35
  rescue NoMethodError, ArgumentError
36
+ =end
31
37
  raise "Can't find mapping from \"#{page_name}\" to a path.\n" +
32
38
  "Now, go and add a mapping in #{__FILE__}"
33
- end
39
+ # end
34
40
  end
41
+
42
+ p += params if params
43
+ p
35
44
  end
36
45
  end
37
46
 
@@ -1,4 +1,61 @@
1
1
  module HtmlSelectorsHelpers
2
+
3
+ # Creates a selector (a string) using xpath or css selectors (default)
4
+ def make_selector(element, attrs={}, method=:css)
5
+ case method
6
+ when :xpath
7
+ # TODO: test xpath with multiple attrs
8
+ "//#{element}" + attrs.map{ |k,v| "[@#{k.to_s}='#{v.to_s}']" }.join
9
+ else # :css
10
+ "#{element}" + attrs.map{ |k,v| "[#{k.to_s}='#{v.to_s}']" }.join
11
+ end
12
+ end
13
+
14
+ # Ensures the page has certain element with certain attributes
15
+ # Same as has_element but for the entire page
16
+ def page_has_element(element, attrs={}, method=:css)
17
+ selector = make_selector(element, attrs, method)
18
+ if page.respond_to? :should
19
+ case method
20
+ when :xpath
21
+ page.should have_xpath(selector)
22
+ else # :css
23
+ page.should have_selector(selector)
24
+ end
25
+ else
26
+ case method
27
+ when :xpath
28
+ assert page.has_xpath?(selector)
29
+ else # :css
30
+ assert page.has_selector?(selector)
31
+ end
32
+ end
33
+ end
34
+
35
+ # Ensures there is a certain element with certain attributes
36
+ # Used inside "within" blocks
37
+ # Exemples (both will have the same result):
38
+ # has_element("input", { :name => 'meeting', :type => 'hidden', :value => 'my-value' })
39
+ # has_element("input[name='meeting'][type='hidden'][value='my-value']")
40
+ def has_element(element, attrs={}, method=:css)
41
+ selector = make_selector(element, attrs, method)
42
+ if respond_to? :should
43
+ case method
44
+ when :xpath
45
+ should have_xpath(selector)
46
+ else # :css
47
+ should have_selector(selector)
48
+ end
49
+ else
50
+ case method
51
+ when :xpath
52
+ assert has_xpath?(selector)
53
+ else # :css
54
+ assert has_xpath?(selector)
55
+ end
56
+ end
57
+ end
58
+
2
59
  # Maps a name to a selector. Used primarily by the
3
60
  #
4
61
  # When /^(.+) within (.+)$/ do |step, scope|
@@ -0,0 +1,7 @@
1
+ module WithinHelpers
2
+ def with_scope(locator)
3
+ locator ? within(*selector_for(locator)) { yield } : yield
4
+ end
5
+ end
6
+
7
+ World(WithinHelpers)
@@ -9,115 +9,123 @@ describe Bigbluebutton::RoomsController do
9
9
  ['bigbluebutton', 'webconference'].each do |prefix|
10
10
 
11
11
  it {
12
- {:get => "/#{prefix}/servers/1/rooms"}.
13
- should route_to(:controller => "bigbluebutton/rooms", :action => "index", :server_id => "1")
12
+ {:get => "/#{prefix}/servers/server-1/rooms"}.
13
+ should route_to(:controller => "bigbluebutton/rooms", :action => "index", :server_id => "server-1")
14
14
  }
15
15
  it {
16
- {:get => "/#{prefix}/servers/1/rooms/new"}.
17
- should route_to(:controller => "bigbluebutton/rooms", :action => "new", :server_id => "1")
16
+ {:get => "/#{prefix}/servers/server-1/rooms/new"}.
17
+ should route_to(:controller => "bigbluebutton/rooms", :action => "new", :server_id => "server-1")
18
18
  }
19
19
  it {
20
- {:get => "/#{prefix}/servers/1/rooms/1/edit"}.
21
- should route_to(:controller => "bigbluebutton/rooms", :action => "edit", :server_id => "1", :id => "1")
20
+ {:get => "/#{prefix}/servers/server-1/rooms/external"}.
21
+ should route_to(:controller => "bigbluebutton/rooms", :action => "external", :server_id => "server-1")
22
22
  }
23
23
  it {
24
- {:get => "/#{prefix}/servers/1/rooms/1"}.
25
- should route_to(:controller => "bigbluebutton/rooms", :action => "show", :server_id => "1", :id => "1")
24
+ {:post => "/#{prefix}/servers/server-1/rooms/external"}.
25
+ should route_to(:controller => "bigbluebutton/rooms", :action => "external_auth", :server_id => "server-1")
26
26
  }
27
27
  it {
28
- {:put => "/#{prefix}/servers/1/rooms/1"}.
29
- should route_to(:controller => "bigbluebutton/rooms", :action => "update", :server_id => "1", :id => "1")
28
+ {:get => "/#{prefix}/servers/server-1/rooms/room-1/edit"}.
29
+ should route_to(:controller => "bigbluebutton/rooms", :action => "edit", :server_id => "server-1", :id => "room-1")
30
30
  }
31
31
  it {
32
- {:delete => "/#{prefix}/servers/1/rooms/1"}.
33
- should route_to(:controller => "bigbluebutton/rooms", :action => "destroy", :server_id => "1", :id => "1")
32
+ {:get => "/#{prefix}/servers/server-1/rooms/room-1"}.
33
+ should route_to(:controller => "bigbluebutton/rooms", :action => "show", :server_id => "server-1", :id => "room-1")
34
34
  }
35
35
  it {
36
- {:get => "/#{prefix}/servers/1/rooms/1/join"}.
37
- should route_to(:controller => "bigbluebutton/rooms", :action => "join", :server_id => "1", :id => "1")
36
+ {:put => "/#{prefix}/servers/server-1/rooms/room-1"}.
37
+ should route_to(:controller => "bigbluebutton/rooms", :action => "update", :server_id => "server-1", :id => "room-1")
38
38
  }
39
39
  it {
40
- {:get => "/#{prefix}/servers/1/rooms/1/join_mobile"}.
41
- should route_to(:controller => "bigbluebutton/rooms", :action => "join_mobile", :server_id => "1", :id => "1")
40
+ {:delete => "/#{prefix}/servers/server-1/rooms/room-1"}.
41
+ should route_to(:controller => "bigbluebutton/rooms", :action => "destroy", :server_id => "server-1", :id => "room-1")
42
42
  }
43
43
  it {
44
- {:get => "/#{prefix}/servers/1/rooms/1/running"}.
45
- should route_to(:controller => "bigbluebutton/rooms", :action => "running", :server_id => "1", :id => "1")
44
+ {:get => "/#{prefix}/servers/server-1/rooms/room-1/join"}.
45
+ should route_to(:controller => "bigbluebutton/rooms", :action => "join", :server_id => "server-1", :id => "room-1")
46
46
  }
47
47
  it {
48
- {:get => "/#{prefix}/servers/1/rooms/1/end"}.
49
- should route_to(:controller => "bigbluebutton/rooms", :action => "end", :server_id => "1", :id => "1")
48
+ {:get => "/#{prefix}/servers/server-1/rooms/room-1/join_mobile"}.
49
+ should route_to(:controller => "bigbluebutton/rooms", :action => "join_mobile", :server_id => "server-1" ,:id => "room-1")
50
50
  }
51
51
  it {
52
- {:get => "/#{prefix}/servers/1/rooms/1/invite"}.
53
- should route_to(:controller => "bigbluebutton/rooms", :action => "invite", :server_id => "1", :id => "1")
52
+ {:get => "/#{prefix}/servers/server-1/rooms/room-1/running"}.
53
+ should route_to(:controller => "bigbluebutton/rooms", :action => "running", :server_id => "server-1", :id => "room-1")
54
54
  }
55
55
  it {
56
- {:post => "/#{prefix}/servers/1/rooms/1/join"}.
57
- should route_to(:controller => "bigbluebutton/rooms", :action => "auth", :server_id => "1", :id => "1")
56
+ {:get => "/#{prefix}/servers/server-1/rooms/room-1/end"}.
57
+ should route_to(:controller => "bigbluebutton/rooms", :action => "end", :server_id => "server-1", :id => "room-1")
58
+ }
59
+ it {
60
+ {:get => "/#{prefix}/servers/server-1/rooms/room-1/invite"}.
61
+ should route_to(:controller => "bigbluebutton/rooms", :action => "invite", :server_id => "server-1", :id => "room-1")
62
+ }
63
+ it {
64
+ {:post => "/#{prefix}/servers/server-1/rooms/room-1/join"}.
65
+ should route_to(:controller => "bigbluebutton/rooms", :action => "auth", :server_id => "server-1", :id => "room-1")
58
66
  }
59
67
 
60
68
  end
61
69
 
62
70
  # room matchers inside users
63
71
  it {
64
- should route(:get, "/users/1/room/1").
65
- to(:action => :show, :user_id => "1", :id => "1")
72
+ should route(:get, "/users/1/room/room-1").
73
+ to(:action => :show, :user_id => "1", :id => "room-1")
66
74
  }
67
75
  it {
68
- should route(:get, "/users/1/room/1/join").
69
- to(:action => :join, :user_id => "1", :id => "1")
76
+ should route(:get, "/users/1/room/room-1/join").
77
+ to(:action => :join, :user_id => "1", :id => "room-1")
70
78
  }
71
79
  it {
72
- should route(:get, "/users/1/room/1/join_mobile").
73
- to(:action => :join_mobile, :user_id => "1", :id => "1")
80
+ should route(:get, "/users/1/room/room-1/join_mobile").
81
+ to(:action => :join_mobile, :user_id => "1", :id => "room-1")
74
82
  }
75
83
  it {
76
- should route(:get, "/users/1/room/1/running").
77
- to(:action => :running, :user_id => "1", :id => "1")
84
+ should route(:get, "/users/1/room/room-1/running").
85
+ to(:action => :running, :user_id => "1", :id => "room-1")
78
86
  }
79
87
  it {
80
- should route(:get, "/users/1/room/1/end").
81
- to(:action => :end, :user_id => "1", :id => "1")
88
+ should route(:get, "/users/1/room/room-1/end").
89
+ to(:action => :end, :user_id => "1", :id => "room-1")
82
90
  }
83
91
  it {
84
- should route(:get, "/users/1/room/1/invite").
85
- to(:action => :invite, :user_id => "1", :id => "1")
92
+ should route(:get, "/users/1/room/room-1/invite").
93
+ to(:action => :invite, :user_id => "1", :id => "room-1")
86
94
  }
87
95
  it {
88
- should route(:post, "/users/1/room/1/join").
89
- to(:action => :auth, :user_id => "1", :id => "1")
96
+ should route(:post, "/users/1/room/room-1/join").
97
+ to(:action => :auth, :user_id => "1", :id => "room-1")
90
98
  }
91
99
 
92
100
  # room matchers inside users/spaces
93
101
  # FIXME shoulda-matcher is not working here, why?
94
102
  it {
95
- { :get => "/users/1/spaces/2/room/3" }.
96
- should route_to(:controller => "bigbluebutton/rooms", :action => "show", :user_id => "1", :space_id => "2", :id => "3")
103
+ { :get => "/users/1/spaces/2/room/room-1" }.
104
+ should route_to(:controller => "bigbluebutton/rooms", :action => "show", :user_id => "1", :space_id => "2", :id => "room-1")
97
105
  }
98
106
  it {
99
- { :get => "/users/1/spaces/2/room/3/join" }.
100
- should route_to(:controller => "bigbluebutton/rooms", :action => "join", :user_id => "1", :space_id => "2", :id => "3")
107
+ { :get => "/users/1/spaces/2/room/room-1/join" }.
108
+ should route_to(:controller => "bigbluebutton/rooms", :action => "join", :user_id => "1", :space_id => "2", :id => "room-1")
101
109
  }
102
110
  it {
103
- { :get => "/users/1/spaces/2/room/3/join_mobile" }.
104
- should route_to(:controller => "bigbluebutton/rooms", :action => "join_mobile", :user_id => "1", :space_id => "2", :id => "3")
111
+ { :get => "/users/1/spaces/2/room/room-1/join_mobile" }.
112
+ should route_to(:controller => "bigbluebutton/rooms", :action => "join_mobile", :user_id => "1", :space_id => "2", :id => "room-1")
105
113
  }
106
114
  it {
107
- { :get => "/users/1/spaces/2/room/3/running" }.
108
- should route_to(:controller => "bigbluebutton/rooms", :action => "running", :user_id => "1", :space_id => "2", :id => "3")
115
+ { :get => "/users/1/spaces/2/room/room-1/running" }.
116
+ should route_to(:controller => "bigbluebutton/rooms", :action => "running", :user_id => "1", :space_id => "2", :id => "room-1")
109
117
  }
110
118
  it {
111
- { :get => "/users/1/spaces/2/room/3/end" }.
112
- should route_to(:controller => "bigbluebutton/rooms", :action => "end", :user_id => "1", :space_id => "2", :id => "3")
119
+ { :get => "/users/1/spaces/2/room/room-1/end" }.
120
+ should route_to(:controller => "bigbluebutton/rooms", :action => "end", :user_id => "1", :space_id => "2", :id => "room-1")
113
121
  }
114
122
  it {
115
- { :get => "/users/1/spaces/2/room/3/invite" }.
116
- should route_to(:controller => "bigbluebutton/rooms", :action => "invite", :user_id => "1", :space_id => "2", :id => "3")
123
+ { :get => "/users/1/spaces/2/room/room-1/invite" }.
124
+ should route_to(:controller => "bigbluebutton/rooms", :action => "invite", :user_id => "1", :space_id => "2", :id => "room-1")
117
125
  }
118
126
  it {
119
- { :post => "/users/1/spaces/2/room/3/join" }.
120
- should route_to(:controller => "bigbluebutton/rooms", :action => "auth", :user_id => "1", :space_id => "2", :id => "3")
127
+ { :post => "/users/1/spaces/2/room/room-1/join" }.
128
+ should route_to(:controller => "bigbluebutton/rooms", :action => "auth", :user_id => "1", :space_id => "2", :id => "room-1")
121
129
  }
122
130
  end
123
131
 
@@ -20,20 +20,20 @@ describe Bigbluebutton::ServersController do
20
20
  should route_to(:controller => "bigbluebutton/servers", :action => "new")
21
21
  }
22
22
  it {
23
- {:get => "/#{prefix}/servers/1/edit"}.
24
- should route_to(:controller => "bigbluebutton/servers", :action => "edit", :id => "1")
23
+ {:get => "/#{prefix}/servers/server-1/edit"}.
24
+ should route_to(:controller => "bigbluebutton/servers", :action => "edit", :id => "server-1")
25
25
  }
26
26
  it {
27
- {:get => "/#{prefix}/servers/1"}.
28
- should route_to(:controller => "bigbluebutton/servers", :action => "show", :id => "1")
27
+ {:get => "/#{prefix}/servers/server-1"}.
28
+ should route_to(:controller => "bigbluebutton/servers", :action => "show", :id => "server-1")
29
29
  }
30
30
  it {
31
- {:put => "/#{prefix}/servers/1"}.
32
- should route_to(:controller => "bigbluebutton/servers", :action => "update", :id => "1")
31
+ {:put => "/#{prefix}/servers/server-1"}.
32
+ should route_to(:controller => "bigbluebutton/servers", :action => "update", :id => "server-1")
33
33
  }
34
34
  it {
35
- {:delete => "/#{prefix}/servers/1"}.
36
- should route_to(:controller => "bigbluebutton/servers", :action => "destroy", :id => "1")
35
+ {:delete => "/#{prefix}/servers/server-1"}.
36
+ should route_to(:controller => "bigbluebutton/servers", :action => "destroy", :id => "server-1")
37
37
  }
38
38
  end
39
39
 
data/spec/spec_helper.rb CHANGED
@@ -1,6 +1,11 @@
1
1
  # Configure Rails Envinronment
2
2
  ENV["RAILS_ENV"] = "test"
3
3
 
4
+ if RUBY_VERSION >= "1.9"
5
+ require 'simplecov'
6
+ SimpleCov.start 'rails'
7
+ end
8
+
4
9
  require "rails_app/config/environment"
5
10
  require "rails/test_help"
6
11
  require "rspec/rails"
@@ -0,0 +1,7 @@
1
+ def build_running_json(value, error=nil)
2
+ hash = { :running => "#{value}" }
3
+ hash[:error] = error unless error.nil?
4
+ hash.to_json
5
+ end
6
+
7
+
@@ -1,6 +1,6 @@
1
1
  module Shoulda
2
2
  module Matchers
3
- module ActiveRecord # :nodoc
3
+ module ActiveModel # :nodoc
4
4
 
5
5
  # Usage example: be_boolean(:private)
6
6
  def be_boolean(attribute)
@@ -0,0 +1,37 @@
1
+ # Checks calls to RoomsController.join_internal method when the user
2
+ # is an ATTENDEE (it can be the role of the current user or can be defined
3
+ # by the password the user typed)
4
+ #
5
+ # Arguments:
6
+ # room # the target BigbluebuttonRoom
7
+ # request # the request to be executed
8
+ # template # the template that should be rendered
9
+ #
10
+ # TODO: review if we really need this shared_example
11
+ shared_examples_for "internal join caller" do
12
+ before {
13
+ BigbluebuttonRoom.stub(:find_by_param).and_return(room)
14
+ controller.stub(:bigbluebutton_role).and_return(:attendee)
15
+ }
16
+
17
+ context "when the user has permission to join" do
18
+ before {
19
+ room.should_receive(:perform_join).with(user.name, :attendee, controller.request).
20
+ and_return("http://test.com/join/url")
21
+ }
22
+ before(:each) { request }
23
+ it { should respond_with(:redirect) }
24
+ it { should redirect_to("http://test.com/join/url") }
25
+ end
26
+
27
+ context "when the user doesn't have permission to join" do
28
+ before {
29
+ room.should_receive(:perform_join).with(user.name, :attendee, controller.request).
30
+ and_return(nil)
31
+ }
32
+ before(:each) { request }
33
+ it { should respond_with(:success) }
34
+ it { should render_template(template) }
35
+ it { should set_the_flash.to(I18n.t('bigbluebutton_rails.rooms.errors.auth.not_running')) }
36
+ end
37
+ end