From 823316d7f78e4ef22cc1cfd3880d58c39adac754 Mon Sep 17 00:00:00 2001
From: Steffen van Bergerem <svbergerem@online.de>
Date: Mon, 6 Oct 2014 01:09:00 +0200
Subject: [PATCH] Convert tag cukes to rspec tests

---
 features/desktop/tags.feature              | 13 -----------
 features/desktop/tags_and_comments.feature | 21 -----------------
 spec/controllers/tags_controller_spec.rb   | 26 +++++++++++++++++++++-
 3 files changed, 25 insertions(+), 35 deletions(-)
 delete mode 100644 features/desktop/tags.feature
 delete mode 100644 features/desktop/tags_and_comments.feature

diff --git a/features/desktop/tags.feature b/features/desktop/tags.feature
deleted file mode 100644
index cf438d97b4..0000000000
--- a/features/desktop/tags.feature
+++ /dev/null
@@ -1,13 +0,0 @@
-@javascript
-Feature: Interacting with tags
-
-  Background:
-    Given there is a user "Samuel Beckett" who's tagged "#rockstar"
-    And I am signed in
-    And I am on the homepage
-
-  Scenario: Searching for a tag
-    When I search for "#rockstar"
-    Then I should be on the tag page for "rockstar"
-    And I should see "Samuel Beckett"
-
diff --git a/features/desktop/tags_and_comments.feature b/features/desktop/tags_and_comments.feature
deleted file mode 100644
index 35111cc22d..0000000000
--- a/features/desktop/tags_and_comments.feature
+++ /dev/null
@@ -1,21 +0,0 @@
-@javascript
-Feature: Issue #3382 The comments under postings are missing when using the #tags -view
-
-  Background:
-    Given a user named "Bob Jones" with email "bob@bob.bob"
-    And I sign in as "bob@bob.bob"
-    When I post a status with the text "This is a post with a #tag"
-    And I am on the homepage
-
-  Scenario:
-    When I search for "#tag"
-    Then I should be on the tag page for "tag"
-    And I should see "This is a post with a #tag"
-
-  Scenario:
-    When I comment "this is a comment on my post" on "This is a post with a #tag"
-    And I search for "#tag"
-    Then I should be on the tag page for "tag"
-    And I should see "this is a comment on my post"
-
-
diff --git a/spec/controllers/tags_controller_spec.rb b/spec/controllers/tags_controller_spec.rb
index f2eef5b72b..06ccdf6eab 100644
--- a/spec/controllers/tags_controller_spec.rb
+++ b/spec/controllers/tags_controller_spec.rb
@@ -47,9 +47,22 @@ describe TagsController, :type => :controller do
       end
     end
 
+    context 'with a tagged user' do
+      before do
+        bob.profile.tag_string = "#cats #diaspora #rad"
+        bob.profile.build_tags
+        bob.profile.save!
+      end
+
+      it 'includes the tagged user' do
+        get :show, :name => 'cats'
+        expect(response.body).to include(bob.diaspora_handle)
+      end
+    end
+
     context 'with a tagged post' do
       before do
-        eve.post(:status_message, text: "#what #yes #hellyes #foo", public: true, to: 'all')
+        @post = eve.post(:status_message, text: "#what #yes #hellyes #foo tagged post", public: true, to: 'all')
       end
 
       context 'signed in' do
@@ -66,6 +79,17 @@ describe TagsController, :type => :controller do
           get :show, :name => 'hellyes'
           expect(response.status).to eq(200)
         end
+
+        it 'includes the tagged post' do
+          get :show, :name => 'foo'
+          expect(assigns[:stream].posts.first.text).to include("tagged post")
+        end
+
+        it 'includes comments of the tagged post' do
+          alice.comment!(@post, "comment on a tagged post")
+          get :show, :name => 'foo', :format => 'json'
+          expect(response.body).to include("comment on a tagged post")
+        end
       end
 
       context "not signed in" do
-- 
GitLab