mirror of
https://github.com/discourse/discourse.git
synced 2025-03-26 07:05:40 +08:00
Merge pull request #5261 from xrav3nz/fix-rebake-match-rake
FIX: `post:rebake_match` rake task
This commit is contained in:
commit
efbd923f60
@ -58,10 +58,12 @@ task 'posts:rebake_match', [:pattern, :type, :delay] => [:environment] do |_, ar
|
|||||||
exit 1
|
exit 1
|
||||||
end
|
end
|
||||||
|
|
||||||
|
search = Post.raw_match(pattern, type)
|
||||||
|
|
||||||
rebaked = 0
|
rebaked = 0
|
||||||
total = search.count
|
total = search.count
|
||||||
|
|
||||||
Post.raw_match(pattern, type).find_each do |post|
|
search.find_each do |post|
|
||||||
rebake_post(post)
|
rebake_post(post)
|
||||||
print_status(rebaked += 1, total)
|
print_status(rebaked += 1, total)
|
||||||
sleep(delay) if delay
|
sleep(delay) if delay
|
||||||
|
@ -3,6 +3,9 @@ require 'highline/import'
|
|||||||
require 'highline/simulate'
|
require 'highline/simulate'
|
||||||
|
|
||||||
RSpec.describe "Post rake tasks" do
|
RSpec.describe "Post rake tasks" do
|
||||||
|
let!(:post) { Fabricate(:post, raw: 'The quick brown fox jumps over the lazy dog') }
|
||||||
|
let!(:tricky_post) { Fabricate(:post, raw: 'Today ^Today') }
|
||||||
|
|
||||||
before do
|
before do
|
||||||
Rake::Task.clear
|
Rake::Task.clear
|
||||||
Discourse::Application.load_tasks
|
Discourse::Application.load_tasks
|
||||||
@ -10,11 +13,7 @@ RSpec.describe "Post rake tasks" do
|
|||||||
end
|
end
|
||||||
|
|
||||||
describe 'remap' do
|
describe 'remap' do
|
||||||
let!(:tricky_post) { Fabricate(:post, raw: 'Today ^Today') }
|
|
||||||
|
|
||||||
it 'should remap posts' do
|
it 'should remap posts' do
|
||||||
post = Fabricate(:post, raw: "The quick brown fox jumps over the lazy dog")
|
|
||||||
|
|
||||||
HighLine::Simulate.with('y') do
|
HighLine::Simulate.with('y') do
|
||||||
Rake::Task['posts:remap'].invoke("brown", "red")
|
Rake::Task['posts:remap'].invoke("brown", "red")
|
||||||
end
|
end
|
||||||
@ -43,4 +42,16 @@ RSpec.describe "Post rake tasks" do
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
describe 'rebake_match' do
|
||||||
|
it 'rebakes matched posts' do
|
||||||
|
post.update_attributes(cooked: '')
|
||||||
|
|
||||||
|
HighLine::Simulate.with('y') do
|
||||||
|
Rake::Task['posts:rebake_match'].invoke('brown')
|
||||||
|
end
|
||||||
|
|
||||||
|
expect(post.reload.cooked).to eq('<p>The quick brown fox jumps over the lazy dog</p>')
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user