Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
E
edx-platform
Overview
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
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
edx
edx-platform
Commits
78deaed2
Commit
78deaed2
authored
Feb 09, 2015
by
Waqas Khalid
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #6445 from MatMoore/forum_vote_race_condition
Vote buttons should be disabled while in use
parents
847f56d1
d857695d
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
28 additions
and
2 deletions
+28
-2
AUTHORS
+1
-0
common/static/coffee/spec/discussion/utils_spec.coffee
+21
-0
common/static/coffee/src/discussion/utils.coffee
+5
-1
common/static/coffee/src/discussion/views/discussion_thread_view.coffee
+1
-1
No files found.
AUTHORS
View file @
78deaed2
...
@@ -195,3 +195,4 @@ Dino Cikatić <dcikatic@edx.org>
...
@@ -195,3 +195,4 @@ Dino Cikatić <dcikatic@edx.org>
Davorin Šego <dsego@edx.org>
Davorin Šego <dsego@edx.org>
Marko Jevtić <mjevtic@edx.org>
Marko Jevtić <mjevtic@edx.org>
Ahsan Ulhaq <ahsan@edx.org>
Ahsan Ulhaq <ahsan@edx.org>
Mat Moore <mat@mooresoftware.co.uk>
common/static/coffee/spec/discussion/utils_spec.coffee
View file @
78deaed2
...
@@ -25,3 +25,24 @@ describe 'DiscussionUtil', ->
...
@@ -25,3 +25,24 @@ describe 'DiscussionUtil', ->
# if the ajax call ends in failure, the model state should be reverted
# if the ajax call ends in failure, the model state should be reverted
deferred
.
reject
()
deferred
.
reject
()
expect
(
model
.
attributes
).
toEqual
({
hello
:
false
,
number
:
42
})
expect
(
model
.
attributes
).
toEqual
({
hello
:
false
,
number
:
42
})
it
"rolls back the changes if the associated element is disabled"
,
->
spyOn
(
DiscussionUtil
,
"safeAjax"
).
andCallThrough
()
model
=
new
Backbone
.
Model
({
hello
:
false
,
number
:
42
})
updates
=
{
hello
:
"world"
}
# This is the element that is disabled/enabled while the ajax request is
# in progress
$elem
=
jasmine
.
createSpyObj
(
'$elem'
,
[
'attr'
])
$elem
.
attr
.
andReturn
(
true
)
res
=
DiscussionUtil
.
updateWithUndo
(
model
,
updates
,
{
foo
:
"bar"
,
$elem
:
$elem
},
"error message"
)
expect
(
$elem
.
attr
).
toHaveBeenCalledWith
(
"disabled"
)
expect
(
DiscussionUtil
.
safeAjax
).
toHaveBeenCalled
()
expect
(
model
.
attributes
).
toEqual
({
hello
:
false
,
number
:
42
})
failed
=
false
res
.
fail
(()
=>
failed
=
true
)
expect
(
failed
).
toBe
(
true
);
common/static/coffee/src/discussion/utils.coffee
View file @
78deaed2
...
@@ -134,8 +134,12 @@ class @DiscussionUtil
...
@@ -134,8 +134,12 @@ class @DiscussionUtil
@
safeAjax
:
(
params
)
->
@
safeAjax
:
(
params
)
->
$elem
=
params
.
$elem
$elem
=
params
.
$elem
if
$elem
and
$elem
.
attr
(
"disabled"
)
if
$elem
and
$elem
.
attr
(
"disabled"
)
return
deferred
=
$
.
Deferred
()
deferred
.
reject
()
return
deferred
.
promise
()
params
[
"url"
]
=
URI
(
params
[
"url"
]).
addSearch
ajax
:
1
params
[
"url"
]
=
URI
(
params
[
"url"
]).
addSearch
ajax
:
1
params
[
"beforeSend"
]
=
->
params
[
"beforeSend"
]
=
->
if
$elem
if
$elem
...
...
common/static/coffee/src/discussion/views/discussion_thread_view.coffee
View file @
78deaed2
...
@@ -127,7 +127,7 @@ if Backbone?
...
@@ -127,7 +127,7 @@ if Backbone?
$loading
:
elem
$loading
:
elem
takeFocus
:
true
takeFocus
:
true
complete
:
=>
complete
:
=>
@
responseRequest
=
null
@
response
s
Request
=
null
success
:
(
data
,
textStatus
,
xhr
)
=>
success
:
(
data
,
textStatus
,
xhr
)
=>
Content
.
loadContentInfos
(
data
[
'annotated_content_info'
])
Content
.
loadContentInfos
(
data
[
'annotated_content_info'
])
if
@
isQuestion
()
if
@
isQuestion
()
...
...
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