youtrack 0.0.8 → 0.0.9

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b49b0b2fa1572425997a8638aed4498b15c8169b
4
- data.tar.gz: 6aab1f47e3f3d7d5b0af1ae408d1a6f1dd07eb01
3
+ metadata.gz: 34b0cfe1c85c133c97760e028aa473f91b6cc488
4
+ data.tar.gz: 572a1ca3ceb3344a48f942c2bad07eca3e6927ee
5
5
  SHA512:
6
- metadata.gz: 4b6b76023f8477b95215d897019837f6c6132c0ab6e0a3c669010d76f76bced792c4726332072a22181fd39c2a316c466e80101b4221910bc228cdd5816f0b89
7
- data.tar.gz: 6d33cc644eec81607418b502e0a3bd90a22188170353fc054f5db7532e6b2981bcb7efd13bb2b594132b402c3c32deed8b5cc54da8d2caf3550520f5b0da7aad
6
+ metadata.gz: 63ea5521cde76e24d6e797cf472384fb6ad64fa3d0a3e0ac6f3c3fd6f676090773b6200c4a1c926651b21c30f4b2899f3cd3cead6224c8618c9b30464c707c47
7
+ data.tar.gz: 517d918c6111abb1e4f25b90a386487008034b7074fef3da85d49b2b0b20326e689e6696c9e78cab9837eb2f583d8b247fa993345883df0f14302db017511edf
data/.envrc ADDED
@@ -0,0 +1 @@
1
+ export PATH=$PWD/binstubs:$PATH
data/.gitignore CHANGED
@@ -16,3 +16,4 @@ spec/reports
16
16
  test/tmp
17
17
  test/version_tmp
18
18
  tmp
19
+ vendor/
data/README.md CHANGED
@@ -3,6 +3,7 @@
3
3
  youTrack REST API Client
4
4
 
