work in progress, will finalize soon
This commit is contained in:
parent
2162e3bbb5
commit
5e23a0681d
|
@ -248,8 +248,13 @@ SQL
|
||||||
builder.exec
|
builder.exec
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def self.synchronize_favorites
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
def self.ensure_consistency!
|
def self.ensure_consistency!
|
||||||
self.synchronize_target_topic_ids
|
self.synchronize_target_topic_ids
|
||||||
|
self.synchronize_favorites
|
||||||
end
|
end
|
||||||
|
|
||||||
protected
|
protected
|
||||||
|
|
|
@ -261,7 +261,23 @@ describe UserAction do
|
||||||
end
|
end
|
||||||
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
|
it 'correct target_topic_id' do
|
||||||
post = Fabricate(:post)
|
post = Fabricate(:post)
|
||||||
|
|
||||||
|
@ -281,11 +297,10 @@ describe UserAction do
|
||||||
target_post_id: post.id,
|
target_post_id: post.id,
|
||||||
)
|
)
|
||||||
|
|
||||||
UserAction.ensure_consistency!
|
UserAction.synchronize_target_topic_ids
|
||||||
|
|
||||||
action.reload
|
action.reload
|
||||||
action.target_topic_id.should == post.topic_id
|
action.target_topic_id.should == post.topic_id
|
||||||
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue