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
22ecca36
Commit
22ecca36
authored
Sep 23, 2021
by
Andrejs Cunskis
Committed by
Mark Lapierre
Sep 23, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
E2E: Allow nil and boolean values for resource attributes
parent
25f1cc5d
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
15 deletions
+12
-15
qa/qa/resource/base.rb
qa/qa/resource/base.rb
+12
-15
No files found.
qa/qa/resource/base.rb
View file @
22ecca36
...
...
@@ -100,7 +100,9 @@ module QA
attr_writer
(
name
)
define_method
(
name
)
do
instance_variable_get
(
"@
#{
name
}
"
)
||
instance_variable_set
(
"@
#{
name
}
"
,
populate_attribute
(
name
,
block
))
return
instance_variable_get
(
"@
#{
name
}
"
)
if
instance_variable_defined?
(
"@
#{
name
}
"
)
instance_variable_set
(
"@
#{
name
}
"
,
attribute_value
(
name
,
block
))
end
end
...
...
@@ -121,9 +123,7 @@ module QA
return
self
unless
api_resource
all_attributes
.
each
do
|
attribute_name
|
api_value
=
api_resource
[
attribute_name
]
instance_variable_set
(
"@
#{
attribute_name
}
"
,
api_value
)
if
api_value
instance_variable_set
(
"@
#{
attribute_name
}
"
,
api_resource
[
attribute_name
])
if
api_resource
.
key?
(
attribute_name
)
end
self
...
...
@@ -160,20 +160,17 @@ module QA
private
def
populate_attribute
(
name
,
block
)
value
=
attribute_value
(
name
,
block
)
raise
NoValueError
,
"No value was computed for
#{
name
}
of
#{
self
.
class
.
name
}
."
unless
value
value
end
def
attribute_value
(
name
,
block
)
api_value
=
api_resource
&
.
dig
(
name
)
no_api_value
=
!
api_resource
&
.
key?
(
name
)
raise
NoValueError
,
"No value was computed for
#{
name
}
of
#{
self
.
class
.
name
}
."
if
no_api_value
&&
!
block
log_having_both_api_result_and_block
(
name
,
api_value
)
if
api_value
&&
block
unless
no_api_value
api_value
=
api_resource
[
name
]
log_having_both_api_result_and_block
(
name
,
api_value
)
if
block
return
api_value
end
api_value
||
(
block
&&
instance_exec
(
&
block
)
)
instance_exec
(
&
block
)
end
# Get all defined attributes across all parents
...
...
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