vzaar 1.4.1 → 1.4.4

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 4e149cb5a25c313d942932a742e4730b7e1123ee
4
- data.tar.gz: 0e0ffebfdba59fb4365bbc97b640d5753c56e3a8
3
+ metadata.gz: daaa5abc46d7d81600d16d5fef1cfee198ccd49c
4
+ data.tar.gz: a4bf4aaf7e2d86a9229962b608f9d0326c2b3be6
5
5
  SHA512:
6
- metadata.gz: f2f2bfe487a22452b22cdc27629e127d5d44ae60363a5c7756f9c70049cb38da39ee6bf0bc30b0696469992fddd64063b54e16f69b10d051331b8fa6d1bf85f1
7
- data.tar.gz: 345eca563b521c5c6d1ef85fdedeee24d6946d252bfee47c8a5bd55741ccd4f8699e84009f050631e0eecfbcbac1bf95cfb3d8c837da06d4a43a5b0b1b5634f9
6
+ metadata.gz: e1abe62fae5216f2752484e8340f33bf42860292f38e349954040fd08fb9986c3a4e18ee930feb1e288ade058e7a465ec13a402c1eecf68f3101c989f04a38e4
7
+ data.tar.gz: 7b7091697a815c4869a37a3709665dea6f2204b4528e2bdf5532e1a697d138c8270f39d8dee838644d825f4d886d3947c32b2e6a070fc61065eb236f0af9930d
data/.gitignore CHANGED
@@ -26,3 +26,4 @@ test.rb
26
26
  .gemtags
27
27
  api_envs.yml
28
28
  .DS_Store
29
+ spec/support/vid2.mov
data/ChangeLog ADDED
@@ -0,0 +1,12 @@
1
+ 2015-02-16 JC <jozef@vzaar.com>
2
+
3
+ * private and seo_url params added to api#edit_video
4
+ * API specs improved for edit_video/json
5
+
6
+ 2015-01-21 JC <jozef@vzaar.com>
7
+
8
+ * API specs added for edit/delete http verbs
9
+
10
+ 2015-01-14 JC <jozef@vzaar.com>
11
+
12
+ * changelog added
data/README.md CHANGED
@@ -55,7 +55,7 @@ api.video_details(video_id, authenticated: true)
55
55
 
56
56
  Fetching videos for a given user:
57
57
  ```ruby
58
- api.video_details("user login", options)
58
+ api.video_list("user login", options)
59
59
  ```
60
60
 
61
61
  Fetching videos for authenticated user (authentication required):
@@ -2,48 +2,116 @@ require_relative './spec_helper'
2
2
 
3
3
  describe "Delete Video" do
4
4
  vid_id = nil
5
+ file_path = "./spec/support/video.mov"
6
+ desc = "Delete Video"
5
7
 
6
- before(:all) do
7
- file_path = "./spec/support/video.mov"
8
- desc = "Delete Video"
9
- @api = _api(login: user1["login"],
10
- application_token: user1["rw_token"])
8
+ describe "POST verb" do
9
+ before(:all) do
10
+ @api = _api(login: user1["login"],
11
+ application_token: user1["rw_token"])
12
+
13
+ title = "api-test-#{rand_str}"
14
+ res = @api.upload_video(path: file_path, title: title, description: desc)
15
+ @vid_id = res.id
16
+ end
11
17
 
12
- @title = "api-test-#{rand_str}"
18
+ context "when there is no method=delete param" do
19
+ describe "xml" do
20
+ specify do
21
+ opts = { video_id: @vid_id, http_verb: :post}
22
+ req = Vzaar::Request::DeleteVideo.new(@api.conn, opts)
23
+
24
+ expect { req.execute }.to raise_error(Vzaar::Error)
25
+ end
26
+ end
13
27
 
14
- res = @api.upload_video(path: file_path, title: @title, description: desc)
15
- vid_id = res.id
16
- end
28
+ describe "json" do
29
+ specify do
30
+ opts = { video_id: @vid_id, http_verb: :post, format: :json}
31
+ req = Vzaar::Request::DeleteVideo.new(@api.conn, opts)
32
+
33
+ expect { req.execute }.to raise_error(Vzaar::Error)
34
+ end
35
+ end
36
+ end
37
+
38
+ context "when method=delete exists in post body" do
39
+ describe "xml" do
40
+ specify do
41
+ opts = { video_id: @vid_id, http_verb: :post}
42
+ req = Vzaar::Request::DeleteVideo.new(@api.conn, opts)
17
43
 
