bigbluebutton_rails 1.4.0 → 2.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 (125) hide show
  1. checksums.yaml +7 -0
  2. data/.ruby-version +1 -1
  3. data/.travis.yml +10 -1
  4. data/CHANGELOG.md +259 -0
  5. data/Gemfile +14 -19
  6. data/Gemfile.lock +194 -188
  7. data/README.md +416 -0
  8. data/Rakefile +12 -12
  9. data/TODO.md +13 -0
  10. data/app/controllers/bigbluebutton/playback_types_controller.rb +44 -0
  11. data/app/controllers/bigbluebutton/recordings_controller.rb +17 -10
  12. data/app/controllers/bigbluebutton/rooms_controller.rb +65 -36
  13. data/app/controllers/bigbluebutton/servers_controller.rb +12 -8
  14. data/app/models/bigbluebutton_metadata.rb +1 -1
  15. data/app/models/bigbluebutton_playback_format.rb +22 -1
  16. data/app/models/bigbluebutton_playback_type.rb +29 -0
  17. data/app/models/bigbluebutton_recording.rb +38 -19
  18. data/app/models/bigbluebutton_room.rb +150 -73
  19. data/app/models/bigbluebutton_room_options.rb +10 -7
  20. data/app/models/bigbluebutton_server.rb +69 -13
  21. data/app/models/bigbluebutton_server_config.rb +49 -0
  22. data/app/views/bigbluebutton/recordings/_form.html.erb +4 -0
  23. data/app/views/bigbluebutton/recordings/_recordings.html.erb +10 -3
  24. data/app/views/bigbluebutton/rooms/_form.html.erb +18 -6
  25. data/app/views/bigbluebutton/rooms/_rooms.html.erb +6 -3
  26. data/app/views/bigbluebutton/rooms/invite.html.erb +5 -5
  27. data/app/views/bigbluebutton/rooms/show.html.erb +18 -6
  28. data/app/views/bigbluebutton/servers/_form.html.erb +1 -1
  29. data/app/views/bigbluebutton/servers/show.html.erb +5 -0
  30. data/app/workers/bigbluebutton_finish_meetings.rb +11 -0
  31. data/app/workers/bigbluebutton_update_recordings.rb +11 -0
  32. data/app/workers/bigbluebutton_update_server_configs.rb +18 -0
  33. data/bigbluebutton_rails.gemspec +8 -7
  34. data/config/locales/en.yml +52 -7
  35. data/config/locales/pt-br.yml +162 -0
  36. data/config/resque/resque.rake +27 -0
  37. data/config/resque/workers_schedule.yml +17 -0
  38. data/lib/bigbluebutton_rails.rb +30 -2
  39. data/lib/bigbluebutton_rails/background_tasks.rb +31 -0
  40. data/lib/bigbluebutton_rails/controller_methods.rb +12 -8
  41. data/lib/bigbluebutton_rails/dial_number.rb +48 -0
  42. data/lib/bigbluebutton_rails/rails/routes.rb +9 -2
  43. data/lib/bigbluebutton_rails/utils.rb +9 -2
  44. data/lib/bigbluebutton_rails/version.rb +1 -1
  45. data/lib/generators/bigbluebutton_rails/install_generator.rb +0 -8
  46. data/lib/generators/bigbluebutton_rails/templates/migration.rb +28 -6
  47. data/lib/generators/bigbluebutton_rails/templates/migration_2_0_0.rb +56 -0
  48. data/lib/tasks/bigbluebutton_rails/meetings.rake +1 -13
  49. data/lib/tasks/bigbluebutton_rails/recordings.rake +1 -12
  50. data/lib/tasks/bigbluebutton_rails/server_configs.rake +10 -0
  51. data/spec/bigbluebutton_rails_spec.rb +0 -13
  52. data/spec/controllers/bigbluebutton/playback_types_controller_spec.rb +76 -0
  53. data/spec/controllers/bigbluebutton/recordings_controller_spec.rb +109 -37
  54. data/spec/controllers/bigbluebutton/rooms_controller_exception_handling_spec.rb +1 -0
  55. data/spec/controllers/bigbluebutton/rooms_controller_json_responses_spec.rb +27 -3
  56. data/spec/controllers/bigbluebutton/rooms_controller_spec.rb +338 -77
  57. data/spec/controllers/bigbluebutton/servers_controller_json_responses_spec.rb +8 -0
  58. data/spec/controllers/bigbluebutton/servers_controller_spec.rb +182 -47
  59. data/spec/factories/bigbluebutton_meeting.rb +2 -2
  60. data/spec/factories/bigbluebutton_playback_format.rb +2 -2
  61. data/spec/factories/bigbluebutton_playback_type.rb +7 -0
  62. data/spec/factories/bigbluebutton_recording.rb +8 -0
  63. data/spec/factories/bigbluebutton_room.rb +10 -3
  64. data/spec/factories/bigbluebutton_server.rb +6 -1
  65. data/spec/factories/bigbluebutton_server_config.rb +6 -0
  66. data/spec/generators/install_generator_spec.rb +0 -16
  67. data/spec/lib/bigbluebutton_rails/background_tasks_spec.rb +61 -0
  68. data/spec/lib/bigbluebutton_rails/dial_number_spec.rb +78 -0
  69. data/spec/lib/bigbluebutton_rails/utils_spec.rb +56 -0
  70. data/spec/lib/tasks/meetings_rake_spec.rb +14 -1
  71. data/spec/lib/tasks/recordings_rake_spec.rb +14 -1
  72. data/spec/models/bigbluebutton_meeting_db_spec.rb +3 -3
  73. data/spec/models/bigbluebutton_meeting_spec.rb +4 -4
  74. data/spec/models/bigbluebutton_playback_format_db_spec.rb +0 -1
  75. data/spec/models/bigbluebutton_playback_format_spec.rb +75 -4
  76. data/spec/models/bigbluebutton_playback_type_db_spec.rb +14 -0
  77. data/spec/models/bigbluebutton_playback_type_spec.rb +76 -0
  78. data/spec/models/bigbluebutton_recording_db_spec.rb +3 -1
  79. data/spec/models/bigbluebutton_recording_spec.rb +234 -58
  80. data/spec/models/bigbluebutton_room_db_spec.rb +8 -6
  81. data/spec/models/bigbluebutton_room_options_db_spec.rb +1 -0
  82. data/spec/models/bigbluebutton_room_options_spec.rb +137 -38
  83. data/spec/models/bigbluebutton_room_spec.rb +540 -153
  84. data/spec/models/bigbluebutton_server_config_spec.rb +115 -0
  85. data/spec/models/bigbluebutton_server_spec.rb +180 -23
  86. data/spec/rails_app/app/controllers/my_playback_types_controller.rb +7 -0
  87. data/spec/rails_app/app/views/frontpage/show.html.erb +1 -0
  88. data/spec/rails_app/app/views/my_playback_types/index.html.erb +33 -0
  89. data/spec/rails_app/config/application.rb +0 -3
  90. data/spec/rails_app/config/database.yml.travis +10 -0
  91. data/spec/rails_app/config/environments/development.rb +1 -6
  92. data/spec/rails_app/config/environments/production.rb +2 -0
  93. data/spec/rails_app/config/environments/test.rb +2 -0
  94. data/spec/rails_app/config/routes.rb +5 -2
  95. data/spec/rails_app/db/seeds.rb +1 -1
  96. data/spec/rails_app/features/config.yml.example +3 -4
  97. data/spec/rails_app/features/join_rooms.feature +14 -14
  98. data/spec/rails_app/features/step_definitions/activity_monitor_servers_step.rb +2 -2
  99. data/spec/rails_app/features/step_definitions/create_rooms_steps.rb +4 -4
  100. data/spec/rails_app/features/step_definitions/destroy_rooms_steps.rb +2 -2
  101. data/spec/rails_app/features/step_definitions/join_rooms_steps.rb +10 -10
  102. data/spec/rails_app/features/step_definitions/web_steps.rb +2 -2
  103. data/spec/rails_app/features/support/configurations.rb +1 -1
  104. data/spec/rails_app/features/support/templates.rb +12 -12
  105. data/spec/rails_app/lib/tasks/db/populate.rake +19 -6
  106. data/spec/routing/bigbluebutton/custom_controllers_routing_spec.rb +1 -1
  107. data/spec/routing/bigbluebutton/recordings_only_routing_spec.rb +2 -2
  108. data/spec/routing/bigbluebutton/recordings_routing_spec.rb +2 -2
  109. data/spec/routing/bigbluebutton/rooms_only_routing_spec.rb +1 -1
  110. data/spec/routing/bigbluebutton/rooms_routing_spec.rb +15 -1
  111. data/spec/routing/bigbluebutton/servers_only_routing_spec.rb +1 -1
  112. data/spec/routing/bigbluebutton/servers_routing_spec.rb +1 -1
  113. data/spec/spec_helper.rb +23 -31
  114. data/spec/support/matchers/delegate_matcher.rb +8 -1
  115. data/spec/support/matchers/shoulda/respond_with_json_matcher.rb +2 -2
  116. data/spec/support/mocked_server.rb +2 -0
  117. data/spec/support/shared_contexts/rake.rb +23 -0
  118. data/spec/workers/bigbluebutton_finish_meetings_spec.rb +14 -0
  119. data/spec/workers/bigbluebutton_update_recordings_spec.rb +14 -0
  120. data/spec/workers/bigbluebutton_update_server_configs_spec.rb +47 -0
  121. metadata +70 -59
  122. data/CHANGELOG.rdoc +0 -111
  123. data/README.rdoc +0 -319
  124. data/TODO.rdoc +0 -16
  125. data/config/schedule.rb +0 -7
@@ -3,7 +3,12 @@ FactoryGirl.define do
3
3
  s.sequence(:name) { |n| "Server #{n}" }
4
4
  s.sequence(:url) { |n| "http://bigbluebutton#{n}.test.com/bigbluebutton/api" }
5
5
  s.salt { Forgery(:basic).password :at_least => 30, :at_most => 40 }
6
- s.version '0.8'
6
+ s.version '0.9'
7
7
  s.sequence(:param) { |n| "server-#{n}" }
8
8
  end
9
+
10
+ after(:create) do |s|
11
+ s.updated_at = s.updated_at.change(:usec => 0)
12
+ s.created_at = s.created_at.change(:usec => 0)
13
+ end
9
14
  end
@@ -0,0 +1,6 @@
1
+ FactoryGirl.define do
2
+ factory :bigbluebutton_server_config do |c|
3
+ c.available_layouts ["Web Conference", "Video", "Chat"]
4
+ c.association :server, factory: :bigbluebutton_server
5
+ end
6
+ end
@@ -18,14 +18,12 @@ describe BigbluebuttonRails::Generators::InstallGenerator do
18
18
  it "all files are properly created" do
19
19
  assert_migration "db/migrate/create_bigbluebutton_rails.rb"
20
20
  assert_file "config/locales/bigbluebutton_rails.en.yml"
