From 1ed0318db77b7647baf8cfb78156590debbe08c5 Mon Sep 17 00:00:00 2001 From: Asphyxia Date: Mon, 14 Jan 2013 04:11:10 -0300 Subject: [PATCH] Reshare alert box is appearing twice --- Changelog.md | 1 + .../javascripts/app/views/feedback_actions.js | 4 +- features/reshare.feature | 12 ++++ .../app/views/feedback_actions_view_spec.js | 55 +++++++++++++++++++ 4 files changed, 71 insertions(+), 1 deletion(-) create mode 100644 spec/javascripts/app/views/feedback_actions_view_spec.js diff --git a/Changelog.md b/Changelog.md index fce438cf0..63b09c8de 100644 --- a/Changelog.md +++ b/Changelog.md @@ -52,6 +52,7 @@ * Resize full scaled image to a specific width. [#3818](https://github.com/diaspora/diaspora/issues/3818) * Fix translation issue in contacts_helper [#3937](https://github.com/diaspora/diaspora/pull/3937) * Show timestamp hovering a timeago string (stream) [#3149](https://github.com/diaspora/diaspora/issues/3149) +* Fix reshare and like a post on a single post view [#3672](https://github.com/diaspora/diaspora/issues/3672) ## Gem Updates diff --git a/app/assets/javascripts/app/views/feedback_actions.js b/app/assets/javascripts/app/views/feedback_actions.js index 60f26237f..b781bccbc 100644 --- a/app/assets/javascripts/app/views/feedback_actions.js +++ b/app/assets/javascripts/app/views/feedback_actions.js @@ -1,5 +1,7 @@ //=require "./feedback_view" app.views.FeedbackActions = app.views.Feedback.extend({ id : "user-controls", - templateName : "feedback-actions" + templateName : "feedback-actions", + events: {}, + initialize: function(){} }); \ No newline at end of file diff --git a/features/reshare.feature b/features/reshare.feature index 422bc8053..aed7cb711 100644 --- a/features/reshare.feature +++ b/features/reshare.feature @@ -11,6 +11,18 @@ Feature: public repost | Alice Smith | alice@alice.alice | And a user with email "bob@bob.bob" is connected with "alice@alice.alice" + Scenario: Resharing a post from a single post page + Given "bob@bob.bob" has a public post with text "reshare this!" + And I sign in as "alice@alice.alice" + And I am on "bob@bob.bob"'s page + And I follow "Last Post" + + And I preemptively confirm the alert + And I click on selector "a.reshare" + And I wait for the ajax to finish + Then I should see a flash message indicating success + And I should see a flash message containing "successfully" + # should be covered in rspec, so testing that the post is added to # app.stream in jasmine should be enough coverage Scenario: When I reshare, it shows up on my profile page diff --git a/spec/javascripts/app/views/feedback_actions_view_spec.js b/spec/javascripts/app/views/feedback_actions_view_spec.js new file mode 100644 index 000000000..a45a9a967 --- /dev/null +++ b/spec/javascripts/app/views/feedback_actions_view_spec.js @@ -0,0 +1,55 @@ +describe("app.views.FeedbackActions", function(){ + beforeEach(function(){ + loginAs({id : -1, name: "alice", avatar : {small : "http://avatar.com/photo.jpg"}}); + + this.post = new app.models.Post({ + "author": { + "diaspora_id": "alice@localhost:3000" + }, + "post_type": "Reshare", + "public": true, + "root": { + "author":{"diaspora_id": null} + } + }) + + this.view = new app.views.PostViewerFeedback({model: this.post}) + }); + + describe("FeedbackActions", function(){ + it("reshares a post", function(){ + + spyOn(window, "confirm").andReturn(true) + spyOn(this.view.model.interactions, "reshare") + + this.view.render() + + this.view.$('.reshare').click() + + expect(this.view.model.interactions.reshare.callCount).toBe(1) + expect(window.confirm.callCount).toBe(1) + }); + + it('cancels a reshare confirmation ', function(){ + spyOn(window, "confirm").andReturn(false) + spyOn(this.view.model.interactions, "reshare") + + this.view.render() + + this.view.$('.reshare').click() + + expect(this.view.model.interactions.reshare).not.toHaveBeenCalled(); + }); + + it("likes a post", function(){ + + spyOn(this.view.model.interactions, "toggleLike") + + this.view.render() + + this.view.$('.like').click() + + expect(this.view.model.interactions.toggleLike.callCount).toBe(1) + }) + }) +})