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
2fe13fbc
Commit
2fe13fbc
authored
Jan 25, 2017
by
Robert Speicher
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use `:empty_project` where possible in helper specs
parent
d5583912
Changes
14
Show whitespace changes
Inline
Side-by-side
Showing
14 changed files
with
41 additions
and
40 deletions
+41
-40
spec/helpers/application_helper_spec.rb
spec/helpers/application_helper_spec.rb
+2
-2
spec/helpers/blob_helper_spec.rb
spec/helpers/blob_helper_spec.rb
+1
-1
spec/helpers/gitlab_markdown_helper_spec.rb
spec/helpers/gitlab_markdown_helper_spec.rb
+10
-9
spec/helpers/graph_helper_spec.rb
spec/helpers/graph_helper_spec.rb
+1
-1
spec/helpers/issues_helper_spec.rb
spec/helpers/issues_helper_spec.rb
+1
-1
spec/helpers/members_helper_spec.rb
spec/helpers/members_helper_spec.rb
+1
-1
spec/helpers/merge_requests_helper_spec.rb
spec/helpers/merge_requests_helper_spec.rb
+5
-5
spec/helpers/milestones_helper_spec.rb
spec/helpers/milestones_helper_spec.rb
+6
-8
spec/helpers/preferences_helper_spec.rb
spec/helpers/preferences_helper_spec.rb
+1
-1
spec/helpers/projects_helper_spec.rb
spec/helpers/projects_helper_spec.rb
+2
-2
spec/helpers/search_helper_spec.rb
spec/helpers/search_helper_spec.rb
+4
-2
spec/helpers/submodule_helper_spec.rb
spec/helpers/submodule_helper_spec.rb
+2
-2
spec/helpers/tree_helper_spec.rb
spec/helpers/tree_helper_spec.rb
+1
-1
spec/helpers/visibility_level_helper_spec.rb
spec/helpers/visibility_level_helper_spec.rb
+4
-4
No files found.
spec/helpers/application_helper_spec.rb
View file @
2fe13fbc
...
...
@@ -55,7 +55,7 @@ describe ApplicationHelper do
describe
'project_icon'
do
it
'returns an url for the avatar'
do
project
=
create
(
:project
,
avatar:
File
.
open
(
uploaded_image_temp_path
))
project
=
create
(
:
empty_
project
,
avatar:
File
.
open
(
uploaded_image_temp_path
))
avatar_url
=
"http://
#{
Gitlab
.
config
.
gitlab
.
host
}
/uploads/project/avatar/
#{
project
.
id
}
/banana_sample.gif"
expect
(
helper
.
project_icon
(
"
#{
project
.
namespace
.
to_param
}
/
#{
project
.
to_param
}
"
).
to_s
).
...
...
@@ -63,7 +63,7 @@ describe ApplicationHelper do
end
it
'gives uploaded icon when present'
do
project
=
create
(
:project
)
project
=
create
(
:
empty_
project
)
allow_any_instance_of
(
Project
).
to
receive
(
:avatar_in_git
).
and_return
(
true
)
...
...
spec/helpers/blob_helper_spec.rb
View file @
2fe13fbc
...
...
@@ -70,7 +70,7 @@ describe BlobHelper do
describe
"#edit_blob_link"
do
let
(
:namespace
)
{
create
(
:namespace
,
name:
'gitlab'
)}
let
(
:project
)
{
create
(
:project
,
namespace:
namespace
)
}
let
(
:project
)
{
create
(
:project
,
:repository
,
namespace:
namespace
)
}
before
do
allow
(
self
).
to
receive
(
:current_user
).
and_return
(
double
)
...
...
spec/helpers/gitlab_markdown_helper_spec.rb
View file @
2fe13fbc
...
...
@@ -3,7 +3,7 @@ require 'spec_helper'
describe
GitlabMarkdownHelper
do
include
ApplicationHelper
let!
(
:project
)
{
create
(
:project
)
}
let!
(
:project
)
{
create
(
:project
,
:repository
)
}
let
(
:user
)
{
create
(
:user
,
username:
'gfm'
)
}
let
(
:commit
)
{
project
.
commit
}
...
...
@@ -55,18 +55,19 @@ describe GitlabMarkdownHelper do
end
describe
'#link_to_gfm'
do
let
(
:commit_path
)
{
namespace_project_commit_path
(
project
.
namespace
,
project
,
commit
)
}
let
(
:issues
)
{
create_list
(
:issue
,
2
,
project:
project
)
}
let
(
:link
)
{
'/commits/0a1b2c3d'
}
let
(
:issues
)
{
create_list
(
:issue
,
2
)
}
let
(
:project
)
{
issues
.
first
.
project
}
it
'handles references nested in links with all the text'
do
actual
=
helper
.
link_to_gfm
(
"This should finally fix
#{
issues
[
0
].
to_reference
}
and
#{
issues
[
1
].
to_reference
}
for real"
,
commit_path
)
actual
=
helper
.
link_to_gfm
(
"This should finally fix
#{
issues
[
0
].
to_reference
}
and
#{
issues
[
1
].
to_reference
}
for real"
,
link
)
doc
=
Nokogiri
::
HTML
.
parse
(
actual
)
# Make sure we didn't create invalid markup
expect
(
doc
.
errors
).
to
be_empty
# Leading commit link
expect
(
doc
.
css
(
'a'
)[
0
].
attr
(
'href'
)).
to
eq
commit_path
expect
(
doc
.
css
(
'a'
)[
0
].
attr
(
'href'
)).
to
eq
link
expect
(
doc
.
css
(
'a'
)[
0
].
text
).
to
eq
'This should finally fix '
# First issue link
...
...
@@ -75,7 +76,7 @@ describe GitlabMarkdownHelper do
expect
(
doc
.
css
(
'a'
)[
1
].
text
).
to
eq
issues
[
0
].
to_reference
# Internal commit link
expect
(
doc
.
css
(
'a'
)[
2
].
attr
(
'href'
)).
to
eq
commit_path
expect
(
doc
.
css
(
'a'
)[
2
].
attr
(
'href'
)).
to
eq
link
expect
(
doc
.
css
(
'a'
)[
2
].
text
).
to
eq
' and '
# Second issue link
...
...
@@ -84,12 +85,12 @@ describe GitlabMarkdownHelper do
expect
(
doc
.
css
(
'a'
)[
3
].
text
).
to
eq
issues
[
1
].
to_reference
# Trailing commit link
expect
(
doc
.
css
(
'a'
)[
4
].
attr
(
'href'
)).
to
eq
commit_path
expect
(
doc
.
css
(
'a'
)[
4
].
attr
(
'href'
)).
to
eq
link
expect
(
doc
.
css
(
'a'
)[
4
].
text
).
to
eq
' for real'
end
it
'forwards HTML options'
do
actual
=
helper
.
link_to_gfm
(
"Fixed in
#{
commit
.
id
}
"
,
commit_path
,
class:
'foo'
)
actual
=
helper
.
link_to_gfm
(
"Fixed in
#{
commit
.
id
}
"
,
link
,
class:
'foo'
)
doc
=
Nokogiri
::
HTML
.
parse
(
actual
)
expect
(
doc
.
css
(
'a'
)).
to
satisfy
do
|
v
|
...
...
@@ -100,7 +101,7 @@ describe GitlabMarkdownHelper do
it
"escapes HTML passed in as the body"
do
actual
=
"This is a <h1>test</h1> - see
#{
issues
[
0
].
to_reference
}
"
expect
(
helper
.
link_to_gfm
(
actual
,
commit_path
)).
expect
(
helper
.
link_to_gfm
(
actual
,
link
)).
to
match
(
'<h1>test</h1>'
)
end
...
...
spec/helpers/graph_helper_spec.rb
View file @
2fe13fbc
...
...
@@ -2,7 +2,7 @@ require 'spec_helper'
describe
GraphHelper
do
describe
'#get_refs'
do
let
(
:project
)
{
create
(
:project
)
}
let
(
:project
)
{
create
(
:project
,
:repository
)
}
let
(
:commit
)
{
project
.
commit
(
"master"
)
}
let
(
:graph
)
{
Network
::
Graph
.
new
(
project
,
'master'
,
commit
,
''
)
}
...
...
spec/helpers/issues_helper_spec.rb
View file @
2fe13fbc
require
"spec_helper"
describe
IssuesHelper
do
let
(
:project
)
{
create
:project
}
let
(
:project
)
{
create
(
:empty_project
)
}
let
(
:issue
)
{
create
:issue
,
project:
project
}
let
(
:ext_project
)
{
create
:redmine_project
}
...
...
spec/helpers/members_helper_spec.rb
View file @
2fe13fbc
...
...
@@ -46,7 +46,7 @@ describe MembersHelper do
end
describe
'#leave_confirmation_message'
do
let
(
:project
)
{
build_stubbed
(
:project
)
}
let
(
:project
)
{
build_stubbed
(
:
empty_
project
)
}
let
(
:group
)
{
build_stubbed
(
:group
)
}
let
(
:user
)
{
build_stubbed
(
:user
)
}
...
...
spec/helpers/merge_requests_helper_spec.rb
View file @
2fe13fbc
...
...
@@ -2,7 +2,7 @@ require 'spec_helper'
describe
MergeRequestsHelper
do
describe
'ci_build_details_path'
do
let
(
:project
)
{
create
:project
}
let
(
:project
)
{
create
(
:empty_project
)
}
let
(
:merge_request
)
{
MergeRequest
.
new
}
let
(
:ci_service
)
{
CiService
.
new
}
let
(
:last_commit
)
{
Ci
::
Pipeline
.
new
({})
}
...
...
@@ -30,7 +30,7 @@ describe MergeRequestsHelper do
it
{
is_expected
.
to
eq
(
'#1, #2, and #3'
)
}
context
'for JIRA issues'
do
let
(
:project
)
{
create
(
:project
)
}
let
(
:project
)
{
create
(
:
empty_
project
)
}
let
(
:issues
)
do
[
ExternalIssue
.
new
(
'JIRA-123'
,
project
),
...
...
@@ -52,8 +52,8 @@ describe MergeRequestsHelper do
end
describe
'within different projects'
do
let
(
:project
)
{
create
(
:project
)
}
let
(
:fork_project
)
{
create
(
:project
,
forked_from_project:
project
)
}
let
(
:project
)
{
create
(
:
empty_
project
)
}
let
(
:fork_project
)
{
create
(
:
empty_
project
,
forked_from_project:
project
)
}
let
(
:merge_request
)
{
create
(
:merge_request
,
source_project:
fork_project
,
target_project:
project
)
}
subject
{
format_mr_branch_names
(
merge_request
)
}
let
(
:source_title
)
{
"
#{
fork_project
.
path_with_namespace
}
:
#{
merge_request
.
source_branch
}
"
}
...
...
@@ -64,8 +64,8 @@ describe MergeRequestsHelper do
end
describe
'mr_widget_refresh_url'
do
let
(
:project
)
{
create
(
:empty_project
)
}
let
(
:merge_request
)
{
create
(
:merge_request
,
source_project:
project
)
}
let
(
:project
)
{
create
(
:project
)
}
it
'returns correct url for MR'
do
expected_url
=
"
#{
project
.
path_with_namespace
}
/merge_requests/
#{
merge_request
.
iid
}
/merge_widget_refresh"
...
...
spec/helpers/milestones_helper_spec.rb
View file @
2fe13fbc
...
...
@@ -21,24 +21,22 @@ describe MilestonesHelper do
end
describe
'#milestone_counts'
do
let
(
:project
)
{
FactoryGirl
.
create
(
:
project
)
}
let
(
:project
)
{
create
(
:empty_
project
)
}
let
(
:counts
)
{
helper
.
milestone_counts
(
project
.
milestones
)
}
context
'when there are milestones'
do
let!
(
:milestone_1
)
{
FactoryGirl
.
create
(
:active_milestone
,
project:
project
)
}
let!
(
:milestone_2
)
{
FactoryGirl
.
create
(
:active_milestone
,
project:
project
)
}
let!
(
:milestone_3
)
{
FactoryGirl
.
create
(
:closed_milestone
,
project:
project
)
}
it
'returns the correct counts'
do
create_list
(
:active_milestone
,
2
,
project:
project
)
create
(
:closed_milestone
,
project:
project
)
expect
(
counts
).
to
eq
(
opened:
2
,
closed:
1
,
all:
3
)
end
end
context
'when there are only milestones of one type'
do
let!
(
:milestone_1
)
{
FactoryGirl
.
create
(
:active_milestone
,
project:
project
)
}
let!
(
:milestone_2
)
{
FactoryGirl
.
create
(
:active_milestone
,
project:
project
)
}
it
'returns the correct counts'
do
create_list
(
:active_milestone
,
2
,
project:
project
)
expect
(
counts
).
to
eq
(
opened:
2
,
closed:
0
,
all:
2
)
end
end
...
...
spec/helpers/preferences_helper_spec.rb
View file @
2fe13fbc
...
...
@@ -110,7 +110,7 @@ describe PreferencesHelper do
end
context
'when repository is not empty'
do
let
(
:project
)
{
create
(
:project
,
:public
)
}
let
(
:project
)
{
create
(
:project
,
:public
,
:repository
)
}
it
'returns readme if user has repository access'
do
allow
(
helper
).
to
receive
(
:can?
).
with
(
nil
,
:download_code
,
project
).
and_return
(
true
)
...
...
spec/helpers/projects_helper_spec.rb
View file @
2fe13fbc
...
...
@@ -10,7 +10,7 @@ describe ProjectsHelper do
end
describe
"can_change_visibility_level?"
do
let
(
:project
)
{
create
(
:project
)
}
let
(
:project
)
{
create
(
:project
,
:repository
)
}
let
(
:user
)
{
create
(
:project_member
,
:reporter
,
user:
create
(
:user
),
project:
project
).
user
}
let
(
:fork_project
)
{
Projects
::
ForkService
.
new
(
project
,
user
).
execute
}
...
...
@@ -97,7 +97,7 @@ describe ProjectsHelper do
end
describe
'#license_short_name'
do
let
(
:project
)
{
create
(
:project
)
}
let
(
:project
)
{
create
(
:
empty_
project
)
}
context
'when project.repository has a license_key'
do
it
'returns the nickname of the license if present'
do
...
...
spec/helpers/search_helper_spec.rb
View file @
2fe13fbc
...
...
@@ -42,7 +42,7 @@ describe SearchHelper do
end
it
"includes the user's projects"
do
project
=
create
(
:project
,
namespace:
create
(
:namespace
,
owner:
user
))
project
=
create
(
:
empty_
project
,
namespace:
create
(
:namespace
,
owner:
user
))
expect
(
search_autocomplete_opts
(
project
.
name
).
size
).
to
eq
(
1
)
end
...
...
@@ -52,7 +52,9 @@ describe SearchHelper do
end
context
"with a current project"
do
before
{
@project
=
create
(
:project
)
}
before
do
@project
=
create
(
:project
,
:repository
)
end
it
"includes project-specific sections"
do
expect
(
search_autocomplete_opts
(
"Files"
).
size
).
to
eq
(
1
)
...
...
spec/helpers/submodule_helper_spec.rb
View file @
2fe13fbc
...
...
@@ -116,7 +116,7 @@ describe SubmoduleHelper do
context
'submodules with relative links'
do
let
(
:group
)
{
create
(
:group
,
name:
"Master Project"
,
path:
"master-project"
)
}
let
(
:project
)
{
create
(
:project
,
group:
group
)
}
let
(
:project
)
{
create
(
:
empty_
project
,
group:
group
)
}
let
(
:commit_id
)
{
sample_commit
[
:id
]
}
before
do
...
...
@@ -145,7 +145,7 @@ describe SubmoduleHelper do
context
'personal project'
do
let
(
:user
)
{
create
(
:user
)
}
let
(
:project
)
{
create
(
:project
,
namespace:
user
.
namespace
)
}
let
(
:project
)
{
create
(
:
empty_
project
,
namespace:
user
.
namespace
)
}
it
'one level down with personal project'
do
result
=
relative_self_links
(
'../test.git'
,
commit_id
)
...
...
spec/helpers/tree_helper_spec.rb
View file @
2fe13fbc
...
...
@@ -2,7 +2,7 @@ require 'spec_helper'
describe
TreeHelper
do
describe
'flatten_tree'
do
let
(
:project
)
{
create
(
:project
)
}
let
(
:project
)
{
create
(
:project
,
:repository
)
}
before
do
@repository
=
project
.
repository
...
...
spec/helpers/visibility_level_helper_spec.rb
View file @
2fe13fbc
require
'spec_helper'
describe
VisibilityLevelHelper
do
let
(
:project
)
{
build
(
:project
)
}
let
(
:project
)
{
build
(
:
empty_
project
)
}
let
(
:group
)
{
build
(
:group
)
}
let
(
:personal_snippet
)
{
build
(
:personal_snippet
)
}
let
(
:project_snippet
)
{
build
(
:project_snippet
)
}
...
...
@@ -60,8 +60,8 @@ describe VisibilityLevelHelper do
describe
"skip_level?"
do
describe
"forks"
do
let
(
:project
)
{
create
(
:project
,
:internal
)
}
let
(
:fork_project
)
{
create
(
:project
,
forked_from_project:
project
)
}
let
(
:project
)
{
create
(
:
empty_
project
,
:internal
)
}
let
(
:fork_project
)
{
create
(
:
empty_
project
,
forked_from_project:
project
)
}
it
"skips levels"
do
expect
(
skip_level?
(
fork_project
,
Gitlab
::
VisibilityLevel
::
PUBLIC
)).
to
be_truthy
...
...
@@ -71,7 +71,7 @@ describe VisibilityLevelHelper do
end
describe
"non-forked project"
do
let
(
:project
)
{
create
(
:project
,
:internal
)
}
let
(
:project
)
{
create
(
:
empty_
project
,
:internal
)
}
it
"skips levels"
do
expect
(
skip_level?
(
project
,
Gitlab
::
VisibilityLevel
::
PUBLIC
)).
to
be_falsey
...
...
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