db consistency check for mismatching topic_ids in user_actions

fix up post mover so it remaps user actions as well
move specs for post mover into post_mover_spec
This commit is contained in:
Sam
2013-07-17 16:40:15 +10:00
parent c2be81a76e
commit 81616a46ba
6 changed files with 226 additions and 175 deletions

View File

@@ -9,7 +9,6 @@ describe UserAction do
it { should validate_presence_of :action_type }
it { should validate_presence_of :user_id }
describe 'lists' do
let(:public_post) { Fabricate(:post) }
@@ -257,4 +256,26 @@ describe UserAction do
end
end
describe 'ensure_consistency!' do
it 'correct target_topic_id' do
post = Fabricate(:post)
action = UserAction.log_action!(
action_type: UserAction::NEW_PRIVATE_MESSAGE,
user_id: post.user.id,
acting_user_id: post.user.id,
target_topic_id: -1,
target_post_id: post.id,
)
action.reload
action.target_topic_id.should == -1
UserAction.ensure_consistency!
action.reload
action.target_topic_id.should == post.topic_id
end
end
end