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
5ffd8707
Commit
5ffd8707
authored
Jul 19, 2018
by
Jasper Maes
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Rails 5 fix NoMethodError: undefined method 'message' for nil:NilClass in host_spec.rb
parent
5a2d9d67
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
32 additions
and
4 deletions
+32
-4
ee/changelogs/unreleased/rails5-fix-loadbalancing-host-spec.yml
...ngelogs/unreleased/rails5-fix-loadbalancing-host-spec.yml
+6
-0
ee/spec/lib/gitlab/database/load_balancing/host_spec.rb
ee/spec/lib/gitlab/database/load_balancing/host_spec.rb
+26
-4
No files found.
ee/changelogs/unreleased/rails5-fix-loadbalancing-host-spec.yml
0 → 100644
View file @
5ffd8707
---
title
:
'
Rails
5
fix
NoMethodError:
undefined
method
'
'
message'
'
for
nil:NilClass
in
host_spec.rb'
merge_request
:
6589
author
:
Jasper Maes
type
:
fixed
ee/spec/lib/gitlab/database/load_balancing/host_spec.rb
View file @
5ffd8707
...
...
@@ -12,6 +12,24 @@ describe Gitlab::Database::LoadBalancing::Host, :postgresql do
.
and_return
(
ActiveRecord
::
Base
.
connection_pool
)
end
def
raise_and_wrap
(
wrapper
,
original
)
raise
original
rescue
original
.
class
raise
wrapper
.
new
(
'boom'
)
end
def
wrapped_exception
(
wrapper
,
original
)
if
Gitlab
.
rails5?
begin
raise_and_wrap
(
wrapper
,
original
.
new
)
rescue
wrapper
=>
error
error
end
else
wrapper
.
new
(
'boom'
,
original
.
new
)
end
end
describe
'#connection'
do
it
'returns a connection from the pool'
do
expect
(
host
.
pool
).
to
receive
(
:connection
)
...
...
@@ -95,11 +113,11 @@ describe Gitlab::Database::LoadBalancing::Host, :postgresql do
context
'when the replica is not online'
do
it
'returns false when ActionView::Template::Error is raised'
do
error
=
StandardError
.
new
wrapped_error
=
wrapped_exception
(
ActionView
::
Template
::
Error
,
StandardError
)
allow
(
host
)
.
to
receive
(
:check_replica_status?
)
.
and_raise
(
ActionView
::
Template
::
Error
.
new
(
'boom'
,
error
)
)
.
and_raise
(
wrapped_error
)
expect
(
host
).
not_to
be_online
end
...
...
@@ -274,9 +292,11 @@ describe Gitlab::Database::LoadBalancing::Host, :postgresql do
end
it
'returns nil when the database connection fails'
do
wrapped_error
=
wrapped_exception
(
ActionView
::
Template
::
Error
,
StandardError
)
allow
(
host
)
.
to
receive
(
:connection
)
.
and_raise
(
ActionView
::
Template
::
Error
.
new
(
'boom'
,
StandardError
.
new
)
)
.
and_raise
(
wrapped_error
)
expect
(
host
.
replication_lag_size
).
to
be_nil
end
...
...
@@ -311,9 +331,11 @@ describe Gitlab::Database::LoadBalancing::Host, :postgresql do
end
it
'returns false when the connection fails'
do
wrapped_error
=
wrapped_exception
(
ActionView
::
Template
::
Error
,
StandardError
)
allow
(
host
)
.
to
receive
(
:connection
)
.
and_raise
(
ActionView
::
Template
::
Error
.
new
(
'boom'
,
StandardError
.
new
)
)
.
and_raise
(
wrapped_error
)
expect
(
host
.
caught_up?
(
'foo'
)).
to
eq
(
false
)
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