jira-ruby 0.1.6 → 0.1.7

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: e56d3c10b1bc942098e389b4e46ed38d0abaa8da
4
- data.tar.gz: 6722f5c8625620140783befd00318dab133e5a38
3
+ metadata.gz: d8a9d8341a978cefa7838d24cb1ab04ed8b7b827
4
+ data.tar.gz: 751b670eee108023f9c9f26c3a047990980d8460
5
5
  SHA512:
6
- metadata.gz: 452b60b173d0feff6bfeacbd448e5d859f817797a84b200bd77ef122e71b0b322727677f3a50cdad877df2d7b457621ad8a0b707506ca90d0bc34c1b9f68a7fa
7
- data.tar.gz: 2f976948dc6ea42f2d73b3a09c9abd1bd8ece5ead29df5dca04c0936a3abee8d6c247c4ff65bd21e22f56f829388da0dda5bd05b38cb78c5b89822619652fa1d
6
+ metadata.gz: 2ad45e5cdc3d906be50dda804c90ce53a3bd82f9388357ad011186456bf51e2b98ce521709cbf95480f515e9e1dd0e37a54c908339ae9dad6db99713491410de
7
+ data.tar.gz: 5e4bf3c7720a0a12e89a0de06a289a9da2bad66d54f93d4b889fb19c189d9e8481f829c716b5f2aa99ace0823e5605529072982949d59dcd1828bff0c99dbada
data/lib/jira.rb CHANGED
@@ -22,6 +22,7 @@ require 'jira/resource/priority'
22
22
  require 'jira/resource/comment'
23
23
  require 'jira/resource/worklog'
24
24
  require 'jira/resource/issue'
25
+ require 'jira/resource/filter'
25
26
 
26
27
  require 'jira/request_client'
27
28
  require 'jira/oauth_client'
data/lib/jira/client.rb CHANGED
@@ -77,6 +77,10 @@ module JIRA
77
77
  JIRA::Resource::IssueFactory.new(self)
78
78
  end
79
79
 
80
+ def Filter # :nodoc:
81
+ JIRA::Resource::FilterFactory.new(self)
82
+ end
83
+
80
84
  def Component # :nodoc:
81
85
  JIRA::Resource::ComponentFactory.new(self)
82
86
  end
@@ -0,0 +1,15 @@
1
+ module JIRA
2
+ module Resource
3
+ class FilterFactory < JIRA::BaseFactory # :nodoc:
4
+ end
5
+
6
+ class Filter < JIRA::Base
7
+ has_one :owner, :class => JIRA::Resource::User
8
+
9
+ # Returns all the issues for this filter
10
+ def issues
11
+ Issue.jql(self.client, self.jql)
12
+ end
13
+ end
14
+ end
15
+ end
data/lib/jira/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module JIRA
2
- VERSION = "0.1.6"
2
+ VERSION = "0.1.7"
3
3
  end
