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
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
gitlab-ce
Commits
b1b354b0
Commit
b1b354b0
authored
Mar 21, 2013
by
Andrey Kumanyaev
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
remove trailing spaces
parent
67ccc8b5
Changes
11
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
173 additions
and
173 deletions
+173
-173
app/contexts/issues_bulk_update_context.rb
app/contexts/issues_bulk_update_context.rb
+2
-2
app/models/milestone.rb
app/models/milestone.rb
+2
-2
lib/api.rb
lib/api.rb
+2
-2
lib/api/groups.rb
lib/api/groups.rb
+1
-1
lib/api/system_hooks.rb
lib/api/system_hooks.rb
+70
-70
lib/gitlab/inline_diff.rb
lib/gitlab/inline_diff.rb
+2
-2
lib/tasks/gitlab/bulk_add_permission.rake
lib/tasks/gitlab/bulk_add_permission.rake
+1
-1
spec/models/merge_request_spec.rb
spec/models/merge_request_spec.rb
+1
-1
spec/models/milestone_spec.rb
spec/models/milestone_spec.rb
+1
-1
spec/requests/api/groups_spec.rb
spec/requests/api/groups_spec.rb
+10
-10
spec/requests/api/system_hooks_spec.rb
spec/requests/api/system_hooks_spec.rb
+81
-81
No files found.
app/contexts/issues_bulk_update_context.rb
View file @
b1b354b0
...
...
@@ -7,7 +7,7 @@ class IssuesBulkUpdateContext < BaseContext
assignee_id
=
update_data
[
:assignee_id
]
status
=
update_data
[
:status
]
opts
=
{}
opts
=
{}
opts
[
:milestone_id
]
=
milestone_id
if
milestone_id
.
present?
opts
[
:assignee_id
]
=
assignee_id
if
assignee_id
.
present?
opts
[
:closed
]
=
(
status
==
"closed"
)
if
status
.
present?
...
...
@@ -15,7 +15,7 @@ class IssuesBulkUpdateContext < BaseContext
issues
=
Issue
.
where
(
id:
issues_ids
).
all
issues
=
issues
.
select
{
|
issue
|
can?
(
current_user
,
:modify_issue
,
issue
)
}
issues
.
each
{
|
issue
|
issue
.
update_attributes
(
opts
)
}
{
{
count:
issues
.
count
,
success:
!
issues
.
count
.
zero?
}
...
...
app/models/milestone.rb
View file @
b1b354b0
...
...
@@ -72,9 +72,9 @@ class Milestone < ActiveRecord::Base
if
due_date
.
past?
"expired at
#{
due_date
.
stamp
(
"Aug 21, 2011"
)
}
"
else
"expires at
#{
due_date
.
stamp
(
"Aug 21, 2011"
)
}
"
"expires at
#{
due_date
.
stamp
(
"Aug 21, 2011"
)
}
"
end
end
end
end
def
can_be_closed?
...
...
lib/api.rb
View file @
b1b354b0
...
...
@@ -17,13 +17,13 @@ module Gitlab
message
<<
exception
.
annoted_source_code
.
to_s
if
exception
.
respond_to?
(
:annoted_source_code
)
message
<<
" "
<<
trace
.
join
(
"
\n
"
)
API
.
logger
.
add
Logger
::
FATAL
,
message
API
.
logger
.
add
Logger
::
FATAL
,
message
rack_response
({
'message'
=>
'500 Internal Server Error'
},
500
)
end
format
:json
helpers
APIHelpers
mount
Groups
mount
Users
mount
Projects
...
...
lib/api/groups.rb
View file @
b1b354b0
...
...
@@ -70,7 +70,7 @@ module Gitlab
else
not_found!
end
end
end
end
end
end
lib/api/system_hooks.rb
View file @
b1b354b0
module
Gitlab
# Hooks API
class
SystemHooks
<
Grape
::
API
before
{
authenticate!
authenticated_as_admin!
}
resource
:hooks
do
# Get the list of system hooks
#
# Example Request:
# GET /hooks
get
do
@hooks
=
SystemHook
.
all
present
@hooks
,
with:
Entities
::
Hook
end
# Create new system hook
#
# Parameters:
# url (required) - url for system hook
# Example Request
# POST /hooks
post
do
attrs
=
attributes_for_keys
[
:url
]
required_attributes!
[
:url
]
@hook
=
SystemHook
.
new
attrs
if
@hook
.
save
present
@hook
,
with:
Entities
::
Hook
else
not_found!
end
end
# Test a hook
#
# Example Request
# GET /hooks/:id
get
":id"
do
@hook
=
SystemHook
.
find
(
params
[
:id
])
data
=
{
event_name:
"project_create"
,
name:
"Ruby"
,
path:
"ruby"
,
project_id:
1
,
owner_name:
"Someone"
,
owner_email:
"example@gitlabhq.com"
}
@hook
.
execute
(
data
)
data
end
# Delete a hook. This is an idempotent function.
#
# Parameters:
# id (required) - ID of the hook
# Example Request:
# DELETE /hooks/:id
delete
":id"
do
begin
@hook
=
SystemHook
.
find
(
params
[
:id
])
@hook
.
destroy
rescue
# SystemHook raises an Error if no hook with id found
end
end
end
end
end
\ No newline at end of file
module
Gitlab
# Hooks API
class
SystemHooks
<
Grape
::
API
before
{
authenticate!
authenticated_as_admin!
}
resource
:hooks
do
# Get the list of system hooks
#
# Example Request:
# GET /hooks
get
do
@hooks
=
SystemHook
.
all
present
@hooks
,
with:
Entities
::
Hook
end
# Create new system hook
#
# Parameters:
# url (required) - url for system hook
# Example Request
# POST /hooks
post
do
attrs
=
attributes_for_keys
[
:url
]
required_attributes!
[
:url
]
@hook
=
SystemHook
.
new
attrs
if
@hook
.
save
present
@hook
,
with:
Entities
::
Hook
else
not_found!
end
end
# Test a hook
#
# Example Request
# GET /hooks/:id
get
":id"
do
@hook
=
SystemHook
.
find
(
params
[
:id
])
data
=
{
event_name:
"project_create"
,
name:
"Ruby"
,
path:
"ruby"
,
project_id:
1
,
owner_name:
"Someone"
,
owner_email:
"example@gitlabhq.com"
}
@hook
.
execute
(
data
)
data
end
# Delete a hook. This is an idempotent function.
#
# Parameters:
# id (required) - ID of the hook
# Example Request:
# DELETE /hooks/:id
delete
":id"
do
begin
@hook
=
SystemHook
.
find
(
params
[
:id
])
@hook
.
destroy
rescue
# SystemHook raises an Error if no hook with id found
end
end
end
end
end
lib/gitlab/inline_diff.rb
View file @
b1b354b0
...
...
@@ -4,7 +4,7 @@ module Gitlab
START
=
"#!idiff-start!#"
FINISH
=
"#!idiff-finish!#"
def
processing
diff_arr
indexes
=
_indexes_of_changed_lines
diff_arr
...
...
@@ -60,7 +60,7 @@ module Gitlab
line
.
gsub!
(
FINISH
,
"</span>"
)
line
end
end
end
...
...
lib/tasks/gitlab/bulk_add_permission.rake
View file @
b1b354b0
...
...
@@ -21,4 +21,4 @@ namespace :gitlab do
UsersProject
.
add_users_into_projects
(
project_ids
,
Array
.
wrap
(
user
.
id
),
UsersProject
::
DEVELOPER
)
end
end
end
\ No newline at end of file
end
spec/models/merge_request_spec.rb
View file @
b1b354b0
...
...
@@ -36,7 +36,7 @@ describe MergeRequest do
it
{
should
respond_to
(
:can_be_merged?
)
}
it
{
should
respond_to
(
:cannot_be_merged?
)
}
end
describe
'modules'
do
it
{
should
include_module
(
Issuable
)
}
end
...
...
spec/models/milestone_spec.rb
View file @
b1b354b0
...
...
@@ -134,7 +134,7 @@ describe Milestone do
it
'should be false if milestone active and not all nestied issues closed'
do
issue
.
milestone
=
milestone
issue
.
save
issue
.
save
milestone
.
can_be_closed?
.
should
be_false
end
...
...
spec/requests/api/groups_spec.rb
View file @
b1b354b0
...
...
@@ -26,7 +26,7 @@ describe Gitlab::API do
json_response
.
first
[
'name'
].
should
==
group1
.
name
end
end
context
"when authenticated as admin"
do
it
"admin: should return an array of all groups"
do
get
api
(
"/groups"
,
admin
)
...
...
@@ -36,7 +36,7 @@ describe Gitlab::API do
end
end
end
describe
"GET /groups/:id"
do
context
"when authenticated as user"
do
it
"should return one of user1's groups"
do
...
...
@@ -44,32 +44,32 @@ describe Gitlab::API do
response
.
status
.
should
==
200
json_response
[
'name'
]
==
group1
.
name
end
it
"should not return a non existing group"
do
get
api
(
"/groups/1328"
,
user1
)
response
.
status
.
should
==
404
end
it
"should not return a group not attached to user1"
do
get
api
(
"/groups/
#{
group2
.
id
}
"
,
user1
)
response
.
status
.
should
==
404
end
end
context
"when authenticated as admin"
do
it
"should return any existing group"
do
get
api
(
"/groups/
#{
group2
.
id
}
"
,
admin
)
response
.
status
.
should
==
200
json_response
[
'name'
]
==
group2
.
name
end
it
"should not return a non existing group"
do
get
api
(
"/groups/1328"
,
admin
)
response
.
status
.
should
==
404
end
end
end
describe
"POST /groups"
do
context
"when authenticated as user"
do
it
"should not create group"
do
...
...
@@ -77,7 +77,7 @@ describe Gitlab::API do
response
.
status
.
should
==
403
end
end
context
"when authenticated as admin"
do
it
"should create group"
do
post
api
(
"/groups"
,
admin
),
attributes_for
(
:group
)
...
...
@@ -104,8 +104,8 @@ describe Gitlab::API do
describe
"POST /groups/:id/projects/:project_id"
do
let
(
:project
)
{
create
(
:project
)
}
before
(
:each
)
do
project
.
stub!
(
:transfer
).
and_return
(
true
)
Project
.
stub
(
:find
).
and_return
(
project
)
project
.
stub!
(
:transfer
).
and_return
(
true
)
Project
.
stub
(
:find
).
and_return
(
project
)
end
...
...
spec/requests/api/system_hooks_spec.rb
View file @
b1b354b0
require
'spec_helper'
describe
Gitlab
::
API
do
include
ApiHelpers
let
(
:user
)
{
create
(
:user
)
}
let
(
:admin
)
{
create
(
:admin
)
}
let!
(
:hook
)
{
create
(
:system_hook
,
url:
"http://example.com"
)
}
before
{
stub_request
(
:post
,
hook
.
url
)
}
describe
"GET /hooks"
do
context
"when no user"
do
it
"should return authentication error"
do
get
api
(
"/hooks"
)
response
.
status
.
should
==
401
end
end
context
"when not an admin"
do
it
"should return forbidden error"
do
get
api
(
"/hooks"
,
user
)
response
.
status
.
should
==
403
end
end
context
"when authenticated as admin"
do
it
"should return an array of hooks"
do
get
api
(
"/hooks"
,
admin
)
response
.
status
.
should
==
200
json_response
.
should
be_an
Array
json_response
.
first
[
'url'
].
should
==
hook
.
url
end
end
end
describe
"POST /hooks"
do
it
"should create new hook"
do
expect
{
post
api
(
"/hooks"
,
admin
),
url:
'http://example.com'
}.
to
change
{
SystemHook
.
count
}.
by
(
1
)
end
it
"should respond with 400 if url not given"
do
post
api
(
"/hooks"
,
admin
)
response
.
status
.
should
==
400
end
it
"should not create new hook without url"
do
expect
{
post
api
(
"/hooks"
,
admin
)
}.
to_not
change
{
SystemHook
.
count
}
end
end
describe
"GET /hooks/:id"
do
it
"should return hook by id"
do
get
api
(
"/hooks/
#{
hook
.
id
}
"
,
admin
)
response
.
status
.
should
==
200
json_response
[
'event_name'
].
should
==
'project_create'
end
it
"should return 404 on failure"
do
get
api
(
"/hooks/404"
,
admin
)
response
.
status
.
should
==
404
end
end
describe
"DELETE /hooks/:id"
do
it
"should delete a hook"
do
expect
{
delete
api
(
"/hooks/
#{
hook
.
id
}
"
,
admin
)
}.
to
change
{
SystemHook
.
count
}.
by
(
-
1
)
end
it
"should return success if hook id not found"
do
delete
api
(
"/hooks/12345"
,
admin
)
response
.
status
.
should
==
200
end
end
end
\ No newline at end of file
require
'spec_helper'
describe
Gitlab
::
API
do
include
ApiHelpers
let
(
:user
)
{
create
(
:user
)
}
let
(
:admin
)
{
create
(
:admin
)
}
let!
(
:hook
)
{
create
(
:system_hook
,
url:
"http://example.com"
)
}
before
{
stub_request
(
:post
,
hook
.
url
)
}
describe
"GET /hooks"
do
context
"when no user"
do
it
"should return authentication error"
do
get
api
(
"/hooks"
)
response
.
status
.
should
==
401
end
end
context
"when not an admin"
do
it
"should return forbidden error"
do
get
api
(
"/hooks"
,
user
)
response
.
status
.
should
==
403
end
end
context
"when authenticated as admin"
do
it
"should return an array of hooks"
do
get
api
(
"/hooks"
,
admin
)
response
.
status
.
should
==
200
json_response
.
should
be_an
Array
json_response
.
first
[
'url'
].
should
==
hook
.
url
end
end
end
describe
"POST /hooks"
do
it
"should create new hook"
do
expect
{
post
api
(
"/hooks"
,
admin
),
url:
'http://example.com'
}.
to
change
{
SystemHook
.
count
}.
by
(
1
)
end
it
"should respond with 400 if url not given"
do
post
api
(
"/hooks"
,
admin
)
response
.
status
.
should
==
400
end
it
"should not create new hook without url"
do
expect
{
post
api
(
"/hooks"
,
admin
)
}.
to_not
change
{
SystemHook
.
count
}
end
end
describe
"GET /hooks/:id"
do
it
"should return hook by id"
do
get
api
(
"/hooks/
#{
hook
.
id
}
"
,
admin
)
response
.
status
.
should
==
200
json_response
[
'event_name'
].
should
==
'project_create'
end
it
"should return 404 on failure"
do
get
api
(
"/hooks/404"
,
admin
)
response
.
status
.
should
==
404
end
end
describe
"DELETE /hooks/:id"
do
it
"should delete a hook"
do
expect
{
delete
api
(
"/hooks/
#{
hook
.
id
}
"
,
admin
)
}.
to
change
{
SystemHook
.
count
}.
by
(
-
1
)
end
it
"should return success if hook id not found"
do
delete
api
(
"/hooks/12345"
,
admin
)
response
.
status
.
should
==
200
end
end
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