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
b2a5344a
Commit
b2a5344a
authored
Aug 25, 2012
by
Robert Speicher
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add a simple `api` method to ApiHelpers, replacing api_prefix
See docs for usage
parent
fba174e9
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
33 additions
and
3 deletions
+33
-3
spec/requests/api/issues_spec.rb
spec/requests/api/issues_spec.rb
+2
-0
spec/requests/api/projects_spec.rb
spec/requests/api/projects_spec.rb
+2
-0
spec/requests/api/users_spec.rb
spec/requests/api/users_spec.rb
+2
-0
spec/spec_helper.rb
spec/spec_helper.rb
+0
-1
spec/support/api_helpers.rb
spec/support/api_helpers.rb
+27
-2
No files found.
spec/requests/api/issues_spec.rb
View file @
b2a5344a
require
'spec_helper'
require
'spec_helper'
describe
Gitlab
::
API
do
describe
Gitlab
::
API
do
include
ApiHelpers
let
(
:user
)
{
Factory
:user
}
let
(
:user
)
{
Factory
:user
}
let!
(
:project
)
{
Factory
:project
,
owner:
user
}
let!
(
:project
)
{
Factory
:project
,
owner:
user
}
let!
(
:issue
)
{
Factory
:issue
,
author:
user
,
assignee:
user
,
project:
project
}
let!
(
:issue
)
{
Factory
:issue
,
author:
user
,
assignee:
user
,
project:
project
}
...
...
spec/requests/api/projects_spec.rb
View file @
b2a5344a
require
'spec_helper'
require
'spec_helper'
describe
Gitlab
::
API
do
describe
Gitlab
::
API
do
include
ApiHelpers
let
(
:user
)
{
Factory
:user
}
let
(
:user
)
{
Factory
:user
}
let!
(
:project
)
{
Factory
:project
,
owner:
user
}
let!
(
:project
)
{
Factory
:project
,
owner:
user
}
let!
(
:snippet
)
{
Factory
:snippet
,
author:
user
,
project:
project
,
title:
'example'
}
let!
(
:snippet
)
{
Factory
:snippet
,
author:
user
,
project:
project
,
title:
'example'
}
...
...
spec/requests/api/users_spec.rb
View file @
b2a5344a
require
'spec_helper'
require
'spec_helper'
describe
Gitlab
::
API
do
describe
Gitlab
::
API
do
include
ApiHelpers
let
(
:user
)
{
Factory
:user
}
let
(
:user
)
{
Factory
:user
}
describe
"GET /users"
do
describe
"GET /users"
do
...
...
spec/spec_helper.rb
View file @
b2a5344a
...
@@ -27,7 +27,6 @@ RSpec.configure do |config|
...
@@ -27,7 +27,6 @@ RSpec.configure do |config|
config
.
mock_with
:rspec
config
.
mock_with
:rspec
config
.
include
LoginHelpers
,
type: :request
config
.
include
LoginHelpers
,
type: :request
config
.
include
ApiHelpers
,
type: :request
# If you're not using ActiveRecord, or you'd prefer not to run each of your
# If you're not using ActiveRecord, or you'd prefer not to run each of your
# examples within a transaction, remove the following line or assign false
# examples within a transaction, remove the following line or assign false
...
...
spec/support/api_helpers.rb
View file @
b2a5344a
module
ApiHelpers
module
ApiHelpers
def
api_prefix
# Public: Prepend a request path with the path to the API
"/api/
#{
Gitlab
::
API
::
VERSION
}
"
#
# path - Path to append
# user - User object - If provided, automatically appends private_token query
# string for authenticated requests
#
# Examples
#
# >> api('/issues')
# => "/api/v2/issues"
#
# >> api('/issues', User.last)
# => "/api/v2/issues?private_token=..."
#
# >> api('/issues?foo=bar', User.last)
# => "/api/v2/issues?foo=bar&private_token=..."
#
# Returns the relative path to the requested API resource
def
api
(
path
,
user
=
nil
)
"/api/
#{
Gitlab
::
API
::
VERSION
}#{
path
}
"
+
# Normalize query string
(
path
.
index
(
'?'
)
?
''
:
'?'
)
+
# Append private_token if given a User object
(
user
.
respond_to?
(
:private_token
)
?
"&private_token=
#{
user
.
private_token
}
"
:
""
)
end
end
def
json_response
def
json_response
...
...
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