Bug Fix for #913 with Rspec and Cucumber test cases, for a scenario, where a user is mentioned on a post and when that user closes his account, then his contacts cannot see their homepages due to this post
This commit is contained in:
parent
ed8d4db3a8
commit
7c3a173010
3 changed files with 45 additions and 3 deletions
|
|
@ -39,7 +39,7 @@ class User < ActiveRecord::Base
|
|||
has_many :services
|
||||
has_many :user_preferences
|
||||
|
||||
before_destroy :disconnect_everyone, :remove_person
|
||||
before_destroy :disconnect_everyone, :remove_mentions, :remove_person
|
||||
before_save do
|
||||
person.save if person && person.changed?
|
||||
end
|
||||
|
|
@ -313,4 +313,11 @@ class User < ActiveRecord::Base
|
|||
}
|
||||
self.aspects.delete_all
|
||||
end
|
||||
|
||||
def remove_mentions
|
||||
Mention.where( :person_id => self.person.id).each do |mentioned_person|
|
||||
mentioned_person.delete
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
|||
|
|
@ -7,13 +7,32 @@ Feature: Close Account
|
|||
Scenario: user closes account
|
||||
Given I am signed in
|
||||
When I click on my name in the header
|
||||
And I follow "account settings"
|
||||
And I follow "account settings"
|
||||
And I click ok in the confirm dialog to appear next
|
||||
And I follow "Close Account"
|
||||
Then I should be on the home page
|
||||
|
||||
|
||||
When I go to the new user session page
|
||||
And I try to sign in
|
||||
Then I should be on the new user session page
|
||||
When I wait for the ajax to finish
|
||||
Then I should see "Invalid email or password."
|
||||
|
||||
Scenario: post display should not throw error when mention is removed for the user whose account is closed
|
||||
Given a user named "Bob Jones" with email "bob@bob.bob"
|
||||
And a user named "Alice Smith" with email "alice@alice.alice"
|
||||
And a user with email "bob@bob.bob" is connected with "alice@alice.alice"
|
||||
When I sign in as "alice@alice.alice"
|
||||
And I am on the home page
|
||||
And I expand the publisher
|
||||
And I fill in "status_message_fake_message" with "Hi, @{Bob Jones; bob_jones@example.org} long time no see"
|
||||
And I press "Share"
|
||||
And I log out
|
||||
Then I sign in as "bob@bob.bob"
|
||||
When I click on my name in the header
|
||||
And I follow "account settings"
|
||||
And I click ok in the confirm dialog to appear next
|
||||
And I follow "Close Account"
|
||||
Then I sign in as "alice@alice.alice"
|
||||
And I am on the home page
|
||||
Then I should see "Hi, Bob Jones long time no see"
|
||||
|
|
|
|||
|
|
@ -381,6 +381,11 @@ describe User do
|
|||
}.should change {alice.invitations_to_me(true).count }.by(-1)
|
||||
end
|
||||
|
||||
it 'should remove mentions' do
|
||||
alice.should_receive(:remove_mentions)
|
||||
alice.destroy
|
||||
end
|
||||
|
||||
it 'should remove person' do
|
||||
alice.should_receive(:remove_person)
|
||||
alice.destroy
|
||||
|
|
@ -421,6 +426,17 @@ describe User do
|
|||
end
|
||||
end
|
||||
|
||||
describe '#remove_mentions' do
|
||||
it 'should remove the mentions' do
|
||||
person = alice.person
|
||||
sm = Factory(:status_message)
|
||||
mention = Mention.create(:person => person, :post=> sm)
|
||||
alice.reload
|
||||
alice.destroy
|
||||
proc { mention.reload }.should raise_error ActiveRecord::RecordNotFound
|
||||
end
|
||||
end
|
||||
|
||||
describe '#disconnect_everyone' do
|
||||
|
||||
it 'has no error on a local friend who has deleted his account' do
|
||||
|
|
|
|||
Loading…
Reference in a new issue