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
Boxiang Sun
gitlab-ce
Commits
64882672
Commit
64882672
authored
Feb 02, 2018
by
Matija Čupić
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Rename Callout to UserCallout
parent
838cc090
Changes
11
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
25 additions
and
27 deletions
+25
-27
app/controllers/user_callouts_controller.rb
app/controllers/user_callouts_controller.rb
+1
-1
app/helpers/user_callouts_helper.rb
app/helpers/user_callouts_helper.rb
+1
-1
app/models/user.rb
app/models/user.rb
+1
-1
app/models/user_callout.rb
app/models/user_callout.rb
+1
-1
config/routes.rb
config/routes.rb
+2
-2
db/migrate/20180125214301_create_user_callouts.rb
db/migrate/20180125214301_create_user_callouts.rb
+3
-3
db/schema.rb
db/schema.rb
+9
-11
spec/controllers/user_callouts_controller_spec.rb
spec/controllers/user_callouts_controller_spec.rb
+3
-3
spec/factories/user_callouts.rb
spec/factories/user_callouts.rb
+1
-1
spec/helpers/user_callouts_helper_spec.rb
spec/helpers/user_callouts_helper_spec.rb
+1
-1
spec/models/user_callout_spec.rb
spec/models/user_callout_spec.rb
+2
-2
No files found.
app/controllers/callouts_controller.rb
→
app/controllers/
user_
callouts_controller.rb
View file @
64882672
class
CalloutsController
<
ApplicationController
class
User
CalloutsController
<
ApplicationController
def
create
if
ensure_callout
respond_to
do
|
format
|
...
...
app/helpers/callouts_helper.rb
→
app/helpers/
user_
callouts_helper.rb
View file @
64882672
module
CalloutsHelper
module
User
CalloutsHelper
GKE_CLUSTER_INTEGRATION
=
'gke_cluster_integration'
.
freeze
# Higher value = higher priority
...
...
app/models/user.rb
View file @
64882672
...
...
@@ -137,7 +137,7 @@ class User < ActiveRecord::Base
has_many
:assigned_merge_requests
,
dependent: :nullify
,
foreign_key: :assignee_id
,
class_name:
"MergeRequest"
# rubocop:disable Cop/ActiveRecordDependent
has_many
:custom_attributes
,
class_name:
'UserCustomAttribute'
has_many
:callouts
has_many
:callouts
,
class_name:
'UserCallout'
#
# Validations
...
...
app/models/callout.rb
→
app/models/
user_
callout.rb
View file @
64882672
class
Callout
<
ActiveRecord
::
Base
class
User
Callout
<
ActiveRecord
::
Base
belongs_to
:user
validates
:user
,
presence:
true
...
...
config/routes.rb
View file @
64882672
...
...
@@ -61,8 +61,8 @@ Rails.application.routes.draw do
resources
:issues
,
module: :boards
,
only:
[
:index
,
:update
]
end
# Callouts
resources
:callouts
,
only:
[
:create
]
#
User
Callouts
resources
:
user_
callouts
,
only:
[
:create
]
end
# Koding route
...
...
db/migrate/20180125214301_create_callouts.rb
→
db/migrate/20180125214301_create_
user_
callouts.rb
View file @
64882672
# See http://doc.gitlab.com/ce/development/migration_style_guide.html
# for more information on how to write migrations for GitLab.
class
CreateCallouts
<
ActiveRecord
::
Migration
class
Create
User
Callouts
<
ActiveRecord
::
Migration
# Set this constant to true if this migration requires downtime.
DOWNTIME
=
false
def
change
create_table
:callouts
do
|
t
|
create_table
:
user_
callouts
do
|
t
|
t
.
string
:feature_name
,
null:
false
t
.
references
:user
,
index:
true
,
foreign_key:
{
on_delete: :cascade
},
null:
false
end
add_index
:callouts
,
[
:user_id
,
:feature_name
],
unique:
true
add_index
:
user_
callouts
,
[
:user_id
,
:feature_name
],
unique:
true
end
end
db/schema.rb
View file @
64882672
...
...
@@ -203,16 +203,6 @@ ActiveRecord::Schema.define(version: 20180125214301) do
add_index
"broadcast_messages"
,
[
"starts_at"
,
"ends_at"
,
"id"
],
name:
"index_broadcast_messages_on_starts_at_and_ends_at_and_id"
,
using: :btree
create_table
"callouts"
,
force: :cascade
do
|
t
|
t
.
string
"feature_name"
,
null:
false
t
.
integer
"user_id"
,
null:
false
t
.
datetime_with_timezone
"created_at"
,
null:
false
t
.
datetime_with_timezone
"updated_at"
,
null:
false
end
add_index
"callouts"
,
[
"user_id"
,
"feature_name"
],
name:
"index_callouts_on_user_id_and_feature_name"
,
unique:
true
,
using: :btree
add_index
"callouts"
,
[
"user_id"
],
name:
"index_callouts_on_user_id"
,
using: :btree
create_table
"chat_names"
,
force: :cascade
do
|
t
|
t
.
integer
"user_id"
,
null:
false
t
.
integer
"service_id"
,
null:
false
...
...
@@ -1779,6 +1769,14 @@ ActiveRecord::Schema.define(version: 20180125214301) do
add_index
"user_agent_details"
,
[
"subject_id"
,
"subject_type"
],
name:
"index_user_agent_details_on_subject_id_and_subject_type"
,
using: :btree
create_table
"user_callouts"
,
force: :cascade
do
|
t
|
t
.
string
"feature_name"
,
null:
false
t
.
integer
"user_id"
,
null:
false
end
add_index
"user_callouts"
,
[
"user_id"
,
"feature_name"
],
name:
"index_user_callouts_on_user_id_and_feature_name"
,
unique:
true
,
using: :btree
add_index
"user_callouts"
,
[
"user_id"
],
name:
"index_user_callouts_on_user_id"
,
using: :btree
create_table
"user_custom_attributes"
,
force: :cascade
do
|
t
|
t
.
datetime_with_timezone
"created_at"
,
null:
false
t
.
datetime_with_timezone
"updated_at"
,
null:
false
...
...
@@ -1934,7 +1932,6 @@ ActiveRecord::Schema.define(version: 20180125214301) do
add_index
"web_hooks"
,
[
"type"
],
name:
"index_web_hooks_on_type"
,
using: :btree
add_foreign_key
"boards"
,
"projects"
,
name:
"fk_f15266b5f9"
,
on_delete: :cascade
add_foreign_key
"callouts"
,
"users"
,
on_delete: :cascade
add_foreign_key
"chat_teams"
,
"namespaces"
,
on_delete: :cascade
add_foreign_key
"ci_build_trace_section_names"
,
"projects"
,
on_delete: :cascade
add_foreign_key
"ci_build_trace_sections"
,
"ci_build_trace_section_names"
,
column:
"section_name_id"
,
name:
"fk_264e112c66"
,
on_delete: :cascade
...
...
@@ -2051,6 +2048,7 @@ ActiveRecord::Schema.define(version: 20180125214301) do
add_foreign_key
"todos"
,
"projects"
,
name:
"fk_45054f9c45"
,
on_delete: :cascade
add_foreign_key
"trending_projects"
,
"projects"
,
on_delete: :cascade
add_foreign_key
"u2f_registrations"
,
"users"
add_foreign_key
"user_callouts"
,
"users"
,
on_delete: :cascade
add_foreign_key
"user_custom_attributes"
,
"users"
,
on_delete: :cascade
add_foreign_key
"user_synced_attributes_metadata"
,
"users"
,
on_delete: :cascade
add_foreign_key
"users_star_projects"
,
"projects"
,
name:
"fk_22cd27ddfc"
,
on_delete: :cascade
...
...
spec/controllers/callouts_controller_spec.rb
→
spec/controllers/
user_
callouts_controller_spec.rb
View file @
64882672
require
'spec_helper'
describe
CalloutsController
do
describe
User
CalloutsController
do
let
(
:user
)
{
create
(
:user
)
}
before
do
...
...
@@ -12,7 +12,7 @@ describe CalloutsController do
context
'when callout entry does not exist'
do
it
'should create a callout entry with dismissed state'
do
expect
{
subject
}.
to
change
{
Callout
.
count
}.
by
(
1
)
expect
{
subject
}.
to
change
{
User
Callout
.
count
}.
by
(
1
)
end
it
'should return success'
do
...
...
@@ -23,7 +23,7 @@ describe CalloutsController do
end
context
'when callout entry already exists'
do
let!
(
:callout
)
{
create
(
:callout
,
feature_name:
'feature_name'
,
user:
user
)
}
let!
(
:callout
)
{
create
(
:
user_
callout
,
feature_name:
'feature_name'
,
user:
user
)
}
it
'should return success'
do
subject
...
...
spec/factories/callouts.rb
→
spec/factories/
user_
callouts.rb
View file @
64882672
FactoryBot
.
define
do
factory
:callout
do
factory
:
user_
callout
do
feature_name
'test_callout'
user
...
...
spec/helpers/callouts_helper_spec.rb
→
spec/helpers/
user_
callouts_helper_spec.rb
View file @
64882672
require
"spec_helper"
describe
CalloutsHelper
do
describe
User
CalloutsHelper
do
let
(
:user
)
{
create
(
:user
)
}
before
do
...
...
spec/models/callout_spec.rb
→
spec/models/
user_
callout_spec.rb
View file @
64882672
require
'rails_helper'
describe
Callout
do
let!
(
:callout
)
{
create
(
:callout
)
}
describe
User
Callout
do
let!
(
:callout
)
{
create
(
:
user_
callout
)
}
describe
'relationships'
do
it
{
is_expected
.
to
belong_to
(
:user
)
}
...
...
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