Skip to content
Snippets Groups Projects
Commit 0afd3006 authored by Pratibha Gupta's avatar Pratibha Gupta
Browse files

Merge branch contributors-gitlab-com:main into main

parents f0a336fe ab9b5f33
No related branches found
No related tags found
No related merge requests found
Pipeline #
......@@ -18,9 +18,10 @@ module Gitlab
groups_json.each_value do |group|
group_label = group['label']
groups_and_categories[group_label] = []
group['categories'].each do |category_name|
category_label = categories_json[category_name]&.[]('label')
existing_categories = groups_and_categories[group_label] || []
existing_categories = groups_and_categories[group_label]
groups_and_categories[group_label] = existing_categories + [category_label]
end
end
......
---
http_interactions:
- request:
method: get
uri: https://about.gitlab.com/groups.json
body:
encoding: US-ASCII
string: ''
headers:
Accept-Encoding:
- gzip;q=1.0,deflate;q=0.6,identity;q=0.3
Accept:
- "*/*"
User-Agent:
- Ruby
response:
status:
code: 200
message: OK
headers:
Date:
- Sat, 05 Apr 2025 19:06:41 GMT
Content-Type:
- application/json
Transfer-Encoding:
- chunked
Connection:
- keep-alive
Cf-Ray:
- 92bb52f7a8d66322-LHR
Cf-Cache-Status:
- REVALIDATED
Cache-Control:
- public, max-age=14400
Etag:
- W/"f50282e839c5b5c85af10860715e1b23"
Expires:
- Sat, 05 Apr 2025 23:06:41 GMT
Last-Modified:
- Thu, 03 Apr 2025 21:23:40 GMT
Vary:
- Accept-Encoding, Origin
X-Goog-Generation:
- '1743715420728765'
X-Goog-Hash:
- crc32c=ILL6Ag==
- md5=9QKC6DnFtcha8QhgcV4bIw==
X-Goog-Meta-Goog-Reserved-File-Mtime:
- '1743715336'
X-Goog-Metageneration:
- '1'
X-Goog-Storage-Class:
- MULTI_REGIONAL
X-Goog-Stored-Content-Encoding:
- identity
X-Goog-Stored-Content-Length:
- '57775'
X-Guploader-Uploadid:
- AKDAyIvcdu1h4OfTE2N37In8M6aFJDRSvhOg4-SoVygCFT5KcvW5kjOPY8q7w-yPYd06BRLRxuvPt7Y
Server:
- cloudflare
body:
encoding: ASCII-8BIT
string: '
{
"import_and_integrate": {
"name": "Import and Integrate",
"section": "core_platform",
"stage": "foundations",
"categories": [
"api",
"integrations",
"webhooks",
"importers"
],
"label": "group::importand integrate",
"extra_labels": [],
"slack_channel": "g_manage_import_and_integrate",
"product_managers": [
"m_frankiewicz"
],
"engineering_managers": [
"wortschi"
],
"fullstack_managers": [],
"backend_engineering_managers": [],
"frontend_engineering_managers": [],
"technical_writers": [
"ashrafkhamis"
],
"support_engineers": [
"anton"
],
"backend_engineers": [
"carlad-gl",
"georgekoltsov",
"Imjaydip",
"jnutt",
"knejad",
".luke",
"reza-marandi",
"rodrigo.tomonari",
"SamWord"
],
"frontend_engineers": [
"justin_ho",
"obaiye"
],
"product_design_managers": [
"chrismicek"
],
"software_engineers_in_test": [],
"product_designers": [],
"triage_ops_config": null
},
"ux_paper_cuts": {
"name": "UXPaper Cuts",
"section": "core_platform",
"stage": "foundations",
"categories": [],
"label": "group::uxpaper cuts",
"extra_labels": [],
"slack_channel": "g_ux_paper_cuts",
"product_managers": [],
"engineering_managers": [
"paintedbicycle-gitlab"
],
"fullstack_managers": [],
"backend_engineering_managers": [],
"frontend_engineering_managers": [],
"technical_writers": [],
"support_engineers": [],
"backend_engineers": [],
"frontend_engineers": [],
"product_design_managers": [],
"software_engineers_in_test": [],
"product_designers": [
"annabeldunstone",
"seggenberger",
"jmiocene",
"clavimoniere"
],
"triage_ops_config": null
}
}'
recorded_at: Sat, 05 Apr 2025 19:06:40 GMT
- request:
method: get
uri: https://about.gitlab.com/categories.json
body:
encoding: US-ASCII
string: ''
headers:
Accept-Encoding:
- gzip;q=1.0,deflate;q=0.6,identity;q=0.3
Accept:
- "*/*"
User-Agent:
- Ruby
response:
status:
code: 200
message: OK
headers:
Date:
- Sat, 05 Apr 2025 19:06:41 GMT
Content-Type:
- application/json
Transfer-Encoding:
- chunked
Connection:
- keep-alive
Cf-Ray:
- 92bb52fa8d556394-LHR
Cf-Cache-Status:
- REVALIDATED
Cache-Control:
- public, max-age=14400
Etag:
- W/"12856900f6488ff825abcfe5b49931a5"
Expires:
- Sat, 05 Apr 2025 23:06:41 GMT
Last-Modified:
- Tue, 25 Mar 2025 07:32:00 GMT
Vary:
- Accept-Encoding, Origin
X-Goog-Generation:
- '1742887920017904'
X-Goog-Hash:
- crc32c=z31SMA==
- md5=EoVpAPZIj/glq8/ltJkxpQ==
X-Goog-Meta-Goog-Reserved-File-Mtime:
- '1742887785'
X-Goog-Metageneration:
- '1'
X-Goog-Storage-Class:
- MULTI_REGIONAL
X-Goog-Stored-Content-Encoding:
- identity
X-Goog-Stored-Content-Length:
- '23699'
X-Guploader-Uploadid:
- AKDAyIsVK2_Oi-8RSpdimZ1TQsmLtqf54PL3pLQXZH-Ujhbc-BTcCT5tLIMk4Uzp6B_vYG97PQ6pPf4
Server:
- cloudflare
body:
encoding: ASCII-8BIT
string: '
{
"importers": {
"name": "Importers",
"stage": "foundations",
"group": "import_and_integrate",
"label": "Category:Importers",
"feature_labels": [
"import",
"projectexport",
"project import"
]
},
"api": {
"name": "API",
"stage": "foundations",
"group": "import_and_integrate",
"label": "Category:API",
"feature_labels": []
},
"integrations": {
"name": "Integrations",
"stage": "foundations",
"group": "import_and_integrate",
"label": "Category:Integrations",
"feature_labels": []
},
"webhooks": {
"name": "Webhooks",
"stage": "foundations",
"group": "import_and_integrate",
"label": "Category:Webhooks",
"feature_labels": []
}
}'
recorded_at: Sat, 05 Apr 2025 19:06:40 GMT
recorded_with: VCR 6.3.1
......@@ -65,6 +65,15 @@ RSpec.configure do |config|
DatabaseCleaner.clean
end
config.around(:each, :with_cache) do |example|
original_null_store = Rails.cache
Rails.cache = ActiveSupport::Cache::MemoryStore.new
example.run
Rails.cache = original_null_store
end
# You can uncomment this line to turn off ActiveRecord support entirely.
# config.use_active_record = false
......
# frozen_string_literal: true
RSpec.describe Api::V1::ManageIssueController do
describe 'GET #index' do
subject(:get_index) { get api_v1_manage_issue_index_path }
let(:groups_and_categories) { { 'group' => ['category'] } }
before do
service = instance_double(Gitlab::GroupsAndCategoriesService, execute: groups_and_categories)
allow(Gitlab::GroupsAndCategoriesService).to receive(:new).and_return(service)
end
it_behaves_like 'an endpoint requiring login'
context 'when logged in' do
let(:current_user) { create(:user) }
it 'returns expected data' do
sign_in
get_index
expect(json_body).to eq({ 'groups' => groups_and_categories })
end
end
end
end
# frozen_string_literal: true
RSpec.describe Gitlab::GroupsAndCategoriesService do
describe '#execute', :with_cache, vcr: { cassette_name: 'Gitlab_GroupsAndCategoriesService/execute' } do
subject(:service) { described_class.new }
let(:groups_and_categories) do
{
'group::importand integrate' => [
'Category:API', 'Category:Integrations', 'Category:Webhooks', 'Category:Importers'
],
'group::uxpaper cuts' => []
}
end
it 'returns a hash of groups and categories' do
expect(service.execute).to eq(groups_and_categories)
end
it 'downloads groups.json and categories.json' do
allow(HTTParty).to receive(:get).and_call_original
service.execute
expect(HTTParty).to have_received(:get).with(described_class::GROUPS_JSON_PATH, format: :plain)
expect(HTTParty).to have_received(:get).with(described_class::CATEGORIES_JSON_PATH, format: :plain)
end
it 'caches returned data' do
expect(Rails.cache.read(described_class::CACHE_KEY)).to be_nil
service.execute
expect(Rails.cache.read(described_class::CACHE_KEY)).to eq(groups_and_categories)
end
it 'returns cached data when available' do
allow(HTTParty).to receive(:get).and_call_original
cached_data = 'cached data'
Rails.cache.write(described_class::CACHE_KEY, cached_data)
expect(service.execute).to eq(cached_data)
expect(HTTParty).not_to have_received(:get)
end
end
end
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment