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
1a3d33e5
Commit
1a3d33e5
authored
Jul 25, 2017
by
Douglas Barbosa Alexandre
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add GeoNodeGroupLink model
parent
e781857d
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
35 additions
and
0 deletions
+35
-0
app/models/geo_node.rb
app/models/geo_node.rb
+3
-0
app/models/geo_node_group_link.rb
app/models/geo_node_group_link.rb
+7
-0
spec/factories/geo_node_group_links.rb
spec/factories/geo_node_group_links.rb
+6
-0
spec/models/geo_node_group_link_spec.rb
spec/models/geo_node_group_link_spec.rb
+16
-0
spec/models/geo_node_spec.rb
spec/models/geo_node_spec.rb
+3
-0
No files found.
app/models/geo_node.rb
View file @
1a3d33e5
...
...
@@ -5,6 +5,9 @@ class GeoNode < ActiveRecord::Base
belongs_to
:oauth_application
,
class_name:
'Doorkeeper::Application'
,
dependent: :destroy
# rubocop: disable Cop/ActiveRecordDependent
belongs_to
:system_hook
,
dependent: :destroy
# rubocop: disable Cop/ActiveRecordDependent
has_many
:geo_node_group_links
has_many
:groups
,
through: :geo_node_group_links
default_values
schema:
lambda
{
Gitlab
.
config
.
gitlab
.
protocol
},
host:
lambda
{
Gitlab
.
config
.
gitlab
.
host
},
port:
lambda
{
Gitlab
.
config
.
gitlab
.
port
},
...
...
app/models/geo_node_group_link.rb
0 → 100644
View file @
1a3d33e5
class
GeoNodeGroupLink
<
ActiveRecord
::
Base
belongs_to
:geo_node
belongs_to
:group
validates
:geo_node_id
,
:group_id
,
presence:
true
validates
:group_id
,
uniqueness:
{
scope:
[
:geo_node_id
]
}
end
spec/factories/geo_node_group_links.rb
0 → 100644
View file @
1a3d33e5
FactoryGirl
.
define
do
factory
:geo_node_group_link
do
geo_node
group
end
end
spec/models/geo_node_group_link_spec.rb
0 → 100644
View file @
1a3d33e5
require
'spec_helper'
describe
GeoNodeGroupLink
,
models:
true
do
describe
'relationships'
do
it
{
is_expected
.
to
belong_to
(
:geo_node
)
}
it
{
is_expected
.
to
belong_to
(
:group
)
}
end
describe
'validations'
do
let!
(
:geo_node_group_link
)
{
create
(
:geo_node_group_link
)
}
it
{
is_expected
.
to
validate_presence_of
(
:geo_node_id
)
}
it
{
is_expected
.
to
validate_presence_of
(
:group_id
)
}
it
{
is_expected
.
to
validate_uniqueness_of
(
:group_id
).
scoped_to
(
:geo_node_id
)
}
end
end
spec/models/geo_node_spec.rb
View file @
1a3d33e5
...
...
@@ -14,6 +14,9 @@ describe GeoNode, type: :model do
context
'associations'
do
it
{
is_expected
.
to
belong_to
(
:geo_node_key
).
dependent
(
:destroy
)
}
it
{
is_expected
.
to
belong_to
(
:oauth_application
).
dependent
(
:destroy
)
}
it
{
is_expected
.
to
have_many
(
:geo_node_group_links
)
}
it
{
is_expected
.
to
have_many
(
:groups
).
through
(
:geo_node_group_links
)
}
end
context
'default values'
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