Commit 5f9a84b3 authored by Walmyr Lima's avatar Walmyr Lima

Create new resources and autoload them

The new resources are:
- board
- label board list
- milestone board list
- project milestone

Also, update issue resource to allow for the fabrication of issues
with milestones.
parent aa84efe2
......@@ -118,8 +118,12 @@ module QA
end
module Resource
autoload :Board, 'qa/ee/resource/board'
autoload :LabelBoardList, 'qa/ee/resource/label_board_list'
autoload :MilestoneBoardList, 'qa/ee/resource/milestone_board_list'
autoload :License, 'qa/ee/resource/license'
autoload :Epic, 'qa/ee/resource/epic'
autoload :ProjectMilestone, 'qa/ee/resource/project_milestone'
module Geo
autoload :Node, 'qa/ee/resource/geo/node'
......
# frozen_string_literal: true
module QA
module EE
module Resource
class Board < QA::Resource::Base
attribute :id
attribute :name
attribute :project do
QA::Resource::Project.fabricate_via_api! do |resource|
resource.name = 'project-with-board'
end
end
def resource_web_url(resource)
super
rescue ResourceURLMissingError
# this particular resource does not expose a web_url property
end
def api_get_path
"/projects/#{project.id}/boards/#{id}"
end
def api_post_path
"/projects/#{project.id}/boards"
end
def api_post_body
{
name: name
}
end
end
end
end
end
# frozen_string_literal: true
module QA
module EE
module Resource
class LabelBoardList < QA::Resource::Base
attribute :id
attribute :project do
QA::Resource::Project.fabricate_via_api! do |resource|
resource.name = 'project-with-label-board-list'
end
end
attribute :board do
QA::EE::Resource::Board.fabricate_via_api! do |b|
b.project = project
b.name = 'Downstream'
end
end
attribute :label do
QA::Resource::Label.fabricate_via_api! do |l|
l.project = board.project
l.title = 'Doing'
end
end
def resource_web_url(resource)
super
rescue ResourceURLMissingError
# this particular resource does not expose a web_url property
end
def api_get_path
"/projects/#{board.project.id}/boards/#{board.id}/lists/#{id}"
end
def api_post_path
"/projects/#{board.project.id}/boards/#{board.id}/lists"
end
def api_post_body
{
board_id: board.id,
label_id: label.id
}
end
end
end
end
end
# frozen_string_literal: true
module QA
module EE
module Resource
class MilestoneBoardList < QA::Resource::Base
attribute :id
attribute :project do
QA::Resource::Project.fabricate_via_api! do |resource|
resource.name = 'project-with-milestone-board-list'
end
end
attribute :board do
QA::EE::Resource::Board.fabricate_via_api! do |b|
b.project = project
b.name = 'Product development'
end
end
attribute :project_milestone do
QA::EE::Resource::ProjectMilestone.fabricate_via_api! do |m|
m.project = board.project
m.title = '1.0'
end
end
def resource_web_url(resource)
super
rescue ResourceURLMissingError
# this particular resource does not expose a web_url property
end
def api_get_path
"/projects/#{board.project.id}/boards/#{board.id}/lists/#{id}"
end
def api_post_path
"/projects/#{board.project.id}/boards/#{board.id}/lists"
end
def api_post_body
{
board_id: board.id,
milestone_id: project_milestone.id
}
end
end
end
end
end
# frozen_string_literal: true
module QA
module EE
module Resource
class ProjectMilestone < QA::Resource::Base
attribute :id
attribute :title
attribute :project do
QA::Resource::Project.fabricate_via_api! do |resource|
resource.name = 'project-with-milestone'
end
end
def resource_web_url(resource)
super
rescue ResourceURLMissingError
# this particular resource does not expose a web_url property
end
def api_get_path
"/projects/#{project.id}/milestones/#{id}"
end
def api_post_path
"/projects/#{project.id}/milestones"
end
def api_post_body
{
title: title
}
end
end
end
end
end
......@@ -3,7 +3,7 @@
module QA
module Resource
class Issue < Base
attr_writer :description
attr_writer :description, :milestone
attribute :project do
Project.fabricate! do |resource|
......@@ -44,7 +44,9 @@ module QA
{
labels: labels,
title: title
}
}.tap do |hash|
hash[:milestone_id] = @milestone.id if @milestone
end
end
end
end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment