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
ed9838cd
Commit
ed9838cd
authored
Oct 14, 2016
by
Felipe Artur
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Create project feature when project is created
parent
c08435e3
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
42 additions
and
10 deletions
+42
-10
CHANGELOG.md
CHANGELOG.md
+1
-0
app/models/project.rb
app/models/project.rb
+1
-6
db/migrate/20161019213545_generate_project_feature_for_projects.rb
...e/20161019213545_generate_project_feature_for_projects.rb
+28
-0
db/schema.rb
db/schema.rb
+1
-1
spec/models/project_spec.rb
spec/models/project_spec.rb
+11
-3
No files found.
CHANGELOG.md
View file @
ed9838cd
...
...
@@ -25,6 +25,7 @@ Please view this file on the master branch, on stable branches it's out of date.
-
Add an example for testing a phoenix application with Gitlab CI in the docs (Manthan Mallikarjun)
-
Cancelled pipelines could be retried. !6927
-
Updating verbiage on git basics to be more intuitive
-
Fix project_feature record not generated on project creation
-
Clarify documentation for Runners API (Gennady Trafimenkov)
-
The instrumentation for Banzai::Renderer has been restored
-
Change user & group landing page routing from /u/:username to /:username
...
...
app/models/project.rb
View file @
ed9838cd
...
...
@@ -32,8 +32,8 @@ class Project < ActiveRecord::Base
default_value_for
(
:shared_runners_enabled
)
{
current_application_settings
.
shared_runners_enabled
}
after_create
:ensure_dir_exist
after_create
:create_project_feature
,
unless: :project_feature
after_save
:ensure_dir_exist
,
if: :namespace_id_changed?
after_initialize
:setup_project_feature
# set last_activity_at to the same as created_at
after_create
:set_last_activity_at
...
...
@@ -1310,11 +1310,6 @@ class Project < ActiveRecord::Base
"projects/
#{
id
}
/pushes_since_gc"
end
# Prevents the creation of project_feature record for every project
def
setup_project_feature
build_project_feature
unless
project_feature
end
def
default_branch_protected?
current_application_settings
.
default_branch_protection
==
Gitlab
::
Access
::
PROTECTION_FULL
||
current_application_settings
.
default_branch_protection
==
Gitlab
::
Access
::
PROTECTION_DEV_CAN_MERGE
...
...
db/migrate/20161019213545_generate_project_feature_for_projects.rb
0 → 100644
View file @
ed9838cd
class
GenerateProjectFeatureForProjects
<
ActiveRecord
::
Migration
DOWNTIME
=
true
DOWNTIME_REASON
=
<<-
HEREDOC
Application was eager loading project_feature for all projects generating an extra query
everytime a project was fetched. We removed that behavior to avoid the extra query, this migration
makes sure all projects have a project_feature record associated.
HEREDOC
def
up
# Generate enabled values for each project feature 20, 20, 20, 20, 20
# All features are enabled by default
enabled_values
=
[
ProjectFeature
::
ENABLED
]
*
5
execute
<<-
EOF
.
strip_heredoc
INSERT INTO project_features
(project_id, merge_requests_access_level, builds_access_level,
issues_access_level, snippets_access_level, wiki_access_level)
(SELECT projects.id,
#{
enabled_values
.
join
(
','
)
}
FROM projects LEFT OUTER JOIN project_features
ON project_features.project_id = projects.id
WHERE project_features.id IS NULL)
EOF
end
def
down
"Not needed"
end
end
db/schema.rb
View file @
ed9838cd
...
...
@@ -11,7 +11,7 @@
#
# It's strongly recommended that you check this file into your version control system.
ActiveRecord
::
Schema
.
define
(
version:
2016101
8024550
)
do
ActiveRecord
::
Schema
.
define
(
version:
2016101
9213545
)
do
# These are extensions that must be enabled in order to support this database
enable_extension
"plpgsql"
...
...
spec/models/project_spec.rb
View file @
ed9838cd
...
...
@@ -67,6 +67,14 @@ describe Project, models: true do
it
{
is_expected
.
to
have_many
(
:notification_settings
).
dependent
(
:destroy
)
}
it
{
is_expected
.
to
have_many
(
:forks
).
through
(
:forked_project_links
)
}
context
'after create'
do
it
"creates project feature"
do
project
=
FactoryGirl
.
build
(
:project
)
expect
{
project
.
save
}.
to
change
{
project
.
project_feature
.
present?
}.
from
(
false
).
to
(
true
)
end
end
describe
'#members & #requesters'
do
let
(
:project
)
{
create
(
:project
,
:public
)
}
let
(
:requester
)
{
create
(
:user
)
}
...
...
@@ -531,9 +539,9 @@ describe Project, models: true do
end
describe
'#has_wiki?'
do
let
(
:no_wiki_project
)
{
build
(
:project
,
wiki_enabled:
false
,
has_external_wiki:
false
)
}
let
(
:wiki_enabled_project
)
{
build
(
:project
)
}
let
(
:external_wiki_project
)
{
build
(
:project
,
has_external_wiki:
true
)
}
let
(
:no_wiki_project
)
{
create
(
:project
,
wiki_access_level:
ProjectFeature
::
DISABLED
,
has_external_wiki:
false
)
}
let
(
:wiki_enabled_project
)
{
create
(
:project
)
}
let
(
:external_wiki_project
)
{
create
(
:project
,
has_external_wiki:
true
)
}
it
'returns true if project is wiki enabled or has external wiki'
do
expect
(
wiki_enabled_project
).
to
have_wiki
...
...
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