Move award_menu_url variable into gon object.

This commit is contained in:
Fatih Acet 2016-06-09 03:27:52 +03:00
parent 52525dc4c2
commit 92af60c244
4 changed files with 8 additions and 11 deletions

View file

@ -282,7 +282,7 @@ class @AwardsHandler
@createEmojiMenu @getAwardMenuUrl(), => @createEmoji_ votesBlock, emoji
getAwardMenuUrl: -> return gl.awardMenuUrl
getAwardMenuUrl: -> return gon.award_menu_url
resolveNameToCssClass: (emoji) ->

View file

@ -7,9 +7,6 @@
= awards.count
- if current_user
:javascript
gl.awardMenuUrl = "#{emojis_path}"
.award-menu-holder.js-award-holder
%button.btn.award-control.js-add-award{ type: "button" }
= icon('smile-o', class: "award-control-icon award-control-icon-normal")

View file

@ -8,6 +8,7 @@ module Gitlab
gon.relative_url_root = Gitlab.config.gitlab.relative_url_root
gon.shortcuts_path = help_shortcuts_path
gon.user_color_scheme = Gitlab::ColorSchemes.for_user(current_user).css_class
gon.award_menu_url = emojis_path
if current_user
gon.current_user_id = current_user.id

View file

@ -3,10 +3,11 @@
#= require jquery.cookie
#= require ./fixtures/emoji_menu
awardsHandler = null
window.gl or= {}
gl.emojiAliases = -> return { '+1': 'thumbsup', '-1': 'thumbsdown' }
gl.awardMenuUrl = '/emojis'
awardsHandler = null
window.gl or= {}
window.gon or= {}
gl.emojiAliases = -> return { '+1': 'thumbsup', '-1': 'thumbsdown' }
gon.award_menu_url = '/emojis'
lazyAssert = (done, assertFn) ->
@ -25,9 +26,7 @@ describe 'AwardsHandler', ->
fixture.load 'awards_handler.html'
awardsHandler = new AwardsHandler
spyOn(awardsHandler, 'postEmoji').and.callFake (url, emoji, cb) => cb()
spyOn(jQuery, 'get').and.callFake (req, cb) ->
expect(req).toBe '/emojis'
cb window.emojiMenu
spyOn(jQuery, 'get').and.callFake (req, cb) -> cb window.emojiMenu
describe '::showEmojiMenu', ->