Skip to content

Commit

Permalink
Merge pull request #320 from wireframe/board-config
Browse files Browse the repository at this point in the history
Add BoardConfiguration API
  • Loading branch information
SimonMiaou authored Mar 14, 2020
2 parents 39e47f4 + f405972 commit cf4c4aa
Show file tree
Hide file tree
Showing 5 changed files with 70 additions and 0 deletions.
1 change: 1 addition & 0 deletions lib/jira-ruby.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
require 'jira/resource/webhook'
require 'jira/resource/agile'
require 'jira/resource/board'
require 'jira/resource/board_configuration'

require 'jira/request_client'
require 'jira/oauth_client'
Expand Down
4 changes: 4 additions & 0 deletions lib/jira/client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,10 @@ def Board
JIRA::Resource::BoardFactory.new(self)
end

def BoardConfiguration
JIRA::Resource::BoardConfigurationFactory.new(self)
end

def RapidView
JIRA::Resource::RapidViewFactory.new(self)
end
Expand Down
7 changes: 7 additions & 0 deletions lib/jira/resource/board.rb
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,13 @@ def issues(params = {})
results.map { |issue| client.Issue.build(issue) }
end

def configuration(params = {})
path = path_base(client) + "/board/#{id}/configuration"
response = client.get(url_with_query_params(path, params))
json = self.class.parse_json(response.body)
client.BoardConfiguration.build(json)
end

# options
# - state ~ future, active, closed, you can define multiple states separated by commas, e.g. state=active,closed
# - maxResults ~ default: 50 (JIRA API), 1000 (this library)
Expand Down
9 changes: 9 additions & 0 deletions lib/jira/resource/board_configuration.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
module JIRA
module Resource
class BoardConfigurationFactory < JIRA::BaseFactory # :nodoc:
end

class BoardConfiguration < JIRA::Base
end
end
end
49 changes: 49 additions & 0 deletions spec/jira/resource/board_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -172,4 +172,53 @@ class JIRAResourceDelegation < SimpleDelegator # :nodoc:
expect(client).to receive(:Sprint).twice.and_return(JIRA::Resource::SprintFactory.new(client))
expect(board.sprints.size).to be(2)
end

it 'should get board configuration for a board' do
response = double

api_json = <<-eos
{
"id":1,
"name":"My Board",
"type":"kanban",
"self":"https://mycompany.atlassian.net/rest/agile/1.0/board/1/configuration",
"location":{
"type":"project",
"key":"MYPROJ",
"id":"10000",
"self":"https://mycompany.atlassian.net/rest/api/2/project/10000",
"name":"My Project"
},
"filter":{
"id":"10000",
"self":"https://mycompany.atlassian.net/rest/api/2/filter/10000"
},
"subQuery":{
"query":"resolution = EMPTY OR resolution != EMPTY AND resolutiondate >= -5d"
},
"columnConfig":{
"columns":[
{
"name":"Backlog",
"statuses":[
{
"id":"10000",
"self":"https://mycompany.atlassian.net/rest/api/2/status/10000"
}
]
}
],
"constraintType":"issueCount"
},
"ranking":{
"rankCustomFieldId":10011
}
}
eos
allow(response).to receive(:body).and_return(api_json)
allow(board).to receive(:id).and_return(84)
expect(client).to receive(:get).with('/rest/agile/1.0/board/84/configuration').and_return(response)
expect(client).to receive(:BoardConfiguration).and_return(JIRA::Resource::BoardConfigurationFactory.new(client))
expect(board.configuration).not_to be(nil)
end
end

0 comments on commit cf4c4aa

Please sign in to comment.