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
Léo-Paul Géneau
gitlab-ce
Commits
07b9b80a
Commit
07b9b80a
authored
Dec 08, 2016
by
Lin Jen-Shin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix tests to use the new API
parent
8384d0d8
Changes
12
Hide whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
130 additions
and
42 deletions
+130
-42
app/services/compare_service.rb
app/services/compare_service.rb
+8
-6
spec/controllers/projects/templates_controller_spec.rb
spec/controllers/projects/templates_controller_spec.rb
+2
-1
spec/factories/projects.rb
spec/factories/projects.rb
+33
-1
spec/features/projects/files/project_owner_creates_license_file_spec.rb
...projects/files/project_owner_creates_license_file_spec.rb
+2
-1
spec/features/projects/issuable_templates_spec.rb
spec/features/projects/issuable_templates_spec.rb
+35
-5
spec/lib/gitlab/git_access_spec.rb
spec/lib/gitlab/git_access_spec.rb
+7
-1
spec/lib/gitlab/template/issue_template_spec.rb
spec/lib/gitlab/template/issue_template_spec.rb
+9
-10
spec/lib/gitlab/template/merge_request_template_spec.rb
spec/lib/gitlab/template/merge_request_template_spec.rb
+9
-10
spec/models/cycle_analytics/production_spec.rb
spec/models/cycle_analytics/production_spec.rb
+7
-1
spec/models/cycle_analytics/staging_spec.rb
spec/models/cycle_analytics/staging_spec.rb
+4
-4
spec/services/merge_requests/resolve_service_spec.rb
spec/services/merge_requests/resolve_service_spec.rb
+7
-1
spec/support/cycle_analytics_helpers.rb
spec/support/cycle_analytics_helpers.rb
+7
-1
No files found.
app/services/compare_service.rb
View file @
07b9b80a
...
@@ -3,29 +3,31 @@ require 'securerandom'
...
@@ -3,29 +3,31 @@ require 'securerandom'
# Compare 2 branches for one repo or between repositories
# Compare 2 branches for one repo or between repositories
# and return Gitlab::Git::Compare object that responds to commits and diffs
# and return Gitlab::Git::Compare object that responds to commits and diffs
class
CompareService
class
CompareService
attr_reader
:source_project
,
:source_
sha
attr_reader
:source_project
,
:source_
branch
def
initialize
(
new_source_project
,
source_branch
)
def
initialize
(
new_source_project
,
source_branch
_name
)
@source_project
=
new_source_project
@source_project
=
new_source_project
@source_
sha
=
new_source_project
.
commit
(
source_branch
).
try
(
:sha
)
@source_
branch
=
new_source_project
.
commit
(
source_branch_name
)
end
end
def
execute
(
target_project
,
target_branch
,
straight:
false
)
def
execute
(
target_project
,
target_branch
,
straight:
false
)
source_sha
=
source_branch
.
try
(
:sha
)
return
unless
source_sha
return
unless
source_sha
# If compare with other project we need to fetch ref first
# If compare with other project we need to fetch ref first
if
target_project
==
source_project
if
target_project
==
source_project
compare
(
target_project
,
target_branch
,
straight
)
compare
(
source_sha
,
target_project
,
target_branch
,
straight
)
else
else
target_project
.
repository
.
with_tmp_ref
(
source_project
,
source_branch
)
do
target_project
.
repository
.
with_tmp_ref
(
source_project
,
source_branch
)
do
compare
(
target_project
,
target_branch
,
straight
)
compare
(
source_sha
,
target_project
,
target_branch
,
straight
)
end
end
end
end
end
end
private
private
def
compare
(
target_project
,
target_branch
,
straight
)
def
compare
(
source_sha
,
target_project
,
target_branch
,
straight
)
raw_compare
=
Gitlab
::
Git
::
Compare
.
new
(
raw_compare
=
Gitlab
::
Git
::
Compare
.
new
(
target_project
.
repository
.
raw_repository
,
target_project
.
repository
.
raw_repository
,
target_branch
,
target_branch
,
...
...
spec/controllers/projects/templates_controller_spec.rb
View file @
07b9b80a
...
@@ -14,7 +14,8 @@ describe Projects::TemplatesController do
...
@@ -14,7 +14,8 @@ describe Projects::TemplatesController do
before
do
before
do
project
.
add_user
(
user
,
Gitlab
::
Access
::
MASTER
)
project
.
add_user
(
user
,
Gitlab
::
Access
::
MASTER
)
project
.
repository
.
commit_file
(
user
,
file_path_1
,
"something valid"
,
"test 3"
,
"master"
,
false
)
project
.
repository
.
commit_file
(
user
,
file_path_1
,
'something valid'
,
message:
'test 3'
,
branch_name:
'master'
,
update:
false
)
end
end
describe
'#show'
do
describe
'#show'
do
...
...
spec/factories/projects.rb
View file @
07b9b80a
...
@@ -91,8 +91,40 @@ FactoryGirl.define do
...
@@ -91,8 +91,40 @@ FactoryGirl.define do
factory
:project
,
parent: :empty_project
do
factory
:project
,
parent: :empty_project
do
path
{
'gitlabhq'
}
path
{
'gitlabhq'
}
after
:create
do
|
project
|
transient
do
create_template
nil
end
after
:create
do
|
project
,
evaluator
|
TestEnv
.
copy_repo
(
project
)
TestEnv
.
copy_repo
(
project
)
if
evaluator
.
create_template
args
=
evaluator
.
create_template
project
.
add_user
(
args
[
:user
],
args
[
:access
])
project
.
repository
.
commit_file
(
args
[
:user
],
".gitlab/
#{
args
[
:path
]
}
/bug.md"
,
'something valid'
,
message:
'test 3'
,
branch_name:
'master'
,
update:
false
)
project
.
repository
.
commit_file
(
args
[
:user
],
".gitlab/
#{
args
[
:path
]
}
/template_test.md"
,
'template_test'
,
message:
'test 1'
,
branch_name:
'master'
,
update:
false
)
project
.
repository
.
commit_file
(
args
[
:user
],
".gitlab/
#{
args
[
:path
]
}
/feature_proposal.md"
,
'feature_proposal'
,
message:
'test 2'
,
branch_name:
'master'
,
update:
false
)
end
end
end
end
end
...
...
spec/features/projects/files/project_owner_creates_license_file_spec.rb
View file @
07b9b80a
...
@@ -6,7 +6,8 @@ feature 'project owner creates a license file', feature: true, js: true do
...
@@ -6,7 +6,8 @@ feature 'project owner creates a license file', feature: true, js: true do
let
(
:project_master
)
{
create
(
:user
)
}
let
(
:project_master
)
{
create
(
:user
)
}
let
(
:project
)
{
create
(
:project
)
}
let
(
:project
)
{
create
(
:project
)
}
background
do
background
do
project
.
repository
.
remove_file
(
project_master
,
'LICENSE'
,
'Remove LICENSE'
,
'master'
)
project
.
repository
.
remove_file
(
project_master
,
'LICENSE'
,
message:
'Remove LICENSE'
,
branch_name:
'master'
)
project
.
team
<<
[
project_master
,
:master
]
project
.
team
<<
[
project_master
,
:master
]
login_as
(
project_master
)
login_as
(
project_master
)
visit
namespace_project_path
(
project
.
namespace
,
project
)
visit
namespace_project_path
(
project
.
namespace
,
project
)
...
...
spec/features/projects/issuable_templates_spec.rb
View file @
07b9b80a
...
@@ -18,8 +18,20 @@ feature 'issuable templates', feature: true, js: true do
...
@@ -18,8 +18,20 @@ feature 'issuable templates', feature: true, js: true do
let
(
:description_addition
)
{
' appending to description'
}
let
(
:description_addition
)
{
' appending to description'
}
background
do
background
do
project
.
repository
.
commit_file
(
user
,
'.gitlab/issue_templates/bug.md'
,
template_content
,
'added issue template'
,
'master'
,
false
)
project
.
repository
.
commit_file
(
project
.
repository
.
commit_file
(
user
,
'.gitlab/issue_templates/test.md'
,
longtemplate_content
,
'added issue template'
,
'master'
,
false
)
user
,
'.gitlab/issue_templates/bug.md'
,
template_content
,
message:
'added issue template'
,
branch_name:
'master'
,
update:
false
)
project
.
repository
.
commit_file
(
user
,
'.gitlab/issue_templates/test.md'
,
longtemplate_content
,
message:
'added issue template'
,
branch_name:
'master'
,
update:
false
)
visit
edit_namespace_project_issue_path
project
.
namespace
,
project
,
issue
visit
edit_namespace_project_issue_path
project
.
namespace
,
project
,
issue
fill_in
:'issue[title]'
,
with:
'test issue title'
fill_in
:'issue[title]'
,
with:
'test issue title'
end
end
...
@@ -68,7 +80,13 @@ feature 'issuable templates', feature: true, js: true do
...
@@ -68,7 +80,13 @@ feature 'issuable templates', feature: true, js: true do
let
(
:issue
)
{
create
(
:issue
,
author:
user
,
assignee:
user
,
project:
project
)
}
let
(
:issue
)
{
create
(
:issue
,
author:
user
,
assignee:
user
,
project:
project
)
}
background
do
background
do
project
.
repository
.
commit_file
(
user
,
'.gitlab/issue_templates/bug.md'
,
template_content
,
'added issue template'
,
'master'
,
false
)
project
.
repository
.
commit_file
(
user
,
'.gitlab/issue_templates/bug.md'
,
template_content
,
message:
'added issue template'
,
branch_name:
'master'
,
update:
false
)
visit
edit_namespace_project_issue_path
project
.
namespace
,
project
,
issue
visit
edit_namespace_project_issue_path
project
.
namespace
,
project
,
issue
fill_in
:'issue[title]'
,
with:
'test issue title'
fill_in
:'issue[title]'
,
with:
'test issue title'
fill_in
:'issue[description]'
,
with:
prior_description
fill_in
:'issue[description]'
,
with:
prior_description
...
@@ -87,7 +105,13 @@ feature 'issuable templates', feature: true, js: true do
...
@@ -87,7 +105,13 @@ feature 'issuable templates', feature: true, js: true do
let
(
:merge_request
)
{
create
(
:merge_request
,
:with_diffs
,
source_project:
project
)
}
let
(
:merge_request
)
{
create
(
:merge_request
,
:with_diffs
,
source_project:
project
)
}
background
do
background
do
project
.
repository
.
commit_file
(
user
,
'.gitlab/merge_request_templates/feature-proposal.md'
,
template_content
,
'added merge request template'
,
'master'
,
false
)
project
.
repository
.
commit_file
(
user
,
'.gitlab/merge_request_templates/feature-proposal.md'
,
template_content
,
message:
'added merge request template'
,
branch_name:
'master'
,
update:
false
)
visit
edit_namespace_project_merge_request_path
project
.
namespace
,
project
,
merge_request
visit
edit_namespace_project_merge_request_path
project
.
namespace
,
project
,
merge_request
fill_in
:'merge_request[title]'
,
with:
'test merge request title'
fill_in
:'merge_request[title]'
,
with:
'test merge request title'
end
end
...
@@ -112,7 +136,13 @@ feature 'issuable templates', feature: true, js: true do
...
@@ -112,7 +136,13 @@ feature 'issuable templates', feature: true, js: true do
fork_project
.
team
<<
[
fork_user
,
:master
]
fork_project
.
team
<<
[
fork_user
,
:master
]
create
(
:forked_project_link
,
forked_to_project:
fork_project
,
forked_from_project:
project
)
create
(
:forked_project_link
,
forked_to_project:
fork_project
,
forked_from_project:
project
)
login_as
fork_user
login_as
fork_user
project
.
repository
.
commit_file
(
fork_user
,
'.gitlab/merge_request_templates/feature-proposal.md'
,
template_content
,
'added merge request template'
,
'master'
,
false
)
project
.
repository
.
commit_file
(
fork_user
,
'.gitlab/merge_request_templates/feature-proposal.md'
,
template_content
,
message:
'added merge request template'
,
branch_name:
'master'
,
update:
false
)
visit
edit_namespace_project_merge_request_path
project
.
namespace
,
project
,
merge_request
visit
edit_namespace_project_merge_request_path
project
.
namespace
,
project
,
merge_request
fill_in
:'merge_request[title]'
,
with:
'test merge request title'
fill_in
:'merge_request[title]'
,
with:
'test merge request title'
end
end
...
...
spec/lib/gitlab/git_access_spec.rb
View file @
07b9b80a
...
@@ -209,7 +209,13 @@ describe Gitlab::GitAccess, lib: true do
...
@@ -209,7 +209,13 @@ describe Gitlab::GitAccess, lib: true do
stub_git_hooks
stub_git_hooks
project
.
repository
.
add_branch
(
user
,
unprotected_branch
,
'feature'
)
project
.
repository
.
add_branch
(
user
,
unprotected_branch
,
'feature'
)
target_branch
=
project
.
repository
.
lookup
(
'feature'
)
target_branch
=
project
.
repository
.
lookup
(
'feature'
)
source_branch
=
project
.
repository
.
commit_file
(
user
,
FFaker
::
InternetSE
.
login_user_name
,
FFaker
::
HipsterIpsum
.
paragraph
,
FFaker
::
HipsterIpsum
.
sentence
,
unprotected_branch
,
false
)
source_branch
=
project
.
repository
.
commit_file
(
user
,
FFaker
::
InternetSE
.
login_user_name
,
FFaker
::
HipsterIpsum
.
paragraph
,
message:
FFaker
::
HipsterIpsum
.
sentence
,
branch_name:
unprotected_branch
,
update:
false
)
rugged
=
project
.
repository
.
rugged
rugged
=
project
.
repository
.
rugged
author
=
{
email:
"email@example.com"
,
time:
Time
.
now
,
name:
"Example Git User"
}
author
=
{
email:
"email@example.com"
,
time:
Time
.
now
,
name:
"Example Git User"
}
...
...
spec/lib/gitlab/template/issue_template_spec.rb
View file @
07b9b80a
...
@@ -4,16 +4,15 @@ describe Gitlab::Template::IssueTemplate do
...
@@ -4,16 +4,15 @@ describe Gitlab::Template::IssueTemplate do
subject
{
described_class
}
subject
{
described_class
}
let
(
:user
)
{
create
(
:user
)
}
let
(
:user
)
{
create
(
:user
)
}
let
(
:project
)
{
create
(
:project
)
}
let
(
:file_path_1
)
{
'.gitlab/issue_templates/bug.md'
}
let
(
:project
)
do
let
(
:file_path_2
)
{
'.gitlab/issue_templates/template_test.md'
}
create
(
:project
,
let
(
:file_path_3
)
{
'.gitlab/issue_templates/feature_proposal.md'
}
create_template:
{
user:
user
,
before
do
access:
Gitlab
::
Access
::
MASTER
,
project
.
add_user
(
user
,
Gitlab
::
Access
::
MASTER
)
path:
'issue_templates'
project
.
repository
.
commit_file
(
user
,
file_path_1
,
"something valid"
,
"test 3"
,
"master"
,
false
)
}
project
.
repository
.
commit_file
(
user
,
file_path_2
,
"template_test"
,
"test 1"
,
"master"
,
false
)
)
project
.
repository
.
commit_file
(
user
,
file_path_3
,
"feature_proposal"
,
"test 2"
,
"master"
,
false
)
end
end
describe
'.all'
do
describe
'.all'
do
...
...
spec/lib/gitlab/template/merge_request_template_spec.rb
View file @
07b9b80a
...
@@ -4,16 +4,15 @@ describe Gitlab::Template::MergeRequestTemplate do
...
@@ -4,16 +4,15 @@ describe Gitlab::Template::MergeRequestTemplate do
subject
{
described_class
}
subject
{
described_class
}
let
(
:user
)
{
create
(
:user
)
}
let
(
:user
)
{
create
(
:user
)
}
let
(
:project
)
{
create
(
:project
)
}
let
(
:file_path_1
)
{
'.gitlab/merge_request_templates/bug.md'
}
let
(
:project
)
do
let
(
:file_path_2
)
{
'.gitlab/merge_request_templates/template_test.md'
}
create
(
:project
,
let
(
:file_path_3
)
{
'.gitlab/merge_request_templates/feature_proposal.md'
}
create_template:
{
user:
user
,
before
do
access:
Gitlab
::
Access
::
MASTER
,
project
.
add_user
(
user
,
Gitlab
::
Access
::
MASTER
)
path:
'merge_request_templates'
project
.
repository
.
commit_file
(
user
,
file_path_1
,
"something valid"
,
"test 3"
,
"master"
,
false
)
}
project
.
repository
.
commit_file
(
user
,
file_path_2
,
"template_test"
,
"test 1"
,
"master"
,
false
)
)
project
.
repository
.
commit_file
(
user
,
file_path_3
,
"feature_proposal"
,
"test 2"
,
"master"
,
false
)
end
end
describe
'.all'
do
describe
'.all'
do
...
...
spec/models/cycle_analytics/production_spec.rb
View file @
07b9b80a
...
@@ -21,7 +21,13 @@ describe 'CycleAnalytics#production', feature: true do
...
@@ -21,7 +21,13 @@ describe 'CycleAnalytics#production', feature: true do
[
"production deploy happens after merge request is merged (along with other changes)"
,
[
"production deploy happens after merge request is merged (along with other changes)"
,
lambda
do
|
context
,
data
|
lambda
do
|
context
,
data
|
# Make other changes on master
# Make other changes on master
sha
=
context
.
project
.
repository
.
commit_file
(
context
.
user
,
context
.
random_git_name
,
"content"
,
"commit message"
,
'master'
,
false
)
sha
=
context
.
project
.
repository
.
commit_file
(
context
.
user
,
context
.
random_git_name
,
'content'
,
message:
'commit message'
,
branch_name:
'master'
,
update:
false
)
context
.
project
.
repository
.
commit
(
sha
)
context
.
project
.
repository
.
commit
(
sha
)
context
.
deploy_master
context
.
deploy_master
...
...
spec/models/cycle_analytics/staging_spec.rb
View file @
07b9b80a
...
@@ -28,10 +28,10 @@ describe 'CycleAnalytics#staging', feature: true do
...
@@ -28,10 +28,10 @@ describe 'CycleAnalytics#staging', feature: true do
sha
=
context
.
project
.
repository
.
commit_file
(
sha
=
context
.
project
.
repository
.
commit_file
(
context
.
user
,
context
.
user
,
context
.
random_git_name
,
context
.
random_git_name
,
"content"
,
'content'
,
"commit message"
,
message:
'commit message'
,
'master'
,
branch_name:
'master'
,
false
)
update:
false
)
context
.
project
.
repository
.
commit
(
sha
)
context
.
project
.
repository
.
commit
(
sha
)
context
.
deploy_master
context
.
deploy_master
...
...
spec/services/merge_requests/resolve_service_spec.rb
View file @
07b9b80a
...
@@ -66,7 +66,13 @@ describe MergeRequests::ResolveService do
...
@@ -66,7 +66,13 @@ describe MergeRequests::ResolveService do
context
'when the source project is a fork and does not contain the HEAD of the target branch'
do
context
'when the source project is a fork and does not contain the HEAD of the target branch'
do
let!
(
:target_head
)
do
let!
(
:target_head
)
do
project
.
repository
.
commit_file
(
user
,
'new-file-in-target'
,
''
,
'Add new file in target'
,
'conflict-start'
,
false
)
project
.
repository
.
commit_file
(
user
,
'new-file-in-target'
,
''
,
message:
'Add new file in target'
,
branch_name:
'conflict-start'
,
update:
false
)
end
end
before
do
before
do
...
...
spec/support/cycle_analytics_helpers.rb
View file @
07b9b80a
...
@@ -35,7 +35,13 @@ module CycleAnalyticsHelpers
...
@@ -35,7 +35,13 @@ module CycleAnalyticsHelpers
project
.
repository
.
add_branch
(
user
,
source_branch
,
'master'
)
project
.
repository
.
add_branch
(
user
,
source_branch
,
'master'
)
end
end
sha
=
project
.
repository
.
commit_file
(
user
,
random_git_name
,
"content"
,
"commit message"
,
source_branch
,
false
)
sha
=
project
.
repository
.
commit_file
(
user
,
random_git_name
,
'content'
,
message:
'commit message'
,
branch_name:
source_branch
,
update:
false
)
project
.
repository
.
commit
(
sha
)
project
.
repository
.
commit
(
sha
)
opts
=
{
opts
=
{
...
...
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