discourse/spec/jobs/process_post_spec.rb

38 lines
1.1 KiB
Ruby
Raw Normal View History

2013-02-05 14:16:51 -05:00
require 'spec_helper'
require 'jobs/regular/process_post'
2013-02-05 14:16:51 -05:00
describe Jobs::ProcessPost do
it "returns when the post cannot be found" do
2013-02-25 11:42:20 -05:00
lambda { Jobs::ProcessPost.new.perform(post_id: 1, sync_exec: true) }.should_not raise_error
2013-02-05 14:16:51 -05:00
end
context 'with a post' do
before do
@post = Fabricate(:post)
end
it 'calls process on a CookedPostProcessor' do
CookedPostProcessor.any_instance.expects(:post_process).once
Jobs::ProcessPost.new.execute(post_id: @post.id)
end
it 'updates the html if the dirty flag is true' do
CookedPostProcessor.any_instance.expects(:dirty?).returns(true)
CookedPostProcessor.any_instance.expects(:html).returns('test')
Post.any_instance.expects(:update_column).with(:cooked, 'test').once
Jobs::ProcessPost.new.execute(post_id: @post.id)
end
it "doesn't update the cooked content if dirty is false" do
CookedPostProcessor.any_instance.expects(:dirty?).returns(false)
Post.any_instance.expects(:update_column).never
Jobs::ProcessPost.new.execute(post_id: @post.id)
2013-02-25 11:42:20 -05:00
end
2013-02-05 14:16:51 -05:00
end
end