Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Back-end_Server
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Jobs
Commits
Open sidebar
Agendador
Back-end_Server
Commits
6f6e42f3
Commit
6f6e42f3
authored
Aug 22, 2018
by
Matheus Horstmann
🐴
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'check_professional_roles' into 'develop'
Check roles on creating professional See merge request
!85
parents
4d70ae81
c6a1e1cc
Pipeline
#17354
passed with stages
in 1 minute and 22 seconds
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
13 additions
and
3 deletions
+13
-3
app/controllers/api/v1/professionals_controller.rb
app/controllers/api/v1/professionals_controller.rb
+12
-2
test/controllers/professionals_controller_test.rb
test/controllers/professionals_controller_test.rb
+1
-1
No files found.
app/controllers/api/v1/professionals_controller.rb
View file @
6f6e42f3
...
...
@@ -103,6 +103,16 @@ module Api::V1
success
=
false
error_message
=
nil
# Check if the roles list is not empty, if it is, displays
# an error message
if
params
[
:professional
][
:roles
].
blank?
render
json:
{
# errors: ["You must inform at least one role!"]
errors:
[
"É necessário informar pelo menos uma permissão!"
]
},
status:
422
return
end
raise_rollback
=
->
(
error
)
{
error_message
=
error
raise
ActiveRecord
::
Rollback
...
...
@@ -144,7 +154,6 @@ module Api::V1
@citizen
.
account_id
=
@account
.
id
raise_rollback
.
call
(
@citizen
.
errors
.
to_hash
)
unless
@citizen
.
save
# Creates professional
@professional
=
Professional
.
new
(
professional_params
)
...
...
@@ -152,8 +161,9 @@ module Api::V1
@professional
.
active
=
true
raise_rollback
.
call
(
@professional
.
errors
.
to_hash
)
unless
@professional
.
save
# Professional service places list
psp_id_list
=
[]
# Creates professionals service places
params
[
:professional
][
:roles
].
each
do
|
item
|
psp
=
ProfessionalsServicePlace
.
new
({
...
...
test/controllers/professionals_controller_test.rb
View file @
6f6e42f3
...
...
@@ -101,7 +101,7 @@ class Api::V1::ProfessionalsControllerTest < ActionDispatch::IntegrationTest
end
it
"should not be permitted"
do
assert_equal
4
04
,
response
.
status
assert_equal
4
22
,
response
.
status
end
it
"should not create a professional"
do
...
...
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