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
a2a7ad29
Commit
a2a7ad29
authored
Nov 08, 2017
by
Alexis Reigel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add project_settings (Project#settings)
parent
d6694100
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
55 additions
and
0 deletions
+55
-0
app/models/project.rb
app/models/project.rb
+8
-0
app/models/project_settings.rb
app/models/project_settings.rb
+3
-0
db/migrate/20171030155459_create_project_settings.rb
db/migrate/20171030155459_create_project_settings.rb
+12
-0
db/schema.rb
db/schema.rb
+7
-0
spec/factories/project_settings.rb
spec/factories/project_settings.rb
+5
-0
spec/models/project_spec.rb
spec/models/project_spec.rb
+20
-0
No files found.
app/models/project.rb
View file @
a2a7ad29
...
...
@@ -232,6 +232,14 @@ class Project < ActiveRecord::Base
has_many
:project_badges
,
class_name:
'ProjectBadge'
has_one
:settings
,
->
(
project
)
{
query
=
where
(
project_id:
project
)
query
.
presence
||
begin
ProjectSettings
.
create
(
project_id:
project
.
id
)
query
end
},
class_name:
'ProjectSettings'
accepts_nested_attributes_for
:variables
,
allow_destroy:
true
accepts_nested_attributes_for
:project_feature
,
update_only:
true
accepts_nested_attributes_for
:import_data
...
...
app/models/project_settings.rb
0 → 100644
View file @
a2a7ad29
class
ProjectSettings
<
ActiveRecord
::
Base
belongs_to
:project
end
db/migrate/20171030155459_create_project_settings.rb
0 → 100644
View file @
a2a7ad29
# See http://doc.gitlab.com/ce/development/migration_style_guide.html
# for more information on how to write migrations for GitLab.
class
CreateProjectSettings
<
ActiveRecord
::
Migration
DOWNTIME
=
false
def
change
create_table
:project_settings
do
|
t
|
t
.
references
:project
,
index:
true
,
foreign_key:
{
on_delete: :cascade
}
end
end
end
db/schema.rb
View file @
a2a7ad29
...
...
@@ -1504,6 +1504,12 @@ ActiveRecord::Schema.define(version: 20180418053107) do
add_index
"project_import_data"
,
[
"project_id"
],
name:
"index_project_import_data_on_project_id"
,
using: :btree
create_table
"project_settings"
,
force: :cascade
do
|
t
|
t
.
integer
"project_id"
end
add_index
"project_settings"
,
[
"project_id"
],
name:
"index_project_settings_on_project_id"
,
using: :btree
create_table
"project_statistics"
,
force: :cascade
do
|
t
|
t
.
integer
"project_id"
,
null:
false
t
.
integer
"namespace_id"
,
null:
false
...
...
@@ -2185,6 +2191,7 @@ ActiveRecord::Schema.define(version: 20180418053107) do
add_foreign_key
"project_features"
,
"projects"
,
name:
"fk_18513d9b92"
,
on_delete: :cascade
add_foreign_key
"project_group_links"
,
"projects"
,
name:
"fk_daa8cee94c"
,
on_delete: :cascade
add_foreign_key
"project_import_data"
,
"projects"
,
name:
"fk_ffb9ee3a10"
,
on_delete: :cascade
add_foreign_key
"project_settings"
,
"projects"
,
on_delete: :cascade
add_foreign_key
"project_statistics"
,
"projects"
,
on_delete: :cascade
add_foreign_key
"protected_branch_merge_access_levels"
,
"protected_branches"
,
name:
"fk_8a3072ccb3"
,
on_delete: :cascade
add_foreign_key
"protected_branch_push_access_levels"
,
"protected_branches"
,
name:
"fk_9ffc86a3d9"
,
on_delete: :cascade
...
...
spec/factories/project_settings.rb
0 → 100644
View file @
a2a7ad29
FactoryBot
.
define
do
factory
:project_settings
do
project
end
end
spec/models/project_spec.rb
View file @
a2a7ad29
...
...
@@ -115,6 +115,26 @@ describe Project do
expect
(
subject
.
boards
.
size
).
to
eq
1
end
end
describe
'#settings'
do
it
'creates lazily a settings record when the project does not have one associated'
do
project
=
create
:project
expect
(
ProjectSettings
.
count
).
to
eq
0
expect
(
project
.
settings
).
to
be_a
ProjectSettings
expect
(
ProjectSettings
.
count
).
to
eq
1
end
it
'returns the associated record when the project has one associated'
do
project
=
create
:project
,
settings:
create
(
:project_settings
)
expect
(
ProjectSettings
.
count
).
to
eq
1
expect
(
project
.
settings
).
to
be_a
ProjectSettings
expect
(
ProjectSettings
.
count
).
to
eq
1
end
end
end
describe
'modules'
do
...
...
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