Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
7ccb3cf8
Commit
7ccb3cf8
authored
Feb 03, 2020
by
Andreas Brandl
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Defaults for pages access level
parent
752736a5
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
70 additions
and
5 deletions
+70
-5
lib/gitlab/background_migration/fix_projects_without_project_feature.rb
...kground_migration/fix_projects_without_project_feature.rb
+13
-2
spec/lib/gitlab/background_migration/fix_projects_without_project_feature_spec.rb
...nd_migration/fix_projects_without_project_feature_spec.rb
+57
-3
No files found.
lib/gitlab/background_migration/fix_projects_without_project_feature.rb
View file @
7ccb3cf8
...
...
@@ -31,12 +31,15 @@ module Gitlab
snippets_access_level,
builds_access_level,
repository_access_level,
pages_access_level,
forking_access_level,
pages_access_level,
created_at,
updated_at
)
SELECT projects.id, 20, 20, 20, 20, 20, 20, 20, 20, NOW(), NOW()
SELECT projects.id,
20, 20, 20, 20, 20, 20, 20,
#{
pages_access_level
}
,
NOW(), NOW()
FROM projects
WHERE projects.id BETWEEN
#{
Integer
(
from_id
)
}
AND
#{
Integer
(
to_id
)
}
AND NOT EXISTS (
...
...
@@ -51,6 +54,14 @@ module Gitlab
SQL
end
def
pages_access_level
if
::
Gitlab
::
Pages
.
access_control_is_forced?
"10"
else
"GREATEST(projects.visibility_level, 10)"
end
end
def
log
(
count
,
from_id
,
to_id
)
logger
=
Gitlab
::
BackgroundMigration
::
Logger
.
build
...
...
spec/lib/gitlab/background_migration/fix_projects_without_project_feature_spec.rb
View file @
7ccb3cf8
...
...
@@ -9,7 +9,15 @@ describe Gitlab::BackgroundMigration::FixProjectsWithoutProjectFeature, :migrati
let
(
:namespace
)
{
namespaces
.
create
(
name:
'foo'
,
path:
'foo'
)
}
let!
(
:project
)
{
projects
.
create!
(
namespace_id:
namespace
.
id
)
}
let!
(
:projects_without_feature
)
{
[
projects
.
create!
(
namespace_id:
namespace
.
id
),
projects
.
create!
(
namespace_id:
namespace
.
id
)]
}
let!
(
:projects_without_feature
)
do
[
projects
.
create!
(
namespace_id:
namespace
.
id
,
visibility_level:
0
),
projects
.
create!
(
namespace_id:
namespace
.
id
,
visibility_level:
20
)
]
end
let
(
:public_project_without_feature
)
{
projects_without_feature
.
last
}
let
(
:private_project_without_feature
)
{
projects_without_feature
.
first
}
before
do
project_features
.
create
({
project_id:
project
.
id
,
pages_access_level:
20
})
...
...
@@ -29,10 +37,10 @@ describe Gitlab::BackgroundMigration::FixProjectsWithoutProjectFeature, :migrati
expect
{
subject
}.
to
change
{
project_feature_records
}.
from
([
project
.
id
]).
to
([
project
.
id
,
*
projects_without_feature
.
map
(
&
:id
)])
end
it
'creates ProjectFeature records with default values'
do
it
'creates ProjectFeature records with default values
for a public project
'
do
subject
project_id
=
p
rojects_without_feature
.
first
.
id
project_id
=
p
ublic_project_without_feature
.
id
record
=
ActiveRecord
::
Base
.
connection
.
select_one
(
"SELECT * FROM project_features WHERE id=
#{
project_id
}
"
)
expect
(
record
.
except
(
'id'
,
'project_id'
,
'created_at'
,
'updated_at'
)).
to
eq
(
...
...
@@ -49,6 +57,52 @@ describe Gitlab::BackgroundMigration::FixProjectsWithoutProjectFeature, :migrati
)
end
it
'creates ProjectFeature records with default values for a private project'
do
subject
project_id
=
private_project_without_feature
.
id
record
=
ActiveRecord
::
Base
.
connection
.
select_one
(
"SELECT * FROM project_features WHERE id=
#{
project_id
}
"
)
expect
(
record
.
except
(
'id'
,
'project_id'
,
'created_at'
,
'updated_at'
)).
to
eq
(
{
"merge_requests_access_level"
=>
20
,
"issues_access_level"
=>
20
,
"wiki_access_level"
=>
20
,
"snippets_access_level"
=>
20
,
"builds_access_level"
=>
20
,
"repository_access_level"
=>
20
,
"pages_access_level"
=>
10
,
"forking_access_level"
=>
20
}
)
end
context
'when access control to pages is forced'
do
before
do
allow
(
::
Gitlab
::
Pages
).
to
receive
(
:access_control_is_forced?
).
and_return
(
true
)
end
it
'creates ProjectFeature records with default values for a public project'
do
subject
project_id
=
public_project_without_feature
.
id
record
=
ActiveRecord
::
Base
.
connection
.
select_one
(
"SELECT * FROM project_features WHERE id=
#{
project_id
}
"
)
expect
(
record
.
except
(
'id'
,
'project_id'
,
'created_at'
,
'updated_at'
)).
to
eq
(
{
"merge_requests_access_level"
=>
20
,
"issues_access_level"
=>
20
,
"wiki_access_level"
=>
20
,
"snippets_access_level"
=>
20
,
"builds_access_level"
=>
20
,
"repository_access_level"
=>
20
,
"pages_access_level"
=>
10
,
"forking_access_level"
=>
20
}
)
end
end
it
'sets created_at/updated_at timestamps'
do
subject
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment