bigbluebutton_rails 0.0.6 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (69) hide show
  1. data/.gitignore +1 -1
  2. data/CHANGELOG.rdoc +8 -0
  3. data/Gemfile +13 -7
  4. data/Gemfile.lock +112 -86
  5. data/README.rdoc +26 -80
  6. data/Rakefile +2 -1
  7. data/TODO_08 +13 -0
  8. data/app/controllers/bigbluebutton/rooms_controller.rb +9 -9
  9. data/app/controllers/bigbluebutton/servers_controller.rb +1 -1
  10. data/app/models/bigbluebutton_room.rb +16 -14
  11. data/app/models/bigbluebutton_server.rb +1 -1
  12. data/app/views/bigbluebutton/rooms/_form.html.erb +1 -1
  13. data/app/views/bigbluebutton/rooms/external.html.erb +3 -3
  14. data/app/views/bigbluebutton/rooms/invite.html.erb +3 -3
  15. data/app/views/bigbluebutton/servers/_form.html.erb +1 -1
  16. data/bigbluebutton_rails.gemspec +2 -2
  17. data/lib/bigbluebutton_rails/version.rb +1 -1
  18. data/spec/controllers/bigbluebutton/rooms_controller_spec.rb +42 -37
  19. data/spec/factories/bigbluebutton_room.rb +3 -1
  20. data/spec/models/bigbluebutton_room_db_spec.rb +34 -0
  21. data/spec/models/bigbluebutton_room_spec.rb +452 -457
  22. data/spec/models/bigbluebutton_server_db_spec.rb +14 -0
  23. data/spec/models/bigbluebutton_server_spec.rb +162 -176
  24. data/spec/rails_app/.gitignore +2 -1
  25. data/spec/rails_app/db/seeds.rb +16 -4
  26. data/spec/rails_app/features/activity_monitor_servers.feature +53 -0
  27. data/spec/rails_app/features/config.yml.example +13 -0
  28. data/spec/rails_app/features/create_rooms.feature +17 -0
  29. data/spec/rails_app/features/create_servers.feature +17 -0
  30. data/spec/rails_app/features/destroy_rooms.feature +12 -0
  31. data/spec/rails_app/features/destroy_servers.feature +11 -0
  32. data/spec/rails_app/features/edit_rooms.feature +26 -0
  33. data/spec/rails_app/features/edit_servers.feature +24 -0
  34. data/spec/rails_app/features/join_external_rooms.feature +61 -0
  35. data/spec/rails_app/features/join_mobile.feature +10 -0
  36. data/spec/rails_app/features/join_rooms.feature +117 -0
  37. data/spec/rails_app/features/list_and_show_rooms.feature +18 -0
  38. data/spec/rails_app/features/list_and_show_servers.feature +16 -0
  39. data/spec/rails_app/features/step_definitions/activity_monitor_servers_step.rb +102 -0
  40. data/spec/rails_app/features/step_definitions/common_steps.rb +99 -3
  41. data/spec/rails_app/features/step_definitions/create_rooms_steps.rb +38 -0
  42. data/spec/rails_app/features/step_definitions/{bigbluebutton_server_steps.rb → create_servers_steps.rb} +11 -6
  43. data/spec/rails_app/features/step_definitions/destroy_rooms_steps.rb +17 -0
  44. data/spec/rails_app/features/step_definitions/destroy_servers_steps.rb +15 -0
  45. data/spec/rails_app/features/step_definitions/edit_rooms_steps.rb +15 -0
  46. data/spec/rails_app/features/step_definitions/edit_servers_steps.rb +15 -0
  47. data/spec/rails_app/features/step_definitions/join_mobile_steps.rb +5 -0
  48. data/spec/rails_app/features/step_definitions/join_rooms_steps.rb +49 -0
  49. data/spec/rails_app/features/step_definitions/list_and_show_rooms_steps.rb +11 -0
  50. data/spec/rails_app/features/step_definitions/list_and_show_servers_steps.rb +11 -0
  51. data/spec/rails_app/features/support/configurations.rb +34 -0
  52. data/spec/rails_app/features/support/content.rb +27 -7
  53. data/spec/rails_app/features/support/env_custom.rb +21 -0
  54. data/spec/rails_app/features/support/factories/bigbluebutton_server_integration.rb +5 -0
  55. data/spec/rails_app/features/support/hooks.rb +14 -0
  56. data/spec/rails_app/features/support/locales.rb +18 -0
  57. data/spec/rails_app/features/support/paths.rb +25 -10
  58. data/spec/rails_app/features/support/selectors.rb +26 -0
  59. data/spec/rails_app/features/support/templates.rb +241 -0
  60. metadata +43 -20
  61. data/spec/factories/integration/bigbluebutton_server_integration.rb +0 -8
  62. data/spec/integration_conf.yml.example +0 -5
  63. data/spec/rails_app/features/join_external_bigbluebutton_rooms.feature +0 -19
  64. data/spec/rails_app/features/manage_bigbluebutton_rooms.feature +0 -9
  65. data/spec/rails_app/features/manage_bigbluebutton_servers.feature +0 -9
  66. data/spec/rails_app/features/step_definitions/bigbluebutton_room_steps.rb +0 -64
  67. data/spec/rails_app/features/support/env_gem.rb +0 -10
  68. data/spec/rails_app/features/support/forms.rb +0 -12
  69. data/spec/support/integration/integration_conf.rb +0 -16
