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
e4c6dbe3
Commit
e4c6dbe3
authored
Aug 06, 2014
by
Dmitriy Zaporozhets
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix api files specs
Signed-off-by:
Dmitriy Zaporozhets
<
dmitriy.zaporozhets@gmail.com
>
parent
8f1e60b0
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
8 deletions
+10
-8
spec/requests/api/files_spec.rb
spec/requests/api/files_spec.rb
+10
-8
No files found.
spec/requests/api/files_spec.rb
View file @
e4c6dbe3
...
@@ -4,20 +4,22 @@ describe API::API, api: true do
...
@@ -4,20 +4,22 @@ describe API::API, api: true do
include
ApiHelpers
include
ApiHelpers
let
(
:user
)
{
create
(
:user
)
}
let
(
:user
)
{
create
(
:user
)
}
let!
(
:project
)
{
create
(
:project
,
namespace:
user
.
namespace
)
}
let!
(
:project
)
{
create
(
:project
,
namespace:
user
.
namespace
)
}
let
(
:file_path
)
{
'files/ruby/popen.rb'
}
before
{
project
.
team
<<
[
user
,
:developer
]
}
before
{
project
.
team
<<
[
user
,
:developer
]
}
describe
"GET /projects/:id/repository/files"
do
describe
"GET /projects/:id/repository/files"
do
it
"should return file info"
do
it
"should return file info"
do
params
=
{
params
=
{
file_path:
'app/models/key.rb'
,
file_path:
file_path
,
ref:
'master'
,
ref:
'master'
,
}
}
get
api
(
"/projects/
#{
project
.
id
}
/repository/files"
,
user
),
params
get
api
(
"/projects/
#{
project
.
id
}
/repository/files"
,
user
),
params
response
.
status
.
should
==
200
response
.
status
.
should
==
200
json_response
[
'file_path'
].
should
==
'app/models/key.rb'
json_response
[
'file_path'
].
should
==
file_path
json_response
[
'file_name'
].
should
==
'
key
.rb'
json_response
[
'file_name'
].
should
==
'
popen
.rb'
Base64
.
decode64
(
json_response
[
'content'
]).
lines
.
first
.
should
==
"
class Key < ActiveRecord::Base
\n
"
Base64
.
decode64
(
json_response
[
'content'
]).
lines
.
first
.
should
==
"
require 'fileutils'
\n
"
end
end
it
"should return a 400 bad request if no params given"
do
it
"should return a 400 bad request if no params given"
do
...
@@ -74,7 +76,7 @@ describe API::API, api: true do
...
@@ -74,7 +76,7 @@ describe API::API, api: true do
describe
"PUT /projects/:id/repository/files"
do
describe
"PUT /projects/:id/repository/files"
do
let
(
:valid_params
)
{
let
(
:valid_params
)
{
{
{
file_path:
'spec/spec_helper.rb'
,
file_path:
file_path
,
branch_name:
'master'
,
branch_name:
'master'
,
content:
'puts 8'
,
content:
'puts 8'
,
commit_message:
'Changed file'
commit_message:
'Changed file'
...
@@ -88,7 +90,7 @@ describe API::API, api: true do
...
@@ -88,7 +90,7 @@ describe API::API, api: true do
put
api
(
"/projects/
#{
project
.
id
}
/repository/files"
,
user
),
valid_params
put
api
(
"/projects/
#{
project
.
id
}
/repository/files"
,
user
),
valid_params
response
.
status
.
should
==
200
response
.
status
.
should
==
200
json_response
[
'file_path'
].
should
==
'spec/spec_helper.rb'
json_response
[
'file_path'
].
should
==
file_path
end
end
it
"should return a 400 bad request if no params given"
do
it
"should return a 400 bad request if no params given"
do
...
@@ -109,7 +111,7 @@ describe API::API, api: true do
...
@@ -109,7 +111,7 @@ describe API::API, api: true do
describe
"DELETE /projects/:id/repository/files"
do
describe
"DELETE /projects/:id/repository/files"
do
let
(
:valid_params
)
{
let
(
:valid_params
)
{
{
{
file_path:
'spec/spec_helper.rb'
,
file_path:
file_path
,
branch_name:
'master'
,
branch_name:
'master'
,
commit_message:
'Changed file'
commit_message:
'Changed file'
}
}
...
@@ -122,7 +124,7 @@ describe API::API, api: true do
...
@@ -122,7 +124,7 @@ describe API::API, api: true do
delete
api
(
"/projects/
#{
project
.
id
}
/repository/files"
,
user
),
valid_params
delete
api
(
"/projects/
#{
project
.
id
}
/repository/files"
,
user
),
valid_params
response
.
status
.
should
==
200
response
.
status
.
should
==
200
json_response
[
'file_path'
].
should
==
'spec/spec_helper.rb'
json_response
[
'file_path'
].
should
==
file_path
end
end
it
"should return a 400 bad request if no params given"
do
it
"should return a 400 bad request if no params given"
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