FIX: Changing owner of small action post failed
Small action posts for invites (CC from email) have a blank raw and revising of posts with blank raw didn't work anymore.
This commit is contained in:
parent
502b1316d0
commit
f8ded9cec9
|
@ -121,8 +121,6 @@ class PostRevisor
|
|||
|
||||
@topic_changes = TopicChanges.new(@topic, editor)
|
||||
|
||||
return false if @fields.has_key?(:raw) && @fields[:raw].blank?
|
||||
|
||||
# some normalization
|
||||
@fields[:raw] = cleanup_whitespaces(@fields[:raw]) if @fields.has_key?(:raw)
|
||||
@fields[:user_id] = @fields[:user_id].to_i if @fields.has_key?(:user_id)
|
||||
|
@ -207,7 +205,7 @@ class PostRevisor
|
|||
end
|
||||
|
||||
def cleanup_whitespaces(raw)
|
||||
TextCleaner.normalize_whitespaces(raw).gsub(/\s+\z/, "")
|
||||
raw.present? ? TextCleaner.normalize_whitespaces(raw).gsub(/\s+\z/, "") : ""
|
||||
end
|
||||
|
||||
def should_revise?
|
||||
|
|
|
@ -36,19 +36,31 @@ describe UserMerger do
|
|||
end
|
||||
|
||||
it "changes owner of personal messages" do
|
||||
pm_topic = Fabricate(:private_message_topic)
|
||||
pm_topic = Fabricate(:private_message_topic, topic_allowed_users: [
|
||||
Fabricate.build(:topic_allowed_user, user: target_user),
|
||||
Fabricate.build(:topic_allowed_user, user: walter),
|
||||
Fabricate.build(:topic_allowed_user, user: source_user)
|
||||
])
|
||||
|
||||
post1 = Fabricate(:post, topic: pm_topic, user: source_user)
|
||||
post2 = Fabricate(:post, topic: pm_topic, user: walter)
|
||||
post3 = Fabricate(:post, topic: pm_topic, user: target_user)
|
||||
post4 = Fabricate(:post, topic: pm_topic, user: source_user, deleted_at: Time.now)
|
||||
|
||||
small1 = pm_topic.add_small_action(source_user, "invited_user", "carol")
|
||||
small2 = pm_topic.add_small_action(target_user, "invited_user", "david")
|
||||
small3 = pm_topic.add_small_action(walter, "invited_user", "eve")
|
||||
|
||||
merge_users!
|
||||
|
||||
expect(post1.reload.user).to eq(target_user)
|
||||
expect(post2.reload.user).to eq(walter)
|
||||
expect(post3.reload.user).to eq(target_user)
|
||||
expect(post4.reload.user).to eq(target_user)
|
||||
|
||||
expect(small1.reload.user).to eq(target_user)
|
||||
expect(small2.reload.user).to eq(target_user)
|
||||
expect(small3.reload.user).to eq(walter)
|
||||
end
|
||||
|
||||
it "changes owner of categories" do
|
||||
|
|
Loading…
Reference in New Issue