From bddd7c717b6778e7aebe54138dd486fa53e9e98a Mon Sep 17 00:00:00 2001
From: Andrej Kacian <andrej@kacian.sk>
Date: Tue, 9 Aug 2011 19:53:28 +0200
Subject: [PATCH] Write jasmine test for the tag unfollow icon visibility

---
 spec/controllers/aspects_controller_spec.rb |  7 +++++++
 spec/javascripts/support/jasmine.yml        |  1 +
 spec/javascripts/tag-followings-spec.js     | 22 +++++++++++++++++++++
 3 files changed, 30 insertions(+)
 create mode 100644 spec/javascripts/tag-followings-spec.js

diff --git a/spec/controllers/aspects_controller_spec.rb b/spec/controllers/aspects_controller_spec.rb
index 6de8a360c3..c358b4eb1d 100644
--- a/spec/controllers/aspects_controller_spec.rb
+++ b/spec/controllers/aspects_controller_spec.rb
@@ -70,6 +70,13 @@ describe AspectsController do
       save_fixture(html_for("body"), "aspects_index_with_posts")
     end
 
+    it 'generates a jasmine fixture with a followed tag' do
+      @tag = ActsAsTaggableOn::Tag.create!(:name => "partytimeexcellent")
+      TagFollowing.create!(:tag => @tag, :user => alice )
+      get :index
+      save_fixture(html_for("body"), "aspects_index_with_one_followed_tag")
+    end
+
     context 'with getting_started = true' do
       before do
         alice.getting_started = true
diff --git a/spec/javascripts/support/jasmine.yml b/spec/javascripts/support/jasmine.yml
index a5f54a7594..a17b09bcda 100644
--- a/spec/javascripts/support/jasmine.yml
+++ b/spec/javascripts/support/jasmine.yml
@@ -43,6 +43,7 @@ src_files:
   - public/javascripts/rails.js
   - public/javascripts/aspect-filters.js
   - public/javascripts/content-updater.js
+  - public/javascripts/tag-followings.js
 # stylesheets
 #
 # Return an array of stylesheet filepaths relative to src_dir to include before jasmine specs.
diff --git a/spec/javascripts/tag-followings-spec.js b/spec/javascripts/tag-followings-spec.js
new file mode 100644
index 0000000000..f26b2c37a6
--- /dev/null
+++ b/spec/javascripts/tag-followings-spec.js
@@ -0,0 +1,22 @@
+/*   Copyright (c) 2011, Diaspora Inc.  This file is
+*   licensed under the Affero General Public License version 3 or later.  See
+*   the COPYRIGHT file.
+*/
+
+describe("TagFollowings", function() {
+  describe("unfollow", function(){
+    it("tests unfollow icon visibility on mouseover event", function(){
+      spec.loadFixture('aspects_index_with_one_followed_tag');
+      TagFollowings.initialize();
+
+      var tag_li = $('li.unfollow#partytimeexcellent');
+      var icon_div = $('.unfollow_icon');
+
+      expect(icon_div.hasClass('hidden')).toBeTruthy();
+      tag_li.mouseover();
+      expect(icon_div.hasClass('hidden')).toBeFalsy();
+      tag_li.mouseout();
+      expect(icon_div.hasClass('hidden')).toBeTruthy();
+    });
+  });
+});
-- 
GitLab