Commit 9c60a1fb authored by Sanad Liaquat's avatar Sanad Liaquat

Merge branch 'acunskis-group-migration-badges' into 'master'

E2E: Group badge migration validation

See merge request gitlab-org/gitlab!70486
parents e01cc524 ab90fe8b
# frozen_string_literal: true
module QA
module Resource
class GroupBadge < Base
attributes :id,
:name,
:link_url,
:image_url,
:group
# API get path
#
# @return [String]
def api_get_path
"/groups/#{CGI.escape(group.full_path)}/badges/#{id}"
end
# API post path
#
# @return [String]
def api_post_path
"/groups/#{CGI.escape(group.full_path)}/badges"
end
# Params for label creation
#
# @return [Hash]
def api_post_body
{
link_url: link_url,
image_url: image_url
}
end
# Override base method as this particular resource does not expose a web_url property
#
# @param [Hash] resource
# @return [String]
def resource_web_url(_resource); end
# Object comparison
#
# @param [QA::Resource::GroupBadge] other
# @return [Boolean]
def ==(other)
other.is_a?(GroupBadge) && comparable_badge == other.comparable_badge
end
# Override inspect for a better rspec failure diff output
#
# @return [String]
def inspect
JSON.pretty_generate(comparable_badge)
end
protected
# Return subset of fields for comparing badges
#
# @return [Hash]
def comparable_badge
reload! unless api_response
api_response.slice(
:name,
:link_url,
:image_url
)
end
end
end
end
......@@ -46,6 +46,22 @@ module QA
end
end
# Get group badges
#
# @return [Array<QA::Resource::GroupBadge>]
def badges
parse_body(api_get_from("#{api_get_path}/badges")).map do |badge|
GroupBadge.init do |resource|
resource.api_client = api_client
resource.group = self
resource.id = badge[:id]
resource.name = badge[:name]
resource.link_url = badge[:link_url]
resource.image_url = badge[:image_url]
end
end
end
# API get path
#
# @return [String]
......
......@@ -89,7 +89,7 @@ module QA
end
end
context 'with milestones' do
context 'with milestones and badges' do
let(:source_milestone) do
Resource::GroupMilestone.fabricate_via_api! do |milestone|
milestone.api_client = api_client
......@@ -99,10 +99,17 @@ module QA
before do
source_milestone
Resource::GroupBadge.fabricate_via_api! do |badge|
badge.api_client = api_client
badge.group = source_group
badge.link_url = "http://example.com/badge"
badge.image_url = "http://shields.io/badge"
end
end
it(
'successfully imports group milestones',
'successfully imports group milestones and badges',
testcase: 'https://gitlab.com/gitlab-org/quality/testcases/-/quality/test_cases/2245'
) do
expect { imported_group.import_status }.to eventually_eq('finished').within(import_wait_duration)
......@@ -113,6 +120,8 @@ module QA
expect(imported_milestone.iid).to eq(source_milestone.iid)
expect(imported_milestone.created_at).to eq(source_milestone.created_at)
expect(imported_milestone.updated_at).to eq(source_milestone.updated_at)
expect(imported_group.badges).to eq(source_group.badges)
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