discourse/spec/jobs/process_post_spec.rb
Sam f0a122a66c move job files so they live underneath app/ and not in lib/
introduce new setting email_always, that will force emails to send to users regardless of presence on site
2013-10-01 17:04:02 +10:00

38 lines
1.1 KiB
Ruby

require 'spec_helper'
require 'jobs/regular/process_post'
describe Jobs::ProcessPost do
it "returns when the post cannot be found" do
lambda { Jobs::ProcessPost.new.perform(post_id: 1, sync_exec: true) }.should_not raise_error
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)
end
end
end