BigW Consortium Gitlab
Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gitlab-ce
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Forest Godfrey
gitlab-ce
Commits
87d90b5b
Commit
87d90b5b
authored
Jul 07, 2017
by
Yorick Peterse
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'fix-sha-attribute-no-table' into 'master'
Fix ShaAttribute concern when there is no table Closes #34798 See merge request !12705
parents
c0e18e86
38fd773b
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
21 additions
and
0 deletions
+21
-0
sha_attribute.rb
app/models/concerns/sha_attribute.rb
+2
-0
sha_attribute_spec.rb
spec/models/concerns/sha_attribute_spec.rb
+19
-0
No files found.
app/models/concerns/sha_attribute.rb
View file @
87d90b5b
...
...
@@ -3,6 +3,8 @@ module ShaAttribute
module
ClassMethods
def
sha_attribute
(
name
)
return
unless
table_exists?
column
=
columns
.
find
{
|
c
|
c
.
name
==
name
.
to_s
}
# In case the table doesn't exist we won't be able to find the column,
...
...
spec/models/concerns/sha_attribute_spec.rb
View file @
87d90b5b
...
...
@@ -13,6 +13,11 @@ describe ShaAttribute do
end
describe
'#sha_attribute'
do
context
' when the table exists'
do
before
do
allow
(
model
).
to
receive
(
:table_exists?
).
and_return
(
true
)
end
it
'defines a SHA attribute for a binary column'
do
expect
(
model
).
to
receive
(
:attribute
)
.
with
(
:sha1
,
an_instance_of
(
Gitlab
::
Database
::
ShaAttribute
))
...
...
@@ -24,4 +29,18 @@ describe ShaAttribute do
expect
{
model
.
sha_attribute
(
:name
)
}.
to
raise_error
(
ArgumentError
)
end
end
context
' when the table does not exist'
do
before
do
allow
(
model
).
to
receive
(
:table_exists?
).
and_return
(
false
)
end
it
'does nothing'
do
expect
(
model
).
not_to
receive
(
:columns
)
expect
(
model
).
not_to
receive
(
:attribute
)
model
.
sha_attribute
(
:name
)
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