Commit 03e6f655 authored by Sanad Liaquat's avatar Sanad Liaquat

Merge branch 'qa-add-assign-group-milestone-spec' into 'master'

Add assign group milestone spec

See merge request gitlab-org/gitlab!35262
parents 5fcbbf27 d067bdec
......@@ -79,6 +79,7 @@ module QA
autoload :PersonalAccessToken, 'qa/resource/personal_access_token'
autoload :User, 'qa/resource/user'
autoload :ProjectMilestone, 'qa/resource/project_milestone'
autoload :GroupMilestone, 'qa/resource/group_milestone'
autoload :Members, 'qa/resource/members'
autoload :File, 'qa/resource/file'
autoload :Fork, 'qa/resource/fork'
......
# frozen_string_literal: true
module QA
module Resource
class GroupMilestone < Base
attr_writer :start_date, :due_date
attribute :id
attribute :title
attribute :group do
Group.fabricate_via_api! do |resource|
resource.name = 'group-with-milestone'
end
end
def initialize
@title = "group-milestone-#{SecureRandom.hex(4)}"
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
}.tap do |hash|
hash[:start_date] = @start_date if @start_date
hash[:due_date] = @due_date if @due_date
end
end
end
end
end
# frozen_string_literal: true
module QA
context 'Plan' do
describe 'Milestones' do
include Support::Dates
let(:start_date) { current_date_yyyy_mm_dd }
let(:due_date) { next_month_yyyy_mm_dd }
let(:group) do
Resource::Group.fabricate_via_api! do |group|
group.name = 'group-to-test-milestones'
end
end
let(:project) do
Resource::Project.fabricate_via_api! do |project|
project.name = 'project-to-test-milestones'
end
end
let(:issue) do
Resource::Issue.fabricate_via_api! do |issue|
issue.project = project
end
end
before do
Flow::Login.sign_in
end
shared_examples 'milestone assigned to existing issue' do
it 'is assigned to an existing issue' do
issue.visit!
Page::Project::Issue::Show.perform do |existing_issue|
existing_issue.assign_milestone(milestone)
expect(existing_issue).to have_milestone(milestone.title)
end
end
end
shared_examples 'milestone assigned to new issue' do
it 'is assigned to a new issue' do
Resource::Issue.fabricate_via_browser_ui! do |new_issue|
new_issue.project = project
new_issue.milestone = milestone
end
Page::Project::Issue::Show.perform do |issue|
expect(issue).to have_milestone(milestone.title)
end
end
end
context 'Group milestone' do
let(:milestone) do
Resource::GroupMilestone.fabricate_via_api! do |milestone|
milestone.group = group
milestone.start_date = start_date
milestone.due_date = due_date
end
end
it_behaves_like 'milestone assigned to existing issue'
it_behaves_like 'milestone assigned to new issue'
end
context 'Project milestone' do
let(:milestone) do
Resource::ProjectMilestone.fabricate_via_api! do |milestone|
milestone.project = project
milestone.start_date = start_date
milestone.due_date = due_date
end
end
it_behaves_like 'milestone assigned to existing issue'
it_behaves_like 'milestone assigned to new issue'
end
end
end
end
# frozen_string_literal: true
module QA
context 'Plan' do
describe 'Project milestone' do
include Support::Dates
let(:title) { 'Project milestone' }
let(:start_date) { current_date_yyyy_mm_dd }
let(:due_date) { next_month_yyyy_mm_dd }
let(:project) do
Resource::Project.fabricate_via_api! do |project|
project.name = 'project-to-test-milestones'
end
end
let(:issue) do
Resource::Issue.fabricate_via_api! do |issue|
issue.project = project
end
end
let(:project_milestone) do
Resource::ProjectMilestone.fabricate_via_api! do |milestone|
milestone.project = project
milestone.start_date = start_date
milestone.due_date = due_date
end
end
before do
Flow::Login.sign_in
end
it 'assigns a project milestone to an existing issue' do
issue.visit!
Page::Project::Issue::Show.perform do |existing_issue|
existing_issue.assign_milestone(project_milestone)
expect(existing_issue).to have_milestone(project_milestone.title)
end
end
it 'assigns a project milestone to a new issue' do
Resource::Issue.fabricate_via_browser_ui! do |issue|
issue.project = project
issue.milestone = project_milestone
end
Page::Project::Issue::Show.perform do |issue|
expect(issue).to have_milestone(project_milestone.title)
end
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