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 :services
|
||||||
has_many :user_preferences
|
has_many :user_preferences
|
||||||
|
|
||||||
before_destroy :disconnect_everyone, :remove_person
|
before_destroy :disconnect_everyone, :remove_mentions, :remove_person
|
||||||
before_save do
|
before_save do
|
||||||
person.save if person && person.changed?
|
person.save if person && person.changed?
|
||||||
end
|
end
|
||||||
|
|
@ -313,4 +313,11 @@ class User < ActiveRecord::Base
|
||||||
}
|
}
|
||||||
self.aspects.delete_all
|
self.aspects.delete_all
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def remove_mentions
|
||||||
|
Mention.where( :person_id => self.person.id).each do |mentioned_person|
|
||||||
|
mentioned_person.delete
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -17,3 +17,22 @@ Feature: Close Account
|
||||||
Then I should be on the new user session page
|
Then I should be on the new user session page
|
||||||
When I wait for the ajax to finish
|
When I wait for the ajax to finish
|
||||||
Then I should see "Invalid email or password."
|
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)
|
}.should change {alice.invitations_to_me(true).count }.by(-1)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it 'should remove mentions' do
|
||||||
|
alice.should_receive(:remove_mentions)
|
||||||
|
alice.destroy
|
||||||
|
end
|
||||||
|
|
||||||
it 'should remove person' do
|
it 'should remove person' do
|
||||||
alice.should_receive(:remove_person)
|
alice.should_receive(:remove_person)
|
||||||
alice.destroy
|
alice.destroy
|
||||||
|
|
@ -421,6 +426,17 @@ describe User do
|
||||||
end
|
end
|
||||||
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
|
describe '#disconnect_everyone' do
|
||||||
|
|
||||||
it 'has no error on a local friend who has deleted his account' do
|
it 'has no error on a local friend who has deleted his account' do
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue