Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
cleaning-portalmec
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Harbor Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Richard Fernando Heise Ferreira
cleaning-portalmec
Commits
db332cfa
Commit
db332cfa
authored
8 years ago
by
Giovanne Marcelo
Browse files
Options
Downloads
Plain Diff
Merge branch 'rspec' of gitlab.c3sl.ufpr.br:portalmec/portalmec into rspec
parents
9b21777f
1e323e3b
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
spec/acceptance/users_spec.rb
+42
-0
42 additions, 0 deletions
spec/acceptance/users_spec.rb
spec/shared/contexts.rb
+13
-0
13 additions, 0 deletions
spec/shared/contexts.rb
with
55 additions
and
0 deletions
spec/acceptance/users_spec.rb
+
42
−
0
View file @
db332cfa
...
...
@@ -210,4 +210,46 @@ resource 'Users' do
end
end
post
'/v1/users'
do
include_context
"authenticate_user_admin"
parameter
:name
,
'The name of the user'
,
scope: :user
parameter
:email
,
'The email of user'
,
scope: :user
parameter
:description
,
'The user description'
,
scope: :user
parameter
:password
,
'The password of user'
,
scope: :user
parameter
:password_confirmation
,
'The password confirmation of user'
,
scope: :user
parameter
:terms_of_service
,
'Checks if user agreed with terms of service'
,
scope: :user
parameter
:avatar
,
'The user avatar'
,
scope: :user
let
(
:name
)
{
Faker
::
Name
.
name
}
let
(
:email
)
{
Faker
::
Internet
.
email
}
let
(
:description
)
{
Faker
::
Lorem
.
sentence
}
let
(
:password
)
{
'12345678'
}
let
(
:password_confirmation
)
{
'12345678'
}
let
(
:terms_of_service
)
{
true
}
let
(
:avatar
)
{
""
}
let
(
:raw_post
)
{
params
.
to_json
}
example
'Creating an user by admin'
do
do_request
expect
(
status
).
to
eq
(
201
)
end
end
delete
'/v1/users/:id'
do
include_context
"authenticate_user_admin"
parameter
:id
,
'The id of the user to be destroyed'
let
(
:id
)
{
@user
.
id
}
before
do
@user
=
create
(
:user
)
end
example
'Destroying an user by admin'
do
do_request
expect
(
status
).
to
eq
(
200
)
end
end
end
This diff is collapsed.
Click to expand it.
spec/shared/contexts.rb
+
13
−
0
View file @
db332cfa
...
...
@@ -14,3 +14,16 @@ RSpec.shared_context "authenticate_user", shared_context: :metadata do
end
end
RSpec
.
shared_context
"authenticate_user_admin"
,
shared_context: :metadata
do
let
(
:auth_client
)
{
@auth_headers
[
'client'
]
}
let
(
:uid
)
{
@auth_headers
[
'uid'
]
}
let
(
:access_token
)
{
@auth_headers
[
'access-token'
]
}
let
(
:role
)
{
Role
.
all
}
before
do
@user
=
create
(
:user
,
roles:
[
role
.
find_by
(
name:
'admin'
)])
@auth_headers
=
@user
.
create_new_auth_token
end
end
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment