From 5f705775cd9e0f93e72a067120f57681db894018 Mon Sep 17 00:00:00 2001 From: Steven Fuchs Date: Tue, 24 Jan 2012 23:04:35 -0500 Subject: [PATCH] spec to generate some notification fixtures and jasmine specs to test them. Notably making sure that start sharing items have an aspects popup menu. --- .../jasmine_fixtures/notifications_spec.rb | 37 +++++++++++++++++++ .../app/views/notification_view_spec.js | 30 +++++++++++++++ 2 files changed, 67 insertions(+) create mode 100644 spec/controllers/jasmine_fixtures/notifications_spec.rb create mode 100644 spec/javascripts/app/views/notification_view_spec.js diff --git a/spec/controllers/jasmine_fixtures/notifications_spec.rb b/spec/controllers/jasmine_fixtures/notifications_spec.rb new file mode 100644 index 000000000..bd26e0939 --- /dev/null +++ b/spec/controllers/jasmine_fixtures/notifications_spec.rb @@ -0,0 +1,37 @@ +# Copyright (c) 2010-2011, Diaspora Inc. This file is +# licensed under the Affero General Public License version 3 or later. See +# the COPYRIGHT file. + +require 'spec_helper' + +describe NotificationsController do + describe '#notifications' do + before do + sign_in :user, alice + end + + context 'jasmine fixtures' do + before do + end + + it "generates a jasmine fixture of two notifications", :fixture => true do + post = Factory(:status_message) + + Factory(:notification, :recipient => alice, :target => post) + Factory(:notification, :recipient => alice, :target => post) + get :index + save_fixture( html_for("body"), "notifications_index") + end + it "generates a jasmine fixture of with a start sharing notifcation from a contact", :fixture => true do + post = Factory(:status_message) + eve.share_with(alice.person, eve.aspects.first) + Factory(:notification, :recipient => alice, :target => post) + Factory(:notification, :recipient => alice, :target => post) + + get :index + save_fixture(html_for("body"), "notifications_index_with_sharing") + end + + end + end +end diff --git a/spec/javascripts/app/views/notification_view_spec.js b/spec/javascripts/app/views/notification_view_spec.js new file mode 100644 index 000000000..2acfeafa4 --- /dev/null +++ b/spec/javascripts/app/views/notification_view_spec.js @@ -0,0 +1,30 @@ +describe("app.views.Notification", function(){ + var pageText = null; + + + describe("render regular notifications", function(){ + beforeEach(function(){ + pageText = spec.readFixture("notifications_index"); + }); + + it("has two notifications", function(){ + expect( $( pageText ).find('.stream_element').length).toBe(2) + }); + it("has no aspects menu", function(){ + expect( $( pageText ).find('.dropdown_list').length).toBe(0) + }); + + }); + describe("render a start sharing notification", function(){ + beforeEach(function(){ + pageText = spec.readFixture("notifications_index_with_sharing"); + }); + + it("has three notifications", function(){ + expect( $( pageText ).find('.stream_element').length).toBe(3) + }); + it("has shows an aspect menu for the start sharing item", function(){ + expect( $( pageText ).find('.aspect_membership').length).toBe(1) + }); + }); +})