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
0
Merge Requests
0
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
Jérome Perrin
gitlab-ce
Commits
4fcae04f
Commit
4fcae04f
authored
Oct 31, 2016
by
Douglas Barbosa Alexandre
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add project_id to subscriptions
parent
8762db3b
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
34 additions
and
0 deletions
+34
-0
app/models/subscription.rb
app/models/subscription.rb
+3
-0
db/migrate/20161031171301_add_project_id_to_subscriptions.rb
db/migrate/20161031171301_add_project_id_to_subscriptions.rb
+14
-0
db/schema.rb
db/schema.rb
+2
-0
spec/models/subscription_spec.rb
spec/models/subscription_spec.rb
+15
-0
No files found.
app/models/subscription.rb
View file @
4fcae04f
class
Subscription
<
ActiveRecord
::
Base
belongs_to
:user
belongs_to
:project
belongs_to
:subscribable
,
polymorphic:
true
validates
:user
,
:project
,
:subscribable
,
presence:
true
validates
:user_id
,
uniqueness:
{
scope:
[
:subscribable_id
,
:subscribable_type
]
},
presence:
true
...
...
db/migrate/20161031171301_add_project_id_to_subscriptions.rb
0 → 100644
View file @
4fcae04f
class
AddProjectIdToSubscriptions
<
ActiveRecord
::
Migration
include
Gitlab
::
Database
::
MigrationHelpers
DOWNTIME
=
false
def
up
add_column
:subscriptions
,
:project_id
,
:integer
add_foreign_key
:subscriptions
,
:projects
,
column: :project_id
,
on_delete: :cascade
end
def
down
remove_column
:subscriptions
,
:project_id
end
end
db/schema.rb
View file @
4fcae04f
...
...
@@ -1052,6 +1052,7 @@ ActiveRecord::Schema.define(version: 20161109150329) do
t
.
boolean
"subscribed"
t
.
datetime
"created_at"
t
.
datetime
"updated_at"
t
.
integer
"project_id"
end
add_index
"subscriptions"
,
[
"subscribable_id"
,
"subscribable_type"
,
"user_id"
],
name:
"subscriptions_user_id_and_ref_fields"
,
unique:
true
,
using: :btree
...
...
@@ -1250,6 +1251,7 @@ ActiveRecord::Schema.define(version: 20161109150329) do
add_foreign_key
"personal_access_tokens"
,
"users"
add_foreign_key
"protected_branch_merge_access_levels"
,
"protected_branches"
add_foreign_key
"protected_branch_push_access_levels"
,
"protected_branches"
add_foreign_key
"subscriptions"
,
"projects"
,
on_delete: :cascade
add_foreign_key
"trending_projects"
,
"projects"
,
on_delete: :cascade
add_foreign_key
"u2f_registrations"
,
"users"
end
spec/models/subscription_spec.rb
0 → 100644
View file @
4fcae04f
require
'spec_helper'
describe
Subscription
,
models:
true
do
describe
'relationships'
do
it
{
is_expected
.
to
belong_to
(
:project
)
}
it
{
is_expected
.
to
belong_to
(
:subscribable
)
}
it
{
is_expected
.
to
belong_to
(
:user
)
}
end
describe
'validations'
do
it
{
is_expected
.
to
validate_presence_of
(
:project
)
}
it
{
is_expected
.
to
validate_presence_of
(
:subscribable
)
}
it
{
is_expected
.
to
validate_presence_of
(
:user
)
}
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