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
iv
gitlab-ce
Commits
56b0c46b
Commit
56b0c46b
authored
Jan 17, 2016
by
Phil Hughes
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added tests
parent
ad7ec744
Changes
4
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
60 additions
and
3 deletions
+60
-3
app/assets/javascripts/project.js.coffee
app/assets/javascripts/project.js.coffee
+6
-3
spec/javascripts/fixtures/project_title.html.haml
spec/javascripts/fixtures/project_title.html.haml
+7
-0
spec/javascripts/fixtures/projects.json
spec/javascripts/fixtures/projects.json
+1
-0
spec/javascripts/project_title_spec.js.coffee
spec/javascripts/project_title_spec.js.coffee
+46
-0
No files found.
app/assets/javascripts/project.js.coffee
View file @
56b0c46b
...
...
@@ -56,10 +56,13 @@ class @Project
projectSelectDropdown
:
->
new
ProjectSelect
()
$
(
'.project-item-select'
).
on
'click'
,
-
>
window
.
location
=
$
(
this
).
val
()
$
(
'.project-item-select'
).
on
'click'
,
(
e
)
=
>
@
changeProject
$
(
e
.
currentTarget
).
val
()
$
(
'.js-projects-dropdown-toggle'
).
on
'click'
,
(
e
)
->
e
.
preventDefault
()
$
(
'.js-projects-dropdown'
).
select2
'open'
$
(
'.js-projects-dropdown'
).
select2
(
'open'
)
changeProject
:
(
url
)
->
window
.
location
=
url
spec/javascripts/fixtures/project_title.html.haml
0 → 100644
View file @
56b0c46b
%h1
.title
%a
GitLab Org
%a
.project-item-select-holder.js-projects-dropdown-toggle
{
href:
"/gitlab-org/gitlab-test"
}
GitLab Test
%span
.fa.fa-chevron-down.dropdown-toggle-caret
%input
#project_path
.project-item-select.js-projects-dropdown.ajax-project-select
{
type:
"hidden"
,
name:
"project_path"
,
"data-include-groups"
=>
"false"
}
spec/javascripts/fixtures/projects.json
0 → 100644
View file @
56b0c46b
This diff is collapsed.
Click to expand it.
spec/javascripts/project_title_spec.js.coffee
0 → 100644
View file @
56b0c46b
#= require select2
#= require api
#= require project_select
#= require project
window
.
gon
=
{}
window
.
gon
.
api_version
=
'v3'
describe
'Project Title'
,
->
fixture
.
preload
(
'project_title.html'
)
fixture
.
preload
(
'projects.json'
)
beforeEach
->
fixture
.
load
(
'project_title.html'
)
@
project
=
new
Project
()
spyOn
(
@
project
,
'changeProject'
).
and
.
callFake
(
url
)
->
window
.
current_project_url
=
url
describe
'project list'
,
->
beforeEach
=>
@
projects_data
=
fixture
.
load
(
'projects.json'
)[
0
]
spyOn
(
jQuery
,
'ajax'
).
and
.
callFake
(
req
)
=>
expect
(
req
.
url
).
toBe
(
'/api/v3/projects.json'
)
d
=
$
.
Deferred
()
d
.
resolve
@
projects_data
d
.
promise
()
it
'to show on toggle click'
,
=>
$
(
'.js-projects-dropdown-toggle'
).
click
()
expect
(
$
(
'.title .select2-container'
).
hasClass
(
'select2-dropdown-open'
)).
toBe
(
true
)
expect
(
$
(
'.ajax-project-dropdown li'
).
length
).
toBe
(
@
projects_data
.
length
)
it
'hide dropdown'
,
->
$
(
"#select2-drop-mask"
).
click
()
expect
(
$
(
'.title .select2-container'
).
hasClass
(
'select2-dropdown-open'
)).
toBe
(
false
)
it
'change project when clicking item'
,
->
$
(
'.js-projects-dropdown-toggle'
).
click
()
$
(
'.ajax-project-dropdown li:nth-child(2)'
).
trigger
(
'mouseup'
)
expect
(
$
(
'.title .select2-container'
).
hasClass
(
'select2-dropdown-open'
)).
toBe
(
false
)
expect
(
window
.
current_project_url
).
toBe
(
'http://localhost:3000/h5bp/html5-boilerplate'
)
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