From a12ca511c38adef26f0944e5c5af7c38e570092c Mon Sep 17 00:00:00 2001
From: Steffen van Bergerem <svbergerem@online.de>
Date: Fri, 10 Oct 2014 01:59:16 +0200
Subject: [PATCH] Convert close mentioned account cuke

---
 features/desktop/closes_account.feature   | 19 -------------------
 spec/controllers/posts_controller_spec.rb | 11 +++++++++++
 2 files changed, 11 insertions(+), 19 deletions(-)

diff --git a/features/desktop/closes_account.feature b/features/desktop/closes_account.feature
index 524714b0bb..0388943dda 100644
--- a/features/desktop/closes_account.feature
+++ b/features/desktop/closes_account.feature
@@ -16,22 +16,3 @@ Feature: Close account
     When I try to sign in manually
     Then I should be on the new user session page
     And I should see a flash message with a warning
-
-  Scenario: post display should not throw error when mention is removed for the user whose account is closed
-    Given following users exist:
-      | username    | email             |
-      | Bob Jones   | bob@bob.bob       |
-      | Alice Smith | alice@alice.alice |
-    And a user with email "bob@bob.bob" is connected with "alice@alice.alice"
-    And Alice has a post mentioning Bob
-
-    Then I sign in as "bob@bob.bob"
-    When I go to the users edit page
-    And I follow "close_account"
-    And I put in my password in "close_account_password" in the modal window
-    And I press "close_account_confirm" in the modal window
-    And I confirm the alert
-    Then I should be on the new user session page
-    When I sign in as "alice@alice.alice"
-    And I am on the home page
-    Then I should see "Bob Jones"
diff --git a/spec/controllers/posts_controller_spec.rb b/spec/controllers/posts_controller_spec.rb
index e3f7a6071c..246238484e 100644
--- a/spec/controllers/posts_controller_spec.rb
+++ b/spec/controllers/posts_controller_spec.rb
@@ -30,6 +30,17 @@ describe PostsController, :type => :controller do
         expect(response).to be_success
       end
 
+      it 'succeeds after removing a mention when closing the mentioned user\'s account' do
+        user = FactoryGirl.create(:user, :username => "user")
+        alice.share_with(user.person, alice.aspects.first)
+        msg = alice.build_post :status_message, text: "Mention @{User ; #{user.diaspora_handle}}", :public => true, :to => 'all'
+        msg.save!
+        expect(msg.mentioned_people.count).to eq(1)
+        user.destroy
+        get :show, "id" => msg.id
+        expect(response).to be_success
+      end
+
       it 'renders the application layout on mobile' do
         get :show, :id => @message.id, :format => :mobile
         expect(response).to render_template('layouts/application')
-- 
GitLab