From d067bdec0a2111b9870801b7bda1fb82f039ae2f Mon Sep 17 00:00:00 2001 From: Desiree Chevalier <dchevalier@gitlab.com> Date: Wed, 24 Jun 2020 11:55:57 -0400 Subject: [PATCH] Add assign group milestone spec Adds a spec for assigning a group milestone --- qa/qa.rb | 1 + qa/qa/resource/group_milestone.rb | 39 +++++++++ .../2_plan/milestone/assign_milestone_spec.rb | 85 +++++++++++++++++++ .../assign_project_milestone_spec.rb | 58 ------------- 4 files changed, 125 insertions(+), 58 deletions(-) create mode 100644 qa/qa/resource/group_milestone.rb create mode 100644 qa/qa/specs/features/browser_ui/2_plan/milestone/assign_milestone_spec.rb delete mode 100644 qa/qa/specs/features/browser_ui/2_plan/milestone/assign_project_milestone_spec.rb diff --git a/qa/qa.rb b/qa/qa.rb index d848aca9a66..78ee8957789 100644 --- a/qa/qa.rb +++ b/qa/qa.rb @@ -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' diff --git a/qa/qa/resource/group_milestone.rb b/qa/qa/resource/group_milestone.rb new file mode 100644 index 00000000000..17ae1255319 --- /dev/null +++ b/qa/qa/resource/group_milestone.rb @@ -0,0 +1,39 @@ +# 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 diff --git a/qa/qa/specs/features/browser_ui/2_plan/milestone/assign_milestone_spec.rb b/qa/qa/specs/features/browser_ui/2_plan/milestone/assign_milestone_spec.rb new file mode 100644 index 00000000000..71736b5ad85 --- /dev/null +++ b/qa/qa/specs/features/browser_ui/2_plan/milestone/assign_milestone_spec.rb @@ -0,0 +1,85 @@ +# 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 diff --git a/qa/qa/specs/features/browser_ui/2_plan/milestone/assign_project_milestone_spec.rb b/qa/qa/specs/features/browser_ui/2_plan/milestone/assign_project_milestone_spec.rb deleted file mode 100644 index e7d7e160741..00000000000 --- a/qa/qa/specs/features/browser_ui/2_plan/milestone/assign_project_milestone_spec.rb +++ /dev/null @@ -1,58 +0,0 @@ -# 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 -- 2.30.9