BigW Consortium Gitlab
Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gitlab-ce
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Forest Godfrey
gitlab-ce
Commits
b94088d5
Commit
b94088d5
authored
May 20, 2016
by
Robert Schilling
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make tests follow the guidelines
parent
25dcd051
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
20 additions
and
10 deletions
+20
-10
todos_spec.rb
spec/requests/api/todos_spec.rb
+20
-10
No files found.
spec/requests/api/todos_spec.rb
View file @
b94088d5
...
@@ -16,23 +16,26 @@ describe API::Todos, api: true do
...
@@ -16,23 +16,26 @@ describe API::Todos, api: true do
describe
'GET /todos'
do
describe
'GET /todos'
do
context
'when unauthenticated'
do
context
'when unauthenticated'
do
it
'
should return
authentication error'
do
it
'
returns
authentication error'
do
get
api
(
'/todos'
)
get
api
(
'/todos'
)
expect
(
response
.
status
).
to
eq
(
401
)
expect
(
response
.
status
).
to
eq
(
401
)
end
end
end
end
context
'when authenticated'
do
context
'when authenticated'
do
it
'
should return
an array of pending todos for current user'
do
it
'
returns
an array of pending todos for current user'
do
get
api
(
'/todos'
,
john_doe
)
get
api
(
'/todos'
,
john_doe
)
expect
(
response
.
status
).
to
eq
(
200
)
expect
(
response
.
status
).
to
eq
(
200
)
expect
(
json_response
).
to
be_an
Array
expect
(
json_response
).
to
be_an
Array
expect
(
json_response
.
length
).
to
eq
(
3
)
expect
(
json_response
.
length
).
to
eq
(
3
)
end
end
context
'and using the author filter'
do
context
'and using the author filter'
do
it
'
should filter
based on author_id param'
do
it
'
filters
based on author_id param'
do
get
api
(
'/todos'
,
john_doe
),
{
author_id:
author_2
.
id
}
get
api
(
'/todos'
,
john_doe
),
{
author_id:
author_2
.
id
}
expect
(
response
.
status
).
to
eq
(
200
)
expect
(
response
.
status
).
to
eq
(
200
)
expect
(
json_response
).
to
be_an
Array
expect
(
json_response
).
to
be_an
Array
expect
(
json_response
.
length
).
to
eq
(
2
)
expect
(
json_response
.
length
).
to
eq
(
2
)
...
@@ -40,8 +43,9 @@ describe API::Todos, api: true do
...
@@ -40,8 +43,9 @@ describe API::Todos, api: true do
end
end
context
'and using the type filter'
do
context
'and using the type filter'
do
it
'
should filter
based on type param'
do
it
'
filters
based on type param'
do
get
api
(
'/todos'
,
john_doe
),
{
type:
'MergeRequest'
}
get
api
(
'/todos'
,
john_doe
),
{
type:
'MergeRequest'
}
expect
(
response
.
status
).
to
eq
(
200
)
expect
(
response
.
status
).
to
eq
(
200
)
expect
(
json_response
).
to
be_an
Array
expect
(
json_response
).
to
be_an
Array
expect
(
json_response
.
length
).
to
eq
(
1
)
expect
(
json_response
.
length
).
to
eq
(
1
)
...
@@ -49,8 +53,9 @@ describe API::Todos, api: true do
...
@@ -49,8 +53,9 @@ describe API::Todos, api: true do
end
end
context
'and using the state filter'
do
context
'and using the state filter'
do
it
'
should filter
based on state param'
do
it
'
filters
based on state param'
do
get
api
(
'/todos'
,
john_doe
),
{
state:
'done'
}
get
api
(
'/todos'
,
john_doe
),
{
state:
'done'
}
expect
(
response
.
status
).
to
eq
(
200
)
expect
(
response
.
status
).
to
eq
(
200
)
expect
(
json_response
).
to
be_an
Array
expect
(
json_response
).
to
be_an
Array
expect
(
json_response
.
length
).
to
eq
(
1
)
expect
(
json_response
.
length
).
to
eq
(
1
)
...
@@ -58,9 +63,10 @@ describe API::Todos, api: true do
...
@@ -58,9 +63,10 @@ describe API::Todos, api: true do
end
end
context
'and using the project filter'
do
context
'and using the project filter'
do
it
'
should filter
based on project_id param'
do
it
'
filters
based on project_id param'
do
project_2
.
team
<<
[
john_doe
,
:developer
]
project_2
.
team
<<
[
john_doe
,
:developer
]
get
api
(
'/todos'
,
john_doe
),
{
project_id:
project_2
.
id
}
get
api
(
'/todos'
,
john_doe
),
{
project_id:
project_2
.
id
}
expect
(
response
.
status
).
to
eq
(
200
)
expect
(
response
.
status
).
to
eq
(
200
)
expect
(
json_response
).
to
be_an
Array
expect
(
json_response
).
to
be_an
Array
expect
(
json_response
.
length
).
to
eq
(
1
)
expect
(
json_response
.
length
).
to
eq
(
1
)
...
@@ -71,15 +77,17 @@ describe API::Todos, api: true do
...
@@ -71,15 +77,17 @@ describe API::Todos, api: true do
describe
'DELETE /todos/:id'
do
describe
'DELETE /todos/:id'
do
context
'when unauthenticated'
do
context
'when unauthenticated'
do
it
'
should return
authentication error'
do
it
'
returns
authentication error'
do
delete
api
(
"/todos/
#{
pending_1
.
id
}
"
)
delete
api
(
"/todos/
#{
pending_1
.
id
}
"
)
expect
(
response
.
status
).
to
eq
(
401
)
expect
(
response
.
status
).
to
eq
(
401
)
end
end
end
end
context
'when authenticated'
do
context
'when authenticated'
do
it
'
should mark
a todo as done'
do
it
'
marks
a todo as done'
do
delete
api
(
"/todos/
#{
pending_1
.
id
}
"
,
john_doe
)
delete
api
(
"/todos/
#{
pending_1
.
id
}
"
,
john_doe
)
expect
(
response
.
status
).
to
eq
(
200
)
expect
(
response
.
status
).
to
eq
(
200
)
expect
(
pending_1
.
reload
).
to
be_done
expect
(
pending_1
.
reload
).
to
be_done
end
end
...
@@ -88,15 +96,17 @@ describe API::Todos, api: true do
...
@@ -88,15 +96,17 @@ describe API::Todos, api: true do
describe
'DELETE /todos'
do
describe
'DELETE /todos'
do
context
'when unauthenticated'
do
context
'when unauthenticated'
do
it
'
should return
authentication error'
do
it
'
returns
authentication error'
do
delete
api
(
'/todos'
)
delete
api
(
'/todos'
)
expect
(
response
.
status
).
to
eq
(
401
)
expect
(
response
.
status
).
to
eq
(
401
)
end
end
end
end
context
'when authenticated'
do
context
'when authenticated'
do
it
'
should mark
all todos as done'
do
it
'
marks
all todos as done'
do
delete
api
(
'/todos'
,
john_doe
)
delete
api
(
'/todos'
,
john_doe
)
expect
(
response
.
status
).
to
eq
(
200
)
expect
(
response
.
status
).
to
eq
(
200
)
expect
(
pending_1
.
reload
).
to
be_done
expect
(
pending_1
.
reload
).
to
be_done
expect
(
pending_2
.
reload
).
to
be_done
expect
(
pending_2
.
reload
).
to
be_done
...
...
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