ruby_vsts 0.1.2 → 0.1.3
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 +4 -4
- checksums.yaml.gz.sig +0 -0
- data.tar.gz.sig +0 -0
- data/lib/ruby_vsts.rb +1 -0
- data/lib/vsts/api_client.rb +2 -1
- data/lib/vsts/change.rb +27 -0
- data/lib/vsts/shelveset.rb +84 -0
- data/lib/vsts/version.rb +1 -1
- data/spec/fixtures/tfvc_shelveset_by_id.json +28 -0
- data/spec/fixtures/tfvc_shelveset_changes.json +61 -0
- data/spec/fixtures/tfvc_shelvesets_list.json +45 -0
- data/spec/vsts/item_spec.rb +24 -1
- data/spec/vsts/shelveset_spec.rb +113 -0
- metadata +7 -2
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5936126e16987a197b693a76f8feb9b49d1245fd
|
4
|
+
data.tar.gz: fe65d2022879cc2db2ebcfc8a22957e56caf9b41
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 42ef7a72d2bba8bee3b47cb47358893bb10ad7b08788cc37ce63f3740e33437619f82b4dbc263a28b7ff2ee455d7da60e9f092f4431da4400bc64e2ca2d8b546
|
7
|
+
data.tar.gz: 9885fd6f5715d84f3a1df0cf2767bcb29dee8609162fd1c3902f354aba66435c22e011fd031044f1a99903a63cc0c784148e46f95a308d26f072feae016ec36b
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data.tar.gz.sig
CHANGED
Binary file
|
data/lib/ruby_vsts.rb
CHANGED
data/lib/vsts/api_client.rb
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
require 'rest-client'
|
2
2
|
require 'base64'
|
3
|
+
require 'erb'
|
3
4
|
|
4
5
|
# VSTS namespace
|
5
6
|
module VSTS
|
@@ -105,7 +106,7 @@ module VSTS
|
|
105
106
|
area = opts[:area] || VSTS.configuration.area
|
106
107
|
resource.sub!(%r{^\/+}, "")
|
107
108
|
|
108
|
-
base = [base_url, collection, team_project, "_apis", area, resource].compact.join("/")
|
109
|
+
base = [base_url, collection, team_project, "_apis", area, ERB::Util.url_encode(resource)].compact.join("/")
|
109
110
|
urlparams["api-version"] ||= api_version
|
110
111
|
url_encoded_params = URI.encode_www_form(urlparams) # makes url params from Hash
|
111
112
|
|
data/lib/vsts/change.rb
CHANGED
@@ -12,5 +12,32 @@ module VSTS
|
|
12
12
|
@change_type = h["changeType"]
|
13
13
|
@item = Item.new(h["item"])
|
14
14
|
end
|
15
|
+
|
16
|
+
# Convenience method to directly access item version
|
17
|
+
def version
|
18
|
+
@item.version
|
19
|
+
end
|
20
|
+
|
21
|
+
# Convenience method to directly access item path
|
22
|
+
def path
|
23
|
+
@item.path
|
24
|
+
end
|
25
|
+
|
26
|
+
# Convenience method to directly access item url
|
27
|
+
def url
|
28
|
+
@item.url
|
29
|
+
end
|
30
|
+
|
31
|
+
# Convenience method to directly download a change item (file)
|
32
|
+
#
|
33
|
+
# @param opts [Hash] options, see VSTS::Item#get
|
34
|
+
# @return [String] the downloaded file contents
|
35
|
+
def get(opts = nil)
|
36
|
+
if opts.nil?
|
37
|
+
@item.get
|
38
|
+
else
|
39
|
+
@item.get(opts)
|
40
|
+
end
|
41
|
+
end
|
15
42
|
end
|
16
43
|
end
|
@@ -0,0 +1,84 @@
|
|
1
|
+
# VSTS namespace
|
2
|
+
module VSTS
|
3
|
+
# Shelveset model
|
4
|
+
class Shelveset < BaseModel
|
5
|
+
attr_accessor :id, :name, :url, :owner, :created_date, :comment
|
6
|
+
|
7
|
+
# Create new shelveset instance from a hash
|
8
|
+
#
|
9
|
+
# @param h [Hash] shelveset data as returned by the VSTS API
|
10
|
+
def initialize(h = {})
|
11
|
+
@id = h["id"]
|
12
|
+
@name = h["name"]
|
13
|
+
@url = h["url"]
|
14
|
+
@owner = Identity.new(h["owner"])
|
15
|
+
@created_date = DateTime.rfc3339(h["createdDate"])
|
16
|
+
@comment = h["comment"]
|
17
|
+
@_changes = nil
|
18
|
+
end
|
19
|
+
|
20
|
+
# Get changes in the shelveset
|
21
|
+
# See https://www.visualstudio.com/en-us/docs/integrate/api/tfvc/shelvesets#get-shelveset-changes
|
22
|
+
#
|
23
|
+
# @param opts [Hash]
|
24
|
+
# @return [array of Change] list of changes in the shelveset
|
25
|
+
def changes(opts = {})
|
26
|
+
return @_changes if @_changes.instance_of?(Array)
|
27
|
+
urlparams = APIClient.build_params(opts, [["$", :top], ["$", :skip]])
|
28
|
+
resp = APIClient.get("/shelvesets/#{id}/changes", area: "tfvc", urlparams: urlparams)
|
29
|
+
@_changes = resp.parsed["changes"].map { |o| Change.new(o) }
|
30
|
+
end
|
31
|
+
|
32
|
+
# List shelvesets
|
33
|
+
# See https://www.visualstudio.com/en-us/docs/integrate/api/tfvc/shelvesets#get-list-of-shelvesets
|
34
|
+
#
|
35
|
+
# @param params [Hash]
|
36
|
+
# @return [array of Shelveset] search results
|
37
|
+
def self.find_all(params = {})
|
38
|
+
urlparams = APIClient.build_params(
|
39
|
+
params,
|
40
|
+
[
|
41
|
+
:owner,
|
42
|
+
:maxCommentLength,
|
43
|
+
["$", :top],
|
44
|
+
["$", :skip]
|
45
|
+
]
|
46
|
+
)
|
47
|
+
resp = APIClient.get("/shelvesets", area: "tfvc", urlparams: urlparams)
|
48
|
+
resp.parsed["value"].map { |o| Shelveset.new(o) }
|
49
|
+
end
|
50
|
+
|
51
|
+
# Find specific shelveset by name and owner
|
52
|
+
# See https://www.visualstudio.com/en-us/docs/integrate/api/tfvc/shelvesets#get-a-shelveset
|
53
|
+
#
|
54
|
+
# @param name [String] shelveset name
|
55
|
+
# @param owner [String] shelveset owner (unique guid, display name or email)
|
56
|
+
# @param opts [Hash] options
|
57
|
+
# @option opts [int] :maxCommentLength
|
58
|
+
# @option opts [int] :maxChangeCount
|
59
|
+
# @option opts [boolean] :includeDetails
|
60
|
+
# @option opts [boolean] :includeWorkItems
|
61
|
+
# @return [Shelveset, nil] the shelveset found or nil
|
62
|
+
def self.find_by_name(name, owner, opts = {})
|
63
|
+
urlparams = APIClient.build_params(opts, [:includeDetails, :includeWorkItems, :maxCommentLength, :maxChangeCount])
|
64
|
+
resp = APIClient.get("/shelvesets/#{name};#{owner}", area: "tfvc", urlparams: urlparams)
|
65
|
+
Shelveset.new(resp.parsed)
|
66
|
+
end
|
67
|
+
|
68
|
+
# Find specific shelveset by id
|
69
|
+
# See https://www.visualstudio.com/en-us/docs/integrate/api/tfvc/shelvesets#get-a-shelveset
|
70
|
+
#
|
71
|
+
# @param name [String] shelveset id
|
72
|
+
# @param opts [Hash] options
|
73
|
+
# @option opts [int] :maxCommentLength
|
74
|
+
# @option opts [int] :maxChangeCount
|
75
|
+
# @option opts [boolean] :includeDetails
|
76
|
+
# @option opts [boolean] :includeWorkItems
|
77
|
+
# @return [Shelveset, nil] the shelveset found or nil
|
78
|
+
def self.find(id, opts = {})
|
79
|
+
urlparams = APIClient.build_params(opts, [:includeDetails, :includeWorkItems, :maxCommentLength, :maxChangeCount])
|
80
|
+
resp = APIClient.get("/shelvesets/#{id}", area: "tfvc", urlparams: urlparams)
|
81
|
+
Shelveset.new(resp.parsed)
|
82
|
+
end
|
83
|
+
end
|
84
|
+
end
|
data/lib/vsts/version.rb
CHANGED
@@ -0,0 +1,28 @@
|
|
1
|
+
{
|
2
|
+
"name": "My first shelveset",
|
3
|
+
"id": "My first shelveset;d6245f20-2af8-44f4-9451-8107cb2767db",
|
4
|
+
"owner": {
|
5
|
+
"id": "d6245f20-2af8-44f4-9451-8107cb2767db",
|
6
|
+
"displayName": "Normal Paulk",
|
7
|
+
"uniqueName": "fabrikamfiber16@hotmail.com",
|
8
|
+
"url": "https://fabrikam-fiber-inc.vssps.visualstudio.com/_apis/Identities/d6245f20-2af8-44f4-9451-8107cb2767db",
|
9
|
+
"imageUrl": "https://fabrikam-fiber-inc.visualstudio.com/DefaultCollection/_api/_common/identityImage?id=d6245f20-2af8-44f4-9451-8107cb2767db"
|
10
|
+
},
|
11
|
+
"createdDate": "2014-07-18T03:37:52.277Z",
|
12
|
+
"comment": "Here is a really long comment describing this shelveset.",
|
13
|
+
"url": "https://fabrikam-fiber-inc.visualstudio.com/DefaultCollection/_apis/tfvc/shelvesets/My%20first%20shelveset%3bd6245f20-2af8-44f4-9451-8107cb2767db",
|
14
|
+
"_links": {
|
15
|
+
"self": {
|
16
|
+
"href": "https://fabrikam-fiber-inc.visualstudio.com/DefaultCollection/_apis/tfvc/shelvesets/My%20first%20shelveset%3bd6245f20-2af8-44f4-9451-8107cb2767db"
|
17
|
+
},
|
18
|
+
"changes": {
|
19
|
+
"href": "https://fabrikam-fiber-inc.visualstudio.com/DefaultCollection/_apis/tfvc/shelvesets/My%20first%20shelveset%3bd6245f20-2af8-44f4-9451-8107cb2767db/changes"
|
20
|
+
},
|
21
|
+
"workItems": {
|
22
|
+
"href": "https://fabrikam-fiber-inc.visualstudio.com/DefaultCollection/_apis/tfvc/shelvesets/My%20first%20shelveset%3bd6245f20-2af8-44f4-9451-8107cb2767db/workitems"
|
23
|
+
},
|
24
|
+
"owner": {
|
25
|
+
"href": "https://fabrikam-fiber-inc.vssps.visualstudio.com/_apis/Identities/d6245f20-2af8-44f4-9451-8107cb2767db"
|
26
|
+
}
|
27
|
+
}
|
28
|
+
}
|
@@ -0,0 +1,61 @@
|
|
1
|
+
{
|
2
|
+
"changes": [
|
3
|
+
{
|
4
|
+
"item": {
|
5
|
+
"version": 9,
|
6
|
+
"path": "$/Fabrikam-Fiber-TFVC/AuthSample/Code/App.config",
|
7
|
+
"url": "https://fabrikam-fiber-inc.visualstudio.com/DefaultCollection/_apis/tfvc/items/%24/Fabrikam-Fiber-TFVC/AuthSample/Code/App.config?versionType=Shelveset&version=My%20first%20shelveset%3Bfabrikamfiber16%40hotmail.com"
|
8
|
+
},
|
9
|
+
"changeType": "edit"
|
10
|
+
},
|
11
|
+
{
|
12
|
+
"item": {
|
13
|
+
"version": 9,
|
14
|
+
"path": "$/Fabrikam-Fiber-TFVC/AuthSample/Code/AuthSample.csproj",
|
15
|
+
"url": "https://fabrikam-fiber-inc.visualstudio.com/DefaultCollection/_apis/tfvc/items/%24/Fabrikam-Fiber-TFVC/AuthSample/Code/AuthSample.csproj?versionType=Shelveset&version=My%20first%20shelveset%3Bfabrikamfiber16%40hotmail.com"
|
16
|
+
},
|
17
|
+
"changeType": "edit"
|
18
|
+
},
|
19
|
+
{
|
20
|
+
"item": {
|
21
|
+
"path": "$/Fabrikam-Fiber-TFVC/AuthSample/Code/FabrikamEngine.cs",
|
22
|
+
"url": "https://fabrikam-fiber-inc.visualstudio.com/DefaultCollection/_apis/tfvc/items/%24/Fabrikam-Fiber-TFVC/AuthSample/Code/FabrikamEngine.cs?versionType=Shelveset&version=My%20first%20shelveset%3Bfabrikamfiber16%40hotmail.com"
|
23
|
+
},
|
24
|
+
"changeType": "add, edit, encoding"
|
25
|
+
},
|
26
|
+
{
|
27
|
+
"item": {
|
28
|
+
"version": 9,
|
29
|
+
"path": "$/Fabrikam-Fiber-TFVC/AuthSample/Code/Properties/AssemblyInfo.cs",
|
30
|
+
"url": "https://fabrikam-fiber-inc.visualstudio.com/DefaultCollection/_apis/tfvc/items/%24/Fabrikam-Fiber-TFVC/AuthSample/Code/Properties/AssemblyInfo.cs?versionType=Shelveset&version=My%20first%20shelveset%3Bfabrikamfiber16%40hotmail.com"
|
31
|
+
},
|
32
|
+
"changeType": "delete"
|
33
|
+
}
|
34
|
+
],
|
35
|
+
"name": "My first shelveset",
|
36
|
+
"id": "My first shelveset;d6245f20-2af8-44f4-9451-8107cb2767db",
|
37
|
+
"owner": {
|
38
|
+
"id": "d6245f20-2af8-44f4-9451-8107cb2767db",
|
39
|
+
"displayName": "Normal Paulk",
|
40
|
+
"uniqueName": "fabrikamfiber16@hotmail.com",
|
41
|
+
"url": "https://fabrikam-fiber-inc.vssps.visualstudio.com/_apis/Identities/d6245f20-2af8-44f4-9451-8107cb2767db",
|
42
|
+
"imageUrl": "https://fabrikam-fiber-inc.visualstudio.com/DefaultCollection/_api/_common/identityImage?id=d6245f20-2af8-44f4-9451-8107cb2767db"
|
43
|
+
},
|
44
|
+
"createdDate": "2014-07-18T03:37:52.277Z",
|
45
|
+
"comment": "Here is a really long comment describing this shelveset.",
|
46
|
+
"url": "https://fabrikam-fiber-inc.visualstudio.com/DefaultCollection/_apis/tfvc/shelvesets/My%20first%20shelveset%3bd6245f20-2af8-44f4-9451-8107cb2767db",
|
47
|
+
"_links": {
|
48
|
+
"self": {
|
49
|
+
"href": "https://fabrikam-fiber-inc.visualstudio.com/DefaultCollection/_apis/tfvc/shelvesets/My%20first%20shelveset%3bd6245f20-2af8-44f4-9451-8107cb2767db"
|
50
|
+
},
|
51
|
+
"changes": {
|
52
|
+
"href": "https://fabrikam-fiber-inc.visualstudio.com/DefaultCollection/_apis/tfvc/shelvesets/My%20first%20shelveset%3bd6245f20-2af8-44f4-9451-8107cb2767db/changes"
|
53
|
+
},
|
54
|
+
"workItems": {
|
55
|
+
"href": "https://fabrikam-fiber-inc.visualstudio.com/DefaultCollection/_apis/tfvc/shelvesets/My%20first%20shelveset%3bd6245f20-2af8-44f4-9451-8107cb2767db/workitems"
|
56
|
+
},
|
57
|
+
"owner": {
|
58
|
+
"href": "https://fabrikam-fiber-inc.vssps.visualstudio.com/_apis/Identities/d6245f20-2af8-44f4-9451-8107cb2767db"
|
59
|
+
}
|
60
|
+
}
|
61
|
+
}
|
@@ -0,0 +1,45 @@
|
|
1
|
+
{
|
2
|
+
"count": 3,
|
3
|
+
"value": [
|
4
|
+
{
|
5
|
+
"name": "My first shelveset",
|
6
|
+
"id": "My first shelveset;d6245f20-2af8-44f4-9451-8107cb2767db",
|
7
|
+
"owner": {
|
8
|
+
"id": "d6245f20-2af8-44f4-9451-8107cb2767db",
|
9
|
+
"displayName": "Normal Paulk",
|
10
|
+
"uniqueName": "fabrikamfiber16@hotmail.com",
|
11
|
+
"url": "https://fabrikam-fiber-inc.vssps.visualstudio.com/_apis/Identities/d6245f20-2af8-44f4-9451-8107cb2767db",
|
12
|
+
"imageUrl": "https://fabrikam-fiber-inc.visualstudio.com/DefaultCollection/_api/_common/identityImage?id=d6245f20-2af8-44f4-9451-8107cb2767db"
|
13
|
+
},
|
14
|
+
"createdDate": "2014-07-18T03:37:52.277Z",
|
15
|
+
"comment": "Here is a really long comment describing this shelveset.",
|
16
|
+
"url": "https://fabrikam-fiber-inc.visualstudio.com/DefaultCollection/_apis/tfvc/shelvesets/My%20first%20shelveset%3bd6245f20-2af8-44f4-9451-8107cb2767db"
|
17
|
+
},
|
18
|
+
{
|
19
|
+
"name": "More changes",
|
20
|
+
"id": "More changes;d6245f20-2af8-44f4-9451-8107cb2767db",
|
21
|
+
"owner": {
|
22
|
+
"id": "d6245f20-2af8-44f4-9451-8107cb2767db",
|
23
|
+
"displayName": "Normal Paulk",
|
24
|
+
"uniqueName": "fabrikamfiber16@hotmail.com",
|
25
|
+
"url": "https://fabrikam-fiber-inc.vssps.visualstudio.com/_apis/Identities/d6245f20-2af8-44f4-9451-8107cb2767db",
|
26
|
+
"imageUrl": "https://fabrikam-fiber-inc.visualstudio.com/DefaultCollection/_api/_common/identityImage?id=d6245f20-2af8-44f4-9451-8107cb2767db"
|
27
|
+
},
|
28
|
+
"createdDate": "2014-07-18T03:29:45.91Z",
|
29
|
+
"url": "https://fabrikam-fiber-inc.visualstudio.com/DefaultCollection/_apis/tfvc/shelvesets/More%20changes%3bd6245f20-2af8-44f4-9451-8107cb2767db"
|
30
|
+
},
|
31
|
+
{
|
32
|
+
"name": "Doc updates",
|
33
|
+
"id": "Doc updates;d6245f20-2af8-44f4-9451-8107cb2767db",
|
34
|
+
"owner": {
|
35
|
+
"id": "d6245f20-2af8-44f4-9451-8107cb2767db",
|
36
|
+
"displayName": "Normal Paulk",
|
37
|
+
"uniqueName": "fabrikamfiber16@hotmail.com",
|
38
|
+
"url": "https://fabrikam-fiber-inc.vssps.visualstudio.com/_apis/Identities/d6245f20-2af8-44f4-9451-8107cb2767db",
|
39
|
+
"imageUrl": "https://fabrikam-fiber-inc.visualstudio.com/DefaultCollection/_api/_common/identityImage?id=d6245f20-2af8-44f4-9451-8107cb2767db"
|
40
|
+
},
|
41
|
+
"createdDate": "2014-07-18T03:27:25.18Z",
|
42
|
+
"url": "https://fabrikam-fiber-inc.visualstudio.com/DefaultCollection/_apis/tfvc/shelvesets/Doc%20updates%3bd6245f20-2af8-44f4-9451-8107cb2767db"
|
43
|
+
}
|
44
|
+
]
|
45
|
+
}
|
data/spec/vsts/item_spec.rb
CHANGED
@@ -21,7 +21,8 @@ describe VSTS::Item do
|
|
21
21
|
.to_return(status: 200, body: "test file\ncontents")
|
22
22
|
end
|
23
23
|
|
24
|
-
let(:
|
24
|
+
let(:change) { VSTS::Changeset.find(16).changes[0] }
|
25
|
+
let(:item) { change.item }
|
25
26
|
let(:expected_url) { "https://test.visualstudio.local/DefaultCollection/_apis/tfvc/items" }
|
26
27
|
|
27
28
|
it "downloads from the correct URL" do
|
@@ -70,5 +71,27 @@ describe VSTS::Item do
|
|
70
71
|
item.get(versionType: :changeset, version: 1000, versionOptions: :previous)
|
71
72
|
expect(a_request(:get, expected_url).with(query: query)).to have_been_made.once
|
72
73
|
end
|
74
|
+
|
75
|
+
describe "convenience methods (shortcuts)" do
|
76
|
+
it "passes on #version to its Item and returns the same results" do
|
77
|
+
expect(change.item.version).to eq(change.version)
|
78
|
+
end
|
79
|
+
|
80
|
+
it "passes on #path to its Item and returns the same results" do
|
81
|
+
expect(change.item.path).to eq(change.path)
|
82
|
+
end
|
83
|
+
|
84
|
+
it "passes on #url to its Item and returns the same results" do
|
85
|
+
expect(change.item.url).to eq(change.url)
|
86
|
+
end
|
87
|
+
|
88
|
+
it "passes on #get to its Item and returns the same results" do
|
89
|
+
expect(change.item.get).to eq(change.get)
|
90
|
+
end
|
91
|
+
|
92
|
+
it "passes on #get to its Item with parameters and returns the same results" do
|
93
|
+
expect(change.item.get(version: 123)).to eq(change.get(version: 123))
|
94
|
+
end
|
95
|
+
end
|
73
96
|
end
|
74
97
|
# rubocop:enable Metrics/BlockLength
|
@@ -0,0 +1,113 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
# rubocop:disable Metrics/BlockLength
|
4
|
+
describe VSTS::Shelveset do
|
5
|
+
before do
|
6
|
+
VSTS.reset
|
7
|
+
VSTS.configure do |config|
|
8
|
+
config.personal_access_token = "test_token"
|
9
|
+
config.base_url = "https://test.visualstudio.local/"
|
10
|
+
config.debug = false
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
let(:expected_url) { "https://test.visualstudio.local/DefaultCollection/_apis/tfvc/shelvesets" }
|
15
|
+
|
16
|
+
describe "finding a single shelveset" do
|
17
|
+
before do
|
18
|
+
# stub one changeset
|
19
|
+
stub_request(:get, /test.visualstudio.local\/.*?\/shelvesets\/[^\/\?]+\?/)
|
20
|
+
.to_return(status: 200, body: File.new(fixtures_path + "tfvc_shelveset_by_id.json"))
|
21
|
+
end
|
22
|
+
|
23
|
+
it "can find a Shelveset instance by name and owner" do
|
24
|
+
described_class.find_by_name("Abc def", "12345")
|
25
|
+
query = {
|
26
|
+
"api-version" => "1.0"
|
27
|
+
}
|
28
|
+
expect(a_request(:get, expected_url + "%2FAbc\%20def;12345").with(query: query)).to have_been_made.once
|
29
|
+
end
|
30
|
+
|
31
|
+
let(:shelveset) { described_class.find("My first shelveset;d6245f20-2af8-44f4-9451-8107cb2767db") }
|
32
|
+
|
33
|
+
it "can find a Shelveset instance by id" do
|
34
|
+
expect(shelveset).to be_a(described_class)
|
35
|
+
end
|
36
|
+
|
37
|
+
it "can fill in Shelveset instance fields from the response" do
|
38
|
+
expect(shelveset.name).to eq("My first shelveset")
|
39
|
+
end
|
40
|
+
|
41
|
+
it "can download changes" do
|
42
|
+
expect(shelveset).to respond_to(:changes)
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
describe "finding a list of shelvesets" do
|
47
|
+
before do
|
48
|
+
# stub list of shelvesets (the same response for any query)
|
49
|
+
stub_request(:get, /test.visualstudio.local\/.*?\/shelvesets\?/)
|
50
|
+
.to_return(status: 200, body: File.new(fixtures_path + "tfvc_shelvesets_list.json"))
|
51
|
+
end
|
52
|
+
|
53
|
+
let(:expected_url) { "https://test.visualstudio.local/DefaultCollection/_apis/tfvc/shelvesets" }
|
54
|
+
|
55
|
+
it "can find a list of changesets as an array" do
|
56
|
+
shelveset_list = described_class.find_all
|
57
|
+
expect(shelveset_list).to be_an(Array)
|
58
|
+
expect(shelveset_list[0]).to be_a(described_class)
|
59
|
+
end
|
60
|
+
|
61
|
+
it "can find all changesets" do
|
62
|
+
changeset_list = described_class.find_all
|
63
|
+
expect(changeset_list.length).to eq(3)
|
64
|
+
end
|
65
|
+
|
66
|
+
it "can request a page at a time" do
|
67
|
+
described_class.find_all(top: 20, skip: 100)
|
68
|
+
query = {
|
69
|
+
"$top" => 20,
|
70
|
+
"$skip" => 100,
|
71
|
+
"api-version" => "1.0"
|
72
|
+
}
|
73
|
+
expect(a_request(:get, expected_url).with(query: query)).to have_been_made.once
|
74
|
+
end
|
75
|
+
|
76
|
+
describe "filtering" do
|
77
|
+
it "can filter by owner" do
|
78
|
+
described_class.find_all(owner: "Normal Paulk") # can be display name, email or unique guid
|
79
|
+
query = {
|
80
|
+
"owner" => "Normal Paulk",
|
81
|
+
"api-version" => "1.0"
|
82
|
+
}
|
83
|
+
expect(a_request(:get, expected_url).with(query: query)).to have_been_made.once
|
84
|
+
end
|
85
|
+
end
|
86
|
+
end
|
87
|
+
|
88
|
+
describe "downloading changes in a shelveset" do
|
89
|
+
before do
|
90
|
+
# stub one shelveset
|
91
|
+
stub_request(:get, /test.visualstudio.local\/.*?\/shelvesets\/[^\/\?]+\?/)
|
92
|
+
.to_return(status: 200, body: File.new(fixtures_path + "tfvc_shelveset_by_id.json"))
|
93
|
+
# stub changes in a shelveset
|
94
|
+
stub_request(:get, /test.visualstudio.local\/.*?\/shelvesets\/[^\/\?]+\/changes\?/)
|
95
|
+
.to_return(status: 200, body: File.new(fixtures_path + "tfvc_shelveset_changes.json"))
|
96
|
+
end
|
97
|
+
|
98
|
+
let(:changes) { described_class.find("My first shelveset;d6245f20-2af8-44f4-9451-8107cb2767db").changes }
|
99
|
+
|
100
|
+
it "can get changes as an Array" do
|
101
|
+
expect(changes).to be_an(Array)
|
102
|
+
end
|
103
|
+
|
104
|
+
it "creates the required amount of changes" do
|
105
|
+
expect(changes.length).to eq(4)
|
106
|
+
end
|
107
|
+
|
108
|
+
it "creates Change instances" do
|
109
|
+
expect(changes[0]).to be_a(VSTS::Change)
|
110
|
+
end
|
111
|
+
end
|
112
|
+
end
|
113
|
+
# rubocop:enable Metrics/BlockLength
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ruby_vsts
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Gabor Lengyel
|
@@ -30,7 +30,7 @@ cert_chain:
|
|
30
30
|
Pfk9fa2jjnmyUPewuJZHmwArB9oRryAdwWtOsvVZHZ1ulcmW+Pbo2IiYQHvl1zQH
|
31
31
|
Z5Mw91gFnDov+9F9be4W5sZmbj640vetlJGLdMFheEZ2HSX+4fEZu1k=
|
32
32
|
-----END CERTIFICATE-----
|
33
|
-
date: 2017-04-
|
33
|
+
date: 2017-04-23 00:00:00.000000000 Z
|
34
34
|
dependencies:
|
35
35
|
- !ruby/object:Gem::Dependency
|
36
36
|
name: rest-client
|
@@ -213,17 +213,22 @@ files:
|
|
213
213
|
- lib/vsts/configuration.rb
|
214
214
|
- lib/vsts/identity.rb
|
215
215
|
- lib/vsts/item.rb
|
216
|
+
- lib/vsts/shelveset.rb
|
216
217
|
- lib/vsts/version.rb
|
217
218
|
- ruby_vsts.gemspec
|
218
219
|
- spec/fixtures/tfvc_changeset_by_id.json
|
219
220
|
- spec/fixtures/tfvc_changeset_changes.json
|
220
221
|
- spec/fixtures/tfvc_changesets_list.json
|
222
|
+
- spec/fixtures/tfvc_shelveset_by_id.json
|
223
|
+
- spec/fixtures/tfvc_shelveset_changes.json
|
224
|
+
- spec/fixtures/tfvc_shelvesets_list.json
|
221
225
|
- spec/spec_helper.rb
|
222
226
|
- spec/vsts/base_model_spec.rb
|
223
227
|
- spec/vsts/change_spec.rb
|
224
228
|
- spec/vsts/changeset_spec.rb
|
225
229
|
- spec/vsts/configuration_spec.rb
|
226
230
|
- spec/vsts/item_spec.rb
|
231
|
+
- spec/vsts/shelveset_spec.rb
|
227
232
|
- spec/vsts_spec.rb
|
228
233
|
homepage: https://github.com/prodexity/ruby_vsts/
|
229
234
|
licenses:
|
metadata.gz.sig
CHANGED
Binary file
|