@@ -1,16 +1,112 @@
1
- When /(?:|I ) go(es)? to the (.+) page$/i do |_, page_name|
2
- visit path_to(page_name, @params)
1
+ When /^a real server$/i do
2
+ @server = Factory.create(:bigbluebutton_server_integration)
3
+ end
4
+
5
+ When /^(\d+) server(s)?$/i do |count, _|
6
+ # Note: these servers are not real, it will NOT be possible to make api requests
7
+ # for a real server use :bigbluebutton_server_integration
8
+ # Use "a real server" whenever possible
9
+ count.to_i.times do
10
+ Factory.create(:bigbluebutton_server)
11
+ end
12
+ end
13
+
14
+ When /^a(n external)? room in this server$/i do |external|
15
+ if external.nil?
16
+ @room = Factory.create(:bigbluebutton_room, :server => @server)
17
+ else
18
+ @room = Factory.build(:bigbluebutton_room, :server => @server, :external => true)
19
+ end
20
+ @room.send_create
21
+ end
22
+
23
+ When /^a public room in this server$/i do
24
+ steps %Q{ When a room in this server }
25
+ @room.update_attributes(:private => false)
26
+ end
27
+
28
+ When /^a private room in this server$/i do
29
+ steps %Q{ When a room in this server }
30
+ @room.update_attributes(:private => true)
3
31
  end
4
32
 
5
- When /(?:|I ) go(es)? to the (.+) page for (.+)$/i do |_, page_name, param|
33
+ When /^(\d+) room(s)? in this server$/i do |count, _|
34
+ count.to_i.times do
35
+ steps %Q{ When a room in this server }
36
+ end
37
+ end
38
+
39
+ # Some paths will just redirect to other paths instead of rendering a view
40
+ # So we can set "(no view check)" and the view won't be verified
41
+ When /(?:|I ) go(es)? to the (.+) page( \(no view check\))?$/i do |_, page_name, not_check|
6
42
  case page_name
7
43
  when /join external room/i
8
44
  @params = { :meeting => @room.meetingid }
9
45
  end
10
46
  visit path_to(page_name, @params)
47
+ check_template(page_name) if not_check.nil?
48
+ end
49
+
50
+ When /see the (.+) page$/i do |page_name|
51
+ check_template(page_name)
11
52
  end
12
53
 
13
54
  When /a user named "(.+)"/i do |username|
14
55
  @user = Factory.build(:user, :name => username)
15
56
  ApplicationController.set_user(@user) # This is now the logged user
16
57
  end
58
+
59
+ When /an anonymous user/i do
60
+ @user = nil
61
+ ApplicationController.set_user(@user)
62
+ end
63
+
64
+ When /(?:|I ) should be at the (.+) URL$/i do |page_name|
65
+ current_url.should match(/#{path_to(page_name)}/)
66
+ end
67
+
68
+ When /^he should be redirected to the (.+) URL$/ do |page|
69
+ steps %Q{ When he should be at the #{page} URL }
70
+ end
71
+
72
+ When /^(he )?should see an error message with the message "(.+)"$/i do |_, msg|
73
+ key = message_to_locale_key(msg)
74
+ within(make_selector("div#error_explanation")) do
75
+ has_content(I18n.t(key))
76
+ end
77
+ end
78
+
79
+ When /^see (\d+) error(s)? in the field "(.+)"$/i do |errors, _, field_name|
80
+ within(make_selector("#error_explanation")) do
81
+ errors.to_i == 1 ? has_content("1 error:") : has_content("#{errors} errors:")
82
+ end
83
+ id = field_name.gsub(/\]?\[/, "_").gsub(/\]/, "")
84
+ has_element("div.field_with_errors > label", { :for => id })
85
+ has_element("div.field_with_errors > input##{id}", { :name => field_name })
86
+ end
87
+
88
+ When /^clicks in the button "(.+)"$/i do |button|
89
+ click_button(button)
90
+ end
91
+
92
+ When /^a meeting is running in this room$/ do
93
+ steps %Q{ When a meeting is running in this room with 1 attendees }
94
+ end
95
+
96
+ When /^a meeting is running in this room with (\d+) attendees$/ do |count|
97
+ msalt = FeaturesConfig.server.has_key?('mobile_salt') ? FeaturesConfig.server['mobile_salt'] : ""
98
+ BigBlueButtonBot.new(@server.api, @room.meetingid, msalt,
99
+ count.to_i, FeaturesConfig.root['timeout_bot_start'])
100
+ end
101
+
102
+
103
+ # helpers for development
104
+
105
+ When /is pending/i do
106
+ pending
107
+ end
108
+
109
+ When /puts the page/i do
110
+ puts current_url
111
+ puts body.inspect
112
+ end
@@ -0,0 +1,38 @@
1
+ When /^registers a new room$/i do
2
+ attrs = Factory.attributes_for(:bigbluebutton_room, :server => @server)
3
+ fill_in("bigbluebutton_room[name]", :with => attrs[:name])
4
+ fill_in("bigbluebutton_room[meetingid]", :with => attrs[:meetingid])
5
+ check("bigbluebutton_room[randomize_meetingid]") if attrs[:randomize_meetingid]
6
+ check("bigbluebutton_room[private]") if attrs[:private]
7
+ fill_in("bigbluebutton_room[attendee_password]", :with => attrs[:attendee_password])
8
+ fill_in("bigbluebutton_room[moderator_password]", :with => attrs[:moderator_password])
9
+ fill_in("bigbluebutton_room[welcome_msg]", :with => attrs[:welcome_msg])
10
+ fill_in("bigbluebutton_room[logout_url]", :with => attrs[:logout_url])
11
+ fill_in("bigbluebutton_room[dial_number]", :with => attrs[:dial_number])
12
+ fill_in("bigbluebutton_room[max_participants]", :with => attrs[:max_participants])
13
+ check("bigbluebutton_room[external]") if attrs[:external]
14
+ fill_in("bigbluebutton_room[param]", :with => attrs[:param])
15
+ # Note: voice_bridge is generated when the BigbluebuttonRoom is created
16
+ click_button("Create")
17
+ end
18
+
19
+ When /^registers a new room with wrong parameters$/i do
20
+ attrs = Factory.attributes_for(:bigbluebutton_room, :server => @server)
21
+ fill_in("bigbluebutton_room[name]", :with => nil) # invalid
22
+ fill_in("bigbluebutton_room[meetingid]", :with => attrs[:meetingid])
23
+ check("bigbluebutton_room[randomize_meetingid]") if attrs[:randomize_meetingid]
24
+ check("bigbluebutton_room[private]") if attrs[:private]
25
+ fill_in("bigbluebutton_room[attendee_password]", :with => attrs[:attendee_password])
26
+ fill_in("bigbluebutton_room[moderator_password]", :with => attrs[:moderator_password])
27
+ fill_in("bigbluebutton_room[welcome_msg]", :with => attrs[:welcome_msg])
28
+ fill_in("bigbluebutton_room[logout_url]", :with => attrs[:logout_url])
29
+ fill_in("bigbluebutton_room[dial_number]", :with => attrs[:dial_number])
30
+ fill_in("bigbluebutton_room[max_participants]", :with => attrs[:max_participants])
31
+ check("bigbluebutton_room[external]") if attrs[:external]
32
+ fill_in("bigbluebutton_room[param]", :with => attrs[:param])
33
+ click_button("Create")
34
+ end
35
+
36
+ When /(?:|I ) should see the information about this room/i do
37
+ steps %Q{ When see the show room page }
38
+ end
@@ -8,11 +8,16 @@ When /^registers a new server$/i do
8
8
  click_button("Create")
9
9
  end
10
10
 
11
+ When /^registers a new server with a wrong URL$/i do
12
+ attrs = Factory.attributes_for(:bigbluebutton_server_integration)
13
+ fill_in("bigbluebutton_server[name]", :with => attrs[:name])
14
+ fill_in("bigbluebutton_server[url]", :with => "invalid url")
15
+ fill_in("bigbluebutton_server[salt]", :with => attrs[:salt])
16
+ fill_in("bigbluebutton_server[version]", :with => attrs[:version])
17
+ fill_in("bigbluebutton_server[param]", :with => attrs[:param])
18
+ click_button("Create")
19
+ end
20
+
11
21
  When /(?:|I ) should see the information about this server/ do
12
- server = BigbluebuttonServer.last
13
- page_has_content(server.name)
14
- page_has_content(server.url)
15
- page_has_content(server.salt)
16
- page_has_content(server.version)
17
- page_has_content(server.param)
22
+ steps %Q{ When see the show server page }
18
23
  end
@@ -0,0 +1,17 @@
1
+ When /^clicks in the link to remove the first room$/i do
2
+ # there's only 1 room created, so only 1 "Destroy" link
3
+ click_link("Destroy")
4
+ end
5
+
6
+ When /^the removed room should not be listed$/i do
7
+ BigbluebuttonRoom.find_by_id(@room.id).should be_nil
8
+
9
+ # check params that are specific for this server
10
+ doesnt_have_content(@room.meetingid)
11
+ doesnt_have_content(@room.name)
12
+ doesnt_have_content(@room.attendee_password)
13
+ doesnt_have_content(@room.moderator_password)
14
+ doesnt_have_content(@room.voice_bridge)
15
+ doesnt_have_content(@room.param)
16
+ end
17
+
@@ -0,0 +1,15 @@
1
+ When /^clicks in the link to remove the first server$/i do
2
+ # there's only 1 server created, so only 1 "Destroy" link
3
+ click_link("Destroy")
4
+ end
5
+
6
+ When /^the removed server should not be listed$/i do
7
+ BigbluebuttonServer.find_by_id(@server.id).should be_nil
8
+
9
+ # check params that are specific for this server
10
+ doesnt_have_content(@server.name)
11
+ doesnt_have_content(@server.url)
12
+ doesnt_have_content(@server.salt)
13
+ doesnt_have_content(@server.param)
14
+ end
15
+
@@ -0,0 +1,15 @@
1
+ When /^change the room name to "(.*)"$/ do |name|
2
+ fill_in("bigbluebutton_room[name]", :with => name)
3
+ end
4
+
5
+ When /^click in the button to save the room$/ do
6
+ find(:css, "input#bigbluebutton_room_submit").click
7
+ end
8
+
9
+ Then /^the room name should( not)? be "(.+)"$/i do |negate, name|
10
+ if negate.nil?
11
+ BigbluebuttonRoom.first.name.should == name
12
+ else
13
+ BigbluebuttonRoom.first.name.should_not == name
14
+ end
15
+ end
@@ -0,0 +1,15 @@
1
+ When /^change the server URL to "(.+)"$/ do |url|
2
+ fill_in("bigbluebutton_server[url]", :with => url)
3
+ end
4
+
5
+ When /^click in the button to save the server$/ do
6
+ find(:css, "input#bigbluebutton_server_submit").click
7
+ end
8
+
9
+ Then /^the server URL should( not)? be "(.+)"$/i do |negate, url|
10
+ if negate.nil?
11
+ BigbluebuttonServer.first.url.should == url
12
+ else
13
+ BigbluebuttonServer.first.url.should_not == url
14
+ end
15
+ end
@@ -0,0 +1,5 @@
1
+ When /^he should see the QR code and a link to join using a mobile device$/i do
2
+ # FIXME this is already being checked in "he goes to the mobile join page"
3
+ # any better ideas?
4
+ check_template("mobile join")
5
+ end
@@ -0,0 +1,49 @@
1
+ When /^he should see a form to join the external room$/i do
2
+ within(form_selector(external_bigbluebutton_server_rooms_path(@server), 'post')) do
3
+ has_element("input", { :name => 'meeting', :type => 'hidden', :value => @room.meetingid })
4
+ has_element("input", { :name => 'user[name]', :type => 'text' })
5
+ has_element("input", { :name => 'user[password]', :type => 'password' })
6
+ end
7
+ end
8
+
9
+ When /^he should see his name in the user name input$/i do
10
+ case current_url
11
+ when /\/invite$/ # normal rooms
12
+ form = form_selector(join_bigbluebutton_server_room_path(@server, @room), 'post')
13
+ when /\/external(\?.*)?/ # external rooms
14
+ form = form_selector(external_bigbluebutton_server_rooms_path(@server), 'post')
15
+ end
16
+ within(form) do
17
+ has_element("input", { :name => 'user[name]', :type => 'text', :value => @user.name })
18
+ end
19
+ end
20
+
21
+ When /^he should( not)? join the conference room$/i do |negate|
22
+ if negate.nil?
23
+ current_url.should match(/\/client\/BigBlueButton\.html/) # BBB client page
24
+ else
25
+ current_url.should_not match(/\/client\/BigBlueButton\.html/)
26
+ end
27
+ end
28
+
29
+ When /^enters his name and the (.+) password$/i do |role|
30
+ name = @user.nil? ? "Anonymous" : @user.name
31
+ password = role.downcase.to_sym == :moderator ? @room.moderator_password : @room.attendee_password
32
+ fill_in("user[name]", :with => name)
33
+ fill_in("user[password]", :with => password)
34
+ end
35
+
36
+ When /^enters only the (.+) password$/ do |role|
37
+ password = role.downcase.to_sym == :moderator ? @room.moderator_password : @room.attendee_password
38
+ fill_in("user[password]", :with => password)
39
+ fill_in("user[name]", :with => "")
40
+ end
41
+
42
+ When /^enters only the user name$/ do
43
+ name = @user.nil? ? "Anonymous" : @user.name
44
+ fill_in("user[name]", :with => name)
45
+ end
46
+
47
+ When /^the password field was pre-filled with the attendee password$/ do
48
+ has_element("input", { :name => 'user[password]', :type => 'password', :value => @room.attendee_password })
49
+ end
@@ -0,0 +1,11 @@
1
+ When /^he should see all available rooms in the list$/i do
2
+ # FIXME this is already being checked in "he goes to the rooms index page"
3
+ # any better ideas?
4
+ check_template("rooms index")
5
+ end
6
+
7
+ When /^he should see all the information available for this room$/i do
8
+ # FIXME this is already being checked in "he goes to the show room page"
9
+ # any better ideas?
10
+ check_template("show room")
11
+ end
@@ -0,0 +1,11 @@
1
+ When /^he should see all available servers in the list$/i do
2
+ # FIXME this is already being checked in "he goes to the servers index page"
3
+ # any better ideas?
4
+ check_template("servers index")
5
+ end
6
+
7
+ When /^he should see all the information available for this server$/i do
8
+ # FIXME this is already being checked in "he goes to the show server page"
9
+ # any better ideas?
10
+ check_template("show server")
11
+ end
@@ -0,0 +1,34 @@
1
+ class FeaturesConfig
2
+ cattr_accessor :root # root of the config file
3
+ cattr_accessor :server # 'pointer' to the server selected
4
+
5
+ def self.load
6
+ self.server = nil
7
+ load_file
8
+ select_server
9
+ end
10
+
11
+ protected
12
+
13
+ def self.load_file
14
+ file = File.join(File.dirname(__FILE__), "..", "config.yml")
15
+ unless File.exists?(file)
16
+ throw Exception.new("Could not load #{file}. Please create it to be able to run the integration tests.")
17
+ end
18
+ self.root = YAML.load_file(file)
19
+ end
20
+
21
+ def self.select_server
22
+ if ENV['SERVER']
23
+ unless self.root['servers'].has_key?(ENV['SERVER'])
24
+ throw Exception.new("Server #{ENV['SERVER']} does not exists in your configuration file.")
25
+ end
26
+ server = self.root['servers'][ENV['SERVER']]
27
+ else
28
+ server = self.root['servers'].first[1]
29
+ end
30
+ server['version'] = '0.7' unless server.has_key?('version')
31
+ server['name'] = URI.parse(server['url']).host
32
+ self.server = server
33
+ end
34
+ end
@@ -1,18 +1,38 @@
1
1
  module ContentHelpers
2
2
 
3
- def page_has_content(text)
4
- if page.respond_to? :should
3
+ # Passing the xpath in the methods below is useful to check for
4
+ # content in any item of a list, for example
5
+ # page_has_content("Hi", './/li[@id="my-element"]'
6
+
7
+ def page_has_content(text, xpath=nil)
8
+ if xpath.nil?
5
9
  page.should have_content(text)
6
10
  else
7
- assert page.has_content?(text)
11
+ page.should_not have_xpath(xpath, :text => text)
8
12
  end
9
13
  end
10
14
 
11
- def page_has_content(text)
12
- if page.respond_to? :should
13
- page.should have_content(text)
15
+ def page_doesnt_have_content(text, xpath=nil)
16
+ if xpath.nil?
17
+ page.should_not have_content(text)
18
+ else
19
+ page.should_not have_xpath(xpath, :text => text)
20
+ end
21
+ end
22
+
23
+ def has_content(text, xpath=nil)
24
+ if xpath.nil?
25
+ should have_content(text)
26
+ else
27
+ should have_xpath(xpath, :text => text)
28
+ end
29
+ end
30
+
31
+ def doesnt_have_content(text, xpath=nil)
32
+ if xpath.nil?
33
+ should_not have_content(text)
14
34
  else
15
- assert page.has_content?(text)
35
+ should_not have_xpath(xpath, :text => text)
16
36
  end
17
37
  end
18
38
 
@@ -0,0 +1,21 @@
1
+ require 'capybara-webkit'
2
+ require 'capybara/mechanize/cucumber'
3
+ require 'bigbluebutton_bot'
4
+
5
+ # Load the environment in the gem folders, not in the rails_app
6
+ # Load the factories in the gem spec/factories folder
7
+ require 'factory_girl'
8
+ require 'forgery'
9
+ Dir["#{ File.dirname(__FILE__)}/../../../factories/*.rb"].each { |f| require f }
10
+
11
+ # Found at: http://www.emmanueloga.com/2011/07/26/taming-a-capybara.html
12
+ # Big Fat Hack (TM) so the ActiveRecord connections are shared across threads.
13
+ # This is a variation of a hack you can find all over the web to make
14
+ # capybara usable without having to switch to non transactional
15
+ # fixtures.
16
+ # http://groups.google.com/group/ruby-capybara/browse_thread/thread/248e89ae2acbf603/e5da9e9bfac733e0
17
+ # https://groups.google.com/forum/#!msg/ruby-capybara/JI6JrirL9gM/R6YiXj4gi_UJ
18
+ Thread.main[:activerecord_connection] = ActiveRecord::Base.retrieve_connection
19
+ def (ActiveRecord::Base).connection
20
+ Thread.main[:activerecord_connection]
21
+ end
@@ -0,0 +1,5 @@
1
+ Factory.define :bigbluebutton_server_integration, :parent => :bigbluebutton_server do |s|
2
+ s.url { FeaturesConfig.server["url"] }
3
+ s.salt { FeaturesConfig.server["salt"] }
4
+ s.version { FeaturesConfig.server["version"] }
5
+ end
@@ -0,0 +1,14 @@
1
+ Before do
2
+ FeaturesConfig.load # load the global configs
3
+ end
4
+
5
+ After do |scenario|
6
+ BigBlueButtonBot.finalize
7
+ end
8
+
9
+ Before('@webkit') do
10
+ Capybara.current_driver = :webkit
11
+ end
12
+ After('@webkit') do
13
+ Capybara.use_default_driver
14
+ end