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
58459f84
Commit
58459f84
authored
Jun 24, 2021
by
Oghenerukevwe Kofi
Committed by
charlie ablett
Jun 24, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Properly return boolean attributes in integrations API
parent
a6ae996d
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
39 additions
and
5 deletions
+39
-5
app/models/integration.rb
app/models/integration.rb
+5
-1
lib/api/entities/project_service.rb
lib/api/entities/project_service.rb
+12
-4
spec/requests/api/services_spec.rb
spec/requests/api/services_spec.rb
+22
-0
No files found.
app/models/integration.rb
View file @
58459f84
...
...
@@ -165,9 +165,13 @@ class Integration < ApplicationRecord
args
.
each
do
|
arg
|
class_eval
<<~
RUBY
,
__FILE__
,
__LINE__
+
1
def
#{
arg
}
Gitlab::Utils.to_boolean(properties['
#{
arg
}
'])
end
def
#{
arg
}
?
# '!!' is used because nil or empty string is converted to nil
!!
ActiveRecord::Type::Boolean.new.cast(
#{
arg
}
)
!!
#{
arg
}
end
RUBY
end
...
...
lib/api/entities/project_service.rb
View file @
58459f84
...
...
@@ -6,10 +6,18 @@ module API
# Expose serialized properties
expose
:properties
do
|
service
,
options
|
# TODO: Simplify as part of https://gitlab.com/gitlab-org/gitlab/issues/29404
if
service
.
data_fields_present?
service
.
data_fields
.
as_json
.
slice
(
*
service
.
api_field_names
)
else
service
.
properties
.
slice
(
*
service
.
api_field_names
)
attributes
=
if
service
.
data_fields_present?
service
.
data_fields
.
as_json
.
keys
else
service
.
properties
.
keys
end
attributes
&=
service
.
api_field_names
attributes
.
each_with_object
({})
do
|
attribute
,
hash
|
hash
[
attribute
]
=
service
.
public_send
(
attribute
)
# rubocop:disable GitlabSecurity/PublicSend
end
end
end
...
...
spec/requests/api/services_spec.rb
View file @
58459f84
...
...
@@ -338,4 +338,26 @@ RSpec.describe API::Services do
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
end
end
describe
'Pipelines Email Integration'
do
let
(
:service_name
)
{
'pipelines-email'
}
context
'notify_only_broken_pipelines property was saved as a string'
do
before
do
project
.
create_pipelines_email_integration
(
active:
false
,
properties:
{
"notify_only_broken_pipelines"
:
"true"
,
"branches_to_be_notified"
:
"default"
}
)
end
it
'returns boolean values for notify_only_broken_pipelines'
do
get
api
(
"/projects/
#{
project
.
id
}
/services/
#{
service_name
}
"
,
user
)
expect
(
json_response
[
'properties'
][
'notify_only_broken_pipelines'
]).
to
eq
(
true
)
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