DEV: Avoid repeating draft key logic in multiple places.

This commit is contained in:
Guo Xiang Tan 2020-05-12 11:13:18 +08:00
parent a009ec597d
commit 3c423faafd
No known key found for this signature in database
GPG Key ID: FBD110179AAC1F20
2 changed files with 3 additions and 4 deletions

View File

@ -303,7 +303,7 @@ class PostCreator
def draft_key
@draft_key ||= @opts[:draft_key]
@draft_key ||= @topic ? "topic_#{@topic.id}" : "new_topic"
@draft_key ||= @topic ? @topic.draft_key : Draft::NEW_TOPIC
end
def build_post_stats

View File

@ -301,9 +301,8 @@ describe PostCreator do
end
it 'creates post stats' do
Draft.set(user, 'new_topic', 0, "test")
Draft.set(user, 'new_topic', 0, "test1")
Draft.set(user, Draft::NEW_TOPIC, 0, "test")
Draft.set(user, Draft::NEW_TOPIC, 0, "test1")
begin
PostCreator.track_post_stats = true