21
- assert_file "config/schedule.rb"
22
21
  end
23
22
 
24
23
  it "all files are properly destroyed" do
25
24
  run_generator %w(), :behavior => :revoke
26
25
  assert_no_migration "db/migrate/create_bigbluebutton_rails.rb"
27
26
  assert_no_file "config/locales/bigbluebutton_rails.en.yml"
28
- assert_no_file "config/schedule.rb"
29
27
  end
30
28
  end
31
29
 
@@ -38,20 +36,6 @@ describe BigbluebuttonRails::Generators::InstallGenerator do
38
36
  it "only the migration is created" do
39
37
  assert_migration "db/migrate/create_bigbluebutton_rails.rb"
40
38
  assert_no_file "config/locales/bigbluebutton_rails.en.yml"
41
- assert_no_file "config/schedule.rb"
42
- end
43
- end
44
-
45
- context "config/schedule.rb" do
46
- before(:all) do
47
- prepare_destination
48
- run_generator
49
- end
50
-
51
- it "has the correct content" do
52
- assert_file "config/schedule.rb"
53
- content = File_.read(File_.expand_path("../../../config/schedule.rb", __FILE__))
54
- File_.read("config/schedule.rb").should match(content)
55
39
  end
56
40
  end
57
41
 
@@ -0,0 +1,61 @@
1
+ require 'spec_helper'
2
+
3
+ describe BigbluebuttonRails::BackgroundTasks do
4
+
5
+ describe ".finish_meetings" do
6
+
7
+ context "set meetings that ended as not running" do
8
+ let(:room) { FactoryGirl.create(:bigbluebutton_room) }
9
+ let!(:meeting) { FactoryGirl.create(:bigbluebutton_meeting, running: true, room: room) }
10
+ before {
11
+ BigBlueButton::BigBlueButtonApi.any_instance
12
+ .stub(:get_api_version).and_return("0.9")
13
+ BigBlueButton::BigBlueButtonApi.any_instance
14
+ .should_receive(:is_meeting_running?).once.with(room.meetingid).and_return(false)
15
+ }
16
+ before(:each) { BigbluebuttonRails::BackgroundTasks.finish_meetings }
17
+ it { meeting.reload.running.should be false }
18
+ end
19
+
20
+ context "doesn't change meetings that are still running" do
21
+ let(:room) { FactoryGirl.create(:bigbluebutton_room) }
22
+ let!(:meeting) { FactoryGirl.create(:bigbluebutton_meeting, running: true, room: room) }
23
+ before {
24
+ BigBlueButton::BigBlueButtonApi.any_instance
25
+ .stub(:get_api_version).and_return("0.9")
26
+ BigBlueButton::BigBlueButtonApi.any_instance
27
+ .should_receive(:is_meeting_running?).once.with(room.meetingid).and_return(true)
28
+ }
29
+ before(:each) { BigbluebuttonRails::BackgroundTasks.finish_meetings }
30
+ it { meeting.reload.running.should be true }
31
+ end
32
+
33
+ context "ignores meetings that are not running" do
34
+ let(:room) { FactoryGirl.create(:bigbluebutton_room) }
35
+ let!(:meeting) { FactoryGirl.create(:bigbluebutton_meeting, running: false, room: room) }
36
+ before {
37
+ BigBlueButton::BigBlueButtonApi.any_instance.should_not_receive(:is_meeting_running?)
38
+ }
39
+ before(:each) { BigbluebuttonRails::BackgroundTasks.finish_meetings }
40
+ it { meeting.reload.running.should be false }
41
+ end
42
+
43
+ it "works for multiple meetings"
44
+ end
45
+
46
+ describe ".update_recordings" do
47
+
48
+ context "fetches the meetings for all servers" do
49
+ let!(:server1) { FactoryGirl.create(:bigbluebutton_server) }
50
+ let!(:server2) { FactoryGirl.create(:bigbluebutton_server) }
51
+ before {
52
+ BigbluebuttonServer.stub(:find_each).and_yield(server1).and_yield(server2)
53
+ server1.should_receive(:fetch_recordings).once
54
+ server2.should_receive(:fetch_recordings).once
55
+ }
56
+ it { BigbluebuttonRails::BackgroundTasks.update_recordings }
57
+ end
58
+
59
+ it "doesn't break if exceptions are returned"
60
+ end
61
+ end
@@ -0,0 +1,78 @@
1
+ require 'spec_helper'
2
+
3
+ describe BigbluebuttonRails::DialNumber do
4
+
5
+ describe '#randomize' do
6
+ context 'with no arguments informed' do
7
+ it { BigbluebuttonRails::DialNumber.randomize.should be_nil }
8
+ end
9
+
10
+ context 'pattern "6xxx-xx"' do
11
+ it { BigbluebuttonRails::DialNumber.randomize('6xxx-xx').should match(/^6\d\d\d-\d\d$/) }
12
+ end
13
+
14
+ context 'pattern "0AA-xAAA" and custom symbol "A"' do
15
+ it {
16
+ BigbluebuttonRails::DialNumber.randomize('0AA-xAAA', symbol: 'A').should match(/^\d\d\d-x\d\d\d$/)
17
+ }
18
+ end
19
+
20
+ context 'pattern only with variables: "(xx) xxxx-xxxx"' do
21
+ it {
22
+ BigbluebuttonRails::DialNumber.randomize('(xx) xxxx-xxxx').should match(/^\(\d\d\) \d\d\d\d-\d\d\d\d$/)
23
+ }
24
+ end
25
+
26
+ context 'pattern without variables: "(51) 1234"' do
27
+ it {
28
+ BigbluebuttonRails::DialNumber.randomize('(51) 1234').should eq("(51) 1234")
29
+ }
30
+ end
31
+ end
32
+
33
+ describe '#get_dial_number_from_ordinal' do
34
+ let(:pattern) { '98xxxx-xxx'}
35
+ let(:n1) { 34 }
36
+ let(:n2) { 142 }
37
+ let(:n3) { 2112 }
38
+
39
+ it { BigbluebuttonRails::DialNumber.get_dial_number_from_ordinal(n1, pattern).should eq('980000-034') }
40
+ it { BigbluebuttonRails::DialNumber.get_dial_number_from_ordinal(n2, pattern).should eq('980000-142') }
41
+ it { BigbluebuttonRails::DialNumber.get_dial_number_from_ordinal(n3, pattern).should eq('980002-112') }
42
+
43
+ context 'with pattern as nil' do
44
+ it { BigbluebuttonRails::DialNumber.get_dial_number_from_ordinal(n1, nil).should eq(nil) }
45
+ it { BigbluebuttonRails::DialNumber.get_dial_number_from_ordinal(n2, nil).should eq(nil) }
46
+ it { BigbluebuttonRails::DialNumber.get_dial_number_from_ordinal(n3, nil).should eq(nil) }
47
+ end
48
+ end
49
+
50
+ describe '#get_ordinal_from_dial_number' do
51
+ let(:pattern) { '67xxx-xxx'}
52
+ let(:n1) { '67000-001' }
53
+ let(:n2) { '67001-001' }
54
+ let(:n3) { '67123-321' }
55
+
56
+ it { BigbluebuttonRails::DialNumber.get_ordinal_from_dial_number(n1, pattern).should eq(1) }
57
+ it { BigbluebuttonRails::DialNumber.get_ordinal_from_dial_number(n2, pattern).should eq(1001) }
58
+ it { BigbluebuttonRails::DialNumber.get_ordinal_from_dial_number(n3, pattern).should eq(123321) }
59
+
60
+ context 'with pattern as nil' do
61
+ let(:pattern) { nil }
62
+
63
+ it { BigbluebuttonRails::DialNumber.get_ordinal_from_dial_number(n1, pattern).should eq(nil) }
64
+ it { BigbluebuttonRails::DialNumber.get_ordinal_from_dial_number(n2, pattern).should eq(nil) }
65
+ it { BigbluebuttonRails::DialNumber.get_ordinal_from_dial_number(n3, pattern).should eq(nil) }
66
+ end
67
+
68
+ context 'with a pattern that doesnt match the number' do
69
+ let(:pattern) { '88xxx-xxx' }
70
+
71
+ it { BigbluebuttonRails::DialNumber.get_ordinal_from_dial_number(n1, pattern).should eq(nil) }
72
+ it { BigbluebuttonRails::DialNumber.get_ordinal_from_dial_number(n2, pattern).should eq(nil) }
73
+ it { BigbluebuttonRails::DialNumber.get_ordinal_from_dial_number(n3, pattern).should eq(nil) }
74
+ end
75
+
76
+ end
77
+
78
+ end
@@ -0,0 +1,56 @@
1
+ require 'spec_helper'
2
+
3
+ describe BigbluebuttonRails do
4
+
5
+ describe '.use_mobile_client?' do
6
+ before do
7
+ @browser = double
8
+ BigbluebuttonRails.stub(:browser).and_return(@browser)
9
+ end
10
+
11
+ context 'for a mobile device' do
12
+ before do
13
+ @browser.stub(:mobile?).and_return(true)
14
+ @browser.stub(:tablet?).and_return(false)
15
+ end
16
+ it { BigbluebuttonRails.use_mobile_client?(@browser).should be(true) }
17
+ end
18
+
19
+ context 'for a tablet' do
20
+ before do
21
+ @browser.stub(:mobile?).and_return(false)
22
+ @browser.stub(:tablet?).and_return(true)
23
+ end
24
+ it { BigbluebuttonRails.use_mobile_client?(@browser).should be(true) }
25
+ end
26
+
27
+ context 'not a mobile device nor tablet' do
28
+ before do
29
+ @browser.stub(:mobile?).and_return(false)
30
+ @browser.stub(:tablet?).and_return(false)
31
+ end
32
+ it { BigbluebuttonRails.use_mobile_client?(@browser).should be(false) }
33
+ end
34
+
35
+ # some user-agents where errors happened in the past
36
+ context 'user-agents' do
37
+ it {
38
+ browser = Browser.new(ua: 'Mozilla/5.0 (iPad; CPU OS 8_1_3 like Mac OS X) AppleWebKit/600.1.4 (KHTML, like Gecko) Version/8.0 Mobile/12B466 Safari/600.1.4', accept_language: 'en-us')
39
+ BigbluebuttonRails.use_mobile_client?(browser).should be(true)
40
+ }
41
+ end
42
+ end
43
+
44
+ describe '.value_to_boolean' do
45
+ it { BigbluebuttonRails.value_to_boolean('true').should be(true) }
46
+ it { BigbluebuttonRails.value_to_boolean('1').should be(true) }
47
+ it { BigbluebuttonRails.value_to_boolean(1).should be(true) }
48
+ it { BigbluebuttonRails.value_to_boolean(true).should be(true) }
49
+ it { BigbluebuttonRails.value_to_boolean('t').should be(true) }
50
+ it { BigbluebuttonRails.value_to_boolean('false').should be(false) }
51
+ it { BigbluebuttonRails.value_to_boolean('0').should be(false) }
52
+ it { BigbluebuttonRails.value_to_boolean(0).should be(false) }
53
+ it { BigbluebuttonRails.value_to_boolean(false).should be(false) }
54
+ it { BigbluebuttonRails.value_to_boolean('f').should be(false) }
55
+ end
56
+ end
@@ -1,5 +1,18 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe "bigbluebutton_rails:meetings:finish" do
4
- it "mark as not running all meetings that were running but are not anymore"
4
+ include_context "rake"
5
+
6
+ before do
7
+ BigbluebuttonRails::BackgroundTasks.stub(:finish_meetings)
8
+ end
9
+
10
+ it "requires environment" do
11
+ subject.prerequisites.should include("environment")
12
+ end
13
+
14
+ it "calls the method that does the work" do
15
+ subject.invoke
16
+ BigbluebuttonRails::BackgroundTasks.should have_received(:finish_meetings)
17
+ end
5
18
  end
