BigW Consortium Gitlab
Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gitlab-ce
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Forest Godfrey
gitlab-ce
Commits
a16547e5
Commit
a16547e5
authored
Mar 01, 2018
by
Jose Ivan Vargas
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
used respond_to formats for persisting flash messages instead
parent
f42397d1
Show whitespace changes
Inline
Side-by-side
Showing
14 changed files
with
36 additions
and
96 deletions
+36
-96
flash_queue.js
app/assets/javascripts/lib/utils/flash_queue.js
+0
-46
main.js
app/assets/javascripts/main.js
+0
-2
promote_milestone_modal.vue
.../milestones/shared/components/promote_milestone_modal.vue
+4
-8
promote_label_modal.vue
.../pages/projects/labels/components/promote_label_modal.vue
+4
-8
labels_controller.rb
app/controllers/projects/labels_controller.rb
+5
-3
milestones_controller.rb
app/controllers/projects/milestones_controller.rb
+10
-2
flash_helper.rb
app/helpers/flash_helper.rb
+0
-8
show.html.haml
app/views/projects/milestones/show.html.haml
+2
-1
_label.html.haml
app/views/shared/_label.html.haml
+4
-3
_milestone.html.haml
app/views/shared/milestones/_milestone.html.haml
+4
-3
labels_controller_spec.rb
spec/controllers/projects/labels_controller_spec.rb
+1
-1
milestones_controller_spec.rb
spec/controllers/projects/milestones_controller_spec.rb
+2
-1
promote_label_modal_spec.js
...ripts/pages/labels/components/promote_label_modal_spec.js
+0
-5
promote_milestone_modal_spec.js
...estones/shared/components/promote_milestone_modal_spec.js
+0
-5
No files found.
app/assets/javascripts/lib/utils/flash_queue.js
deleted
100644 → 0
View file @
f42397d1
import
_
from
'underscore'
;
import
createFlash
from
'~/flash'
;
import
AccessorUtilities
from
'~/lib/utils/accessor'
;
const
FLASH_QUEUE_KEY
=
'flash-key'
;
export
function
popFlashMessage
()
{
const
page
=
$
(
'body'
).
attr
(
'data-page'
);
let
savedFlashMessages
;
let
returnVal
=
false
;
if
(
!
page
)
{
return
returnVal
;
}
if
(
AccessorUtilities
.
isLocalStorageAccessSafe
())
{
savedFlashMessages
=
JSON
.
parse
(
window
.
localStorage
.
getItem
(
FLASH_QUEUE_KEY
));
const
queuedMessage
=
_
.
findWhere
(
savedFlashMessages
,
{
bodyData
:
page
});
if
(
queuedMessage
)
{
const
queuedMessageIndex
=
_
.
findIndex
(
savedFlashMessages
,
{
bodyData
:
page
});
createFlash
(
queuedMessage
.
message
,
queuedMessage
.
type
);
savedFlashMessages
.
splice
(
queuedMessageIndex
,
1
);
window
.
localStorage
.
setItem
(
FLASH_QUEUE_KEY
,
JSON
.
stringify
(
savedFlashMessages
));
}
returnVal
=
true
;
}
return
returnVal
;
}
export
function
saveFlashMessage
(
bodyData
,
message
,
type
)
{
let
savedFlashMessages
;
if
(
AccessorUtilities
.
isLocalStorageAccessSafe
())
{
savedFlashMessages
=
JSON
.
parse
(
window
.
localStorage
.
getItem
(
FLASH_QUEUE_KEY
));
if
(
!
savedFlashMessages
)
{
savedFlashMessages
=
[];
}
savedFlashMessages
.
push
({
bodyData
,
message
,
type
,
});
window
.
localStorage
.
setItem
(
FLASH_QUEUE_KEY
,
JSON
.
stringify
(
savedFlashMessages
));
}
}
app/assets/javascripts/main.js
View file @
a16547e5
...
@@ -33,7 +33,6 @@ import './milestone_select';
...
@@ -33,7 +33,6 @@ import './milestone_select';
import
'./projects_dropdown'
;
import
'./projects_dropdown'
;
import
'./render_gfm'
;
import
'./render_gfm'
;
import
initBreadcrumbs
from
'./breadcrumb'
;
import
initBreadcrumbs
from
'./breadcrumb'
;
import
{
popFlashMessage
}
from
'./lib/utils/flash_queue'
;
import
initDispatcher
from
'./dispatcher'
;
import
initDispatcher
from
'./dispatcher'
;
...
@@ -263,5 +262,4 @@ document.addEventListener('DOMContentLoaded', () => {
...
@@ -263,5 +262,4 @@ document.addEventListener('DOMContentLoaded', () => {
}
}
initDispatcher
();
initDispatcher
();
popFlashMessage
();
});
});
app/assets/javascripts/pages/milestones/shared/components/promote_milestone_modal.vue
View file @
a16547e5
<
script
>
<
script
>
import
axios
from
'~/lib/utils/axios_utils'
;
import
axios
from
'~/lib/utils/axios_utils'
;
import
createFlash
from
'~/flash'
;
import
createFlash
from
'~/flash'
;
import
{
saveFlashMessage
}
from
'~/lib/utils/flash_queue'
;
import
GlModal
from
'~/vue_shared/components/gl_modal.vue'
;
import
GlModal
from
'~/vue_shared/components/gl_modal.vue'
;
import
{
redirectTo
}
from
'~/lib/utils/url_utility'
;
import
{
s__
,
sprintf
}
from
'~/locale'
;
import
{
s__
,
sprintf
}
from
'~/locale'
;
import
{
visitUrl
}
from
'~/lib/utils/url_utility'
;
import
eventHub
from
'../event_hub'
;
import
eventHub
from
'../event_hub'
;
export
default
{
export
default
{
...
@@ -27,20 +26,17 @@
...
@@ -27,20 +26,17 @@
},
},
text
()
{
text
()
{
return
s__
(
`Milestones|Promoting this milestone will make it available for all projects inside the group.
return
s__
(
`Milestones|Promoting this milestone will make it available for all projects inside the group.
Existing project milestones with the same
nam
e will be merged.
Existing project milestones with the same
titl
e will be merged.
This action cannot be reversed.`
);
This action cannot be reversed.`
);
},
},
},
},
methods
:
{
methods
:
{
onSubmit
()
{
onSubmit
()
{
eventHub
.
$emit
(
'promoteMilestoneModal.requestStarted'
,
this
.
url
);
eventHub
.
$emit
(
'promoteMilestoneModal.requestStarted'
,
this
.
url
);
return
axios
.
post
(
this
.
url
)
return
axios
.
post
(
this
.
url
,
{
params
:
{
format
:
'json'
}
}
)
.
then
((
response
)
=>
{
.
then
((
response
)
=>
{
eventHub
.
$emit
(
'promoteMilestoneModal.requestFinished'
,
{
milestoneUrl
:
this
.
url
,
successful
:
true
});
eventHub
.
$emit
(
'promoteMilestoneModal.requestFinished'
,
{
milestoneUrl
:
this
.
url
,
successful
:
true
});
const
responseURL
=
new
URL
(
response
.
request
.
responseURL
);
visitUrl
(
response
.
data
.
url
);
const
bodyData
=
responseURL
.
searchParams
.
get
(
'body_data'
);
saveFlashMessage
(
bodyData
,
`
${
this
.
milestoneTitle
}
promoted to group milestone`
,
'notice'
);
redirectTo
(
`
${
responseURL
.
protocol
}
//
${
responseURL
.
host
}${
responseURL
.
pathname
}
`
);
})
})
.
catch
((
error
)
=>
{
.
catch
((
error
)
=>
{
eventHub
.
$emit
(
'promoteMilestoneModal.requestFinished'
,
{
milestoneUrl
:
this
.
url
,
successful
:
false
});
eventHub
.
$emit
(
'promoteMilestoneModal.requestFinished'
,
{
milestoneUrl
:
this
.
url
,
successful
:
false
});
...
...
app/assets/javascripts/pages/projects/labels/components/promote_label_modal.vue
View file @
a16547e5
<
script
>
<
script
>
import
axios
from
'~/lib/utils/axios_utils'
;
import
axios
from
'~/lib/utils/axios_utils'
;
import
{
saveFlashMessage
}
from
'~/lib/utils/flash_queue'
;
import
createFlash
from
'~/flash'
;
import
createFlash
from
'~/flash'
;
import
GlModal
from
'~/vue_shared/components/gl_modal.vue'
;
import
GlModal
from
'~/vue_shared/components/gl_modal.vue'
;
import
{
redirectTo
}
from
'~/lib/utils/url_utility'
;
import
{
s__
,
sprintf
}
from
'~/locale'
;
import
{
s__
,
sprintf
}
from
'~/locale'
;
import
{
visitUrl
}
from
'~/lib/utils/url_utility'
;
import
eventHub
from
'../event_hub'
;
import
eventHub
from
'../event_hub'
;
export
default
{
export
default
{
...
@@ -32,7 +31,7 @@
...
@@ -32,7 +31,7 @@
computed
:
{
computed
:
{
text
()
{
text
()
{
return
s__
(
`Milestones|Promoting this label will make it available for all projects inside the group.
return
s__
(
`Milestones|Promoting this label will make it available for all projects inside the group.
Existing project labels with the same
nam
e will be merged. This action cannot be reversed.`
);
Existing project labels with the same
titl
e will be merged. This action cannot be reversed.`
);
},
},
title
()
{
title
()
{
const
label
=
`<span
const
label
=
`<span
...
@@ -48,13 +47,10 @@
...
@@ -48,13 +47,10 @@
methods
:
{
methods
:
{
onSubmit
()
{
onSubmit
()
{
eventHub
.
$emit
(
'promoteLabelModal.requestStarted'
,
this
.
url
);
eventHub
.
$emit
(
'promoteLabelModal.requestStarted'
,
this
.
url
);
return
axios
.
post
(
this
.
url
)
return
axios
.
post
(
this
.
url
,
{
params
:
{
format
:
'json'
}
}
)
.
then
((
response
)
=>
{
.
then
((
response
)
=>
{
eventHub
.
$emit
(
'promoteLabelModal.requestFinished'
,
{
labelUrl
:
this
.
url
,
successful
:
true
});
eventHub
.
$emit
(
'promoteLabelModal.requestFinished'
,
{
labelUrl
:
this
.
url
,
successful
:
true
});
const
responseURL
=
new
URL
(
response
.
request
.
responseURL
);
visitUrl
(
response
.
data
.
url
);
const
bodyData
=
responseURL
.
searchParams
.
get
(
'body_data'
);
saveFlashMessage
(
bodyData
,
`
${
this
.
labelTitle
}
promoted to group label`
,
'notice'
);
redirectTo
(
`
${
responseURL
.
protocol
}
//
${
responseURL
.
host
}${
responseURL
.
pathname
}
`
);
})
})
.
catch
((
error
)
=>
{
.
catch
((
error
)
=>
{
eventHub
.
$emit
(
'promoteLabelModal.requestFinished'
,
{
labelUrl
:
this
.
url
,
successful
:
false
});
eventHub
.
$emit
(
'promoteLabelModal.requestFinished'
,
{
labelUrl
:
this
.
url
,
successful
:
false
});
...
...
app/controllers/projects/labels_controller.rb
View file @
a16547e5
class
Projects
::
LabelsController
<
Projects
::
ApplicationController
class
Projects
::
LabelsController
<
Projects
::
ApplicationController
include
ToggleSubscriptionAction
include
ToggleSubscriptionAction
include
FlashHelper
before_action
:check_issuables_available!
before_action
:check_issuables_available!
before_action
:label
,
only:
[
:edit
,
:update
,
:destroy
,
:promote
]
before_action
:label
,
only:
[
:edit
,
:update
,
:destroy
,
:promote
]
...
@@ -113,11 +112,14 @@ class Projects::LabelsController < Projects::ApplicationController
...
@@ -113,11 +112,14 @@ class Projects::LabelsController < Projects::ApplicationController
begin
begin
return
render_404
unless
promote_service
.
execute
(
@label
)
return
render_404
unless
promote_service
.
execute
(
@label
)
flash
[
:notice
]
=
"
#{
@label
.
title
}
promoted to group label."
respond_to
do
|
format
|
respond_to
do
|
format
|
format
.
html
do
format
.
html
do
redirect_to
(
project_labels_path
(
@project
,
body_data:
get_body_data_page
(
project_labels_path
(
@project
))),
status:
303
)
redirect_to
(
project_labels_path
(
@project
),
status:
303
)
end
format
.
json
do
render
json:
{
url:
project_labels_path
(
@project
)
}
end
end
format
.
js
end
end
rescue
ActiveRecord
::
RecordInvalid
=>
e
rescue
ActiveRecord
::
RecordInvalid
=>
e
Gitlab
::
AppLogger
.
error
"Failed to promote label
\"
#{
@label
.
title
}
\"
to group label"
Gitlab
::
AppLogger
.
error
"Failed to promote label
\"
#{
@label
.
title
}
\"
to group label"
...
...
app/controllers/projects/milestones_controller.rb
View file @
a16547e5
class
Projects
::
MilestonesController
<
Projects
::
ApplicationController
class
Projects
::
MilestonesController
<
Projects
::
ApplicationController
include
MilestoneActions
include
MilestoneActions
include
FlashHelper
before_action
:check_issuables_available!
before_action
:check_issuables_available!
before_action
:milestone
,
only:
[
:edit
,
:update
,
:destroy
,
:show
,
:merge_requests
,
:participants
,
:labels
,
:promote
]
before_action
:milestone
,
only:
[
:edit
,
:update
,
:destroy
,
:show
,
:merge_requests
,
:participants
,
:labels
,
:promote
]
...
@@ -72,7 +71,16 @@ class Projects::MilestonesController < Projects::ApplicationController
...
@@ -72,7 +71,16 @@ class Projects::MilestonesController < Projects::ApplicationController
def
promote
def
promote
Milestones
::
PromoteService
.
new
(
project
,
current_user
).
execute
(
milestone
)
Milestones
::
PromoteService
.
new
(
project
,
current_user
).
execute
(
milestone
)
redirect_to
project_milestones_path
(
project
,
body_data:
get_body_data_page
(
project_milestones_path
(
project
))),
status:
303
flash
[
:notice
]
=
"
#{
milestone
.
title
}
promoted to group milestone"
respond_to
do
|
format
|
format
.
html
do
redirect_to
project_milestones_path
(
project
)
end
format
.
json
do
render
json:
{
url:
project_milestones_path
(
project
)
}
end
end
rescue
Milestones
::
PromoteService
::
PromoteMilestoneError
=>
error
rescue
Milestones
::
PromoteService
::
PromoteMilestoneError
=>
error
redirect_to
milestone
,
alert:
error
.
message
redirect_to
milestone
,
alert:
error
.
message
end
end
...
...
app/helpers/flash_helper.rb
deleted
100644 → 0
View file @
f42397d1
module
FlashHelper
def
get_body_data_page
(
path
)
return
unless
path
.
empty?
==
false
path_controller
=
Rails
.
application
.
routes
.
recognize_path
(
path
)
[
path_controller
[
:controller
].
split
(
'/'
),
path_controller
[
:action
]].
compact
.
join
(
':'
)
end
end
app/views/projects/milestones/show.html.haml
View file @
a16547e5
...
@@ -32,7 +32,8 @@
...
@@ -32,7 +32,8 @@
milestone_title:
@milestone
.
title
,
milestone_title:
@milestone
.
title
,
url:
promote_project_milestone_path
(
@milestone
.
project
,
@milestone
),
url:
promote_project_milestone_path
(
@milestone
.
project
,
@milestone
),
container:
'body'
},
container:
'body'
},
disabled:
true
}
disabled:
true
,
type:
'button'
}
=
_
(
'Promote'
)
=
_
(
'Promote'
)
#promote-milestone-modal
#promote-milestone-modal
...
...
app/views/shared/_label.html.haml
View file @
a16547e5
...
@@ -48,15 +48,16 @@
...
@@ -48,15 +48,16 @@
.pull-right.hidden-xs.hidden-sm
.pull-right.hidden-xs.hidden-sm
-
if
label
.
is_a?
(
ProjectLabel
)
&&
label
.
project
.
group
&&
can?
(
current_user
,
:admin_label
,
label
.
project
.
group
)
-
if
label
.
is_a?
(
ProjectLabel
)
&&
label
.
project
.
group
&&
can?
(
current_user
,
:admin_label
,
label
.
project
.
group
)
%a
.js-promote-project-label-button.btn.btn-transparent.btn-action.has-tooltip
{
title:
_
(
'Promote to Group Label'
),
%button
.js-promote-project-label-button.btn.btn-transparent.btn-action.has-tooltip
{
title:
_
(
'Promote to Group Label'
),
disabled:
true
,
type:
'button'
,
data:
{
url:
promote_project_label_path
(
label
.
project
,
label
),
data:
{
url:
promote_project_label_path
(
label
.
project
,
label
),
label_title:
label
.
title
,
label_title:
label
.
title
,
label_color:
label
.
color
,
label_color:
label
.
color
,
label_text_color:
label
.
text_color
,
label_text_color:
label
.
text_color
,
target:
'#promote-label-modal'
,
target:
'#promote-label-modal'
,
container:
'body'
,
container:
'body'
,
toggle:
'modal'
},
toggle:
'modal'
}
}
disabled:
true
}
=
sprite_icon
(
'level-up'
)
=
sprite_icon
(
'level-up'
)
-
if
can?
(
current_user
,
:admin_label
,
label
)
-
if
can?
(
current_user
,
:admin_label
,
label
)
=
link_to
edit_label_path
(
label
),
title:
"Edit"
,
class:
'btn btn-transparent btn-action'
,
data:
{
toggle:
"tooltip"
}
do
=
link_to
edit_label_path
(
label
),
title:
"Edit"
,
class:
'btn btn-transparent btn-action'
,
data:
{
toggle:
"tooltip"
}
do
...
...
app/views/shared/milestones/_milestone.html.haml
View file @
a16547e5
...
@@ -51,13 +51,14 @@
...
@@ -51,13 +51,14 @@
\
\
-
if
@project
.
group
-
if
@project
.
group
%a
.js-promote-project-milestone-button.btn.btn-xs.btn-grouped.has-tooltip
{
title:
_
(
'Promote to Group Milestone'
),
%button
.js-promote-project-milestone-button.btn.btn-xs.btn-grouped.has-tooltip
{
title:
_
(
'Promote to Group Milestone'
),
disabled:
true
,
type:
'button'
,
data:
{
url:
promote_project_milestone_path
(
milestone
.
project
,
milestone
),
data:
{
url:
promote_project_milestone_path
(
milestone
.
project
,
milestone
),
milestone_title:
milestone
.
title
,
milestone_title:
milestone
.
title
,
target:
'#promote-milestone-modal'
,
target:
'#promote-milestone-modal'
,
container:
'body'
,
container:
'body'
,
toggle:
'modal'
},
toggle:
'modal'
}
}
disabled:
true
}
=
_
(
'Promote'
)
=
_
(
'Promote'
)
=
link_to
'Close Milestone'
,
project_milestone_path
(
@project
,
milestone
,
milestone:
{
state_event: :close
}),
method: :put
,
remote:
true
,
class:
"btn btn-xs btn-close btn-grouped"
=
link_to
'Close Milestone'
,
project_milestone_path
(
@project
,
milestone
,
milestone:
{
state_event: :close
}),
method: :put
,
remote:
true
,
class:
"btn btn-xs btn-close btn-grouped"
...
...
spec/controllers/projects/labels_controller_spec.rb
View file @
a16547e5
...
@@ -133,7 +133,7 @@ describe Projects::LabelsController do
...
@@ -133,7 +133,7 @@ describe Projects::LabelsController do
it
'gives access'
do
it
'gives access'
do
post
:promote
,
namespace_id:
project
.
namespace
.
to_param
,
project_id:
project
,
id:
label_1
.
to_param
post
:promote
,
namespace_id:
project
.
namespace
.
to_param
,
project_id:
project
,
id:
label_1
.
to_param
expect
(
response
.
location
).
to
include
(
namespace_project_labels_path
)
expect
(
response
).
to
redirect_to
(
namespace_project_labels_path
)
end
end
it
'promotes the label'
do
it
'promotes the label'
do
...
...
spec/controllers/projects/milestones_controller_spec.rb
View file @
a16547e5
...
@@ -98,7 +98,8 @@ describe Projects::MilestonesController do
...
@@ -98,7 +98,8 @@ describe Projects::MilestonesController do
it
'shows group milestone'
do
it
'shows group milestone'
do
post
:promote
,
namespace_id:
project
.
namespace
.
id
,
project_id:
project
.
id
,
id:
milestone
.
iid
post
:promote
,
namespace_id:
project
.
namespace
.
id
,
project_id:
project
.
id
,
id:
milestone
.
iid
expect
(
response
.
location
).
to
include
(
project_milestones_path
(
project
))
expect
(
flash
[
:notice
]).
to
eq
(
"
#{
milestone
.
title
}
promoted to group milestone"
)
expect
(
response
).
to
redirect_to
(
project_milestones_path
(
project
))
end
end
end
end
...
...
spec/javascripts/pages/labels/components/promote_label_modal_spec.js
View file @
a16547e5
...
@@ -2,7 +2,6 @@ import Vue from 'vue';
...
@@ -2,7 +2,6 @@ import Vue from 'vue';
import
promoteLabelModal
from
'~/pages/projects/labels/components/promote_label_modal.vue'
;
import
promoteLabelModal
from
'~/pages/projects/labels/components/promote_label_modal.vue'
;
import
eventHub
from
'~/pages/projects/labels/event_hub'
;
import
eventHub
from
'~/pages/projects/labels/event_hub'
;
import
axios
from
'~/lib/utils/axios_utils'
;
import
axios
from
'~/lib/utils/axios_utils'
;
import
*
as
urlUtility
from
'~/lib/utils/url_utility'
;
import
mountComponent
from
'../../../helpers/vue_mount_component_helper'
;
import
mountComponent
from
'../../../helpers/vue_mount_component_helper'
;
describe
(
'Promote label modal'
,
()
=>
{
describe
(
'Promote label modal'
,
()
=>
{
...
@@ -59,11 +58,9 @@ describe('Promote label modal', () => {
...
@@ -59,11 +58,9 @@ describe('Promote label modal', () => {
},
},
});
});
});
});
const
redirectSpy
=
spyOn
(
urlUtility
,
'redirectTo'
);
vm
.
onSubmit
()
vm
.
onSubmit
()
.
then
(()
=>
{
.
then
(()
=>
{
expect
(
redirectSpy
).
toHaveBeenCalledWith
(
responseURL
);
expect
(
eventHub
.
$emit
).
toHaveBeenCalledWith
(
'promoteLabelModal.requestFinished'
,
{
labelUrl
:
labelMockData
.
url
,
successful
:
true
});
expect
(
eventHub
.
$emit
).
toHaveBeenCalledWith
(
'promoteLabelModal.requestFinished'
,
{
labelUrl
:
labelMockData
.
url
,
successful
:
true
});
})
})
.
then
(
done
)
.
then
(
done
)
...
@@ -78,12 +75,10 @@ describe('Promote label modal', () => {
...
@@ -78,12 +75,10 @@ describe('Promote label modal', () => {
expect
(
eventHub
.
$emit
).
toHaveBeenCalledWith
(
'promoteLabelModal.requestStarted'
,
labelMockData
.
url
);
expect
(
eventHub
.
$emit
).
toHaveBeenCalledWith
(
'promoteLabelModal.requestStarted'
,
labelMockData
.
url
);
return
Promise
.
reject
(
dummyError
);
return
Promise
.
reject
(
dummyError
);
});
});
const
redirectSpy
=
spyOn
(
urlUtility
,
'redirectTo'
);
vm
.
onSubmit
()
vm
.
onSubmit
()
.
catch
((
error
)
=>
{
.
catch
((
error
)
=>
{
expect
(
error
).
toBe
(
dummyError
);
expect
(
error
).
toBe
(
dummyError
);
expect
(
redirectSpy
).
not
.
toHaveBeenCalled
();
expect
(
eventHub
.
$emit
).
toHaveBeenCalledWith
(
'promoteLabelModal.requestFinished'
,
{
labelUrl
:
labelMockData
.
url
,
successful
:
false
});
expect
(
eventHub
.
$emit
).
toHaveBeenCalledWith
(
'promoteLabelModal.requestFinished'
,
{
labelUrl
:
labelMockData
.
url
,
successful
:
false
});
})
})
.
then
(
done
)
.
then
(
done
)
...
...
spec/javascripts/pages/milestones/shared/components/promote_milestone_modal_spec.js
View file @
a16547e5
...
@@ -2,7 +2,6 @@ import Vue from 'vue';
...
@@ -2,7 +2,6 @@ import Vue from 'vue';
import
promoteMilestoneModal
from
'~/pages/milestones/shared/components/promote_milestone_modal.vue'
;
import
promoteMilestoneModal
from
'~/pages/milestones/shared/components/promote_milestone_modal.vue'
;
import
eventHub
from
'~/pages/milestones/shared/event_hub'
;
import
eventHub
from
'~/pages/milestones/shared/event_hub'
;
import
axios
from
'~/lib/utils/axios_utils'
;
import
axios
from
'~/lib/utils/axios_utils'
;
import
*
as
urlUtility
from
'~/lib/utils/url_utility'
;
import
mountComponent
from
'../../../../helpers/vue_mount_component_helper'
;
import
mountComponent
from
'../../../../helpers/vue_mount_component_helper'
;
describe
(
'Promote milestone modal'
,
()
=>
{
describe
(
'Promote milestone modal'
,
()
=>
{
...
@@ -54,11 +53,9 @@ describe('Promote milestone modal', () => {
...
@@ -54,11 +53,9 @@ describe('Promote milestone modal', () => {
},
},
});
});
});
});
const
redirectSpy
=
spyOn
(
urlUtility
,
'redirectTo'
);
vm
.
onSubmit
()
vm
.
onSubmit
()
.
then
(()
=>
{
.
then
(()
=>
{
expect
(
redirectSpy
).
toHaveBeenCalledWith
(
responseURL
);
expect
(
eventHub
.
$emit
).
toHaveBeenCalledWith
(
'promoteMilestoneModal.requestFinished'
,
{
milestoneUrl
:
milestoneMockData
.
url
,
successful
:
true
});
expect
(
eventHub
.
$emit
).
toHaveBeenCalledWith
(
'promoteMilestoneModal.requestFinished'
,
{
milestoneUrl
:
milestoneMockData
.
url
,
successful
:
true
});
})
})
.
then
(
done
)
.
then
(
done
)
...
@@ -73,12 +70,10 @@ describe('Promote milestone modal', () => {
...
@@ -73,12 +70,10 @@ describe('Promote milestone modal', () => {
expect
(
eventHub
.
$emit
).
toHaveBeenCalledWith
(
'promoteMilestoneModal.requestStarted'
,
milestoneMockData
.
url
);
expect
(
eventHub
.
$emit
).
toHaveBeenCalledWith
(
'promoteMilestoneModal.requestStarted'
,
milestoneMockData
.
url
);
return
Promise
.
reject
(
dummyError
);
return
Promise
.
reject
(
dummyError
);
});
});
const
redirectSpy
=
spyOn
(
urlUtility
,
'redirectTo'
);
vm
.
onSubmit
()
vm
.
onSubmit
()
.
catch
((
error
)
=>
{
.
catch
((
error
)
=>
{
expect
(
error
).
toBe
(
dummyError
);
expect
(
error
).
toBe
(
dummyError
);
expect
(
redirectSpy
).
not
.
toHaveBeenCalled
();
expect
(
eventHub
.
$emit
).
toHaveBeenCalledWith
(
'promoteMilestoneModal.requestFinished'
,
{
milestoneUrl
:
milestoneMockData
.
url
,
successful
:
false
});
expect
(
eventHub
.
$emit
).
toHaveBeenCalledWith
(
'promoteMilestoneModal.requestFinished'
,
{
milestoneUrl
:
milestoneMockData
.
url
,
successful
:
false
});
})
})
.
then
(
done
)
.
then
(
done
)
...
...
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