From 3016280ef12681a1ffd1c8f71df8efaa1ebd37d4 Mon Sep 17 00:00:00 2001 From: ivan sebastian Date: Sun, 13 Aug 2017 18:22:37 +0700 Subject: [PATCH] add jquery are you sure to comment form closes #7530 --- Changelog.md | 1 + app/assets/javascripts/app/views/comment_stream_view.js | 2 ++ features/desktop/comments.feature | 1 + spec/javascripts/app/views/comment_stream_view_spec.js | 6 ++++++ 4 files changed, 10 insertions(+) diff --git a/Changelog.md b/Changelog.md index a6f9d244e..7e6292217 100644 --- a/Changelog.md +++ b/Changelog.md @@ -5,6 +5,7 @@ ## Bug fixes ## Features +* Ask for confirmation when leaving a submittable comment field [#7530](https://github.com/diaspora/diaspora/pull/7530) # 0.7.0.0 diff --git a/app/assets/javascripts/app/views/comment_stream_view.js b/app/assets/javascripts/app/views/comment_stream_view.js index 2a1b81612..0401b585a 100644 --- a/app/assets/javascripts/app/views/comment_stream_view.js +++ b/app/assets/javascripts/app/views/comment_stream_view.js @@ -37,6 +37,8 @@ app.views.CommentStream = app.views.Base.extend({ }.bind(this), onFocus: this.openForm.bind(this) }); + + this.$("form").areYouSure(); }, presenter: function(){ diff --git a/features/desktop/comments.feature b/features/desktop/comments.feature index 0ef2ca6c8..2a1afbf54 100644 --- a/features/desktop/comments.feature +++ b/features/desktop/comments.feature @@ -19,6 +19,7 @@ Feature: commenting When I focus the comment field And I fill in the following: | text | is that a poodle? | + And I reject the alert after I follow "My activity" And I press "Comment" Then I should see "is that a poodle?" within ".comment" And I should see "less than a minute ago" within ".comment time" diff --git a/spec/javascripts/app/views/comment_stream_view_spec.js b/spec/javascripts/app/views/comment_stream_view_spec.js index 284b16c7a..2076871cd 100644 --- a/spec/javascripts/app/views/comment_stream_view_spec.js +++ b/spec/javascripts/app/views/comment_stream_view_spec.js @@ -92,6 +92,12 @@ describe("app.views.CommentStream", function(){ expect(renderedPreview).toBe("
" + renderedText + "
"); expect(renderedPreview).toContain("Alice Awesome"); }); + + it("calls jQuery.AreYouSure()", function() { + spyOn($.fn, "areYouSure"); + this.view.postRenderTemplate(); + expect($.fn.areYouSure).toHaveBeenCalled(); + }); }); describe("createComment", function() {