Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add BoardConfiguration API #320

Merged
merged 2 commits into from
Mar 14, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -159,6 +159,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