18
- context "when user is unauthenticated" do
19
- it_behaves_like "Unauthenticated", -> (api) do
20
- api.delete_video(vid_id)
44
+ def req.xml_body
45
+ '<?xml version="1.0" encoding="UTF-8"?><vzaar-api><_method>delete</_method></vzaar-api>'
46
+ end
47
+ res = req.execute
48
+ expect(res.http_status_code).to eq(200)
49
+ end
50
+ end
51
+
52
+ describe "json" do
53
+ specify do
54
+ title = "api-test-#{rand_str}"
55
+ res = @api.upload_video(path: file_path, title: title, description: desc)
56
+ vid_id = res.id
57
+
58
+
59
+ opts = { video_id: vid_id, http_verb: :post, format: :json}
60
+ req = Vzaar::Request::DeleteVideo.new(@api.conn, opts)
61
+
62
+ def req.json_body
63
+ { "vzaar-api" => { "_method" => "delete" } }
64
+ end
65
+
66
+ res = req.execute
67
+ expect(res["title"]).to eq(title)
68
+ end
69
+ end
21
70
  end
71
+
22
72
  end
23
73
 
24
- context "Authenticated User" do
25
- context "different account" do
26
- specify do
27
- api = _api(login: user2["login"],
28
- application_token: user2["rw_token"])
29
- expect do
30
- api.delete_video(vid_id)
31
- end.to raise_error(Vzaar::Error, "Protected Resource")
74
+ describe "DELETE verb" do
75
+ before(:all) do
76
+ @api = _api(login: user1["login"],
77
+ application_token: user1["rw_token"])
78
+
79
+ @title = "api-test-#{rand_str}"
80
+
81
+ res = @api.upload_video(path: file_path, title: @title, description: desc)
82
+ vid_id = res.id
83
+ end
84
+
85
+ context "when user is unauthenticated" do
86
+ it_behaves_like "Unauthenticated", -> (api) do
87
+ api.delete_video(vid_id)
32
88
  end
33
89
  end
34
90
 
35
- context "RW token" do
36
- before(:all) do
37
- @res = @api.delete_video(vid_id)
91
+ context "Authenticated User" do
92
+ context "different account" do
93
+ specify do
94
+ api = _api(login: user2["login"],
95
+ application_token: user2["rw_token"])
96
+ expect do
97
+ api.delete_video(vid_id)
98
+ end.to raise_error(Vzaar::Error, "Protected Resource")
99
+ end
38
100
  end
39
101
 
40
- specify { expect(@res.http_status_code).to eq 200 }
41
- specify { expect(@res.title).to eq(@title) }
42
- end
102
+ context "RW token" do
103
+ before(:all) do
104
+ @res = @api.delete_video(vid_id)
105
+ end
43
106
 
44
- context "RO token" do
45
- it_behaves_like "RO only", user1["login"], user1["ro_token"], -> (api) do
46
- api.delete_video(vid_id)
107
+ specify { expect(@res.http_status_code).to eq 200 }
108
+ specify { expect(@res.title).to eq(@title) }
109
+ end
110
+
111
+ context "RO token" do
112
+ it_behaves_like "RO only", user1["login"], user1["ro_token"], -> (api) do
113
+ api.delete_video(vid_id)
114
+ end
47
115
  end
48
116
  end
49
117
  end
@@ -1,6 +1,8 @@
1
1
  require_relative './spec_helper'
2
2
 
3
3
  describe "Edit Video" do
4
+ file_path = "./spec/support/video.mov"
5
+
4
6
  context "when user is unauthenticated" do
5
7
  it_behaves_like "Unauthenticated", -> (api) do
6
8
  api.edit_video(test_video_id("user1"), title: "foo")
@@ -8,42 +10,117 @@ describe "Edit Video" do
8
10
  end
9
11
 
10
12
  context "Authenticated User" do
