Commit fe0c6256 authored by Walmyr Lima e Silva Filho's avatar Walmyr Lima e Silva Filho Committed by Dan Davison

Simplify project milestone resource

The fabricate method is not in use, and so it just adds unnecessary
complexity. This is why it is being removed.
The same applies to the description attribute.

Also, instead of having a title= method, better having it initiali-
zed with a default value so that it doesn't need to be provided
when creating the resource in the test file.

Finally, the test that uses the updated resource was updated to use
the default title.
parent e4e85a10
......@@ -3,12 +3,11 @@
module QA
module EE
module Resource
class ProjectMilestone < QA::Resource::Base
class ProjectMilestone < QA::Resource::ProjectMilestone
attr_writer :start_date, :due_date
attribute :id
attribute :iid
attribute :title
attribute :project do
QA::Resource::Project.fabricate_via_api! do |resource|
......@@ -16,24 +15,6 @@ module QA
end
end
def initialize
@title = "project-milestone-#{SecureRandom.hex(8)}"
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
......
......@@ -3,33 +3,14 @@
module QA
module Resource
class ProjectMilestone < Base
attr_reader :title
attr_accessor :description
attribute :title
attribute :project do
Project.fabricate!
end
def title=(title)
@title = "#{title}-#{SecureRandom.hex(4)}"
@description = 'A milestone'
end
def fabricate!
project.visit!
Page::Project::Menu.perform do |menu|
menu.click_issues
menu.click_milestones
end
Page::Project::Milestone::Index.perform(&:click_new_milestone)
Page::Project::Milestone::New.perform do |milestone_new|
milestone_new.set_title(@title)
milestone_new.set_description(@description)
milestone_new.click_milestone_create_button
end
def initialize
@title = "project-milestone-#{SecureRandom.hex(4)}"
end
def api_get_path
......@@ -42,8 +23,7 @@ module QA
def api_post_body
{
description: @description,
title: @title
title: title
}
end
end
......
......@@ -32,7 +32,6 @@ module QA
milestone = Resource::ProjectMilestone.fabricate_via_api! do |milestone|
milestone.project = @project
milestone.title = 'milestone'
end
label = Resource::Label.fabricate_via_api! do |label|
......
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