@@ -1,5 +1,18 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe "bigbluebutton_rails:recordings:update" do
4
- it "fetches the recordings"
4
+ include_context "rake"
5
+
6
+ before do
7
+ BigbluebuttonRails::BackgroundTasks.stub(:update_recordings)
8
+ end
9
+
10
+ it "requires environment" do
11
+ subject.prerequisites.should include("environment")
12
+ end
13
+
14
+ it "calls the method that does the work" do
15
+ subject.invoke
16
+ BigbluebuttonRails::BackgroundTasks.should have_received(:update_recordings)
17
+ end
5
18
  end
@@ -10,14 +10,14 @@ describe BigbluebuttonMeeting do
10
10
  it { should have_db_column(:name).of_type(:string) }
11
11
  it { should have_db_column(:start_time).of_type(:datetime) }
12
12
  it { should have_db_column(:running).of_type(:boolean) }
13
- it { should have_db_column(:record).of_type(:boolean) }
13
+ it { should have_db_column(:recorded).of_type(:boolean) }
14
14
  it { should have_db_column(:creator_id).of_type(:integer) }
15
15
  it { should have_db_column(:creator_name).of_type(:string) }
16
16
  it { should have_db_index([:meetingid, :start_time]).unique(true) }
17
17
  it "default values" do
18
18
  room = BigbluebuttonRoom.new
19
- room.running.should be_false
20
- room.record.should be_false
19
+ room.running.should be_falsey
20
+ room.record_meeting.should be_falsey
21
21
  end
22
22
  end
23
23
 
@@ -26,7 +26,7 @@ describe BigbluebuttonMeeting do
26
26
  let(:target) { FactoryGirl.create(:bigbluebutton_meeting) }
27
27
 
28
28
  context "if the user informed is nil" do
29
- it { target.created_by?(nil).should be_false }
29
+ it { target.created_by?(nil).should be_falsey }
30
30
  end
31
31
 
32
32
  context "with a valid user informed" do
@@ -34,18 +34,18 @@ describe BigbluebuttonMeeting do
34
34
 
35
35
  context "if the meeting has no creator_id" do
36
36
  before { target.update_attributes(:creator_id => nil) }
37
- it { target.created_by?(user).should be_false }
37
+ it { target.created_by?(user).should be_falsey }
38
38
  end
39
39
 
40
40
  context "if it wasn't the user that created the meeting" do
41
41
  let(:user2) { FactoryGirl.build(:user) }
42
42
  before { target.update_attributes(:creator_id => user2.id, :creator_name => user2.name) }
43
- it { target.created_by?(user).should be_false }
43
+ it { target.created_by?(user).should be_falsey }
44
44
  end
