blob: b9ec53e929caf55301dd38aeb7193171e49e18c9 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
|
# frozen_string_literal: true
module QA
module Resource
class GroupMilestone < Base
attributes :id,
:iid,
:title,
:description,
:start_date,
:due_date,
:updated_at,
:created_at
attribute :group do
Group.fabricate_via_api! do |resource|
resource.name = 'group-with-milestone'
end
end
def initialize
@title = "group-milestone-#{SecureRandom.hex(4)}"
@description = "My awesome group milestone."
end
def fabricate!
group.visit!
Page::Group::Menu.perform(&:go_to_milestones)
Page::Group::Milestone::Index.perform(&:click_new_milestone_link)
Page::Group::Milestone::New.perform do |new_milestone|
new_milestone.set_title(@title)
new_milestone.set_description(@description)
new_milestone.set_start_date(@start_date) if @start_date
new_milestone.set_due_date(@due_date) if @due_date
new_milestone.click_create_milestone_button
end
end
def api_get_path
"/groups/#{group.id}/milestones/#{id}"
end
def api_post_path
"/groups/#{group.id}/milestones"
end
def api_post_body
{
title: title,
description: description
}.tap do |hash|
hash[:start_date] = @start_date if @start_date
hash[:due_date] = @due_date if @due_date
end
end
protected
# Return subset of fields for comparing milestones
#
# @return [Hash]
def comparable
reload! unless api_response
api_response.slice(
:title,
:description,
:state,
:due_date,
:start_date
)
end
end
end
end
|