Commit f1fc5900 authored by GitLab Bot's avatar GitLab Bot

Automatic merge of gitlab-org/gitlab master

parents f4c96792 35eaf35c
mutation toggleLock($projectPath: ID!, $filePath: String!, $lock: Boolean!) {
projectSetLocked(input: { projectPath: $projectPath, filePath: $filePath, lock: $lock }) {
project {
pathLocks {
nodes {
path
}
}
}
errors
}
}
...@@ -1013,6 +1013,8 @@ class User < ApplicationRecord ...@@ -1013,6 +1013,8 @@ class User < ApplicationRecord
# Returns a relation of groups the user has access to, including their parent # Returns a relation of groups the user has access to, including their parent
# and child groups (recursively). # and child groups (recursively).
def all_expanded_groups def all_expanded_groups
return groups if groups.empty?
Gitlab::ObjectHierarchy.new(groups).all_objects Gitlab::ObjectHierarchy.new(groups).all_objects
end end
......
...@@ -7,6 +7,7 @@ class Ci::PipelineEntity < Grape::Entity ...@@ -7,6 +7,7 @@ class Ci::PipelineEntity < Grape::Entity
delegate :name, :failure_reason, to: :presented_pipeline delegate :name, :failure_reason, to: :presented_pipeline
expose :id expose :id
expose :iid
expose :user, using: UserEntity expose :user, using: UserEntity
expose :active?, as: :active expose :active?, as: :active
......
...@@ -52,6 +52,7 @@ Example of response ...@@ -52,6 +52,7 @@ Example of response
[ [
{ {
"id": 47, "id": 47,
"iid": 12,
"project_id": 1, "project_id": 1,
"status": "pending", "status": "pending",
"ref": "new-pipeline", "ref": "new-pipeline",
...@@ -62,6 +63,7 @@ Example of response ...@@ -62,6 +63,7 @@ Example of response
}, },
{ {
"id": 48, "id": 48,
"iid": 13,
"project_id": 1, "project_id": 1,
"status": "pending", "status": "pending",
"ref": "new-pipeline", "ref": "new-pipeline",
...@@ -93,6 +95,7 @@ Example of response ...@@ -93,6 +95,7 @@ Example of response
```json ```json
{ {
"id": 46, "id": 46,
"iid": 11,
"project_id": 1, "project_id": 1,
"status": "success", "status": "success",
"ref": "main", "ref": "main",
...@@ -281,6 +284,7 @@ Example of response ...@@ -281,6 +284,7 @@ Example of response
```json ```json
{ {
"id": 61, "id": 61,
"iid": 21,
"project_id": 1, "project_id": 1,
"sha": "384c444e840a515b23f21915ee5766b87068a70d", "sha": "384c444e840a515b23f21915ee5766b87068a70d",
"ref": "main", "ref": "main",
...@@ -328,6 +332,7 @@ Response: ...@@ -328,6 +332,7 @@ Response:
```json ```json
{ {
"id": 46, "id": 46,
"iid": 11,
"project_id": 1, "project_id": 1,
"status": "pending", "status": "pending",
"ref": "main", "ref": "main",
...@@ -375,6 +380,7 @@ Response: ...@@ -375,6 +380,7 @@ Response:
```json ```json
{ {
"id": 46, "id": 46,
"iid": 11,
"project_id": 1, "project_id": 1,
"status": "canceled", "status": "canceled",
"ref": "main", "ref": "main",
......
...@@ -56,7 +56,7 @@ class Feature ...@@ -56,7 +56,7 @@ class Feature
# use `default_enabled: true` to default the flag to being `enabled` # use `default_enabled: true` to default the flag to being `enabled`
# unless set explicitly. The default is `disabled` # unless set explicitly. The default is `disabled`
# TODO: remove the `default_enabled:` and read it from the `defintion_yaml` # TODO: remove the `default_enabled:` and read it from the `definition_yaml`
# check: https://gitlab.com/gitlab-org/gitlab/-/issues/30228 # check: https://gitlab.com/gitlab-org/gitlab/-/issues/30228
def enabled?(key, thing = nil, type: :development, default_enabled: false) def enabled?(key, thing = nil, type: :development, default_enabled: false)
if check_feature_flags_definition? if check_feature_flags_definition?
......
...@@ -2,10 +2,14 @@ ...@@ -2,10 +2,14 @@
module Gitlab module Gitlab
module MarkdownCache module MarkdownCache
# Increment this number every time the renderer changes its output. # Increment this number to invalidate cached HTML from Markdown documents.
# Even when reverting an MR, we should increment this because we only
# persist the cache when the new version is higher.
#
# Changing this value puts strain on the database, as every row with # Changing this value puts strain on the database, as every row with
# cached markdown needs to be updated. As a result, this line should # cached markdown needs to be updated. As a result, avoid changing
# not be changed. # this if the change to the renderer output is a new feature or a
# minor bug fix.
# See: https://gitlab.com/gitlab-org/gitlab/-/issues/330313 # See: https://gitlab.com/gitlab-org/gitlab/-/issues/330313
CACHE_COMMONMARK_VERSION = 28 CACHE_COMMONMARK_VERSION = 28
CACHE_COMMONMARK_VERSION_START = 10 CACHE_COMMONMARK_VERSION_START = 10
......
...@@ -39,6 +39,7 @@ module Gitlab ...@@ -39,6 +39,7 @@ module Gitlab
def save_markdown(updates) def save_markdown(updates)
return unless persisted? && Gitlab::Database.read_write? return unless persisted? && Gitlab::Database.read_write?
return if cached_markdown_version < cached_markdown_version_in_database
update_columns(updates) update_columns(updates)
end end
......
...@@ -216,4 +216,16 @@ RSpec.describe Gitlab::MarkdownCache::ActiveRecord::Extension do ...@@ -216,4 +216,16 @@ RSpec.describe Gitlab::MarkdownCache::ActiveRecord::Extension do
end end
end end
end end
context 'when persisted cache is newer than current version' do
before do
thing.update_column(:cached_markdown_version, thing.cached_markdown_version + 1)
end
it 'does not save the generated HTML' do
expect(thing).not_to receive(:update_columns)
thing.refresh_markdown_cache!
end
end
end end
...@@ -4039,6 +4039,14 @@ RSpec.describe User do ...@@ -4039,6 +4039,14 @@ RSpec.describe User do
] ]
end end
end end
context 'when the user is not saved' do
let(:user) { build(:user) }
it 'returns empty when there are no groups or ancestor groups for the user' do
is_expected.to eq([])
end
end
end end
describe '#refresh_authorized_projects', :clean_gitlab_redis_shared_state do describe '#refresh_authorized_projects', :clean_gitlab_redis_shared_state do
...@@ -4300,6 +4308,14 @@ RSpec.describe User do ...@@ -4300,6 +4308,14 @@ RSpec.describe User do
expect(user.two_factor_grace_period).to be 48 expect(user.two_factor_grace_period).to be 48
end end
end end
context 'when the user is not saved' do
let(:user) { build(:user) }
it 'does not raise an ActiveRecord::StatementInvalid statement exception' do
expect { user.update_two_factor_requirement }.not_to raise_error
end
end
end end
describe '#source_groups_of_two_factor_authentication_requirement' do describe '#source_groups_of_two_factor_authentication_requirement' do
......
...@@ -18,7 +18,7 @@ RSpec.describe Ci::PipelineEntity do ...@@ -18,7 +18,7 @@ RSpec.describe Ci::PipelineEntity do
let(:pipeline) { create(:ci_empty_pipeline) } let(:pipeline) { create(:ci_empty_pipeline) }
it 'contains required fields' do it 'contains required fields' do
expect(subject).to include :id, :user, :path, :coverage, :source expect(subject).to include :id, :iid, :user, :path, :coverage, :source
expect(subject).to include :ref, :commit expect(subject).to include :ref, :commit
expect(subject).to include :updated_at, :created_at expect(subject).to include :updated_at, :created_at
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