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
e8bb32e6
Commit
e8bb32e6
authored
Nov 07, 2013
by
Dmitriy Zaporozhets
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Specs for Create file API
Signed-off-by:
Dmitriy Zaporozhets
<
dmitriy.zaporozhets@gmail.com
>
parent
0b67606a
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
47 additions
and
0 deletions
+47
-0
spec/requests/api/files_spec.rb
spec/requests/api/files_spec.rb
+46
-0
spec/support/test_env.rb
spec/support/test_env.rb
+1
-0
No files found.
spec/requests/api/files_spec.rb
0 → 100644
View file @
e8bb32e6
require
'spec_helper'
describe
API
::
API
do
include
ApiHelpers
before
(
:each
)
{
ActiveRecord
::
Base
.
observers
.
enable
(
:user_observer
)
}
after
(
:each
)
{
ActiveRecord
::
Base
.
observers
.
disable
(
:user_observer
)
}
let
(
:user
)
{
create
(
:user
)
}
let!
(
:project
)
{
create
(
:project_with_code
,
namespace:
user
.
namespace
)
}
before
{
project
.
team
<<
[
user
,
:developer
]
}
describe
"POST /projects/:id/repository/files"
do
it
"should create a new file in project repo"
do
Gitlab
::
Satellite
::
NewFileAction
.
any_instance
.
stub
(
commit!:
true
,
)
post
api
(
"/projects/
#{
project
.
id
}
/repository/files"
,
user
),
valid_params
response
.
status
.
should
==
201
json_response
[
'file_name'
].
should
==
'newfile.rb'
end
it
"should return a 400 bad request if no params given"
do
post
api
(
"/projects/
#{
project
.
id
}
/repository/files"
,
user
)
response
.
status
.
should
==
400
end
it
"should return a 400 if satellite fails to create file"
do
Gitlab
::
Satellite
::
NewFileAction
.
any_instance
.
stub
(
commit!:
false
,
)
post
api
(
"/projects/
#{
project
.
id
}
/repository/files"
,
user
),
valid_params
response
.
status
.
should
==
400
end
end
def
valid_params
{
file_name:
'newfile.rb'
,
branch_name:
'master'
,
content:
'puts 8'
,
commit_message:
'Added newfile'
}
end
end
spec/support/test_env.rb
View file @
e8bb32e6
...
...
@@ -45,6 +45,7 @@ module TestEnv
def
disable_mailer
NotificationService
.
any_instance
.
stub
(
mailer:
double
.
as_null_object
)
end
def
enable_mailer
NotificationService
.
any_instance
.
unstub
(
:mailer
)
end
...
...
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