kaltura_fu 0.1.3.prel → 0.1.3
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +2 -0
- data/Rakefile +17 -7
- data/VERSION.yml +1 -1
- data/kaltura_fu.gemspec +20 -10
- data/lib/kaltura_fu.rb +15 -92
- data/lib/kaltura_fu/configuration.rb +92 -0
- data/lib/kaltura_fu/entry.rb +16 -0
- data/lib/kaltura_fu/entry/class_methods.rb +61 -0
- data/lib/kaltura_fu/entry/instance_methods.rb +25 -0
- data/lib/kaltura_fu/entry/metadata.rb +147 -0
- data/lib/kaltura_fu/entry/metadata/class_and_instance_methods.rb +39 -0
- data/lib/kaltura_fu/flavor.rb +89 -0
- data/lib/kaltura_fu/railtie.rb +2 -2
- data/rails/init.rb +1 -1
- data/spec/entry_spec.rb +73 -0
- data/spec/kaltura_fu_spec.rb +53 -156
- data/spec/metadata_spec.rb +271 -0
- data/spec/spec.opts +1 -0
- data/spec/spec_helper.rb +26 -8
- metadata +38 -18
- data/lib/kaltura_fu/category.rb +0 -112
- data/test/kaltura_fu_test.rb +0 -8
- data/test/test_helper.rb +0 -3
@@ -0,0 +1,147 @@
|
|
1
|
+
require 'active_support'
|
2
|
+
|
3
|
+
module KalturaFu
|
4
|
+
module Entry
|
5
|
+
module Metadata
|
6
|
+
|
7
|
+
##
|
8
|
+
# @private
|
9
|
+
##
|
10
|
+
def self.included(base)
|
11
|
+
base.extend ClassAndInstanceMethods
|
12
|
+
base.class_eval do
|
13
|
+
include ClassAndInstanceMethods
|
14
|
+
end
|
15
|
+
super
|
16
|
+
end
|
17
|
+
|
18
|
+
##
|
19
|
+
# @private
|
20
|
+
##
|
21
|
+
def method_missing(name, *args)
|
22
|
+
case name.to_s
|
23
|
+
when /^set_(.*)/
|
24
|
+
valid_entry_attribute?($1.to_sym) ? set_attribute($1,*args) : super
|
25
|
+
when /^add_(.*)/
|
26
|
+
valid_entry_attribute?($1.pluralize.to_sym) ? add_attribute($1.pluralize,*args) : super
|
27
|
+
when /^get_(.*)/
|
28
|
+
valid_entry_attribute?($1.to_sym) ? get_entry(*args).send($1.to_sym) : super
|
29
|
+
else
|
30
|
+
super
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
##
|
35
|
+
# @private
|
36
|
+
##
|
37
|
+
def respond_to?(method)
|
38
|
+
case method.to_s
|
39
|
+
when /^(get|set)_(.*)/
|
40
|
+
valid_entry_attribute?($2.to_sym) || super
|
41
|
+
when /^(add)_(.*)/
|
42
|
+
(valid_entry_attribute?($2.pluralize.to_sym) && valid_add_attribute?($2) ) || super
|
43
|
+
else
|
44
|
+
super
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
##
|
49
|
+
# Gets a Kaltura::MediaEntry given a Kaltura entry.
|
50
|
+
#
|
51
|
+
# @param [String] video_id Kaltura entry_id of the video.
|
52
|
+
#
|
53
|
+
# @return [Kaltura::MediaEntry] The MediaEntry object for the Kaltura entry.
|
54
|
+
# @raose [Kaltura::APIError] Raises a kaltura error if it can't find the entry.
|
55
|
+
##
|
56
|
+
def get_entry(entry_id)
|
57
|
+
KalturaFu.check_for_client_session
|
58
|
+
|
59
|
+
KalturaFu.client.media_service.get(entry_id)
|
60
|
+
end
|
61
|
+
|
62
|
+
##
|
63
|
+
# Sets a specific Kaltura::MediaEntry attribute given a Kaltura entry.
|
64
|
+
# This method is called by method_missing, allowing this module set attributes based
|
65
|
+
# off of the current API wrapper, rather than having to update along side the API wrapper.
|
66
|
+
#
|
67
|
+
# @param [String] attr_name The attribute to set.
|
68
|
+
# @param [String] entry_id The Kaltura entry ID.
|
69
|
+
# @param [String] value The value you wish to set the attribute to.
|
70
|
+
#
|
71
|
+
# @return [String] Returns the value as stored in the Kaltura database. Tag strings come back
|
72
|
+
# slightly funny.
|
73
|
+
#
|
74
|
+
# @raise [Kaltura::APIError] Passes Kaltura API errors directly through.
|
75
|
+
##
|
76
|
+
def set_attribute(attr_name,entry_id,value)
|
77
|
+
KalturaFu.check_for_client_session
|
78
|
+
|
79
|
+
add_categories_to_kaltura(value) if (attr_name =~ /^(.*)_categories/ || attr_name =~ /^categories/)
|
80
|
+
|
81
|
+
media_entry = Kaltura::MediaEntry.new
|
82
|
+
media_entry.send("#{attr_name}=",value)
|
83
|
+
KalturaFu.client.media_service.update(entry_id,media_entry).send(attr_name.to_sym)
|
84
|
+
|
85
|
+
end
|
86
|
+
|
87
|
+
##
|
88
|
+
# @private
|
89
|
+
##
|
90
|
+
def add_categories_to_kaltura(categories)
|
91
|
+
KalturaFu.check_for_client_session
|
92
|
+
|
93
|
+
categories.split(",").each do |category|
|
94
|
+
unless category_exists?(category)
|
95
|
+
cat = Kaltura::Category.new
|
96
|
+
cat.name = category
|
97
|
+
KalturaFu.client.category_service.add(cat)
|
98
|
+
end
|
99
|
+
end
|
100
|
+
end
|
101
|
+
|
102
|
+
##
|
103
|
+
# @private
|
104
|
+
##
|
105
|
+
def category_exists?(category_name)
|
106
|
+
KalturaFu.check_for_client_session
|
107
|
+
|
108
|
+
category_filter = Kaltura::Filter::CategoryFilter.new
|
109
|
+
category_filter.full_name_equal = category_name
|
110
|
+
category_check = KalturaFu.client.category_service.list(category_filter).objects
|
111
|
+
if category_check.nil?
|
112
|
+
false
|
113
|
+
else
|
114
|
+
category_check
|
115
|
+
end
|
116
|
+
end
|
117
|
+
|
118
|
+
|
119
|
+
##
|
120
|
+
# Appends a specific Kaltura::MediaEntry attribute to the end of the original attribute given a Kaltura entry.
|
121
|
+
# This method is called by method_missing, allowing this module add attributes based
|
122
|
+
# off of the current API wrapper, rather than having to update along side the API wrapper.
|
123
|
+
#
|
124
|
+
# @param [String] attr_name The attribute to set.
|
125
|
+
# @param [String] entry_id The Kaltura entry ID.
|
126
|
+
# @param [String] value The value you wish to append the attribute with.
|
127
|
+
#
|
128
|
+
# @return [String] Returns the value as stored in the Kaltura database. Tag strings come back
|
129
|
+
# slightly funny.
|
130
|
+
#
|
131
|
+
# @raise [Kaltura::APIError] Passes Kaltura API errors directly through.
|
132
|
+
##
|
133
|
+
def add_attribute(attr_name,entry_id,value)
|
134
|
+
KalturaFu.check_for_client_session
|
135
|
+
|
136
|
+
|
137
|
+
add_categories_to_kaltura(value) if (attr_name =~ /^(.*)_categor(ies|y)/ || attr_name =~ /^categor(ies|y)/)
|
138
|
+
|
139
|
+
old_attributes = KalturaFu.client.media_service.get(entry_id).send(attr_name.to_sym)
|
140
|
+
media_entry = Kaltura::MediaEntry.new
|
141
|
+
media_entry.send("#{attr_name}=","#{old_attributes},#{value}")
|
142
|
+
KalturaFu.client.media_service.update(entry_id,media_entry).send(attr_name.to_sym)
|
143
|
+
end
|
144
|
+
|
145
|
+
end
|
146
|
+
end
|
147
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
module KalturaFu
|
2
|
+
module Entry
|
3
|
+
module Metadata
|
4
|
+
|
5
|
+
module ClassAndInstanceMethods
|
6
|
+
|
7
|
+
##
|
8
|
+
# Checks if a requested attribute is in fact a valid MediaEntry atrribute.
|
9
|
+
##
|
10
|
+
def valid_entry_attribute?(request_attribute)
|
11
|
+
object_methods, media_entry_methods = Object.instance_methods , Kaltura::MediaEntry.instance_methods
|
12
|
+
|
13
|
+
#clean out all the setter methods from the media entry methods
|
14
|
+
valid_media_entry_methods = media_entry_methods.map{|m| m unless m =~/^(.*)=/}.compact!
|
15
|
+
|
16
|
+
valid_media_entry_methods -= object_methods
|
17
|
+
valid_media_entry_methods.find{|m| m.to_sym == request_attribute.to_sym} ? true : false
|
18
|
+
end
|
19
|
+
|
20
|
+
##
|
21
|
+
# Determines if an attribute is valid in the sense of the add method making sense. Only
|
22
|
+
# categories and tags are currently considered valid.
|
23
|
+
##
|
24
|
+
def valid_add_attribute?(request_attribute)
|
25
|
+
case request_attribute.to_s
|
26
|
+
when /^(.*)_(categor(y|ies)|(tag|tags))/
|
27
|
+
return true
|
28
|
+
when /^(categor(y|ies)|tag)/
|
29
|
+
return true
|
30
|
+
else
|
31
|
+
return false
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
end
|
36
|
+
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
@@ -0,0 +1,89 @@
|
|
1
|
+
module KalturaFu
|
2
|
+
##
|
3
|
+
# The Flavor module provides interactions for adding and removing specific encodings from a Kaltura entry.
|
4
|
+
##
|
5
|
+
module Flavor
|
6
|
+
|
7
|
+
##
|
8
|
+
# Adds a specific encoding profile to a Kaltura entry.
|
9
|
+
#
|
10
|
+
# @param [String] video_id The Kaltura media entry.
|
11
|
+
# @param [Integer] flavor_param_id The ID of the FlavorParam (individual encoding profile) to use.
|
12
|
+
#
|
13
|
+
# @return [nil] Returns nothing.
|
14
|
+
#
|
15
|
+
# @raie [RuntimeError] Raises a runtime error if the video_id doesn't exist.
|
16
|
+
#
|
17
|
+
# @since 0.1.3
|
18
|
+
#
|
19
|
+
# @todo Make this method return something.
|
20
|
+
##
|
21
|
+
def add_flavor_to_video(video_id,flavor_param_id)
|
22
|
+
self.check_for_client_session
|
23
|
+
|
24
|
+
if video_exists?(video_id)
|
25
|
+
@@client.flavor_asset_service.convert(video_id,flavor_param_id)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
##
|
30
|
+
# Finds a specific flavor object given a Kaltura entry and FlavorParam. This is useful if you want to
|
31
|
+
# delete a specific type of encoding from a Video programatically.
|
32
|
+
#
|
33
|
+
# @param [String] video_id The Kaltura media entry.
|
34
|
+
# @param [Integer] flavor_param_id The ID of the FlavorParam (individual encoding profile) to use.
|
35
|
+
#
|
36
|
+
# @return [Kaltura::FlavorAsset] Returns the requested FlavorAsset.
|
37
|
+
#
|
38
|
+
# @raise [RuntimeError] Raises a runtime error if the video_id doesn't exist.
|
39
|
+
#
|
40
|
+
# @since 0.1.3
|
41
|
+
#
|
42
|
+
# @todo Ensure a graceful error when the FlavorAsset isn't found as well.
|
43
|
+
##
|
44
|
+
def find_flavor_from_entry(video_id,flavor_param_id)
|
45
|
+
self.check_for_client_session
|
46
|
+
return_flavor = nil
|
47
|
+
|
48
|
+
if video_exists?(video_id)
|
49
|
+
flavor_array = @@client.flavor_asset_service.get_flavor_assets_with_params(video_id)
|
50
|
+
flavor_array.each do |flavor_object|
|
51
|
+
if flavor_object.flavor_params.id == flavor_param_id
|
52
|
+
return_flavor = flavor_object.flavor_asset.id
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
##
|
59
|
+
# Removes either a specific flavor asset. If you know the exact Flavor you wish to delete
|
60
|
+
# you can specify it. Otherwise, you can specify the videos entry_id and a specific
|
61
|
+
# FlavorParam (encoding profile) and it will locate and remove the Flavor for you.
|
62
|
+
#
|
63
|
+
# @param [String] entry_or_flavor The Kaltura entry_id or the FlavorAsset ID.
|
64
|
+
# @param [Integer] flavor_param_id An optional flavorParam encoding profile to seek.
|
65
|
+
#
|
66
|
+
# @return [Boolean] Returns true if the removal was succesful.
|
67
|
+
#
|
68
|
+
# @raise [RuntimeError] Raises a runtime error if the video's entry_id doesn't exist.
|
69
|
+
#
|
70
|
+
# @since 0.1.3
|
71
|
+
#
|
72
|
+
# @todo Ensure that a missing FlavorParam or FlavorAsset doesn't cause unexpected behavior.
|
73
|
+
##
|
74
|
+
def remove_flavor_from_video(entry_or_flavor, flavor_param_id=nil)
|
75
|
+
self.check_for_client_session
|
76
|
+
ret_val = false
|
77
|
+
|
78
|
+
if flavor_param_id.nil?
|
79
|
+
@@client.flavor_asset_service.delete(entry_or_flavor)
|
80
|
+
ret_val = true
|
81
|
+
else
|
82
|
+
flavor_to_delete = self.find_flavor_from_entry(entry_or_flavor,flavor_param_id)
|
83
|
+
self.remove_flavor_from_video(flavor_to_delete)
|
84
|
+
end
|
85
|
+
ret_val
|
86
|
+
end
|
87
|
+
|
88
|
+
end
|
89
|
+
end
|
data/lib/kaltura_fu/railtie.rb
CHANGED
@@ -15,8 +15,8 @@ module KalturaFu
|
|
15
15
|
raise RuntimeError, "Unable to find \"config/kaltura.yml\" file."
|
16
16
|
end
|
17
17
|
|
18
|
-
|
19
|
-
KalturaFu.config =
|
18
|
+
config_file = YAML.load_file(kaltura_yml)[Rails.env]
|
19
|
+
KalturaFu.config = config_file.symbolize_keys
|
20
20
|
|
21
21
|
|
22
22
|
unless[:partner_id,:subpartner_id,:administrator_secret].all? {|key| KalturaFu.config.key?(key)}
|
data/rails/init.rb
CHANGED
@@ -13,7 +13,7 @@ unless File.exists?(kaltura_yml)
|
|
13
13
|
end
|
14
14
|
|
15
15
|
|
16
|
-
KalturaFu.config = YAML.load_file(kaltura_yml).
|
16
|
+
KalturaFu.config = YAML.load_file(kaltura_yml).symbolize_keys[RAILS_ENV.to_sym]
|
17
17
|
|
18
18
|
|
19
19
|
unless[:partner_id,:subpartner_id,:administrator_secret].all? {|key| KalturaFu.config.key?(key)}
|
data/spec/entry_spec.rb
ADDED
@@ -0,0 +1,73 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/spec_helper'
|
2
|
+
|
3
|
+
class EntrySpecTester
|
4
|
+
include KalturaFu::Entry
|
5
|
+
end
|
6
|
+
|
7
|
+
describe "Kaltura Fu's Entry Class Methods" do
|
8
|
+
before(:all) do
|
9
|
+
KalturaFuTestConfiguration.setup
|
10
|
+
@tester = EntrySpecTester.new
|
11
|
+
end
|
12
|
+
|
13
|
+
it "Responds to upload" do
|
14
|
+
EntrySpecTester.should respond_to :upload
|
15
|
+
end
|
16
|
+
|
17
|
+
it "Allows a valid file to be uploaded and deleted" do
|
18
|
+
entry_id = nil
|
19
|
+
lambda {entry_id = EntrySpecTester.upload(KalturaFuTestConfiguration.video, :source=>:file)}.should_not raise_error
|
20
|
+
|
21
|
+
lambda {@tester.get_entry(entry_id)}.should_not raise_error
|
22
|
+
check = @tester.delete_entry(entry_id)
|
23
|
+
check.should be_true
|
24
|
+
end
|
25
|
+
|
26
|
+
it "Does nothing when you don't source the method as a file upload" do
|
27
|
+
entry_id = nil
|
28
|
+
lambda {entry_id = EntrySpecTester.upload("waffles",:source=>:url)}.should_not raise_error
|
29
|
+
entry_id.should be_nil
|
30
|
+
end
|
31
|
+
|
32
|
+
it "Handles valid Media Entry attributes when you provide them in the options hash" do
|
33
|
+
video_options = {}
|
34
|
+
video_options[:name] = "My fantastic movie."
|
35
|
+
video_options[:description] = "A movie of unparralled awesomeness."
|
36
|
+
video_options[:tags] = "man, this, is, awesome"
|
37
|
+
video_options[:source] = :file
|
38
|
+
|
39
|
+
entry_id = nil
|
40
|
+
lambda {entry_id = EntrySpecTester.upload(KalturaFuTestConfiguration.video,video_options)}.should_not raise_error
|
41
|
+
|
42
|
+
media_entry = nil
|
43
|
+
lambda {media_entry = @tester.get_entry(entry_id)}.should_not raise_error
|
44
|
+
media_entry.name.should == video_options[:name]
|
45
|
+
media_entry.description.should == video_options[:description]
|
46
|
+
media_entry.tags.should == video_options[:tags]
|
47
|
+
|
48
|
+
check = @tester.delete_entry(entry_id)
|
49
|
+
check.should be_true
|
50
|
+
end
|
51
|
+
|
52
|
+
it "Is totally cool with you supplying jibberish in the options too." do
|
53
|
+
video_options = {}
|
54
|
+
video_options[:name] = "My fantastic movie."
|
55
|
+
video_options[:description] = "A movie of unparralled awesomeness."
|
56
|
+
video_options[:tags] = "man, this, is, awesome"
|
57
|
+
video_options[:source] = :file
|
58
|
+
video_options[:waffles] = "WHATEVER WAFFLES"
|
59
|
+
|
60
|
+
entry_id = nil
|
61
|
+
lambda {entry_id = EntrySpecTester.upload(KalturaFuTestConfiguration.video,video_options)}.should_not raise_error
|
62
|
+
|
63
|
+
media_entry = nil
|
64
|
+
lambda {media_entry = @tester.get_entry(entry_id)}.should_not raise_error
|
65
|
+
media_entry.name.should == video_options[:name]
|
66
|
+
media_entry.description.should == video_options[:description]
|
67
|
+
media_entry.tags.should == video_options[:tags]
|
68
|
+
media_entry.should_not respond_to :waffles
|
69
|
+
|
70
|
+
check = @tester.delete_entry(entry_id)
|
71
|
+
check.should be_true
|
72
|
+
end
|
73
|
+
end
|
data/spec/kaltura_fu_spec.rb
CHANGED
@@ -1,166 +1,63 @@
|
|
1
1
|
require File.dirname(__FILE__) + '/spec_helper'
|
2
2
|
|
3
|
-
describe
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
"http://ajax.googleapis.com/ajax/libs/swfobject" +
|
10
|
-
"/2.2/swfobject.js" )
|
11
|
-
|
12
|
-
html.should have_tag("script[src = ?]",
|
13
|
-
%r{/javascripts/kaltura_upload.js\?[0-9]*})
|
3
|
+
describe "General Configuration testing" do
|
4
|
+
before(:all) do
|
5
|
+
KalturaFu.config = {}
|
6
|
+
KalturaFu.client_configuration =nil
|
7
|
+
KalturaFu.clear_session_key!
|
8
|
+
KalturaFu.client = nil
|
14
9
|
end
|
15
|
-
|
16
|
-
|
17
|
-
html = helper.kaltura_thumbnail(12345)
|
18
|
-
|
19
|
-
|
20
|
-
if KalturaFu.config[:thumb_width] && KalturaFu.config[:thumb_height]
|
21
|
-
html.should have_tag("img[src = ?]" , "http://www.kaltura.com/p/" +
|
22
|
-
KalturaFu.config[:partner_id] +
|
23
|
-
"/thumbnail/entry_id/12345" + "/width/" +
|
24
|
-
KalturaFu.config[:thumb_width] + "/height/" +
|
25
|
-
KalturaFu.config[:thumb_height])
|
26
|
-
else
|
27
|
-
html.should have_tag("img[src = ?]",
|
28
|
-
"http://www.kaltura.com/p/" +
|
29
|
-
KalturaFu.config[:partner_id] +
|
30
|
-
"/thumbnail/entry_id/12345")
|
31
|
-
end
|
10
|
+
it "Should start with an empty config" do
|
11
|
+
KalturaFu.config.should be_empty
|
32
12
|
end
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
html.should have_tag("img[src = ?]", "http://www.kaltura.com/p/" +
|
37
|
-
KalturaFu.config[:partner_id] +
|
38
|
-
"/thumbnail/entry_id/12345" + "/width/800" +
|
39
|
-
"/height/600")
|
40
|
-
end
|
41
|
-
it "should create a thumbnail at the right second" do
|
42
|
-
html = helper.kaltura_thumbnail(12345,:size=>[800,600],:second=> 6)
|
43
|
-
|
44
|
-
html.should have_tag("img[src = ?]", "http://www.kaltura.com/p/" +
|
45
|
-
KalturaFu.config[:partner_id] +
|
46
|
-
"/thumbnail/entry_id/12345" + "/vid_sec/6" +
|
47
|
-
"/width/800/height/600")
|
13
|
+
|
14
|
+
it "Shouldn't generate a Kaltura session on an empty config" do
|
15
|
+
lambda {KalturaFu.generate_session_key}.should raise_error(RuntimeError, "Missing Partner Identifier")
|
48
16
|
end
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
html.should have_tag("div#kplayer")
|
54
|
-
|
55
|
-
# check the parameters
|
56
|
-
html.should have_tag("script",%r{allowscriptaccess: "always"})
|
57
|
-
html.should have_tag("script",%r{allownetworking: "all"})
|
58
|
-
html.should have_tag("script",%r{allowfullscreen: "true"})
|
59
|
-
html.should have_tag("script",%r{wmode: "opaque"})
|
60
|
-
|
61
|
-
# check the vars
|
62
|
-
html.should have_tag("script",%r{entryId: "12345"})
|
63
|
-
|
64
|
-
# check the embed
|
65
|
-
html.should have_tag("script",%r{swfobject.embedSWF})
|
66
|
-
html.should have_tag("script",
|
67
|
-
%r{http://www.kaltura.com/kwidget/wid/_#{KalturaFu.config[:partner_id]}})
|
68
|
-
if KalturaFu.config[:player_conf_id]
|
69
|
-
html.should have_tag("script",
|
70
|
-
%r{/ui_conf_id/#{KalturaFu.config[:player_conf_id]}})
|
71
|
-
else
|
72
|
-
html.should have_tag("script",
|
73
|
-
%r{/ui_conf_id/#{KalturaFu::ViewHelpers::DEFAULT_KPLAYER}})
|
74
|
-
end
|
75
|
-
html.should have_tag("script",%r{"kplayer","400","330"})
|
17
|
+
|
18
|
+
it "Shouldn't generate a Kaltura session without an administrator secret" do
|
19
|
+
KalturaFu.config[:partner_id] = '121413'
|
20
|
+
lambda {KalturaFu.generate_session_key}.should raise_error(RuntimeError, "Missing Administrator Secret")
|
76
21
|
end
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
# check the vars
|
90
|
-
html.should have_tag("script",%r{entryId: "12345"})
|
91
|
-
|
92
|
-
# check the embed
|
93
|
-
html.should have_tag("script",%r{swfobject.embedSWF})
|
94
|
-
html.should have_tag("script",
|
95
|
-
%r{http://www.kaltura.com/kwidget/wid/_#{KalturaFu.config[:partner_id]}})
|
96
|
-
if KalturaFu.config[:player_conf_id]
|
97
|
-
html.should have_tag("script",
|
98
|
-
%r{/ui_conf_id/#{KalturaFu.config[:player_conf_id]}})
|
99
|
-
else
|
100
|
-
html.should have_tag("script",
|
101
|
-
%r{/ui_conf_id/#{KalturaFu::ViewHelpers::DEFAULT_KPLAYER}})
|
102
|
-
end
|
103
|
-
html.should have_tag("script",%r{"waffles","400","330"})
|
104
|
-
end
|
105
|
-
|
106
|
-
it "should embed a player with a different config id" do
|
107
|
-
html = helper.kaltura_player_embed(12345, :player_conf_id=>"1234")
|
108
|
-
|
109
|
-
#check the outer div
|
110
|
-
html.should have_tag("div#kplayer")
|
111
|
-
|
112
|
-
# check the parameters
|
113
|
-
html.should have_tag("script",%r{allowscriptaccess: "always"})
|
114
|
-
html.should have_tag("script",%r{allownetworking: "all"})
|
115
|
-
html.should have_tag("script",%r{allowfullscreen: "true"})
|
116
|
-
html.should have_tag("script",%r{wmode: "opaque"})
|
117
|
-
|
118
|
-
# check the vars
|
119
|
-
html.should have_tag("script",%r{entryId: "12345"})
|
120
|
-
|
121
|
-
# check the embed
|
122
|
-
html.should have_tag("script",%r{swfobject.embedSWF})
|
123
|
-
html.should have_tag("script",
|
124
|
-
%r{http://www.kaltura.com/kwidget/wid/_#{KalturaFu.config[:partner_id]}})
|
125
|
-
html.should have_tag("script",
|
126
|
-
%r{/ui_conf_id/1234})
|
127
|
-
html.should have_tag("script",%r{"kplayer","400","330"})
|
128
|
-
end
|
129
|
-
|
130
|
-
it "should allow a resize on the player" do
|
131
|
-
html = helper.kaltura_player_embed(12345,:size=>[200,170])
|
132
|
-
|
133
|
-
#check the outer div
|
134
|
-
html.should have_tag("div#kplayer")
|
135
|
-
|
136
|
-
# check the parameters
|
137
|
-
html.should have_tag("script",%r{allowscriptaccess: "always"})
|
138
|
-
html.should have_tag("script",%r{allownetworking: "all"})
|
139
|
-
html.should have_tag("script",%r{allowfullscreen: "true"})
|
140
|
-
html.should have_tag("script",%r{wmode: "opaque"})
|
141
|
-
|
142
|
-
# check the vars
|
143
|
-
html.should have_tag("script",%r{entryId: "12345"})
|
144
|
-
|
145
|
-
# check the embed
|
146
|
-
html.should have_tag("script",%r{swfobject.embedSWF})
|
147
|
-
html.should have_tag("script",
|
148
|
-
%r{http://www.kaltura.com/kwidget/wid/_#{KalturaFu.config[:partner_id]}})
|
149
|
-
if KalturaFu.config[:player_conf_id]
|
150
|
-
html.should have_tag("script",
|
151
|
-
%r{/ui_conf_id/#{KalturaFu.config[:player_conf_id]}})
|
152
|
-
else
|
153
|
-
html.should have_tag("script",
|
154
|
-
%r{/ui_conf_id/#{KalturaFu::ViewHelpers::DEFAULT_KPLAYER}})
|
155
|
-
end
|
156
|
-
html.should have_tag("script",%r{"kplayer","200","170"})
|
22
|
+
|
23
|
+
it "Should respect the Service URL when constructing a Client configuration" do
|
24
|
+
KalturaFu.config[:parnter_id] = '123434'
|
25
|
+
lambda {KalturaFu.create_client_config}.should_not raise_error
|
26
|
+
|
27
|
+
KalturaFu.client_configuration.service_url.should == "http://www.kaltura.com"
|
28
|
+
|
29
|
+
service_url = "http://www.waffletastic.com"
|
30
|
+
KalturaFu.config[:service_url] = service_url
|
31
|
+
KalturaFu.create_client_config
|
32
|
+
KalturaFu.client_configuration.service_url.should == service_url
|
157
33
|
end
|
158
34
|
|
159
|
-
it "
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
html.should_not have_tag("a[div_id=\"kplayer\"]")
|
35
|
+
it "Should raise a Kaltura::APIError when you provide incorrect information." do
|
36
|
+
KalturaFu.config = {}
|
37
|
+
KalturaFu.config[:partner_id] , KalturaFu.config[:administrator_secret] = '1241' , 'a3$35casd'
|
38
|
+
lambda {KalturaFu.generate_session_key}.should raise_error(Kaltura::APIError)
|
164
39
|
end
|
165
|
-
|
166
40
|
end
|
41
|
+
describe "Valid Configuration tests" do
|
42
|
+
before :each do
|
43
|
+
KalturaFuTestConfiguration.setup
|
44
|
+
end
|
45
|
+
|
46
|
+
it "Should function just fine with proper credentials" do
|
47
|
+
lambda {KalturaFu.generate_session_key}.should_not raise_error
|
48
|
+
end
|
49
|
+
|
50
|
+
it "Should allow you to clear the session" do
|
51
|
+
KalturaFu.generate_session_key
|
52
|
+
KalturaFu.clear_session_key!
|
53
|
+
|
54
|
+
KalturaFu.session_key.should be nil
|
55
|
+
end
|
56
|
+
|
57
|
+
it "Should generate a valid session if you ask politely" do
|
58
|
+
KalturaFu.clear_session_key!
|
59
|
+
KalturaFu.check_for_client_session
|
60
|
+
|
61
|
+
KalturaFu.session_key.should_not be nil
|
62
|
+
end
|
63
|
+
end
|