45
45
 
46
46
  context "if it was the user that created the meeting" do
47
47
  before { target.update_attributes(:creator_id => user.id, :creator_name => user.name) }
48
- it { target.created_by?(user).should be_true }
48
+ it { target.created_by?(user).should be_truthy }
49
49
  end
50
50
  end
51
51
  end
@@ -5,7 +5,6 @@ describe BigbluebuttonPlaybackFormat do
5
5
  # to ensure that the migration is correct
6
6
  context "db" do
7
7
  it { should have_db_column(:recording_id).of_type(:integer) }
8
- it { should have_db_column(:format_type).of_type(:string) }
9
8
  it { should have_db_column(:url).of_type(:string) }
10
9
  it { should have_db_column(:length).of_type(:integer) }
11
10
  it { should have_db_column(:created_at).of_type(:datetime) }
@@ -6,13 +6,84 @@ describe BigbluebuttonPlaybackFormat do
6
6
  BigbluebuttonPlaybackFormat.new.should be_a_kind_of(ActiveRecord::Base)
7
7
  end
8
8
 
9
- before { FactoryGirl.create(:bigbluebutton_playback_format) }
10
-
11
9
  it { should belong_to(:recording) }
12
- it { should validate_presence_of(:recording_id) }
10
+ it { should belong_to(:playback_type) }
13
11
 
