work in progress, will finalize soon

This commit is contained in:
Sam 2013-08-02 09:59:12 +10:00
parent 2162e3bbb5
commit 5e23a0681d
2 changed files with 23 additions and 3 deletions

View File

@ -248,8 +248,13 @@ SQL
builder.exec
end
def self.synchronize_favorites
end
def self.ensure_consistency!
self.synchronize_target_topic_ids
self.synchronize_favorites
end
protected

View File

@ -261,7 +261,23 @@ describe UserAction do
end
end
describe 'ensure_consistency!' do
describe 'synchronize_favorites' do
pending 'corrects out of sync favs' do
post = Fabricate(:post)
post.topic.toggle_star(post.user, true)
action1 = UserAction.log_action!(
action_type: UserAction::STAR,
user_id: post.user.id,
acting_user_id: post.user.id,
target_topic_id: -1,
target_post_id: post.id,
)
end
end
describe 'synchronize_target_topic_ids' do
it 'correct target_topic_id' do
post = Fabricate(:post)
@ -281,11 +297,10 @@ describe UserAction do
target_post_id: post.id,
)
UserAction.ensure_consistency!
UserAction.synchronize_target_topic_ids
action.reload
action.target_topic_id.should == post.topic_id
end
end
end