From 71bae103170975c05d309b658cc59c4347027553 Mon Sep 17 00:00:00 2001 From: danielgrippi Date: Sat, 31 Dec 2011 19:13:47 -0500 Subject: [PATCH] fixed notification specs; removed a cuke around reshares already tested in jasmine --- app/models/comment.rb | 2 +- features/reshare.feature | 28 +---------------- .../app/views/feedback_view_spec.js | 30 +++++++++---------- 3 files changed, 17 insertions(+), 43 deletions(-) diff --git a/app/models/comment.rb b/app/models/comment.rb index 7ec5b236e..f8de11dad 100644 --- a/app/models/comment.rb +++ b/app/models/comment.rb @@ -65,7 +65,7 @@ class Comment < ActiveRecord::Base def notification_type(user, person) if self.post.author == user.person - + return Notifications::CommentOnPost elsif self.post.comments.where(:author_id => user.person.id) != [] && self.author_id != user.person.id return Notifications::AlsoCommented else diff --git a/features/reshare.feature b/features/reshare.feature index 1f0c5c485..a9e764c69 100644 --- a/features/reshare.feature +++ b/features/reshare.feature @@ -25,24 +25,6 @@ Feature: public repost Then I should see a ".reshare" And I should see "Bob" - # (NOTE) this should be a jasmine spec - # assert that it is added to app.stream's collection - Scenario: When I reshare, it shows up in my stream - Given "bob@bob.bob" has a public post with text "reshare this!" - And I sign in as "alice@alice.alice" - And I preemptively confirm the alert - And I follow "Reshare" - And I wait for the ajax to finish - - # NOTE(why do we need this to make this work?) - And I wait for 2 seconds - And I go to the home page - - And I wait for the ajax to finish - Then I should see a ".reshare" - And I should see "reshare this!" - And I should see "Bob" - # (NOTE) this should be a jasmine spec Scenario: I can see the number of reshares Given "bob@bob.bob" has a public post with text "reshare this!" @@ -51,15 +33,7 @@ Feature: public repost And I preemptively confirm the alert And I follow "Reshare" - # NOTE(why do we need this to make this work?) - And I wait for 2 seconds - When I go to the home page - - Then I should see a ".reshare" - And I should see "reshare this!" - And I should see "Bob" - - # NOTE(why do we need this to make this work?) And I wait for 2 seconds When I go to the home page + And I wait for the ajax to finish Then I should see "1 reshare" diff --git a/spec/javascripts/app/views/feedback_view_spec.js b/spec/javascripts/app/views/feedback_view_spec.js index 524e6a52a..d22e547c4 100644 --- a/spec/javascripts/app/views/feedback_view_spec.js +++ b/spec/javascripts/app/views/feedback_view_spec.js @@ -113,26 +113,26 @@ describe("app.views.Feedback", function(){ expect($(this.view.el).html()).not.toContain('reshare_action') }) }) + }) - context("reshares", function(){ - beforeEach(function(){ - this.post.attributes.public = true - this.post.attributes.root = {author : {name : "susan"}}; - this.view.render(); - }) + describe("resharePost", function(){ + beforeEach(function(){ + this.post.attributes.public = true + this.post.attributes.root = {author : {name : "susan"}}; + this.view.render(); + }) - it("displays a confirmation dialog", function(){ - spyOn(window, "confirm") + it("displays a confirmation dialog", function(){ + spyOn(window, "confirm") - this.view.$(".reshare_action").first().click(); - expect(window.confirm).toHaveBeenCalled(); - }) + this.view.$(".reshare_action").first().click(); + expect(window.confirm).toHaveBeenCalled(); + }) - it("creates a reshare if the confirmation dialog is accepted", function(){ - spyOn(window, "confirm").andReturn(true); + it("creates a reshare if the confirmation dialog is accepted", function(){ + spyOn(window, "confirm").andReturn(true); - expect(this.view.resharePost().constructor).toBe(app.models.Reshare); - }) + expect(this.view.resharePost().constructor).toBe(app.models.Reshare); }) }) })