11
- context "different account" do
12
- specify do
13
- api = _api(login: user2["login"],
14
- application_token: user2["rw_token"])
15
-
16
- expect do
17
- api.edit_video(test_video_id("user1"))
18
- end.to raise_error(Vzaar::Error, "Moved Temporarily")
19
- end
20
- end
21
-
22
- context "RW token" do
13
+ describe "POST verb" do
23
14
  before(:all) do
24
15
  @api = _api(login: user1["login"],
25
16
  application_token: user1["rw_token"])
17
+ @vid_id = test_video_id("user1")
26
18
  end
27
19
 
28
- describe "updating params" do
29
- before(:all) do
30
- @title = rand_str()
31
- @desc = rand_str()
32
- @res = @api.edit_video(test_video_id("user1"),
33
- title: @title,
34
- description: @desc)
20
+ context "when there is no method=put param" do
21
+ describe "xml" do
22
+ specify do
23
+ opts = { video_id: @vid_id, http_verb: :post }
24
+ req = Vzaar::Request::EditVideo.new(@api.conn, opts)
25
+
26
+ expect { req.execute }.to raise_error(Vzaar::Error)
27
+ end
35
28
  end
29
+ end
30
+
31
+ context "when method=put exists in post body" do
32
+ describe "xml" do
33
+ specify do
34
+ opts = { video_id: @vid_id, http_verb: :post}
35
+ req = Vzaar::Request::EditVideo.new(@api.conn, opts)
36
36
 
37
- it_behaves_like "200 OK"
37
+ def req.xml_body
38
+ <<-XML
39
+ <?xml version="1.0" encoding="UTF-8"?>
40
+ <vzaar-api>
41
+ <_method>put</_method>
42
+ <video>
43
+ <title>woof</title>
44
+ </video>
45
+ </vzaar-api>
46
+ XML
47
+ end
38
48
 
39
- specify { expect(@res.title).to eq(@title) }
40
- specify { expect(@res.description).to eq(@desc) }
49
+ res = req.execute
50
+ expect(res.http_status_code).to eq(200)
51
+ end
52
+ end
41
53
  end
42
54
  end
43
55
 
44
- context "RO token" do
45
- it_behaves_like "RO only", user1["login"], user1["ro_token"], -> (api) do
46
- api.edit_video(test_video_id("user1"), title: "woof")
56
+ describe "PUT verb" do
57
+ context "different account" do
58
+
59
+ describe "xml" do
60
+ specify do
61
+ api = _api(login: user2["login"],
62
+ application_token: user2["rw_token"])
63
+
64
+ expect do
65
+ api.edit_video(test_video_id("user1"))
66
+ end.to raise_error(Vzaar::Error, "Protected Resource")
67
+ end
68
+ end
69
+
70
+ describe "json" do
71
+ specify do
72
+ api = _api(login: user2["login"],
73
+ application_token: user2["rw_token"])
74
+
75
+ expect do
76
+ api.edit_video(test_video_id("user1"), format: "json")
77
+ end.to raise_error(Vzaar::Error, "Protected Resource")
78
+ end
79
+ end
80
+ end
81
+
82
+ context "RW token" do
83
+ before(:all) do
84
+ @api = _api(login: user1["login"],
85
+ application_token: user1["rw_token"])
86
+ end
87
+
88
+ describe "updating params" do
89
+
90
+ describe "xml" do
91
+ before(:all) do
92
+ @title = rand_str()
93
+ @desc = rand_str()
94
+ @res = @api.edit_video(test_video_id("user1"),
95
+ title: @title,
96
+ description: @desc)
97
+ end
98
+
99
+ it_behaves_like "200 OK"
100
+ specify { expect(@res.title).to eq(@title) }
101
+ specify { expect(@res.description).to eq(@desc) }
102
+ end
103
+ end
104
+
105
+ describe "json" do
106
+ before(:all) do
107
+ @title = rand_str()
108
+ @desc = rand_str()
109
+ @res = @api.edit_video(test_video_id("user1"),
110
+ title: @title,
111
+ description: @desc,
112
+ format: "json")
113
+ end
114
+
115
+ specify { expect(@res["oembed"]["title"]).to eq(@title) }
116
+ specify { expect(@res["oembed"]["description"]).to eq(@desc) }
117
+ end
118
+ end
119
+
120
+ context "RO token" do
121
+ it_behaves_like "RO only", user1["login"], user1["ro_token"], -> (api) do
122
+ api.edit_video(test_video_id("user1"), title: "woof")
123
+ end
47
124
  end
48
125
  end
49
126
  end
@@ -14,11 +14,18 @@ describe "Upload Video" do
14
14
  application_token: user1["rw_token"])
15
15
 
16
16
  title = "api-test-#{rand_str}"
17
- @res = api.upload_video(path: file_path, title: title, description: desc)
17
+ @res = api.upload_video(path: file_path, title: title, description: desc, profile: "boom")
18
+
19
+ # cleanup
20
+ api.delete_video(@res.id)
18
21
  end
19
22
 
20
23
  specify { expect(@res.http_status_code).to eq 201 }
21
24
  specify { expect(@res.id.to_s).to match(/^[0-9]+$/) }
25
+
26
+ after(:all) do
27
+
28
+ end
22
29
  end
23
30
 
24
31
  describe "json" do
@@ -28,6 +35,9 @@ describe "Upload Video" do
28
35
 
29
36
  title = "api-test-#{rand_str}"
30
37
  @res = api.upload_video(path: file_path, title: title, description: desc, format: :json)
38
+
39
+ # cleanup
40
+ api.delete_video(@res["id"])
31
41
  end
32
42
 
33
43
  specify { expect(@res["id"].to_s).to match(/^[0-9]+$/) }
@@ -61,6 +71,9 @@ describe "Upload Video" do
61
71
 
62
72
  title = "api-test-#{rand_str}"
63
73
  @res = api.upload_video(url: file_url, title: title, description: desc)
74
+
75
+ # cleanup
76
+ api.delete_video(@res.id)
64
77
  end
65
78
 
66
79
  specify { expect(@res.http_status_code).to eq 200 }
@@ -1,36 +1,49 @@
1
1
  require_relative './spec_helper'
2
2
 
3
3
  describe "Video Details" do
4
- context "Fully Protected API" do
5
- it_behaves_like "Unauthenticated", -> (api) do
6
- api.video_details(test_video_id("user1"))
7
- end
8
- end
9
-
10
- context "Public API" do
11
- before(:all) do
12
- api = unauthenticated_api
13
- @res = api.video_details(test_video_id("user_with_public_api"))
4
+ describe "Authenticated" do
5
+ before do
6
+ api = _api(login: user1["login"],
7
+ application_token: user1["rw_token"])
8
+
9
+ @res = api.video_details(test_video_id("user1"), authenticated: true)
14
10
  end
15
11
 
16
12
  it_behaves_like "200 OK"
17
13
  end
14
+
15
+ describe "Unauthenticated" do
16
+ context "Fully Protected API" do
17
+ it_behaves_like "Unauthenticated", -> (api) do
18
+ api.video_details(test_video_id("user1"))
19
+ end
20
+ end
18
21
 
19
- context "Protected API with access for public videos" do
20
- scope = api_envs[env]["user_with_public_videos_access_only"]
21
-
22
- context "when video is public" do
23
- before do
22
+ context "Public API" do
23
+ before(:all) do
24
24
  api = unauthenticated_api
25
- @res = api.video_details(scope["test_public_video_id"])
25
+ @res = api.video_details(test_video_id("user_with_public_api"))
26
26
  end
27
27
 
28
28
  it_behaves_like "200 OK"
29
29
  end
30
30
 
31
- context "when video is private" do
32
- it_behaves_like "Unauthenticated", -> (api) do
33
- api.video_details(scope["test_video_id"])
31
+ context "Protected API with access for public videos" do
32
+ scope = api_envs[env]["user_with_public_videos_access_only"]
33
+
34
+ context "when video is public" do
35
+ before do
36
+ api = unauthenticated_api
37
+ @res = api.video_details(scope["test_public_video_id"])
38
+ end
39
+
40
+ it_behaves_like "200 OK"
41
+ end
42
+
43
+ context "when video is private" do
44
+ it_behaves_like "Unauthenticated", -> (api) do
45
+ api.video_details(scope["test_video_id"])
46
+ end
34
47
  end
35
48
  end
36
49
  end
@@ -1,7 +1,20 @@
1
1
  require_relative './spec_helper'
