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
0731365b
Commit
0731365b
authored
Mar 13, 2017
by
Grzegorz Bizon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add GitLab QA CE strategy and simplify inflector
parent
cbba9184
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
35 additions
and
61 deletions
+35
-61
qa/qa.rb
qa/qa.rb
+1
-3
qa/qa/ce/strategy.rb
qa/qa/ce/strategy.rb
+15
-0
qa/qa/runtime/release.rb
qa/qa/runtime/release.rb
+5
-19
qa/spec/runtime/release_spec.rb
qa/spec/runtime/release_spec.rb
+14
-39
No files found.
qa/qa.rb
View file @
0731365b
...
@@ -78,6 +78,4 @@ module QA
...
@@ -78,6 +78,4 @@ module QA
end
end
end
end
if
QA
::
Runtime
::
Release
.
has_autoloads?
QA
::
Runtime
::
Release
.
extend_autoloads!
require
QA
::
Runtime
::
Release
.
autoloads_file
end
qa/qa/ce/strategy.rb
0 → 100644
View file @
0731365b
module
QA
module
CE
module
Strategy
extend
self
def
extend_autoloads!
# noop
end
def
perform_before_hooks
# noop
end
end
end
end
qa/qa/runtime/release.rb
View file @
0731365b
...
@@ -8,34 +8,20 @@ module QA
...
@@ -8,34 +8,20 @@ module QA
# CE to EE.
# CE to EE.
#
#
class
Release
class
Release
def
initialize
(
variant
=
nil
)
def
initialize
@version
=
variant
||
version
require
"qa/
#{
version
.
downcase
}
/strategy"
begin
require
"qa/
#{
@version
.
downcase
}
/strategy"
rescue
LoadError
# noop
end
end
end
def
version
def
version
File
.
directory?
(
"
#{
__dir__
}
/../ee"
)
?
:EE
:
:CE
@version
||=
File
.
directory?
(
"
#{
__dir__
}
/../ee"
)
?
:EE
:
:CE
end
def
has_strategy?
QA
.
const_defined?
(
"QA::
#{
@version
}
::Strategy"
)
end
end
def
strategy
def
strategy
QA
.
const_get
(
"QA::
#{
@
version
}
::Strategy"
)
QA
.
const_get
(
"QA::
#{
version
}
::Strategy"
)
end
end
def
self
.
method_missing
(
name
,
*
args
)
def
self
.
method_missing
(
name
,
*
args
)
@release
||=
self
.
new
self
.
new
.
strategy
.
public_send
(
name
,
*
args
)
if
@release
.
has_strategy?
@release
.
strategy
.
public_send
(
name
,
*
args
)
end
end
end
end
end
end
end
...
...
qa/spec/runtime/release_spec.rb
View file @
0731365b
describe
QA
::
Runtime
::
Release
do
describe
QA
::
Runtime
::
Release
do
context
'when release version has extension strategy'
do
context
'when release version has extension strategy'
do
subject
{
described_class
.
new
(
'VER'
)
}
let
(
:strategy
)
{
spy
(
'strategy'
)
}
let
(
:strategy
)
{
spy
(
'VER::Strategy'
)
}
before
do
before
do
stub_const
(
'QA::VER::Strategy'
,
strategy
)
stub_const
(
'QA::CE::Strategy'
,
strategy
)
stub_const
(
'QA::EE::Strategy'
,
strategy
)
end
end
describe
'#
has_strategy?
'
do
describe
'#
version
'
do
it
'return
true
'
do
it
'return
either CE or EE version
'
do
expect
(
subject
.
has_strategy?
).
to
be
true
expect
(
subject
.
version
).
to
eq
(
:CE
).
or
eq
(
:EE
)
end
end
end
end
describe
'#strategy'
do
describe
'#strategy'
do
it
'return the strategy constant'
do
it
'return the strategy constant'
do
expect
(
subject
.
strategy
).
to
eq
QA
::
VER
::
S
trategy
expect
(
subject
.
strategy
).
to
eq
s
trategy
end
end
end
end
describe
'delegated class methods'
do
describe
'delegated class methods'
do
before
do
allow_any_instance_of
(
described_class
)
.
to
receive
(
:has_strategy?
).
and_return
(
true
)
allow_any_instance_of
(
described_class
)
.
to
receive
(
:strategy
).
and_return
(
strategy
)
end
it
'delegates all calls to strategy class'
do
it
'delegates all calls to strategy class'
do
described_class
.
some_method
(
1
,
2
)
described_class
.
some_method
(
1
,
2
)
...
@@ -38,37 +30,20 @@ describe QA::Runtime::Release do
...
@@ -38,37 +30,20 @@ describe QA::Runtime::Release do
end
end
context
'when release version does not have extension strategy'
do
context
'when release version does not have extension strategy'
do
subject
{
described_class
.
new
(
'NOVER'
)
}
before
do
allow_any_instance_of
(
described_class
)
describe
'#has_strategy?'
do
.
to
receive
(
:version
).
and_return
(
'something'
)
it
'returns false'
do
expect
(
subject
.
has_strategy?
).
to
be
false
end
end
end
describe
'#strategy'
do
describe
'#strategy'
do
it
'raises error'
do
it
'raises error'
do
expect
{
subject
.
strategy
}.
to
raise_error
(
Name
Error
)
expect
{
subject
.
strategy
}.
to
raise_error
(
Load
Error
)
end
end
end
end
describe
'does not delegate class methods'
do
describe
'delegated class methods'
do
before
do
it
'raises error'
do
allow_any_instance_of
(
described_class
)
expect
{
described_class
.
some_method
(
2
,
3
)
}.
to
raise_error
(
LoadError
)
.
to
receive
(
:has_strategy?
).
and_return
(
false
)
end
it
'behaves like a null object and does nothing'
do
expect
{
described_class
.
some_method
(
2
,
3
)
}.
not_to
raise_error
end
it
'returns nil'
do
expect
(
described_class
.
something
).
to
be_nil
end
it
'does not delegate to strategy object'
do
expect_any_instance_of
(
described_class
)
.
not_to
receive
(
:strategy
)
end
end
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