FIX: Load post revisions in correct order

This commit is contained in:
Gerhard Schlager 2018-05-28 11:24:54 +02:00
parent ef84099db1
commit ed2ae3cb0a
2 changed files with 2 additions and 3 deletions

View File

@ -4,6 +4,8 @@ class PostRevision < ActiveRecord::Base
belongs_to :post
belongs_to :user
default_scope { order('number ASC') }
serialize :modifications, Hash
after_create :create_notification

View File

@ -224,8 +224,6 @@ describe UsernameChanger do
end
it 'replaces mentions within revisions' do
skip("Erratically fails here raw is nil")
revisions = [{ raw: "Hello Foo" }, { title: "new topic title" }, { raw: "Hello @foo!" }, { raw: "Hello @foo!!" }]
post = create_post_and_change_username(raw: "Hello @foo", revisions: revisions)
@ -234,7 +232,6 @@ describe UsernameChanger do
expect(post.revisions.count).to eq(4)
# fails here sometimes with raw is nil
expect(post.revisions[0].modifications["raw"][0]).to eq("Hello @bar")
expect(post.revisions[0].modifications["raw"][1]).to eq("Hello Foo")
expect(post.revisions[0].modifications["cooked"][0]).to eq(%Q(<p>Hello <a class="mention" href="/u/bar">@bar</a></p>))