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
Léo-Paul Géneau
gitlab-ce
Commits
42d27f0b
Commit
42d27f0b
authored
May 10, 2018
by
Brett Walker
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
only issue a warning if column doesn't exist
parent
8279df2c
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
8 additions
and
5 deletions
+8
-5
app/models/concerns/sha_attribute.rb
app/models/concerns/sha_attribute.rb
+2
-1
spec/models/concerns/sha_attribute_spec.rb
spec/models/concerns/sha_attribute_spec.rb
+6
-4
No files found.
app/models/concerns/sha_attribute.rb
View file @
42d27f0b
...
@@ -22,7 +22,8 @@ module ShaAttribute
...
@@ -22,7 +22,8 @@ module ShaAttribute
column
=
columns
.
find
{
|
c
|
c
.
name
==
name
.
to_s
}
column
=
columns
.
find
{
|
c
|
c
.
name
==
name
.
to_s
}
unless
column
unless
column
raise
ArgumentError
.
new
(
"sha_attribute
#{
name
.
inspect
}
is invalid since the column doesn't exist"
)
warn
"WARNING: sha_attribute
#{
name
.
inspect
}
is invalid since the column doesn't exist - you may need to run database migrations"
return
end
end
unless
column
.
type
==
:binary
unless
column
.
type
==
:binary
...
...
spec/models/concerns/sha_attribute_spec.rb
View file @
42d27f0b
...
@@ -36,24 +36,26 @@ describe ShaAttribute do
...
@@ -36,24 +36,26 @@ describe ShaAttribute do
end
end
context
'when the table does not exist'
do
context
'when the table does not exist'
do
it
'allows the attribute to be added'
do
it
'allows the attribute to be added
and issues a warning
'
do
allow
(
model
).
to
receive
(
:table_exists?
).
and_return
(
false
)
allow
(
model
).
to
receive
(
:table_exists?
).
and_return
(
false
)
expect
(
model
).
not_to
receive
(
:columns
)
expect
(
model
).
not_to
receive
(
:columns
)
expect
(
model
).
to
receive
(
:attribute
)
expect
(
model
).
to
receive
(
:attribute
)
expect
(
model
).
to
receive
(
:warn
)
model
.
sha_attribute
(
:name
)
model
.
sha_attribute
(
:name
)
end
end
end
end
context
'when the column does not exist'
do
context
'when the column does not exist'
do
it
'
raises ArgumentError
'
do
it
'
allows the attribute to be added and issues a warning
'
do
allow
(
model
).
to
receive
(
:table_exists?
).
and_return
(
true
)
allow
(
model
).
to
receive
(
:table_exists?
).
and_return
(
true
)
expect
(
model
).
to
receive
(
:columns
)
expect
(
model
).
to
receive
(
:columns
)
expect
(
model
).
not_to
receive
(
:attribute
)
expect
(
model
).
to
receive
(
:attribute
)
expect
(
model
).
to
receive
(
:warn
)
expect
{
model
.
sha_attribute
(
:no_name
)
}.
to
raise_error
(
ArgumentError
)
model
.
sha_attribute
(
:no_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