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
e8a455dc
Commit
e8a455dc
authored
Sep 01, 2018
by
Lin Jen-Shin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Following the feedbacks
parent
d6c4bc46
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
37 additions
and
12 deletions
+37
-12
lib/gitlab/utils/override.rb
lib/gitlab/utils/override.rb
+3
-3
spec/lib/gitlab/patch/prependable_spec.rb
spec/lib/gitlab/patch/prependable_spec.rb
+34
-9
No files found.
lib/gitlab/utils/override.rb
View file @
e8a455dc
...
@@ -89,19 +89,19 @@ module Gitlab
...
@@ -89,19 +89,19 @@ module Gitlab
def
included
(
base
=
nil
)
def
included
(
base
=
nil
)
super
super
queue_verification
(
base
)
queue_verification
(
base
)
if
base
end
end
def
prepended
(
base
=
nil
)
def
prepended
(
base
=
nil
)
super
super
queue_verification
(
base
)
queue_verification
(
base
)
if
base
end
end
def
extended
(
mod
=
nil
)
def
extended
(
mod
=
nil
)
super
super
queue_verification
(
mod
.
singleton_class
)
queue_verification
(
mod
.
singleton_class
)
if
mod
end
end
def
queue_verification
(
base
)
def
queue_verification
(
base
)
...
...
spec/lib/gitlab/patch/prependable_spec.rb
View file @
e8a455dc
...
@@ -6,11 +6,13 @@ require 'fast_spec_helper'
...
@@ -6,11 +6,13 @@ require 'fast_spec_helper'
require_relative
'../../../../config/initializers/0_as_concern'
require_relative
'../../../../config/initializers/0_as_concern'
describe
Gitlab
::
Patch
::
Prependable
do
describe
Gitlab
::
Patch
::
Prependable
do
let
(
:prepended_modules
)
{
[]
}
before
do
@prepended_modules
=
[]
end
let
(
:ee
)
do
let
(
:ee
)
do
# So that block in Module.new could see them
# So that block in Module.new could see them
prepended_modules
_
=
prepended_modules
prepended_modules
=
@
prepended_modules
Module
.
new
do
Module
.
new
do
extend
ActiveSupport
::
Concern
extend
ActiveSupport
::
Concern
...
@@ -23,7 +25,7 @@ describe Gitlab::Patch::Prependable do
...
@@ -23,7 +25,7 @@ describe Gitlab::Patch::Prependable do
this
=
self
this
=
self
prepended
do
prepended
do
prepended_modules
_
<<
[
self
,
this
]
prepended_modules
<<
[
self
,
this
]
end
end
def
name
def
name
...
@@ -33,7 +35,7 @@ describe Gitlab::Patch::Prependable do
...
@@ -33,7 +35,7 @@ describe Gitlab::Patch::Prependable do
end
end
let
(
:ce
)
do
let
(
:ce
)
do
prepended_modules
_
=
prepended_modules
prepended_modules
=
@
prepended_modules
ee_
=
ee
ee_
=
ee
Module
.
new
do
Module
.
new
do
...
@@ -48,7 +50,7 @@ describe Gitlab::Patch::Prependable do
...
@@ -48,7 +50,7 @@ describe Gitlab::Patch::Prependable do
this
=
self
this
=
self
prepended
do
prepended
do
prepended_modules
_
<<
[
self
,
this
]
prepended_modules
<<
[
self
,
this
]
end
end
def
name
def
name
...
@@ -65,16 +67,24 @@ describe Gitlab::Patch::Prependable do
...
@@ -65,16 +67,24 @@ describe Gitlab::Patch::Prependable do
expect
(
subject
.
class_name
).
to
eq
(
'EE'
)
expect
(
subject
.
class_name
).
to
eq
(
'EE'
)
end
end
it
'has the expected ancestors'
do
expect
(
subject
.
ancestors
.
take
(
3
)).
to
eq
([
subject
,
ee
,
ce
])
expect
(
subject
.
singleton_class
.
ancestors
.
take
(
3
))
.
to
eq
([
subject
.
singleton_class
,
ee
.
const_get
(
:ClassMethods
),
ce
.
const_get
(
:ClassMethods
)])
end
it
'prepends only once'
do
it
'prepends only once'
do
ce
.
prepend
(
ee
)
ce
.
prepend
(
ee
)
ce
.
prepend
(
ee
)
ce
.
prepend
(
ee
)
subject
subject
expect
(
prepended_modules
).
to
eq
([[
ce
,
ee
]])
expect
(
@
prepended_modules
).
to
eq
([[
ce
,
ee
]])
end
end
context
'overriding
a method
'
do
context
'overriding
methods
'
do
before
do
before
do
subject
.
module_eval
do
subject
.
module_eval
do
def
self
.
class_name
def
self
.
class_name
...
@@ -102,10 +112,18 @@ describe Gitlab::Patch::Prependable do
...
@@ -102,10 +112,18 @@ describe Gitlab::Patch::Prependable do
expect
(
subject
.
class_name
).
to
eq
(
'EE'
)
expect
(
subject
.
class_name
).
to
eq
(
'EE'
)
end
end
it
'has the expected ancestors'
do
expect
(
subject
.
ancestors
.
take
(
3
)).
to
eq
([
ee
,
ce
,
subject
])
expect
(
subject
.
singleton_class
.
ancestors
.
take
(
3
))
.
to
eq
([
ee
.
const_get
(
:ClassMethods
),
ce
.
const_get
(
:ClassMethods
),
subject
.
singleton_class
])
end
it
'prepends only once'
do
it
'prepends only once'
do
subject
.
prepend
(
ce
)
subject
.
prepend
(
ce
)
expect
(
prepended_modules
).
to
eq
([[
ce
,
ee
],
[
subject
,
ce
]])
expect
(
@
prepended_modules
).
to
eq
([[
ce
,
ee
],
[
subject
,
ce
]])
end
end
end
end
...
@@ -131,10 +149,17 @@ describe Gitlab::Patch::Prependable do
...
@@ -131,10 +149,17 @@ describe Gitlab::Patch::Prependable do
expect
(
subject
.
class_name
).
to
eq
(
'EE'
)
expect
(
subject
.
class_name
).
to
eq
(
'EE'
)
end
end
it
'has the expected ancestors'
do
expect
(
subject
.
ancestors
.
take
(
2
)).
to
eq
([
ee
,
subject
])
expect
(
subject
.
singleton_class
.
ancestors
.
take
(
2
))
.
to
eq
([
ee
.
const_get
(
:ClassMethods
),
subject
.
singleton_class
])
end
it
'prepends only once'
do
it
'prepends only once'
do
subject
.
prepend
(
ee
)
subject
.
prepend
(
ee
)
expect
(
prepended_modules
).
to
eq
([[
subject
,
ee
]])
expect
(
@
prepended_modules
).
to
eq
([[
subject
,
ee
]])
end
end
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