Skip to content
代码片段 群组 项目
未验证 提交 891e966d 编辑于 作者: Mehmet Emin INAC's avatar Mehmet Emin INAC 提交者: GitLab
浏览文件

Merge branch 'kassio/work-items-rolledup-dates-widget-nullable-fixed-date-graphql' into 'master'

WorkItems rolledup dates: make fixed dates nullable on graphql

See merge request https://gitlab.com/gitlab-org/gitlab/-/merge_requests/144451



Merged-by: default avatarMehmet Emin INAC <minac@gitlab.com>
Approved-by: default avatarEugenia Grieff <egrieff@gitlab.com>
Approved-by: default avatarMehmet Emin INAC <minac@gitlab.com>
Reviewed-by: default avatarKassio Borges <kborges@gitlab.com>
Co-authored-by: default avatarKassio Borges <kassioborgesm@gmail.com>
No related branches found
No related tags found
无相关合并请求
......@@ -22,16 +22,14 @@ def build
attr_reader :work_item, :params
def start_date_attributes
if params[:start_date_fixed].present?
if params.key?(:start_date_fixed)
{
start_date_is_fixed: true,
start_date: params[:start_date_fixed],
start_date_fixed: params[:start_date_fixed]
}
elsif params[:start_date_is_fixed] == true
{
start_date_is_fixed: true
}
elsif params[:start_date_is_fixed]
{ start_date_is_fixed: true }
else
finder.minimum_start_date.first.then do |result|
{
......@@ -45,16 +43,14 @@ def start_date_attributes
end
def due_date_attributes
if params[:due_date_fixed].present?
if params.key?(:due_date_fixed)
{
due_date: params[:due_date_fixed],
due_date_fixed: params[:due_date_fixed],
due_date_is_fixed: true
}
elsif params[:due_date_is_fixed] == true
{
due_date_is_fixed: true
}
elsif params[:due_date_is_fixed]
{ due_date_is_fixed: true }
else
finder.maximum_due_date.first.then do |result|
{
......
......@@ -282,7 +282,9 @@
title: "some WI",
workItemTypeId: WorkItems::Type.default_by_type(:epic).to_gid.to_s,
rolledupDatesWidget: {
startDateIsFixed: true,
startDateFixed: start_date.to_s,
dueDateIsFixed: true,
dueDateFixed: due_date.to_s
}
}
......
......@@ -476,7 +476,9 @@ def work_item_color
let(:input) do
{
"rolledupDatesWidget" => {
"startDateIsFixed" => true,
"startDateFixed" => start_date,
"dueDateIsFixed" => true,
"dueDateFixed" => due_date
}
}
......
......@@ -37,78 +37,137 @@ def query_result(values)
subject(:builder) { described_class.new(work_item, params) }
describe "#build" do
context "when params[:start_date_fixed] and params[:due_date_fixed] is present" do
let(:params) { { start_date_fixed: start_date, due_date_fixed: due_date } }
it "creates the work_item dates_souce and populates it" do
expect(builder.build).to eq(
due_date: due_date,
due_date_fixed: due_date,
due_date_is_fixed: true,
start_date: start_date,
start_date_fixed: start_date,
start_date_is_fixed: true
)
context "when updating start_date" do
context "when params[:start_date_is_fixed] is true" do
context "when params[:start_date_fixed] is not provided" do
let(:params) { { start_date_is_fixed: true } }
it "does not set start_date and start_date_fixed values" do
expect(builder.build).to eq(
due_date: milestone.due_date,
due_date_is_fixed: false,
due_date_sourcing_milestone_id: milestone.id,
due_date_sourcing_work_item_id: nil,
start_date_is_fixed: true
)
end
end
context "when params[:start_date_fixed] is provided" do
let(:params) { { start_date_is_fixed: true, start_date_fixed: start_date } }
it "sets the start_date and start_date_fixed to the given value" do
expect(builder.build).to eq(
due_date: milestone.due_date,
due_date_is_fixed: false,
due_date_sourcing_milestone_id: milestone.id,
due_date_sourcing_work_item_id: nil,
start_date: start_date,
start_date_fixed: start_date,
start_date_is_fixed: true
)
end
context "when params[:start_date_fixed] is nil" do
let(:params) { { start_date_is_fixed: true, start_date_fixed: nil } }
it "sets the start_date and start_date_fixed to nil" do
expect(builder.build).to eq(
due_date: milestone.due_date,
due_date_is_fixed: false,
due_date_sourcing_milestone_id: milestone.id,
due_date_sourcing_work_item_id: nil,
start_date: nil,
start_date_fixed: nil,
start_date_is_fixed: true
)
end
end
end
end
end
context "when only params[:start_date_fixed] is present" do
let(:params) { { start_date_fixed: start_date } }
it "creates the work_item dates_souce and populates it" do
expect(builder.build).to eq(
due_date: milestone.due_date,
due_date_is_fixed: false,
due_date_sourcing_milestone_id: milestone.id,
due_date_sourcing_work_item_id: nil,
start_date: start_date,
start_date_fixed: start_date,
start_date_is_fixed: true
)
context "when params[:start_date_is_fixed] is false" do
let(:params) { { start_date_is_fixed: false } }
it "sets the start_date to the rolledup value" do
expect(builder.build).to eq(
due_date: milestone.due_date,
due_date_is_fixed: false,
due_date_sourcing_milestone_id: milestone.id,
due_date_sourcing_work_item_id: nil,
start_date_is_fixed: false,
start_date: milestone.start_date,
start_date_sourcing_milestone_id: milestone.id,
start_date_sourcing_work_item_id: nil
)
end
end
end
context "when only params[:start_date_fixed] is not present and params[:start_date_is_fixed] is true" do
let(:params) { { start_date_is_fixed: true } }
it "creates the work_item dates_souce and populates it" do
expect(builder.build).to eq(
due_date: milestone.due_date,
due_date_is_fixed: false,
due_date_sourcing_milestone_id: milestone.id,
due_date_sourcing_work_item_id: nil,
start_date_is_fixed: true
)
context "when updating due_date" do
context "when params[:due_date_is_fixed] is true" do
context "when params[:due_date_fixed] is not provided" do
let(:params) { { due_date_is_fixed: true } }
it "does not set due_date and due_date_fixed values" do
expect(builder.build).to eq(
start_date: milestone.start_date,
start_date_is_fixed: false,
start_date_sourcing_milestone_id: milestone.id,
start_date_sourcing_work_item_id: nil,
due_date_is_fixed: true
)
end
end
context "when params[:due_date_fixed] is provided" do
let(:params) { { due_date_is_fixed: true, due_date_fixed: due_date } }
it "sets the due_date and due_date_fixed to the given value" do
expect(builder.build).to eq(
start_date: milestone.start_date,
start_date_is_fixed: false,
start_date_sourcing_milestone_id: milestone.id,
start_date_sourcing_work_item_id: nil,
due_date: due_date,
due_date_fixed: due_date,
due_date_is_fixed: true
)
end
context "when params[:due_date_fixed] is nil" do
let(:params) { { due_date_is_fixed: true, due_date_fixed: nil } }
it "sets the due_date and due_date_fixed to nil" do
expect(builder.build).to eq(
start_date: milestone.start_date,
start_date_is_fixed: false,
start_date_sourcing_milestone_id: milestone.id,
start_date_sourcing_work_item_id: nil,
due_date: nil,
due_date_fixed: nil,
due_date_is_fixed: true
)
end
end
end
end
end
context "when only params[:due_date_fixed] is present" do
let(:params) { { due_date_fixed: due_date } }
it "creates the work_item dates_souce and populates it" do
expect(builder.build).to eq(
due_date: due_date,
due_date_fixed: due_date,
due_date_is_fixed: true,
start_date: milestone.start_date,
start_date_is_fixed: false,
start_date_sourcing_milestone_id: milestone.id,
start_date_sourcing_work_item_id: nil
)
end
end
context "when only params[:due_date_fixed] is not present and params[:due_date_is_fixed] is true" do
let(:params) { { due_date_is_fixed: true } }
it "creates the work_item dates_souce and populates it" do
expect(builder.build).to eq(
due_date_is_fixed: true,
start_date: milestone.start_date,
start_date_is_fixed: false,
start_date_sourcing_milestone_id: milestone.id,
start_date_sourcing_work_item_id: nil
)
context "when params[:due_date_is_fixed] is false" do
let(:params) { { due_date_is_fixed: false } }
it "sets the due_date to the rolledup value" do
expect(builder.build).to eq(
start_date: milestone.start_date,
start_date_is_fixed: false,
start_date_sourcing_milestone_id: milestone.id,
start_date_sourcing_work_item_id: nil,
due_date_is_fixed: false,
due_date: milestone.due_date,
due_date_sourcing_milestone_id: milestone.id,
due_date_sourcing_work_item_id: nil
)
end
end
end
......
0% 加载中 .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册