diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-09-20 13:18:24 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-09-20 13:18:24 +0000 |
commit | 0653e08efd039a5905f3fa4f6e9cef9f5d2f799c (patch) | |
tree | 4dcc884cf6d81db44adae4aa99f8ec1233a41f55 /qa/qa/resource/group_milestone.rb | |
parent | 744144d28e3e7fddc117924fef88de5d9674fe4c (diff) | |
download | gitlab-ce-14.3.0-rc42.tar.gz |
Add latest changes from gitlab-org/gitlab@14-3-stable-eev14.3.0-rc42
Diffstat (limited to 'qa/qa/resource/group_milestone.rb')
-rw-r--r-- | qa/qa/resource/group_milestone.rb | 67 |
1 files changed, 51 insertions, 16 deletions
diff --git a/qa/qa/resource/group_milestone.rb b/qa/qa/resource/group_milestone.rb index 1fb07fdbd0b..880ca2b9721 100644 --- a/qa/qa/resource/group_milestone.rb +++ b/qa/qa/resource/group_milestone.rb @@ -3,11 +3,14 @@ module QA module Resource class GroupMilestone < Base - attr_writer :start_date, :due_date - - attribute :id - attribute :title - attribute :description + attributes :id, + :iid, + :title, + :description, + :start_date, + :due_date, + :updated_at, + :created_at attribute :group do Group.fabricate_via_api! do |resource| @@ -20,6 +23,21 @@ module QA @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 @@ -38,19 +56,36 @@ module QA end end - def fabricate! - group.visit! + # Object comparison + # + # @param [QA::Resource::GroupMilestone] other + # @return [Boolean] + def ==(other) + other.is_a?(GroupMilestone) && comparable_milestone == other.comparable_milestone + end - Page::Group::Menu.perform(&:go_to_milestones) - Page::Group::Milestone::Index.perform(&:click_new_milestone_link) + # Override inspect for a better rspec failure diff output + # + # @return [String] + def inspect + JSON.pretty_generate(comparable_milestone) + end - 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 + protected + + # Return subset of fields for comparing milestones + # + # @return [Hash] + def comparable_milestone + reload! unless api_response + + api_response.slice( + :title, + :description, + :state, + :due_date, + :start_date + ) end end end |