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