Commit fc312c49 authored by Walmyr Lima's avatar Walmyr Lima

Add BoardList superclass

And refactor other resources to inherit from the superclass.
parent 7215a40a
......@@ -134,12 +134,16 @@ module QA
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 BoardList
autoload :BaseBoardList, 'qa/ee/resource/board_list/base_board_list'
autoload :LabelBoardList, 'qa/ee/resource/board_list/label_board_list'
autoload :MilestoneBoardList, 'qa/ee/resource/board_list/milestone_board_list'
end
module Geo
autoload :Node, 'qa/ee/resource/geo/node'
end
......
# frozen_string_literal: true
module QA
module EE
module Resource
module BoardList
class BaseBoardList < QA::Resource::Base
attribute :id
attribute :project do
QA::Resource::Project.fabricate_via_api! do |resource|
resource.name = 'project-with-board-list'
end
end
attribute :board do
QA::EE::Resource::Board.fabricate_via_api! do |b|
b.project = project
b.name = 'Downstream'
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
}
end
end
end
end
end
end
# frozen_string_literal: true
module QA
module EE
module Resource
module BoardList
class LabelBoardList < BaseBoardList
attribute :label do
QA::Resource::Label.fabricate_via_api! do |l|
l.project = board.project
l.title = 'Doing'
end
end
def api_post_body
{
board_id: board.id,
label_id: label.id
}
end
end
end
end
end
end
# frozen_string_literal: true
module QA
module EE
module Resource
module BoardList
class MilestoneBoardList < BaseBoardList
attribute :project_milestone do
QA::EE::Resource::ProjectMilestone.fabricate_via_api! do |m|
m.project = board.project
m.title = '1.0'
end
end
def api_post_body
{
board_id: board.id,
milestone_id: project_milestone.id
}
end
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
......@@ -14,7 +14,7 @@ module QA
let(:label) { 'Doing' }
let(:label_board_list) do
EE::Resource::LabelBoardList.fabricate_via_api!
EE::Resource::BoardList::LabelBoardList.fabricate_via_api!
end
before do
......@@ -40,7 +40,7 @@ module QA
context 'Milestone issue board' do
let(:milestone_board_list) do
EE::Resource::MilestoneBoardList.fabricate_via_api!
EE::Resource::BoardList::MilestoneBoardList.fabricate_via_api!
end
before do
......
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