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
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Boxiang Sun
gitlab-ce
Commits
ccf0686b
Commit
ccf0686b
authored
Jan 02, 2013
by
Dmitriy Zaporozhets
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix api specs. Use id instead path
parent
d431e433
Changes
8
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
26 additions
and
40 deletions
+26
-40
app/controllers/search_controller.rb
app/controllers/search_controller.rb
+1
-1
spec/lib/project_mover_spec.rb
spec/lib/project_mover_spec.rb
+1
-0
spec/observers/user_observer_spec.rb
spec/observers/user_observer_spec.rb
+1
-4
spec/observers/users_project_observer_spec.rb
spec/observers/users_project_observer_spec.rb
+4
-13
spec/requests/api/issues_spec.rb
spec/requests/api/issues_spec.rb
+5
-5
spec/requests/api/merge_requests_spec.rb
spec/requests/api/merge_requests_spec.rb
+6
-6
spec/requests/api/milestones_spec.rb
spec/requests/api/milestones_spec.rb
+4
-4
spec/spec_helper.rb
spec/spec_helper.rb
+4
-7
No files found.
app/controllers/search_controller.rb
View file @
ccf0686b
class
SearchController
<
ApplicationController
class
SearchController
<
ApplicationController
def
show
def
show
result
=
SearchContext
.
new
(
current_user
.
project_ids
,
params
).
execute
result
=
SearchContext
.
new
(
current_user
.
authorized_projects
.
map
(
&
:id
)
,
params
).
execute
@projects
=
result
[
:projects
]
@projects
=
result
[
:projects
]
@merge_requests
=
result
[
:merge_requests
]
@merge_requests
=
result
[
:merge_requests
]
...
...
spec/lib/project_mover_spec.rb
View file @
ccf0686b
...
@@ -5,6 +5,7 @@ describe Gitlab::ProjectMover do
...
@@ -5,6 +5,7 @@ describe Gitlab::ProjectMover do
before
do
before
do
FileUtils
.
rm_rf
base_path
if
File
.
exists?
base_path
FileUtils
.
rm_rf
base_path
if
File
.
exists?
base_path
FileUtils
.
mkdir_p
base_path
Gitlab
.
config
.
gitolite
.
stub
(
repos_path:
base_path
)
Gitlab
.
config
.
gitolite
.
stub
(
repos_path:
base_path
)
...
...
spec/observers/user_observer_spec.rb
View file @
ccf0686b
...
@@ -6,11 +6,8 @@ describe UserObserver do
...
@@ -6,11 +6,8 @@ describe UserObserver do
it
'calls #after_create when new users are created'
do
it
'calls #after_create when new users are created'
do
new_user
=
build
(
:user
)
new_user
=
build
(
:user
)
subject
.
should_receive
(
:after_create
).
with
(
new_user
)
subject
.
should_receive
(
:after_create
).
with
(
new_user
)
User
.
observers
.
enable
:user_observer
do
new_user
.
save
new_user
.
save
end
end
end
context
'when a new user is created'
do
context
'when a new user is created'
do
let
(
:user
)
{
double
(
:user
,
id:
42
,
let
(
:user
)
{
double
(
:user
,
id:
42
,
...
...
spec/observers/users_project_observer_spec.rb
View file @
ccf0686b
...
@@ -11,10 +11,8 @@ describe UsersProjectObserver do
...
@@ -11,10 +11,8 @@ describe UsersProjectObserver do
describe
"#after_commit"
do
describe
"#after_commit"
do
it
"should called when UsersProject created"
do
it
"should called when UsersProject created"
do
subject
.
should_receive
(
:after_commit
).
once
subject
.
should_receive
(
:after_commit
).
once
UsersProject
.
observers
.
enable
:users_project_observer
do
create
(
:users_project
)
create
(
:users_project
)
end
end
end
it
"should send email to user"
do
it
"should send email to user"
do
Notify
.
should_receive
(
:project_access_granted_email
).
with
(
users_project
.
id
).
and_return
(
double
(
deliver:
true
))
Notify
.
should_receive
(
:project_access_granted_email
).
with
(
users_project
.
id
).
and_return
(
double
(
deliver:
true
))
...
@@ -36,10 +34,8 @@ describe UsersProjectObserver do
...
@@ -36,10 +34,8 @@ describe UsersProjectObserver do
describe
"#after_update"
do
describe
"#after_update"
do
it
"should called when UsersProject updated"
do
it
"should called when UsersProject updated"
do
subject
.
should_receive
(
:after_commit
).
once
subject
.
should_receive
(
:after_commit
).
once
UsersProject
.
observers
.
enable
:users_project_observer
do
create
(
:users_project
).
update_attribute
(
:project_access
,
UsersProject
::
MASTER
)
create
(
:users_project
).
update_attribute
(
:project_access
,
UsersProject
::
MASTER
)
end
end
end
it
"should send email to user"
do
it
"should send email to user"
do
Notify
.
should_receive
(
:project_access_granted_email
).
with
(
users_project
.
id
).
and_return
(
double
(
deliver:
true
))
Notify
.
should_receive
(
:project_access_granted_email
).
with
(
users_project
.
id
).
and_return
(
double
(
deliver:
true
))
...
@@ -47,20 +43,15 @@ describe UsersProjectObserver do
...
@@ -47,20 +43,15 @@ describe UsersProjectObserver do
end
end
it
"should not called after UsersProject destroyed"
do
it
"should not called after UsersProject destroyed"
do
subject
.
should_not_receive
(
:after_commit
)
subject
.
should_not_receive
(
:after_commit
)
UsersProject
.
observers
.
enable
:users_project_observer
do
users_project
.
destroy
users_project
.
destroy
end
end
end
end
end
describe
"#after_destroy"
do
describe
"#after_destroy"
do
it
"should called when UsersProject destroyed"
do
it
"should called when UsersProject destroyed"
do
subject
.
should_receive
(
:after_destroy
)
subject
.
should_receive
(
:after_destroy
)
UsersProject
.
observers
.
enable
:users_project_observer
do
create
(
:users_project
).
destroy
create
(
:users_project
).
destroy
end
end
end
it
"should create new event"
do
it
"should create new event"
do
Event
.
should_receive
(
:create
).
with
(
Event
.
should_receive
(
:create
).
with
(
...
...
spec/requests/api/issues_spec.rb
View file @
ccf0686b
...
@@ -28,7 +28,7 @@ describe Gitlab::API do
...
@@ -28,7 +28,7 @@ describe Gitlab::API do
describe
"GET /projects/:id/issues"
do
describe
"GET /projects/:id/issues"
do
it
"should return project issues"
do
it
"should return project issues"
do
get
api
(
"/projects/
#{
project
.
path
}
/issues"
,
user
)
get
api
(
"/projects/
#{
project
.
id
}
/issues"
,
user
)
response
.
status
.
should
==
200
response
.
status
.
should
==
200
json_response
.
should
be_an
Array
json_response
.
should
be_an
Array
json_response
.
first
[
'title'
].
should
==
issue
.
title
json_response
.
first
[
'title'
].
should
==
issue
.
title
...
@@ -37,7 +37,7 @@ describe Gitlab::API do
...
@@ -37,7 +37,7 @@ describe Gitlab::API do
describe
"GET /projects/:id/issues/:issue_id"
do
describe
"GET /projects/:id/issues/:issue_id"
do
it
"should return a project issue by id"
do
it
"should return a project issue by id"
do
get
api
(
"/projects/
#{
project
.
path
}
/issues/
#{
issue
.
id
}
"
,
user
)
get
api
(
"/projects/
#{
project
.
id
}
/issues/
#{
issue
.
id
}
"
,
user
)
response
.
status
.
should
==
200
response
.
status
.
should
==
200
json_response
[
'title'
].
should
==
issue
.
title
json_response
[
'title'
].
should
==
issue
.
title
end
end
...
@@ -45,7 +45,7 @@ describe Gitlab::API do
...
@@ -45,7 +45,7 @@ describe Gitlab::API do
describe
"POST /projects/:id/issues"
do
describe
"POST /projects/:id/issues"
do
it
"should create a new project issue"
do
it
"should create a new project issue"
do
post
api
(
"/projects/
#{
project
.
path
}
/issues"
,
user
),
post
api
(
"/projects/
#{
project
.
id
}
/issues"
,
user
),
title:
'new issue'
,
labels:
'label, label2'
title:
'new issue'
,
labels:
'label, label2'
response
.
status
.
should
==
201
response
.
status
.
should
==
201
json_response
[
'title'
].
should
==
'new issue'
json_response
[
'title'
].
should
==
'new issue'
...
@@ -56,7 +56,7 @@ describe Gitlab::API do
...
@@ -56,7 +56,7 @@ describe Gitlab::API do
describe
"PUT /projects/:id/issues/:issue_id"
do
describe
"PUT /projects/:id/issues/:issue_id"
do
it
"should update a project issue"
do
it
"should update a project issue"
do
put
api
(
"/projects/
#{
project
.
path
}
/issues/
#{
issue
.
id
}
"
,
user
),
put
api
(
"/projects/
#{
project
.
id
}
/issues/
#{
issue
.
id
}
"
,
user
),
title:
'updated title'
,
labels:
'label2'
,
closed:
1
title:
'updated title'
,
labels:
'label2'
,
closed:
1
response
.
status
.
should
==
200
response
.
status
.
should
==
200
json_response
[
'title'
].
should
==
'updated title'
json_response
[
'title'
].
should
==
'updated title'
...
@@ -67,7 +67,7 @@ describe Gitlab::API do
...
@@ -67,7 +67,7 @@ describe Gitlab::API do
describe
"DELETE /projects/:id/issues/:issue_id"
do
describe
"DELETE /projects/:id/issues/:issue_id"
do
it
"should delete a project issue"
do
it
"should delete a project issue"
do
delete
api
(
"/projects/
#{
project
.
path
}
/issues/
#{
issue
.
id
}
"
,
user
)
delete
api
(
"/projects/
#{
project
.
id
}
/issues/
#{
issue
.
id
}
"
,
user
)
response
.
status
.
should
==
405
response
.
status
.
should
==
405
end
end
end
end
...
...
spec/requests/api/merge_requests_spec.rb
View file @
ccf0686b
...
@@ -11,14 +11,14 @@ describe Gitlab::API do
...
@@ -11,14 +11,14 @@ describe Gitlab::API do
describe
"GET /projects/:id/merge_requests"
do
describe
"GET /projects/:id/merge_requests"
do
context
"when unauthenticated"
do
context
"when unauthenticated"
do
it
"should return authentication error"
do
it
"should return authentication error"
do
get
api
(
"/projects/
#{
project
.
path
}
/merge_requests"
)
get
api
(
"/projects/
#{
project
.
id
}
/merge_requests"
)
response
.
status
.
should
==
401
response
.
status
.
should
==
401
end
end
end
end
context
"when authenticated"
do
context
"when authenticated"
do
it
"should return an array of merge_requests"
do
it
"should return an array of merge_requests"
do
get
api
(
"/projects/
#{
project
.
path
}
/merge_requests"
,
user
)
get
api
(
"/projects/
#{
project
.
id
}
/merge_requests"
,
user
)
response
.
status
.
should
==
200
response
.
status
.
should
==
200
json_response
.
should
be_an
Array
json_response
.
should
be_an
Array
json_response
.
first
[
'title'
].
should
==
merge_request
.
title
json_response
.
first
[
'title'
].
should
==
merge_request
.
title
...
@@ -28,7 +28,7 @@ describe Gitlab::API do
...
@@ -28,7 +28,7 @@ describe Gitlab::API do
describe
"GET /projects/:id/merge_request/:merge_request_id"
do
describe
"GET /projects/:id/merge_request/:merge_request_id"
do
it
"should return merge_request"
do
it
"should return merge_request"
do
get
api
(
"/projects/
#{
project
.
path
}
/merge_request/
#{
merge_request
.
id
}
"
,
user
)
get
api
(
"/projects/
#{
project
.
id
}
/merge_request/
#{
merge_request
.
id
}
"
,
user
)
response
.
status
.
should
==
200
response
.
status
.
should
==
200
json_response
[
'title'
].
should
==
merge_request
.
title
json_response
[
'title'
].
should
==
merge_request
.
title
end
end
...
@@ -36,7 +36,7 @@ describe Gitlab::API do
...
@@ -36,7 +36,7 @@ describe Gitlab::API do
describe
"POST /projects/:id/merge_requests"
do
describe
"POST /projects/:id/merge_requests"
do
it
"should return merge_request"
do
it
"should return merge_request"
do
post
api
(
"/projects/
#{
project
.
path
}
/merge_requests"
,
user
),
post
api
(
"/projects/
#{
project
.
id
}
/merge_requests"
,
user
),
title:
'Test merge_request'
,
source_branch:
"stable"
,
target_branch:
"master"
,
author:
user
title:
'Test merge_request'
,
source_branch:
"stable"
,
target_branch:
"master"
,
author:
user
response
.
status
.
should
==
201
response
.
status
.
should
==
201
json_response
[
'title'
].
should
==
'Test merge_request'
json_response
[
'title'
].
should
==
'Test merge_request'
...
@@ -45,7 +45,7 @@ describe Gitlab::API do
...
@@ -45,7 +45,7 @@ describe Gitlab::API do
describe
"PUT /projects/:id/merge_request/:merge_request_id"
do
describe
"PUT /projects/:id/merge_request/:merge_request_id"
do
it
"should return merge_request"
do
it
"should return merge_request"
do
put
api
(
"/projects/
#{
project
.
path
}
/merge_request/
#{
merge_request
.
id
}
"
,
user
),
title:
"New title"
put
api
(
"/projects/
#{
project
.
id
}
/merge_request/
#{
merge_request
.
id
}
"
,
user
),
title:
"New title"
response
.
status
.
should
==
200
response
.
status
.
should
==
200
json_response
[
'title'
].
should
==
'New title'
json_response
[
'title'
].
should
==
'New title'
end
end
...
@@ -53,7 +53,7 @@ describe Gitlab::API do
...
@@ -53,7 +53,7 @@ describe Gitlab::API do
describe
"POST /projects/:id/merge_request/:merge_request_id/comments"
do
describe
"POST /projects/:id/merge_request/:merge_request_id/comments"
do
it
"should return comment"
do
it
"should return comment"
do
post
api
(
"/projects/
#{
project
.
path
}
/merge_request/
#{
merge_request
.
id
}
/comments"
,
user
),
note:
"My comment"
post
api
(
"/projects/
#{
project
.
id
}
/merge_request/
#{
merge_request
.
id
}
/comments"
,
user
),
note:
"My comment"
response
.
status
.
should
==
201
response
.
status
.
should
==
201
json_response
[
'note'
].
should
==
'My comment'
json_response
[
'note'
].
should
==
'My comment'
end
end
...
...
spec/requests/api/milestones_spec.rb
View file @
ccf0686b
...
@@ -11,7 +11,7 @@ describe Gitlab::API do
...
@@ -11,7 +11,7 @@ describe Gitlab::API do
describe
"GET /projects/:id/milestones"
do
describe
"GET /projects/:id/milestones"
do
it
"should return project milestones"
do
it
"should return project milestones"
do
get
api
(
"/projects/
#{
project
.
path
}
/milestones"
,
user
)
get
api
(
"/projects/
#{
project
.
id
}
/milestones"
,
user
)
response
.
status
.
should
==
200
response
.
status
.
should
==
200
json_response
.
should
be_an
Array
json_response
.
should
be_an
Array
json_response
.
first
[
'title'
].
should
==
milestone
.
title
json_response
.
first
[
'title'
].
should
==
milestone
.
title
...
@@ -20,7 +20,7 @@ describe Gitlab::API do
...
@@ -20,7 +20,7 @@ describe Gitlab::API do
describe
"GET /projects/:id/milestones/:milestone_id"
do
describe
"GET /projects/:id/milestones/:milestone_id"
do
it
"should return a project milestone by id"
do
it
"should return a project milestone by id"
do
get
api
(
"/projects/
#{
project
.
path
}
/milestones/
#{
milestone
.
id
}
"
,
user
)
get
api
(
"/projects/
#{
project
.
id
}
/milestones/
#{
milestone
.
id
}
"
,
user
)
response
.
status
.
should
==
200
response
.
status
.
should
==
200
json_response
[
'title'
].
should
==
milestone
.
title
json_response
[
'title'
].
should
==
milestone
.
title
end
end
...
@@ -28,7 +28,7 @@ describe Gitlab::API do
...
@@ -28,7 +28,7 @@ describe Gitlab::API do
describe
"POST /projects/:id/milestones"
do
describe
"POST /projects/:id/milestones"
do
it
"should create a new project milestone"
do
it
"should create a new project milestone"
do
post
api
(
"/projects/
#{
project
.
path
}
/milestones"
,
user
),
post
api
(
"/projects/
#{
project
.
id
}
/milestones"
,
user
),
title:
'new milestone'
title:
'new milestone'
response
.
status
.
should
==
201
response
.
status
.
should
==
201
json_response
[
'title'
].
should
==
'new milestone'
json_response
[
'title'
].
should
==
'new milestone'
...
@@ -38,7 +38,7 @@ describe Gitlab::API do
...
@@ -38,7 +38,7 @@ describe Gitlab::API do
describe
"PUT /projects/:id/milestones/:milestone_id"
do
describe
"PUT /projects/:id/milestones/:milestone_id"
do
it
"should update a project milestone"
do
it
"should update a project milestone"
do
put
api
(
"/projects/
#{
project
.
path
}
/milestones/
#{
milestone
.
id
}
"
,
user
),
put
api
(
"/projects/
#{
project
.
id
}
/milestones/
#{
milestone
.
id
}
"
,
user
),
title:
'updated title'
title:
'updated title'
response
.
status
.
should
==
200
response
.
status
.
should
==
200
json_response
[
'title'
].
should
==
'updated title'
json_response
[
'title'
].
should
==
'updated title'
...
...
spec/spec_helper.rb
View file @
ccf0686b
...
@@ -37,13 +37,10 @@ RSpec.configure do |config|
...
@@ -37,13 +37,10 @@ RSpec.configure do |config|
config
.
before
do
config
.
before
do
stub_gitolite!
stub_gitolite!
# !!! Observers disabled by default in tests
#ActiveRecord::Base.observers.disable(:all)
# ActiveRecord::Base.observers.enable(:all)
# Use tmp dir for FS manipulations
# Use tmp dir for FS manipulations
Gitlab
.
config
.
gitolite
.
stub
(
repos_path:
Rails
.
root
.
join
(
'tmp'
,
'test-git-base-path'
))
temp_repos_path
=
Rails
.
root
.
join
(
'tmp'
,
'test-git-base-path'
)
FileUtils
.
rm_rf
Gitlab
.
config
.
gitolite
.
repos_path
Gitlab
.
config
.
gitolite
.
stub
(
repos_path:
temp_repos_path
)
FileUtils
.
mkdir_p
Gitlab
.
config
.
gitolite
.
repos_path
FileUtils
.
rm_rf
temp_repos_path
FileUtils
.
mkdir_p
temp_repos_path
end
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