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
2e8d75f3
Commit
2e8d75f3
authored
Mar 13, 2019
by
Rémy Coutable
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'bvl-design-management-model' into 'master'
Add a designs model See merge request gitlab-org/gitlab-ee!9801
parents
6a17d248
b465c62f
Changes
10
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
137 additions
and
0 deletions
+137
-0
db/schema.rb
db/schema.rb
+19
-0
ee/app/models/design_management.rb
ee/app/models/design_management.rb
+7
-0
ee/app/models/design_management/design.rb
ee/app/models/design_management/design.rb
+13
-0
ee/app/models/design_management/version.rb
ee/app/models/design_management/version.rb
+20
-0
ee/db/migrate/20190228134845_create_designs.rb
ee/db/migrate/20190228134845_create_designs.rb
+11
-0
ee/db/migrate/20190302144241_create_design_versions.rb
ee/db/migrate/20190302144241_create_design_versions.rb
+8
-0
ee/spec/factories/design_management/designs.rb
ee/spec/factories/design_management/designs.rb
+9
-0
ee/spec/factories/design_management/versions.rb
ee/spec/factories/design_management/versions.rb
+8
-0
ee/spec/models/design_management/design_spec.rb
ee/spec/models/design_management/design_spec.rb
+22
-0
ee/spec/models/design_management/version_spec.rb
ee/spec/models/design_management/version_spec.rb
+20
-0
No files found.
db/schema.rb
View file @
2e8d75f3
...
...
@@ -1035,6 +1035,22 @@ ActiveRecord::Schema.define(version: 20190305162221) do
t
.
index
[
"project_id"
,
"status"
],
name:
"index_deployments_on_project_id_and_status"
,
using: :btree
end
create_table
"design_management_designs"
,
id: :bigserial
,
force: :cascade
do
|
t
|
t
.
integer
"project_id"
,
null:
false
t
.
integer
"issue_id"
,
null:
false
t
.
string
"filename"
,
null:
false
t
.
index
[
"issue_id"
,
"filename"
],
name:
"index_design_management_designs_on_issue_id_and_filename"
,
unique:
true
,
using: :btree
t
.
index
[
"issue_id"
],
name:
"index_design_management_designs_on_issue_id"
,
unique:
true
,
using: :btree
t
.
index
[
"project_id"
],
name:
"index_design_management_designs_on_project_id"
,
using: :btree
end
create_table
"design_management_versions"
,
id: :bigserial
,
force: :cascade
do
|
t
|
t
.
bigint
"design_management_design_id"
,
null:
false
t
.
binary
"sha"
,
null:
false
t
.
index
[
"design_management_design_id"
],
name:
"index_design_management_versions_on_design_management_design_id"
,
using: :btree
t
.
index
[
"sha"
],
name:
"index_design_management_versions_on_sha"
,
unique:
true
,
using: :btree
end
create_table
"draft_notes"
,
id: :bigserial
,
force: :cascade
do
|
t
|
t
.
integer
"merge_request_id"
,
null:
false
t
.
integer
"author_id"
,
null:
false
...
...
@@ -3405,6 +3421,9 @@ ActiveRecord::Schema.define(version: 20190305162221) do
add_foreign_key
"container_repositories"
,
"projects"
add_foreign_key
"deploy_keys_projects"
,
"projects"
,
name:
"fk_58a901ca7e"
,
on_delete: :cascade
add_foreign_key
"deployments"
,
"projects"
,
name:
"fk_b9a3851b82"
,
on_delete: :cascade
add_foreign_key
"design_management_designs"
,
"issues"
,
on_delete: :cascade
add_foreign_key
"design_management_designs"
,
"projects"
,
on_delete: :cascade
add_foreign_key
"design_management_versions"
,
"design_management_designs"
,
on_delete: :cascade
add_foreign_key
"draft_notes"
,
"merge_requests"
,
on_delete: :cascade
add_foreign_key
"draft_notes"
,
"users"
,
column:
"author_id"
,
on_delete: :cascade
add_foreign_key
"environments"
,
"projects"
,
name:
"fk_d1c8c1da6a"
,
on_delete: :cascade
...
...
ee/app/models/design_management.rb
0 → 100644
View file @
2e8d75f3
# frozen_string_literal: true
module
DesignManagement
def
self
.
table_name_prefix
'design_management_'
end
end
ee/app/models/design_management/design.rb
0 → 100644
View file @
2e8d75f3
# frozen_string_literal: true
module
DesignManagement
class
Design
<
ApplicationRecord
belongs_to
:project
belongs_to
:issue
has_many
:versions
,
class_name:
'DesignManagement::Version'
,
inverse_of: :design
validates
:project
,
:issue
,
:filename
,
presence:
true
validates
:issue
,
uniqueness:
true
validates
:filename
,
uniqueness:
{
scope: :issue_id
}
end
end
ee/app/models/design_management/version.rb
0 → 100644
View file @
2e8d75f3
# frozen_string_literal: true
module
DesignManagement
class
Version
<
ApplicationRecord
include
ShaAttribute
belongs_to
:design
,
class_name:
"DesignManagement::Design"
,
foreign_key:
'design_management_design_id'
has_one
:project
,
through: :design
has_one
:issue
,
through: :design
# This is a polymorphic association, so we can't count on FK's to delete the
# data
has_many
:notes
,
as: :noteable
,
dependent: :delete_all
# rubocop:disable Cop/ActiveRecordDependent
validates
:sha
,
:design
,
presence:
true
validates
:sha
,
uniqueness:
{
case_sensitive:
false
}
sha_attribute
:sha
end
end
ee/db/migrate/20190228134845_create_designs.rb
0 → 100644
View file @
2e8d75f3
class
CreateDesigns
<
ActiveRecord
::
Migration
[
5.0
]
def
change
create_table
:design_management_designs
,
id: :bigserial
do
|
t
|
t
.
references
:project
,
foreign_key:
{
on_delete: :cascade
},
index:
true
,
null:
false
t
.
references
:issue
,
foreign_key:
{
on_delete: :cascade
},
index:
{
unique:
true
},
null:
false
t
.
string
:filename
,
null:
false
t
.
index
[
:issue_id
,
:filename
],
unique:
true
end
end
end
ee/db/migrate/20190302144241_create_design_versions.rb
0 → 100644
View file @
2e8d75f3
class
CreateDesignVersions
<
ActiveRecord
::
Migration
[
5.0
]
def
change
create_table
:design_management_versions
,
id: :bigserial
do
|
t
|
t
.
references
:design_management_design
,
foreign_key:
{
on_delete: :cascade
},
type: :bigint
,
null:
false
,
index:
true
t
.
binary
:sha
,
null:
false
,
index:
{
unique:
true
},
limit:
20
end
end
end
ee/spec/factories/design_management/designs.rb
0 → 100644
View file @
2e8d75f3
# frozen_string_literal: true
FactoryBot
.
define
do
factory
:design
,
class:
DesignManagement
::
Design
do
issue
project
{
issue
.
project
}
sequence
(
:filename
)
{
|
n
|
"homescreen-
#{
n
}
.jpg"
}
end
end
ee/spec/factories/design_management/versions.rb
0 → 100644
View file @
2e8d75f3
# frozen_string_literal: true
FactoryBot
.
define
do
factory
:design_version
,
class:
DesignManagement
::
Version
do
design
sequence
(
:sha
)
{
|
n
|
Digest
::
SHA1
.
hexdigest
(
"commit-like-
#{
n
}
"
)
}
end
end
ee/spec/models/design_management/design_spec.rb
0 → 100644
View file @
2e8d75f3
# frozen_string_literal: true
require
'rails_helper'
describe
DesignManagement
::
Design
do
describe
'relations'
do
it
{
is_expected
.
to
belong_to
(
:project
)
}
it
{
is_expected
.
to
belong_to
(
:issue
)
}
it
{
is_expected
.
to
have_many
(
:versions
)
}
end
describe
'validations'
do
subject
(
:design
)
{
build
(
:design
)
}
it
{
is_expected
.
to
be_valid
}
it
{
is_expected
.
to
validate_presence_of
(
:project
)
}
it
{
is_expected
.
to
validate_presence_of
(
:issue
)
}
it
{
is_expected
.
to
validate_presence_of
(
:filename
)
}
it
{
is_expected
.
to
validate_uniqueness_of
(
:issue
)
}
it
{
is_expected
.
to
validate_uniqueness_of
(
:filename
).
scoped_to
(
:issue_id
)
}
end
end
ee/spec/models/design_management/version_spec.rb
0 → 100644
View file @
2e8d75f3
# frozen_string_literal: true
require
'rails_helper'
describe
DesignManagement
::
Version
do
describe
'relations'
do
it
{
is_expected
.
to
belong_to
(
:design
)
}
it
{
is_expected
.
to
have_one
(
:issue
)
}
it
{
is_expected
.
to
have_one
(
:project
)
}
it
{
is_expected
.
to
have_many
(
:notes
).
dependent
(
:delete_all
)
}
end
describe
'validations'
do
subject
(
:design_version
)
{
build
(
:design_version
)
}
it
{
is_expected
.
to
be_valid
}
it
{
is_expected
.
to
validate_presence_of
(
:design
)
}
it
{
is_expected
.
to
validate_presence_of
(
:sha
)
}
it
{
is_expected
.
to
validate_uniqueness_of
(
:sha
).
case_insensitive
}
end
end
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