5
5
  [![Build Status](https://travis-ci.org/jwaterfaucett/youtrack.png)](https://travis-ci.org/jwaterfaucett/youtrack)
6
+ [![Gem Version](https://badge.fury.io/rb/youtrack.png)](http://badge.fury.io/rb/youtrack)
6
7
 
7
8
  ## Installation
8
9
 
@@ -1,29 +1,3 @@
1
1
  require "youtrack"
2
2
  require "webmock"
3
- include WebMock::API
4
3
 
5
- module YServer
6
- URL = "https://youtrackserver.com"
7
- Endpoint = "#{URL}/rest"
8
- Login = "root"
9
- Lorem = 'lorem'
10
- Password = "root"
11
- FIXTURE_PATH = File.expand_path('../../../spec/fixtures', __FILE__ )
12
- COOKIE = "jetbrains.charisma.main.security.PRINCIPAL=NmZkNDc3NDgxZjBhOWNjMTVjNDQwNTljNTE1NzM1ODEwM2I3MjgyMDlkZDAzZGJhYTAzYzU1ZmYyZGUyZWMxNzpyb290;Path=/youtrack;Expires=Sat, 24-Jan-2015 07:49:19 GMT"
13
- end
14
-
15
- def fixture(filename)
16
- File.read(YServer::FIXTURE_PATH + "/#{filename}")
17
- end
18
-
19
- #=========================
20
- # Request Stubs
21
- #=========================
22
-
23
- stub_request(:post, "#{YServer::Endpoint}/user/login").
24
- with(:body => "login=#{YServer::Login}&password=#{YServer::Password}").
25
- to_return(:status => 200, body: fixture('login_body_ok.xml'), :headers => { 'set-cookie' => YServer::COOKIE })
26
-
27
- stub_request(:post, "#{YServer::Endpoint}/user/login").
28
- with(:body => "login=#{YServer::Lorem}&password=#{YServer::Lorem}").
29
- to_return(:status => 403, body: fixture('login_body_error.xml'), :headers => { 'set-cookie' => YServer::COOKIE })
@@ -1,4 +1 @@
1
1
 
2
- Before do
3
- @client = Youtrack::Client.new
4
- end
@@ -0,0 +1,16 @@
1
+ require "vcr"
2
+
3
+
4
+ VCR.config do |c|
5
+
6
+ # tell vcr where to store recorded responses
7
+ c.cassette_library_dir = "fixtures/cassette_library"
8
+
9
+ # use webmock for stubbing
10
+ c.hook_into :webmock
11
+
12
+ # allow local requests
13
+ c.ignore_localhost = true
14
+
15
+ c.default_cassette_options = { record: :none }
16
+ end
@@ -1 +0,0 @@
1
- World(YServer)
@@ -7,4 +7,5 @@ module Youtrack
7
7
  autoload :Issue, "youtrack/resources/issue"
8
8
  autoload :Project, "youtrack/resources/project"
9
9
  autoload :User, "youtrack/resources/user"
10
+ autoload :Tag, "youtrack/resources/tag"
10
11
  end
@@ -26,9 +26,13 @@ module Youtrack
26
26
  true == @admin
27
27
  end
28
28
 
29
+ # Sets debugging mode
30
+ attr_accessor :debug
31
+
29
32
  def initialize(options={}, &block)
30
- @cookies = {}
31
- @admin = false
33
+ @cookies = {}
34
+ @admin = false
35
+ @debug = false
32
36
 
33
37
  yield(self) if block_given?
34
38
  end
@@ -68,6 +72,10 @@ module Youtrack
68
72
  resource(:issue).new(self)
69
73
  end
70
74
 
75
+ def tags
76
+ resource(:tag).new(self)
77
+ end
78
+
71
79
  private
72
80
 
73
81
  def resource(resource_name)
@@ -15,6 +15,7 @@ module Youtrack
15
15
  def initialize(client)
16
16
  @service = client
17
17
  @base_url = @service.endpoint
18
+ self.class.debug_output($stderr) if client.debug
18
19
  end
19
20
 
20
21
  protected
@@ -16,7 +16,7 @@ module Youtrack
16
16
  # attachments file in "multipart/form-data" format One or several files in "multipart/form-data" format that should be attached to the new issue.
17
17
  # permittedGroup string Set visibility for the new issue, that is: Specify a user group to which the issue will be visible.
18
18
  def create(attributes={})
19
- put("issue", body: attributes)
19
+ put("issue", query: attributes)
20
20
  response
21
21
  end
22
22
 
@@ -61,7 +61,7 @@ module Youtrack
61
61
  # summary string New summary for the specified issue.
62
62
  # description string Updated description for the specified issue.
63
63
  def update(issue_id, attributes={})
64
- post("issue/#{issue_id}", body: attributes)
64
+ post("issue/#{issue_id}", query: attributes)
65
65
  response.parsed_response
66
66
  end
67
67
 
@@ -74,13 +74,21 @@ module Youtrack
74
74
  url = URI.parse(join(base_url, "issue/#{issue_id}/attachment"))
75
75
  req = Net::HTTP::Post::Multipart.new( url.path, "file" => UploadIO.new(data, content_type, filename))
76
76
  req['Cookie'] = service.cookies['Cookie']
77
- response = Net::HTTP.start(url.host, url.port) { |http| http.request(req) }
77
+ http = Net::HTTP.new(url.host, url.port)
78
+ http.set_debug_output($stderr) if service.debug
79
+
80
+ if url.scheme == 'https'
81
+ http.use_ssl = true
82
+ http.verify_mode = OpenSSL::SSL::VERIFY_PEER
83
+ end
84
+
85
+ response = http.request(req)
78
86
  response
79
87
  end
80
88
 
81
89
 
82
90
  def add_comment(issue_id, attributes={})
83
- post("issue/#{issue_id}/execute", body: attributes)
91
+ post("issue/#{issue_id}/execute", query: attributes)
84
92
  response
85
93
  end
86
94
 
@@ -40,7 +40,7 @@ module Youtrack
40
40
  # projectLeadLogin string required Login name of a user to be assigned as a project leader.
41
41
  # description string Optional description of the new project
42
42
  def create(attributes={})
43
- put("admin/project/#{attributes[:projectId]}", body: attributes)
43
+ put("admin/project/#{attributes[:projectId]}", query: attributes)
44
44
  response
45
45
  end
46
46
 
@@ -0,0 +1,52 @@
1
+ module Youtrack
2
+ class Tag < Base
3
+
4
+ # get all user's tags
5
+ def get_all_tags
6
+ get('user/tag')
7
+ response.parsed_response
8
+ end
9
+
10
+ # get a user's tag by name
11
+ def get_tag_by_name( tag_name )
12
+ get("user/tag/#{tag_name}")
13
+ response.parsed_response
14
+ end
15
+
16
+ # add new user's tag
17
+ #
18
+ # attributes:
19
+ # tagName (required) String The name of the new tag
20
+ # visibleForGroup (required) String Name of a user group in which tag should be visible
21
+ # updatableByGroup (required) String Name of user group whose members can edit the new tag
22
+ # untagOnResolve (optional) Boolean autoremove when issue's state changes
23
+ #
24
+ # API Success: Returns 201 Created with Location Header set
25
+ # Returns the response object
26
+
27
+ def create(attributes={})
28
+ tag_name = attributes.delete(:tagName)
29
+ put("user/tag/#{tag_name}", attributes)
30
+ response
31
+ end
32
+
33
+ # update an existing tag
34
+ #
35
+ # attributes:
36
+ # tagName (required) String The name of tag to edit.
37
+ # newName (required) String the new name for the tag.
38
+ # visibleForGroup (required) String Name of a user group in which tag should be visible
39
+ # updatableByGroup (required) String Name of user group whose members can edit the new tag
40
+ # untagOnResolve (optional) Boolean autoremove when issue's state changes
41
+ #
42
+ # API Success: Returns 301 Moved Permanently with Location Header set
43
+ # Returns the response object
44
+
45
+ def update(attributes={})
46
+ tag_name = attributes.delete(:tagName)
47
+ post("user/tag/#{tag_name}", attributes)
48
+ response
49
+ end
50
+
51
+ end
52
+ end
@@ -1,3 +1,3 @@
1
1
  module Youtrack
2
- VERSION = "0.0.8"
2
+ VERSION = "0.0.9"
3
3
  end
@@ -0,0 +1,40 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: post
5
+ uri: https://testcloud.myjetbrains.com/youtrack/rest/user/login
6
+ body:
7
+ encoding: UTF-8
8
+ string: login=testuser&password=testuser
9
+ headers: {}
10
+ response:
11
+ status:
12
+ code: 200
13
+ message: OK
14
+ headers:
15
+ Server:
16
+ - nginx
17
+ Date:
18
+ - Fri, 07 Feb 2014 21:23:50 GMT
19
+ Content-Type:
20
+ - application/xml; charset=UTF-8
21
+ Transfer-Encoding:
22
+ - chunked
23
+ Connection:
24
+ - keep-alive
25
+ Vary:
26
+ - Accept-Encoding
27
+ Set-Cookie:
28
+ - JSESSIONID=i1nlki01vb7k2ti2k3wmizbk;Path=/youtrack;Secure
29
+ - jetbrains.charisma.main.security.PRINCIPAL=YWU1ZGViODIyZTBkNzE5OTI5MDA0NzFhNzE5OWQwZDk1YjhlN2M5ZDA1YzQwYTgyNDVhMjgxZmQyYzFkNjY4NDp0ZXN0dXNlcg;Path=/youtrack;Expires=Sat,
30
+ 07-Feb-2015 21:23:50 GMT
31
+ Expires:
32
+ - Thu, 01 Jan 1970 00:00:00 GMT
33
+ Cache-Control:
34
+ - no-cache, no-store, no-transform, must-revalidate
35
+ body:
36
+ encoding: UTF-8
37
+ string: <login>ok</login>
38
+ http_version:
39
+ recorded_at: Fri, 07 Feb 2014 21:25:36 GMT
40
+ recorded_with: VCR 2.8.0
@@ -0,0 +1,39 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: post
5
+ uri: https://testcloud.myjetbrains.com/youtrack/rest/user/login
6
+ body:
7
+ encoding: UTF-8
8
+ string: login=invalid_user&password=invalid_pass
9
+ headers: {}
10
+ response:
11
+ status:
12
+ code: 403
13
+ message: Forbidden
14
+ headers:
15
+ Server:
16
+ - nginx
17
+ Date:
18
+ - Fri, 07 Feb 2014 21:59:44 GMT
19
+ Content-Type:
20
+ - application/xml; charset=UTF-8
21
+ Content-Length:
22
+ - '98'
23
+ Connection:
24
+ - keep-alive
25
+ Vary:
26
+ - Accept-Encoding
27
+ Set-Cookie:
28
+ - JSESSIONID=16ngfmvqeqmc912t0v7q6fo2kc;Path=/youtrack;Secure
29
+ Expires:
30
+ - Thu, 01 Jan 1970 00:00:00 GMT
31
+ Cache-Control:
32
+ - no-cache, no-store, no-transform, must-revalidate
33
+ body:
34
+ encoding: UTF-8
35
+ string: <?xml version="1.0" encoding="UTF-8" standalone="yes"?><error>Incorrect
36
+ login or password.</error>
37
+ http_version:
38
+ recorded_at: Fri, 07 Feb 2014 22:01:31 GMT
39
+ recorded_with: VCR 2.8.0
@@ -0,0 +1,45 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: post
5
+ uri: https://testcloud.myjetbrains.com/youtracks/rest/user/login
6
+ body:
7
+ encoding: UTF-8
8
+ string: login=testuser&password=testuser
9
+ headers: {}
10
+ response:
11
+ status:
12
+ code: 404
13
+ message: Not Found
14
+ headers:
15
+ Server:
16
+ - nginx
17
+ Date:
18
+ - Fri, 07 Feb 2014 21:59:42 GMT
19
+ Content-Type:
20
+ - text/html;charset=ISO-8859-1
21
+ Content-Length:
22
+ - '1292'
23
+ Connection:
24
+ - keep-alive
25
+ Cache-Control:
26
+ - must-revalidate,no-cache,no-store
27
+ body:
28
+ encoding: UTF-8
29
+ string: "<html>\n<head>\n<meta http-equiv=\"Content-Type\" content=\"text/html;charset=ISO-8859-1\"/>\n<title>Error
30
+ 404 Not Found</title>\n</head>\n<body>\n<h2>HTTP ERROR: 404</h2>\n<p>Problem
31
+ accessing /youtracks/rest/user/login. Reason:\n<pre> Not Found</pre></p>\n<hr
32
+ /><i><small>Powered by Jetty://</small></i>\n \n
33
+ \ \n \n
34
+ \ \n \n
35
+ \ \n \n
36
+ \ \n \n
37
+ \ \n \n
38
+ \ \n \n
39
+ \ \n \n
40
+ \ \n \n
41
+ \ \n \n
42
+ \ \n</body>\n</html>\n"
43
+ http_version:
44
+ recorded_at: Fri, 07 Feb 2014 22:01:29 GMT
45
+ recorded_with: VCR 2.8.0
@@ -0,0 +1,75 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: post
5
+ uri: https://testcloud.myjetbrains.com/youtrack/rest/user/login
6
+ body:
7
+ encoding: UTF-8
8
+ string: login=testuser&password=testuser
9
+ headers: {}
10
+ response:
11
+ status:
12
+ code: 200
13
+ message: OK
14
+ headers:
15
+ Server:
16
+ - nginx
17
+ Date:
18
+ - Fri, 07 Feb 2014 22:39:52 GMT
19
+ Content-Type:
20
+ - application/xml; charset=UTF-8
21
+ Transfer-Encoding:
22
+ - chunked
23
+ Connection:
24
+ - keep-alive
25
+ Vary:
26
+ - Accept-Encoding
27
+ Set-Cookie:
28
+ - JSESSIONID=1x6fz1xa878jlneco9qotclw8;Path=/youtrack;Secure
29
+ - jetbrains.charisma.main.security.PRINCIPAL=YWU1ZGViODIyZTBkNzE5OTI5MDA0NzFhNzE5OWQwZDk1YjhlN2M5ZDA1YzQwYTgyNDVhMjgxZmQyYzFkNjY4NDp0ZXN0dXNlcg;Path=/youtrack;Expires=Sat,
30
+ 07-Feb-2015 22:39:52 GMT
31
+ Expires:
32
+ - Thu, 01 Jan 1970 00:00:00 GMT
33
+ Cache-Control:
34
+ - no-cache, no-store, no-transform, must-revalidate
35
+ body:
36
+ encoding: UTF-8
37
+ string: <login>ok</login>
38
+ http_version:
39
+ recorded_at: Fri, 07 Feb 2014 22:41:39 GMT
40
+ - request:
41
+ method: get
42
+ uri: https://testcloud.myjetbrains.com/youtrack/rest/user/current
43
+ body:
44
+ encoding: US-ASCII
45
+ string: ''
46
+ headers:
47
+ Cookie:
48
+ - JSESSIONID=1x6fz1xa878jlneco9qotclw8;Path=/youtrack;Secure, jetbrains.charisma.main.security.PRINCIPAL=YWU1ZGViODIyZTBkNzE5OTI5MDA0NzFhNzE5OWQwZDk1YjhlN2M5ZDA1YzQwYTgyNDVhMjgxZmQyYzFkNjY4NDp0ZXN0dXNlcg;Path=/youtrack;Expires=Sat,
49
+ 07-Feb-2015 22:39:52 GMT
50
+ response:
51
+ status:
52
+ code: 200
53
+ message: OK
54
+ headers:
55
+ Server:
56
+ - nginx
57
+ Date:
58
+ - Fri, 07 Feb 2014 22:41:19 GMT
59
+ Content-Type:
60
+ - application/xml; charset=UTF-8
61
+ Content-Length:
62
+ - '130'
63
+ Connection:
64
+ - keep-alive
65
+ Vary:
66
+ - Accept-Encoding
67
+ Cache-Control:
68
+ - no-cache, no-store, no-transform, must-revalidate
69
+ body:
70
+ encoding: UTF-8
71
+ string: <?xml version="1.0" encoding="UTF-8" standalone="yes"?><user login="testuser"
72
+ email="testuser@testcloud.de" fullName="Test User"/>
73
+ http_version:
74
+ recorded_at: Fri, 07 Feb 2014 22:43:05 GMT
75
+ recorded_with: VCR 2.8.0
@@ -0,0 +1,75 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: post
5
+ uri: https://testcloud.myjetbrains.com/youtrack/rest/user/login
6
+ body:
7
+ encoding: UTF-8
8
+ string: login=testuser&password=testuser
9
+ headers: {}
10
+ response:
11
+ status:
12
+ code: 200
13
+ message: OK
14
+ headers:
15
+ Server:
16
+ - nginx
17
+ Date:
18
+ - Fri, 07 Feb 2014 22:42:20 GMT
19
+ Content-Type:
20
+ - application/xml; charset=UTF-8
21
+ Transfer-Encoding:
22
+ - chunked
23
+ Connection:
24
+ - keep-alive
25
+ Vary:
26
+ - Accept-Encoding
27
+ Set-Cookie:
28
+ - JSESSIONID=xt1ovx8ac8acjld0v70wx33o;Path=/youtrack;Secure
29
+ - jetbrains.charisma.main.security.PRINCIPAL=YWU1ZGViODIyZTBkNzE5OTI5MDA0NzFhNzE5OWQwZDk1YjhlN2M5ZDA1YzQwYTgyNDVhMjgxZmQyYzFkNjY4NDp0ZXN0dXNlcg;Path=/youtrack;Expires=Sat,
30
+ 07-Feb-2015 22:42:20 GMT
31
+ Expires:
32
+ - Thu, 01 Jan 1970 00:00:00 GMT
33
+ Cache-Control:
34
+ - no-cache, no-store, no-transform, must-revalidate
35
+ body:
36
+ encoding: UTF-8
37
+ string: <login>ok</login>
38
+ http_version:
39
+ recorded_at: Fri, 07 Feb 2014 22:44:07 GMT
40
+ - request:
41
+ method: get
42
+ uri: https://testcloud.myjetbrains.com/youtrack/rest/user/testuser
43
+ body:
44
+ encoding: US-ASCII
45
+ string: ''
46
+ headers:
47
+ Cookie:
48
+ - JSESSIONID=xt1ovx8ac8acjld0v70wx33o;Path=/youtrack;Secure, jetbrains.charisma.main.security.PRINCIPAL=YWU1ZGViODIyZTBkNzE5OTI5MDA0NzFhNzE5OWQwZDk1YjhlN2M5ZDA1YzQwYTgyNDVhMjgxZmQyYzFkNjY4NDp0ZXN0dXNlcg;Path=/youtrack;Expires=Sat,
49
+ 07-Feb-2015 22:42:20 GMT
50
+ response:
51
+ status:
52
+ code: 200
53
+ message: OK
54
+ headers:
55
+ Server:
56
+ - nginx
57
+ Date:
58
+ - Fri, 07 Feb 2014 22:42:21 GMT
59
+ Content-Type:
60
+ - application/xml; charset=UTF-8
61
+ Content-Length:
62
+ - '130'
63
+ Connection:
64
+ - keep-alive
65
+ Vary:
66
+ - Accept-Encoding
67
+ Cache-Control:
68
+ - no-cache, no-store, no-transform, must-revalidate
69
+ body:
70
+ encoding: UTF-8
71
+ string: <?xml version="1.0" encoding="UTF-8" standalone="yes"?><user login="testuser"
72
+ email="testuser@testcloud.de" fullName="Test User"/>
73
+ http_version:
74
+ recorded_at: Fri, 07 Feb 2014 22:44:08 GMT
75
+ recorded_with: VCR 2.8.0
@@ -0,0 +1,76 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: post
5
+ uri: https://testcloud.myjetbrains.com/youtrack/rest/user/login
6
+ body:
7
+ encoding: UTF-8
8
+ string: login=testuser&password=testuser
9
+ headers: {}
10
+ response:
11
+ status:
12
+ code: 200
13
+ message: OK
14
+ headers:
15
+ Server:
16
+ - nginx
17
+ Date:
18
+ - Fri, 07 Feb 2014 22:39:55 GMT
19
+ Content-Type:
20
+ - application/xml; charset=UTF-8
21
+ Transfer-Encoding:
22
+ - chunked
23
+ Connection:
24
+ - keep-alive
25
+ Vary:
26
+ - Accept-Encoding
27
+ Set-Cookie:
28
+ - JSESSIONID=114e57my63svq68gcd6kn2821;Path=/youtrack;Secure
29
+ - jetbrains.charisma.main.security.PRINCIPAL=YWU1ZGViODIyZTBkNzE5OTI5MDA0NzFhNzE5OWQwZDk1YjhlN2M5ZDA1YzQwYTgyNDVhMjgxZmQyYzFkNjY4NDp0ZXN0dXNlcg;Path=/youtrack;Expires=Sat,
30
+ 07-Feb-2015 22:39:55 GMT
31
+ Expires:
32
+ - Thu, 01 Jan 1970 00:00:00 GMT
33
+ Cache-Control:
34
+ - no-cache, no-store, no-transform, must-revalidate
35
+ body:
36
+ encoding: UTF-8
37
+ string: <login>ok</login>
38
+ http_version:
39
+ recorded_at: Fri, 07 Feb 2014 22:41:41 GMT
40
+ - request:
41
+ method: get
42
+ uri: https://testcloud.myjetbrains.com/youtrack/rest/user/testuser/filter
43
+ body:
44
+ encoding: US-ASCII
45
+ string: ''
46
+ headers:
47
+ Cookie:
48
+ - JSESSIONID=114e57my63svq68gcd6kn2821;Path=/youtrack;Secure, jetbrains.charisma.main.security.PRINCIPAL=YWU1ZGViODIyZTBkNzE5OTI5MDA0NzFhNzE5OWQwZDk1YjhlN2M5ZDA1YzQwYTgyNDVhMjgxZmQyYzFkNjY4NDp0ZXN0dXNlcg;Path=/youtrack;Expires=Sat,
49
+ 07-Feb-2015 22:39:55 GMT
50
+ response:
51
+ status:
52
+ code: 200
53
+ message: OK
54
+ headers:
55
+ Server:
56
+ - nginx
57
+ Date:
58
+ - Fri, 07 Feb 2014 22:41:16 GMT
59
+ Content-Type:
60
+ - application/xml; charset=UTF-8
61
+ Content-Length:
62
+ - '218'
63
+ Connection:
64
+ - keep-alive
65
+ Vary:
66
+ - Accept-Encoding
67
+ Cache-Control:
68
+ - no-cache, no-store, no-transform, must-revalidate
69
+ body:
70
+ encoding: UTF-8
71
+ string: '<?xml version="1.0" encoding="UTF-8" standalone="yes"?><queries><query
72
+ name="Assigned to me" query="for: me"/><query name="Commented by me" query="commenter:
73
+ me"/><query name="Reported by me" query="by: me"/></queries>'
74
+ http_version:
75
+ recorded_at: Fri, 07 Feb 2014 22:43:02 GMT
76
+ recorded_with: VCR 2.8.0
@@ -7,15 +7,34 @@
7
7
 
8
8
  require "webmock/rspec"
9
9
  require "youtrack"
10
+ require "vcr"
11
+
12
+ VCR.configure do |c|
13
+ c.cassette_library_dir = "spec/cassettes"
14
+ c.hook_into :webmock
15
+ c.configure_rspec_metadata!
16
+ end
10
17
 
11
18
  RSpec.configure do |config|
12
19
  config.treat_symbols_as_metadata_keys_with_true_values = true
13
20
  config.run_all_when_everything_filtered = true
14
21
  config.filter_run :focus
15
22
 
23
+ config.treat_symbols_as_metadata_keys_with_true_values = true
24
+ config.extend VCR::RSpec::Macros
25
+
16
26
  # Run specs in random order to surface order dependencies. If you find an
17
27
  # order dependency and want to debug it, you can fix the order by providing
18
28
  # the seed, which is printed after each run.
19
29
  # --seed 1234
20
30
  config.order = 'random'
21
31
  end
32
+
33
+ def build_client(proto="http", user, pass)
34
+ Youtrack::Client.new do |c|
35
+ c.url = "#{proto}://testcloud.myjetbrains.com/youtrack"
36
+ c.login = user
37
+ c.password = pass
38
+ end
39
+ end
40
+
@@ -1,7 +1,6 @@
1
1
  require "spec_helper"
2
2
 
3
3
  describe Youtrack::Client do
4
- let(:client) { Youtrack::Client.new }
5
4
 
6
5
  describe "attributes" do
7
6
 
@@ -26,4 +25,68 @@ describe Youtrack::Client do
26
25
  it { should respond_to(:issues) }
27
26
  end
28
27
 
28
+ describe "connecting" do
29
+
30
+ context "success" do
31
+ let(:client) { build_client("https", "testuser", "testuser") }
32
+ use_vcr_cassette "client/connect"
33
+
34
+ it "should connect to a youtrack endpoint when having valid credentials" do
35
+ client.connect!
36
+
37
+ # STATUS
38
+ expect(client.connected?).to eq(true)
39
+ expect(client.connection.code).to eq(200)
40
+ expect(client.connection.message).to eq("OK")
41
+
42
+ # MESSAGE
43
+ entity_body = client.connection.parsed_response
44
+ expect(entity_body["error"]).to eq(nil)
45
+ expect(entity_body["login"]).to eq("ok")
46
+
47
+ # AUTH COOKIE
48
+ expect(client.connection.response["set-cookie"]).to match(%r{jetbrains.charisma.main.security})
49
+ end
50
+
51
+ end
52
+
53
+ context "credentials failure" do
54
+ let(:client) { build_client("https", "invalid_user", "invalid_pass") }
55
+ use_vcr_cassette "client/connect_credentials_error"
56
+
57
+ it "should not connect to a youtrack endpoint when credentials are invalid" do
58
+ client.connect!
59
+
60
+ # STATUS
61
+ expect(client.connected?).to eq(false)
62
+ expect(client.connection.code).to eq(403)
63
+ expect(client.connection.message).to eq("Forbidden")
64
+
65
+ # MESSAGE
66
+ entity_body = client.connection.parsed_response
67
+ expect(entity_body["login"]).to eq(nil)
68
+ expect(entity_body["error"]).to eq("Incorrect login or password.")
69
+
70
+ # AUTH COOKIE
71
+ expect(client.connection.response["set-cookie"]).to_not match(%r{jetbrains.charisma.main.security})
72
+ end
73
+ end
74
+
75
+ context "url endpoint failure" do
76
+ let(:client) { build_client("https", "testuser", "testuser") }
77
+ use_vcr_cassette "client/connect_url_error"
78
+
79
+ it "should not connect to a youtrack endpoint when the url is invalid" do
80
+ client.url = "https://testcloud.myjetbrains.com/youtracks"
81
+ client.connect!
82
+
83
+ # STATUS
84
+ expect(client.connected?).to eq(false)
85
+ expect(client.connection.code).to eq(404)
86
+ expect(client.connection.message).to eq("Not Found")
87
+
88
+ end
89
+ end
90
+
91
+ end
29
92
  end
@@ -1,26 +1,81 @@
1
1
  require "spec_helper"
2
2
 
3
3
  describe Youtrack::User do
4
- let(:users) do
5
- client = Youtrack::Client.new do |c|
6
- c.url = "https://example.com"
7
- c.login = "test"
8
- c.password = "test"
4
+ describe "api methods" do
5
+ use_vcr_cassette "users/init", record: :new_episodes
6
+
7
+ let(:users) do
8
+ client = build_client("https", "testuser", "testuser")
9
+ client.connect!
10
+ client.users
9
11
  end
10
- client.users
11
- end
12
12
 
13
- describe "api methods" do
14
- it "#current" do
15
- users.method(:current).arity.should eq(0)
13
+ context "#current" do
14
+ use_vcr_cassette "users/current", record: :new_episodes
15
+
16
+ it "should take no arguments" do
17
+ expect(users.method(:current).arity).to eq(0)
18
+ end
19
+
20
+ it "should return info about the currently authenticated user" do
21
+ entity_body = users.current
22
+
23
+ # STATUS
24
+ expect(users.response.code).to eq(200)
25
+
26
+ # BODY
27
+ expect(entity_body["user"]).to be_kind_of(Hash)
28
+ user_hash = entity_body["user"]
29
+
30
+ expect(user_hash.keys).to include("login")
31
+ expect(user_hash.keys).to include("email")
32
+ expect(user_hash.keys).to include("fullName")
33
+ end
34
+
16
35
  end
17
36
 
18
- it "#get_by_login" do
19
- users.method(:get_by_login).arity.should eq(1)
37
+ context "#get_by_login" do
38
+ use_vcr_cassette "users/get_by_login", record: :new_episodes
39
+
40
+ it "should take one argument the user's login name" do
41
+ users.method(:get_by_login).arity.should eq(1)
42
+ end
43
+
44
+ it "should return info about a searched for user" do
45
+ entity_body = users.get_by_login("testuser")
46
+
47
+ # STATUS
48
+ expect(users.response.code).to eq(200)
49
+
50
+ # BODY
51
+ user_hash = entity_body["user"]
52
+ expect(user_hash).to be_kind_of(Hash)
53
+ expect(user_hash["login"]).to_not eq(nil)
54
+ expect(user_hash["email"]).to_not eq(nil)
55
+ expect(user_hash["fullName"]).to_not eq(nil)
56
+
57
+ end
20
58
  end
21
59
 
22
- it "#get_saved_searches_for" do
23
- users.method(:get_saved_searches_for).arity.should eq(1)
60
+ context "#get_saved_searches_for" do
61
+ use_vcr_cassette "users/get_saved_searches_for", record: :new_episodes
62
+
63
+ it "should take one argument the user's login name" do
64
+ users.method(:get_saved_searches_for).arity.should eq(1)
65
+ end
66
+
67
+ it "should return a list of the user's saved searches with name/query keys" do
68
+ entity_body = users.get_saved_searches_for("testuser")
69
+
70
+ # STATUS
71
+ expect(users.response.code).to eq(200)
72
+
73
+ # BODY
74
+ query_ary = entity_body["queries"]["query"].first
75
+ expect(query_ary).to be_kind_of(Hash)
76
+ expect(query_ary["name"]).to_not eq(nil)
77
+ expect(query_ary["query"]).to_not eq(nil)
78
+ end
24
79
  end
25
80
 
26
81
  end
@@ -4,6 +4,8 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
4
  require 'youtrack/version'
5
5
 
6
6
  Gem::Specification.new do |spec|
7
+
8
+ # META
7
9
  spec.name = "youtrack"
8
10
  spec.version = Youtrack::VERSION
9
11
  spec.authors = ["John Faucett"]
@@ -13,7 +15,8 @@ Gem::Specification.new do |spec|
13
15
  spec.homepage = "http://jwaterfaucett.github.io/youtrack/"
14
16
  spec.license = "GPLv3"
15
17
 
16
- spec.files = `git ls-files`.split($/)
18
+ # FILES
19
+ spec.files = `git ls-files`.split($/).grep(%r{^(?!binstubs|examples)})
17
20
  spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
21
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
22
  spec.require_paths = ["lib"]
@@ -28,4 +31,5 @@ Gem::Specification.new do |spec|
28
31
  spec.add_development_dependency "cucumber", "~> 1.3.10"
29
32
  spec.add_development_dependency "rspec", "~> 2.14.1"
30
33
  spec.add_development_dependency "webmock", "~> 1.17.1"
34
+ spec.add_development_dependency "vcr", "~> 2.8.0"
31
35
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: youtrack
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.8
4
+ version: 0.0.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - John Faucett
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-01-26 00:00:00.000000000 Z
11
+ date: 2014-02-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: httparty
@@ -108,6 +108,20 @@ dependencies:
108
108
  - - ~>
109
109
  - !ruby/object:Gem::Version
110
110
  version: 1.17.1
111
+ - !ruby/object:Gem::Dependency
112
+ name: vcr
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - ~>
116
+ - !ruby/object:Gem::Version
117
+ version: 2.8.0
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - ~>
123
+ - !ruby/object:Gem::Version
124
+ version: 2.8.0
111
125
  description: JetBrains youTrack Rest API Client in Ruby
112
126
  email:
113
127
  - jwaterfaucett@gmail.com
@@ -115,6 +129,7 @@ executables: []
115
129
  extensions: []
116
130
  extra_rdoc_files: []
117
131
  files:
132
+ - .envrc
118
133
  - .gitignore
119
134
  - .rspec
120
135
  - .ruby-gemset
@@ -124,25 +139,24 @@ files:
124
139
  - LICENSE.txt
125
140
  - README.md
126
141
  - Rakefile
127
- - examples/authentication.rb
128
- - examples/issues.rb
129
- - examples/projects.rb
130
- - examples/users.rb
131
- - features/client/new_client_session.feature
132
- - features/step_definitions/client/client_steps.rb
133
142
  - features/support/env.rb
134
143
  - features/support/hooks.rb
144
+ - features/support/vcr.rb
135
145
  - features/support/world.rb
136
146
  - lib/youtrack.rb
137
147
  - lib/youtrack/client.rb
138
148
  - lib/youtrack/resources/base.rb
139
149
  - lib/youtrack/resources/issue.rb
140
150
  - lib/youtrack/resources/project.rb
151
+ - lib/youtrack/resources/tag.rb
141
152
  - lib/youtrack/resources/user.rb
142
153
  - lib/youtrack/version.rb
143
- - spec/fixtures/login_body_error.xml
144
- - spec/fixtures/login_body_ok.xml
145
- - spec/fixtures/login_header.json
154
+ - spec/cassettes/client/connect.yml
155
+ - spec/cassettes/client/connect_credentials_error.yml
156
+ - spec/cassettes/client/connect_url_error.yml
157
+ - spec/cassettes/users/current.yml
158
+ - spec/cassettes/users/get_by_login.yml
159
+ - spec/cassettes/users/get_saved_searches_for.yml
146
160
  - spec/spec_helper.rb
147
161
  - spec/youtrack/client_spec.rb
148
162
  - spec/youtrack/resources/user_spec.rb
@@ -172,14 +186,16 @@ signing_key:
172
186
  specification_version: 4
173
187
  summary: A Ruby REST API Client for JetBrains youTrack software
174
188
  test_files:
175
- - features/client/new_client_session.feature
176
- - features/step_definitions/client/client_steps.rb
177
189
  - features/support/env.rb
178
190
  - features/support/hooks.rb
191
+ - features/support/vcr.rb
179
192
  - features/support/world.rb
180
- - spec/fixtures/login_body_error.xml
181
- - spec/fixtures/login_body_ok.xml
182
- - spec/fixtures/login_header.json
193
+ - spec/cassettes/client/connect.yml
194
+ - spec/cassettes/client/connect_credentials_error.yml
195
+ - spec/cassettes/client/connect_url_error.yml
196
+ - spec/cassettes/users/current.yml
197
+ - spec/cassettes/users/get_by_login.yml
198
+ - spec/cassettes/users/get_saved_searches_for.yml
183
199
  - spec/spec_helper.rb
184
200
  - spec/youtrack/client_spec.rb
185
201
  - spec/youtrack/resources/user_spec.rb
@@ -1,12 +0,0 @@
1
- require "youtrack"
2
-
3
- # Setup the client configuration
4
- client = Youtrack::Client.new do |c|
5
- c.url = "http://example.your-youtrack.com"
6
- c.login = "demo"
7
- c.password = "demo"
8
- end
9
-
10
- # connect to the youtrack endpoint
11
- # and save cookies in the client object
12
- client.connect!
@@ -1,53 +0,0 @@
1
- require "youtrack"
2
-
3
- # Setup the client configuration
4
- client = Youtrack::Client.new do |c|
5
- c.url = "http://example.your-youtrack.com"
6
- c.login = "demo"
7
- c.password = "demo"
8
- end
9
-
10
- # connect to the youtrack endpoint
11
- # and save cookies in the client object
12
- client.connect!
13
-
14
-
15
- # Get the issue resource inheriting cookies
16
- # from client
17
- issue_resource = client.issues
18
-
19
- # Find an issue by ID
20
- issue_resource.find("TT-6")
21
-
22
- # Check if an issue exists
23
- issue_resource.exists?("TT-6")
24
-
25
- # Getting issue associated data
26
- issue_resource.get_history_for("TT-6")
27
- issue_resource.get_changes_for("TT-6")
28
- issue_resource.get_attachments_for("TT-6")
29
- issue_resource.get_comments_for("TT-6")
30
- issue_resource.get_links_for("TT-6")
31
-
32
- # Create an Issue
33
- issue_resource.create(
34
- project: "TT",
35
- summary: "An example Bug",
36
- description: "This Bug is evil"
37
- )
38
-
39
- # Update an Issue
40
- issue_id = "TT-6"
41
- issue_resource.update( issue_id , summary: "Evil Bug")
42
-
43
- # Delete
44
- issue_resource.destroy(issue_id)
45
-
46
- # Add attachments to an issue
47
- data = File.open("/tmp/dummy.txt")
48
- content_type = "text/plain"
49
- filename = "dummy.txt"
50
- issue_resource.add_attachment(issue_id, data, content_type, filename )
51
-
52
- # Add comments to an issue
53
- issue_resource.add_comment(issue_id, comment: "This bug has been fixed")
@@ -1,48 +0,0 @@
1
- require "youtrack"
2
-
3
- # Setup the client configuration
4
- client = Youtrack::Client.new do |c|
5
- c.url = "http://example.your-youtrack.com"
6
- c.login = "demo"
7
- c.password = "demo"
8
- end
9
-
10
- # connect to the youtrack endpoint
11
- # and save cookies in the client object
12
- client.connect!
13
-
14
-
15
-
16
- # create a project resource
17
- # that inherits the connection
18
- # from the client
19
- project_resource = client.projects
20
-
21
- # Get all accessible projects
22
- project_list = project_resource.get_accessible_projects
23
-
24
- # Get all issues for a particular project
25
- project_id = "TT"
26
- issue_list = project_resource.get_issues_for(project_id)
27
-
28
- # These methods require that the login/password user
29
- # have admin privileges
30
-
31
- # Get all projects
32
- project_resource.all
33
-
34
- # Find a project by ID (shortName in youTrack vernacular)
35
- project_resource.find("TT")
36
-
37
- # Delete a project
38
- project_resource.destroy("TT")
39
-
40
- # Create a project
41
- # All are required except description
42
- project_resource.create(
43
- projectId: "CC",
44
- projectName: "Cool Cats",
45
- startingNumber: 4,
46
- projectLeadLogin: "demo",
47
- description: "A Project about really awesome cats"
48
- )
File without changes
@@ -1,19 +0,0 @@
1
- Feature: New Client Session
2
-
3
- In order to start a new session with the youTrack Server
4
- As a Client
5
- I should be able to connect to the remote host
6
-
7
- Scenario: starting a new session
8
- Given I create a new Client
9
- When I set the Client url to point to the Server
10
- And I enter the correct login credentials
11
- And I connect ok
12
- Then I should be connected to the Server
13
-
14
- Scenario: failing to start a new session
15
- Given I create a new Client
16
- When I set the Client url to point to the Server
17
- And I enter incorrect login credentials
18
- And I connect with error
19
- Then I should receive an error Response
@@ -1,46 +0,0 @@
1
-
2
- def fixture(filename)
3
- File.join(YServer::FIXTURE_PATH, filename)
4
- end
5
-
6
- Given /^I create a new Client$/ do
7
- @client.is_a?(Youtrack::Client).should eq(true)
8
- end
9
-
10
- Given /^I enter the correct login credentials$/ do
11
- step "I set the Client#login= to <#{YServer::Login}>"
12
- step "I set the Client#password= to <#{YServer::Password}>"
13
- end
14
-
15
- Given /^I enter incorrect login credentials$/ do
16
- step "I set the Client#login= to <#{YServer::Lorem}>"
17
- step "I set the Client#password= to <#{YServer::Lorem}>"
18
- end
19
-
20
- Given /^I set the Client url to point to the Server$/ do
21
- @client.url = YServer::URL
22
- end
23
-
24
- Given /^I connect ok$/ do
25
- @client.connect!
26
- end
27
-
28
- Given /^I connect with error$/ do
29
- @client.connect!
30
- end
31
-
32
- Given /^I set the Client#([a-zA-Z_=]+) to <([a-zA-Z0-9_-]+)>$/ do |method, value|
33
- @client.__send__(method, value)
34
- end
35
-
36
- Then /^I should be connected to the Server$/ do
37
- @client.connected?.should eq(true)
38
- end
39
-
40
- Then /^I should receive an error response from the Server$/ do
41
- @client.connected?.should eq(false)
42
- end
43
-
44
- Then(/^I should receive an error Response$/) do
45
- @client.connected?.should eq(false)
46
- end
@@ -1 +0,0 @@
1
- <?xml version="1.0" encoding="UTF-8" standalone="yes"?><error>Incorrect login or password.</error>
@@ -1 +0,0 @@
1
- <login>ok</login>
@@ -1,10 +0,0 @@
1
- {
2
- "Server": "nginx",
3
- "Date": "Fri, 24 Jan 2014 07:49:19 GMT",
4
- "Content-Type": "application/xml; charset=UTF-8",
5
- "Set-Cookie": "jetbrains.charisma.main.security.PRINCIPAL=NmZkNDc3NDgxZjBhOWNjMTVjNDQwNTljNTE1NzM1ODEwM2I3MjgyMDlkZDAzZGJhYTAzYzU1ZmYyZGUyZWMxNzpyb290;Path=/youtrack;Expires=Sat, 24-Jan-2015 07:49:19 GMT",
6
- "Expires": "Thu, 01 Jan 1970 00:00:00 GMT",
7
- "Access-Control-Allow-Origin": "chrome-extension://hgmloofddffdnphfgcellkdfbfbjeloo",
8
- "Access-Control-Allow-Credentials": "true",
9
- "Cache-Control": "no-cache, no-store, no-transform, must-revalidate"
10
- }