@@ -133,6 +133,75 @@ class JIRAResourceDelegation < SimpleDelegator # :nodoc:
133133 expect ( JIRA ::Resource ::Issue . jql ( client , 'foo bar' , expand : %w( transitions ) ) ) . to eq ( "issues" => [ "" ] )
134134 end
135135
136+ it "should search an issue with a jql query string for v2 version" do
137+ response = double ( )
138+ issue = double ( )
139+
140+ allow ( response ) . to receive ( :body ) . and_return ( '{"issues": {"key":"foo"}}' )
141+ expect ( client ) . to receive ( :get ) . with ( '/jira/rest/api/2/search?jql=foo+bar' ) .
142+ and_return ( response )
143+ expect ( client ) . to receive ( :Issue ) . and_return ( issue )
144+ expect ( issue ) . to receive ( :build ) . with ( [ "key" , "foo" ] ) . and_return ( '' )
145+
146+ expect ( JIRA ::Resource ::Issue . jql_v2 ( client , 'foo bar' ) ) . to eq ( [ '' ] )
147+ end
148+
149+ it "should search an issue with a jql query string and fields for v2 version" do
150+ response = double ( )
151+ issue = double ( )
152+
153+ allow ( response ) . to receive ( :body ) . and_return ( '{"issues": {"key":"foo"}}' )
154+ expect ( client ) . to receive ( :get )
155+ . with ( '/jira/rest/api/2/search?jql=foo+bar&fields=foo,bar' )
156+ . and_return ( response )
157+ expect ( client ) . to receive ( :Issue ) . and_return ( issue )
158+ expect ( issue ) . to receive ( :build ) . with ( [ "key" , "foo" ] ) . and_return ( '' )
159+
160+ expect ( JIRA ::Resource ::Issue . jql_v2 ( client , 'foo bar' , fields : [ 'foo' , 'bar' ] ) ) . to eq ( [ '' ] )
161+ end
162+
163+ it "should search an issue with a jql query string, start at, and maxResults for v2 version" do
164+ response = double ( )
165+ issue = double ( )
166+
167+ allow ( response ) . to receive ( :body ) . and_return ( '{"issues": {"key":"foo"}}' )
168+ expect ( client ) . to receive ( :get )
169+ . with ( '/jira/rest/api/2/search?jql=foo+bar&startAt=1&maxResults=3' )
170+ . and_return ( response )
171+ expect ( client ) . to receive ( :Issue ) . and_return ( issue )
172+ expect ( issue ) . to receive ( :build ) . with ( [ "key" , "foo" ] ) . and_return ( '' )
173+
174+ expect ( JIRA ::Resource ::Issue . jql_v2 ( client , 'foo bar' , start_at : 1 , max_results : 3 ) ) . to eq ( [ '' ] )
175+ end
176+
177+ it "should search an issue with a jql query string and string expand for v2 version" do
178+ response = double ( )
179+ issue = double ( )
180+
181+ allow ( response ) . to receive ( :body ) . and_return ( '{"issues": {"key":"foo"}}' )
182+ expect ( client ) . to receive ( :get )
183+ . with ( '/jira/rest/api/2/search?jql=foo+bar&expand=transitions' )
184+ . and_return ( response )
185+ expect ( client ) . to receive ( :Issue ) . and_return ( issue )
186+ expect ( issue ) . to receive ( :build ) . with ( [ "key" , "foo" ] ) . and_return ( '' )
187+
188+ expect ( JIRA ::Resource ::Issue . jql_v2 ( client , 'foo bar' , expand : 'transitions' ) ) . to eq ( [ '' ] )
189+ end
190+
191+ it "should search an issue with a jql query string and array expand for v2 version" do
192+ response = double ( )
193+ issue = double ( )
194+
195+ allow ( response ) . to receive ( :body ) . and_return ( '{"issues": {"key":"foo"}}' )
196+ expect ( client ) . to receive ( :get )
197+ . with ( '/jira/rest/api/2/search?jql=foo+bar&expand=transitions' )
198+ . and_return ( response )
199+ expect ( client ) . to receive ( :Issue ) . and_return ( issue )
200+ expect ( issue ) . to receive ( :build ) . with ( [ "key" , "foo" ] ) . and_return ( '' )
201+
202+ expect ( JIRA ::Resource ::Issue . jql_v2 ( client , 'foo bar' , expand : %w( transitions ) ) ) . to eq ( [ '' ] )
203+ end
204+
136205 it 'should return meta data available for editing an issue' do
137206 subject = JIRA ::Resource ::Issue . new ( client , :attrs => { 'fields' => { 'key' => 'TST=123' } } )
138207 response = double ( )
@@ -222,3 +291,4 @@ class JIRAResourceDelegation < SimpleDelegator # :nodoc:
222291 end
223292 end
224293end
294+
0 commit comments