14
- it { should validate_presence_of(:format_type) }
12
+ it { should validate_presence_of(:recording_id) }
15
13
 
14
+ it { should_not validate_presence_of(:playback_type_id) }
16
15
  it { should_not validate_presence_of(:url) }
17
16
  it { should_not validate_presence_of(:length) }
17
+
18
+ it { should delegate_method(:name).to(:playback_type) }
19
+ it { should delegate_method(:visible).to(:playback_type) }
20
+ it { should delegate_method(:visible?).to(:playback_type) }
21
+ it { should delegate_method(:identifier).to(:playback_type) }
22
+ it { should delegate_method(:default).to(:playback_type) }
23
+ it { should delegate_method(:default?).to(:playback_type) }
24
+ it { should delegate_method(:description).to(:playback_type) }
25
+
26
+ context "allows nil for delegates to playback_type" do
27
+ let(:target) { FactoryGirl.create(:bigbluebutton_playback_format, playback_type: nil) }
28
+ it { target.name.should be_nil }
29
+ it { target.identifier.should be_nil }
30
+ it { target.visible.should be_nil }
31
+ it { target.visible?.should be_nil }
32
+ it { target.default.should be_nil }
33
+ it { target.default?.should be_nil }
34
+ it { target.format_type.should be_nil }
35
+ end
36
+
37
+ it("alias :format_type to :identifier") {
38
+ target = FactoryGirl.create(:bigbluebutton_playback_format)
39
+ target.playback_type.identifier = "anything"
40
+ target.format_type.should eql("anything")
41
+ }
42
+
43
+ describe "#ordered" do
44
+ context "when there's a default set" do
45
+ let!(:type_default) { FactoryGirl.create(:bigbluebutton_playback_type, default: true) }
46
+ let!(:type1) { FactoryGirl.create(:bigbluebutton_playback_type, default: false) }
47
+ let!(:type2) { FactoryGirl.create(:bigbluebutton_playback_type, default: false) }
48
+ before {
49
+ @format1 = FactoryGirl.create(:bigbluebutton_playback_format, playback_type: type1)
50
+ @format2 = FactoryGirl.create(:bigbluebutton_playback_format, playback_type: type2)
51
+ @format3 = FactoryGirl.create(:bigbluebutton_playback_format, playback_type: type_default)
52
+ @format4 = FactoryGirl.create(:bigbluebutton_playback_format, playback_type: nil)
53
+ }
54
+ subject { BigbluebuttonPlaybackFormat.ordered }
55
+ it { subject[0].should eql(@format3) }
56
+ it { subject[1].should eql(@format1) }
57
+ it { subject[2].should eql(@format2) }
58
+ it { subject[3].should eql(@format4) }
59
+ end
60
+
61
+ context "when there's no default set" do
62
+ let!(:type1) { FactoryGirl.create(:bigbluebutton_playback_type, default: false) }
63
+ let!(:type2) { FactoryGirl.create(:bigbluebutton_playback_type, default: false) }
64
+ before {
65
+ @format1 = FactoryGirl.create(:bigbluebutton_playback_format, playback_type: type1)
66
+ @format2 = FactoryGirl.create(:bigbluebutton_playback_format, playback_type: type2)
67
+ @format3 = FactoryGirl.create(:bigbluebutton_playback_format, playback_type: nil)
68
+ }
69
+ subject { BigbluebuttonPlaybackFormat.ordered }
70
+ it { subject[0].should eql(@format1) }
71
+ it { subject[1].should eql(@format2) }
72
+ it { subject[2].should eql(@format3) }
73
+ end
74
+
75
+ context "when there are no formats" do
76
+ subject { BigbluebuttonPlaybackFormat.ordered }
77
+ it { subject.should eql([]) }
78
+ end
79
+ end
80
+
81
+ describe "#length_in_secs" do
82
+ it { FactoryGirl.create(:bigbluebutton_playback_format, length: nil).length_in_secs.should eql(0) }
83
+ it { FactoryGirl.create(:bigbluebutton_playback_format, length: "").length_in_secs.should eql(0) }
84
+ it { FactoryGirl.create(:bigbluebutton_playback_format, length: -1).length_in_secs.should eql(0) }
85
+ it { FactoryGirl.create(:bigbluebutton_playback_format, length: 0).length_in_secs.should eql(0) }
86
+ it { FactoryGirl.create(:bigbluebutton_playback_format, length: 5).length_in_secs.should eql(300) }
87
+ it { FactoryGirl.create(:bigbluebutton_playback_format, length: 99).length_in_secs.should eql(5940) }
88
+ end
18
89
  end
@@ -0,0 +1,14 @@
1
+ require 'spec_helper'
2
+
3
+ describe BigbluebuttonPlaybackType do
4
+
5
+ # to ensure that the migration is correct
6
+ context "db" do
7
+ it { should have_db_column(:identifier).of_type(:string) }
8
+ it { should have_db_column(:visible).of_type(:boolean) }
9
+ it { should have_db_column(:default).of_type(:boolean) }
10
+ it { should have_db_column(:created_at).of_type(:datetime) }
11
+ it { should have_db_column(:updated_at).of_type(:datetime) }
12
+ end
13
+
14
+ end