2
2
 
3
3
  describe "Video List" do
4
- context "when user is unauthenticated" do
4
+ describe "authenticated" do
5
+ describe "labels" do
6
+ before do
7
+ api = _api(login: user1["login"],
8
+ application_token: user1["rw_token"])
9
+
10
+ @res = api.video_list(user1["login"], authenticated: true, params: { labels: "api,api2" })
11
+ end
12
+
13
+ specify { expect(@res.count).to eq(1) }
14
+ end
15
+ end
16
+
17
+ describe "Unauthenticated" do
5
18
  context "when Public API Feeds is enabled" do
6
19
  describe "params" do
7
20
  before(:all) do
@@ -7,7 +7,8 @@ module Vzaar
7
7
  [:authenticated, :http_verb].each do |method_name|
8
8
  define_method(method_name) do |val|
9
9
  define_method(method_name) do
10
- val.nil? ? self.options[method_name] : val
10
+ param = self.options[method_name]
11
+ blank?(param) ? val : param
11
12
  end
12
13
  end
13
14
  end
@@ -5,16 +5,30 @@ module Vzaar
5
5
  http_verb :put
6
6
  resource "Video"
7
7
 
8
+ # JC: duplicated, refactor
9
+ def json_body
10
+ get_opts.to_json
11
+ end
12
+
8
13
  def xml_body
9
- <<-XML
14
+ request_xml = %{
10
15
  <?xml version="1.0" encoding="UTF-8"?>
11
- <vzaar-api>
12
- <video>
13
- <title>#{options[:title]}</title>
14
- <description>#{options[:description]}</description >
15
- </video>
16
- </vzaar-api>
17
- XML
16
+ #{hash_to_xml(get_opts)}
17
+ }
18
+
19
+ request_xml
20
+ end
21
+
22
+ def get_opts
23
+ { "vzaar-api" => {
24
+ "video" => {
25
+ "title" => options[:title],
26
+ "seo_url" => options[:seo_url],
27
+ "description" => options[:description],
28
+ "private" => options[:private]
29
+ }
30
+ }
31
+ }
18
32
  end
19
33
  end
20
34
  end
@@ -35,7 +35,7 @@ module Vzaar
35
35
 
36
36
  { vzaar_api: {
37
37
  video: h
38
- }
38
+ }
39
39
  }
40
40
  end
41
41
 
data/lib/vzaar/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Vzaar
2
- VERSION = "1.4.1"
2
+ VERSION = "1.4.4"
3
3
  end
@@ -16,16 +16,18 @@ describe Vzaar::Request::Base do
16
16
  let(:authenticated?) { true }
17
17
 
18
18
  before do
19
- class TestClass < Vzaar::Request::Base; end
19
+ class TestClass < Vzaar::Request::Base
20
+ authenticated false
21
+ end
20
22
  end
21
23
 
22
24
  it "overwites setting with param from options" do
23
- expect(subject.authenticated).to eq(opts[:authenticated])
25
+ expect(subject.authenticated).to eq(authenticated?)
24
26
  end
25
27
  end
26
28
 
27
29
  context "when setting is defined within the class" do
28
- let(:authenticated?) { false }
30
+ let(:opts) { {} }
29
31
 
30
32
  before do
31
33
  class TestClass < Vzaar::Request::Base
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vzaar
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.4.1
4
+ version: 1.4.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ed James
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2014-11-26 00:00:00.000000000 Z
12
+ date: 2015-02-16 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: nokogiri
@@ -178,6 +178,7 @@ files:
178
178
  - ".ruby-gemset"
179
179
  - ".ruby-version"
180
180
  - ".travis.yml"
181
+ - ChangeLog
181
182
  - Gemfile
182
183
  - Guardfile
183
184
  - LICENSE
@@ -315,7 +316,7 @@ rubyforge_project:
315
316
  rubygems_version: 2.4.2
316
317
  signing_key:
317
318
  specification_version: 4
318
- summary: vzaar-1.4.1
319
+ summary: vzaar-1.4.4
319
320
  test_files:
320
321
  - spec/fixtures/vcr_cassettes/account_type-fail.yml
321
322
  - spec/fixtures/vcr_cassettes/account_type-success.yml