summaryrefslogtreecommitdiff
path: root/spec/javascripts
diff options
context:
space:
mode:
authorFatih Acet <acetfatih@gmail.com>2016-06-15 00:15:46 +0300
committerJacob Schatz <jschatz1@gmail.com>2016-06-15 11:37:45 -0400
commit415b032ba1d003bb407581ce3069c95ac178bfd4 (patch)
tree83424f0d577323fe9729520bbd182beb2a003cd5 /spec/javascripts
parent93a496d270cb638c76a4df45a74121c189146888 (diff)
downloadgitlab-ce-415b032ba1d003bb407581ce3069c95ac178bfd4.tar.gz
Prevent default disabled buttons and links.preventdefault-disabled-buttons
Diffstat (limited to 'spec/javascripts')
-rw-r--r--spec/javascripts/application_spec.js.coffee30
-rw-r--r--spec/javascripts/fixtures/application.html.haml2
2 files changed, 32 insertions, 0 deletions
diff --git a/spec/javascripts/application_spec.js.coffee b/spec/javascripts/application_spec.js.coffee
new file mode 100644
index 00000000000..8af39c41f2f
--- /dev/null
+++ b/spec/javascripts/application_spec.js.coffee
@@ -0,0 +1,30 @@
+#= require lib/common_utils
+
+describe 'Application', ->
+ describe 'disable buttons', ->
+ fixture.preload('application.html')
+
+ beforeEach ->
+ fixture.load('application.html')
+
+ it 'should prevent default action for disabled buttons', ->
+
+ gl.utils.preventDisabledButtons()
+
+ isClicked = false
+ $button = $ '#test-button'
+
+ $button.click -> isClicked = true
+ $button.trigger 'click'
+
+ expect(isClicked).toBe false
+
+
+ it 'should be on the same page if a disabled link clicked', ->
+
+ locationBeforeLinkClick = window.location.href
+ gl.utils.preventDisabledButtons()
+
+ $('#test-link').click()
+
+ expect(window.location.href).toBe locationBeforeLinkClick
diff --git a/spec/javascripts/fixtures/application.html.haml b/spec/javascripts/fixtures/application.html.haml
new file mode 100644
index 00000000000..3fc6114407d
--- /dev/null
+++ b/spec/javascripts/fixtures/application.html.haml
@@ -0,0 +1,2 @@
+%a#test-link.btn.disabled{:href => "/foo"} Test link
+%button#test-button.btn.disabled Test Button