@@ -0,0 +1,97 @@
1
+ require 'spec_helper'
2
+
3
+ describe JIRA::Resource::Filter do
4
+ let(:client) do
5
+ client = double()
6
+ client.stub(:Issue) { JIRA::Resource::IssueFactory.new(self) }
7
+ client
8
+ end
9
+ let(:collection_path) { '/rest/api/2/filter' }
10
+ let(:jira_user) do
11
+ {
12
+ :self => "https://localhost/rest/api/2/user?username=ljharb",
13
+ :name => 'ljharb',
14
+ :avatarUrls => {
15
+ '16x16' => 'https://localhost/secure/useravatar?size=small&ownerId=ljharb&avatarId=1',
16
+ '48x48' => 'https://localhost/secure/useravatar?ownerId=ljharb&avatarId=1'
17
+ },
18
+ :displayName => 'Jordan Harband',
19
+ :active => true
20
+ }
21
+ end
22
+ let(:filter_attrs) do
23
+ {
24
+ :self => "https://localhost#{collection_path}/42",
25
+ :id => 42,
26
+ :name => 'Resolved Tickets',
27
+ :description => '',
28
+ :owner => jira_user,
29
+ :jql => '"Git Repository" ~ jira-ruby AND status = Resolved',
30
+ :viewUrl => 'https://localhost/secure/IssueNavigator.jspa?mode=hide&requestId=42',
31
+ :searchUrl => 'https://localhost/rest/api/2/search?jql=%22Git+Repository%22+~+jira-ruby+AND+status+%3D+Resolved',
32
+ :favourite => false,
33
+ :sharePermissions => [
34
+ {
35
+ :id => 123,
36
+ :type => 'global'
37
+ }
38
+ ],
39
+ :subscriptions => {
40
+ :size => 0,
41
+ :items => []
42
+ }
43
+ }
44
+ end
45
+ let(:filter_response) do
46
+ response = double()
47
+ response.stub(:body).and_return(filter_attrs.to_json)
48
+ response
49
+ end
50
+ let(:filter) do
51
+ client.should_receive(:get).with("#{collection_path}/42").and_return(filter_response)
52
+ JIRA::Resource::Filter.stub(:collection_path).and_return(collection_path)
53
+ JIRA::Resource::Filter.find(client, 42)
54
+ end
55
+ let(:jql_issue) do
56
+ {
57
+ :id => '663147',
58
+ :self => 'https://localhost/rest/api/2/issue/663147',
59
+ :key => "JIRARUBY-2386",
60
+ :fields => {
61
+ :reporter => jira_user,
62
+ :created => '2013-12-11T23:28:02.000+0000',
63
+ :assignee => jira_user
64
+ }
65
+ }
66
+ end
67
+ let(:jql_attrs) do
68
+ {
69
+ :startAt => 0,
70
+ :maxResults => 50,
71
+ :total => 2,
72
+ :issues => [jql_issue]
73
+ }
74
+ end
75
+ let(:issue_jql_response) do
76
+ response = double()
77
+ response.stub(:body).and_return(jql_attrs.to_json)
78
+ response
79
+ end
80
+
81
+ it "can be found by ID" do
82
+ expect(JSON.parse(filter.attrs.to_json)).to eql(JSON.parse(filter_attrs.to_json))
83
+ end
84
+
85
+ it "returns issues" do
86
+ expect(filter).to be_present
87
+ client.stub(:options) { { :rest_base_path => 'localhost' } }
88
+ client.should_receive(:get).
89
+ with("localhost/search?jql=#{CGI.escape(filter.jql)}").
90
+ and_return(issue_jql_response)
91
+ issues = filter.issues
92
+ expect(issues).to be_an(Array)
93
+ expect(issues.size).to eql(1)
94
+ expected_issue = client.Issue.build(JSON.parse(jql_issue.to_json))
95
+ expect(issues.first.attrs).to eql(expected_issue.attrs)
96
+ end
97
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jira-ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.6
4
+ version: 0.1.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - SUMO Heavy Industries
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-01-20 00:00:00.000000000 Z
11
+ date: 2014-01-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: oauth
@@ -150,6 +150,7 @@ files:
150
150
  - lib/jira/resource/attachment.rb
151
151
  - lib/jira/resource/comment.rb
152
152
  - lib/jira/resource/component.rb
153
+ - lib/jira/resource/filter.rb
153
154
  - lib/jira/resource/issue.rb
154
155
  - lib/jira/resource/issuetype.rb
155
156
  - lib/jira/resource/priority.rb
@@ -183,6 +184,7 @@ files:
183
184
  - spec/jira/oauth_client_spec.rb
184
185
  - spec/jira/request_client_spec.rb
185
186
  - spec/jira/resource/attachment_spec.rb
187
+ - spec/jira/resource/filter_spec.rb
186
188
  - spec/jira/resource/issue_spec.rb
187
189
  - spec/jira/resource/project_factory_spec.rb
188
190
  - spec/jira/resource/project_spec.rb
@@ -272,6 +274,7 @@ test_files:
272
274
  - spec/jira/oauth_client_spec.rb
273
275
  - spec/jira/request_client_spec.rb
274
276
  - spec/jira/resource/attachment_spec.rb
277
+ - spec/jira/resource/filter_spec.rb
275
278
  - spec/jira/resource/issue_spec.rb
276
279
  - spec/jira/resource/project_factory_spec.rb
277
280
  - spec/jira/resource/project_spec.rb