mirror of
https://github.com/codeninjasllc/discourse.git
synced 2024-11-27 09:36:19 -05:00
add specs for post ownership change without revision
This commit is contained in:
parent
03ce370d5e
commit
4a2f0e772c
3 changed files with 42 additions and 0 deletions
|
@ -323,6 +323,20 @@ describe PostRevisor do
|
||||||
expect(post.revisions.size).to eq(1)
|
expect(post.revisions.size).to eq(1)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
context 'passing skip_revision as true' do
|
||||||
|
before do
|
||||||
|
SiteSetting.stubs(:editing_grace_period).returns(1.minute.to_i)
|
||||||
|
subject.revise!(changed_by, { raw: 'yet another updated body' }, { revised_at: post.updated_at + 10.hours, skip_revision: true })
|
||||||
|
post.reload
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'does not create new revision ' do
|
||||||
|
expect(post.version).to eq(2)
|
||||||
|
expect(post.public_version).to eq(2)
|
||||||
|
expect(post.revisions.size).to eq(1)
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe "topic excerpt" do
|
describe "topic excerpt" do
|
||||||
|
|
|
@ -874,6 +874,27 @@ describe Post do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
describe "#set_owner" do
|
||||||
|
let(:post) { Fabricate(:post) }
|
||||||
|
let(:coding_horror) { Fabricate(:coding_horror) }
|
||||||
|
|
||||||
|
it "will change owner of a post correctly" do
|
||||||
|
post.set_owner(coding_horror, Discourse.system_user)
|
||||||
|
post.reload
|
||||||
|
|
||||||
|
expect(post.user).to eq(coding_horror)
|
||||||
|
expect(post.revisions.size).to eq(1)
|
||||||
|
end
|
||||||
|
|
||||||
|
it "skips creating new post revision if skip_revision is true" do
|
||||||
|
post.set_owner(coding_horror, Discourse.system_user, true)
|
||||||
|
post.reload
|
||||||
|
|
||||||
|
expect(post.user).to eq(coding_horror)
|
||||||
|
expect(post.revisions.size).to eq(0)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
describe ".rebake_old" do
|
describe ".rebake_old" do
|
||||||
it "will catch posts it needs to rebake" do
|
it "will catch posts it needs to rebake" do
|
||||||
post = create_post
|
post = create_post
|
||||||
|
|
|
@ -51,6 +51,13 @@ describe PostOwnerChanger do
|
||||||
expect(p2.user).not_to eq(user_a)
|
expect(p2.user).not_to eq(user_a)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it "skips creating new post revision if skip_revision is true" do
|
||||||
|
described_class.new(post_ids: [p1.id, p2.id], topic_id: topic.id, new_owner: user_a, acting_user: editor, skip_revision: true).change_owner!
|
||||||
|
p1.reload; p2.reload
|
||||||
|
expect(p1.revisions.size).to eq(0)
|
||||||
|
expect(p2.revisions.size).to eq(0)
|
||||||
|
end
|
||||||
|
|
||||||
context "integration tests" do
|
context "integration tests" do
|
||||||
let(:p1user) { p1.user }
|
let(:p1user) { p1.user }
|
||||||
let(:p2user) { p2.user }
|
let(:p2user) { p2.user }
|
||||||
|
|
Loading…
Reference in a new issue