Fix the build.

This commit is contained in:
Guo Xiang Tan 2019-04-16 15:47:16 +08:00
parent 1056dd16d3
commit 784940bea0
5 changed files with 21 additions and 19 deletions

View File

@ -23,10 +23,8 @@ class TopicConverter
PostRevisor.new(@topic.first_post, @topic).revise!(
@user,
{
category_id: category_id,
archetype: Archetype.default
}
category_id: category_id,
archetype: Archetype.default
)
update_user_stats
@ -43,10 +41,8 @@ class TopicConverter
PostRevisor.new(@topic.first_post, @topic).revise!(
@user,
{
category_id: nil,
archetype: Archetype.private_message
}
category_id: nil,
archetype: Archetype.private_message
)
add_allowed_users

View File

@ -13,6 +13,8 @@ RSpec.describe Jobs::PublishTopicToCategory do
topic: topic
)
Fabricate(:post, topic: topic)
topic
end
@ -40,20 +42,18 @@ RSpec.describe Jobs::PublishTopicToCategory do
message = MessageBus.track_publish do
described_class.new.execute(topic_timer_id: topic.public_topic_timer.id)
end.find do |m|
Hash === m.data && m.data.key?(:reload_topic)
Hash === m.data && m.data.key?(:reload_topic) && m.data.key?(:refresh_stream)
end
topic.reload
expect(topic.category).to eq(another_category)
expect(topic.visible).to eq(true)
expect(topic.public_topic_timer).to eq(nil)
expect(message.channel).to eq("/topic/#{topic.id}")
%w{created_at bumped_at updated_at last_posted_at}.each do |attribute|
expect(topic.public_send(attribute)).to be_within(1.second).of(Time.zone.now)
end
expect(message.data[:reload_topic]).to be_present
expect(message.data[:refresh_stream]).to be_present
end
describe 'when topic is a private message' do

View File

@ -2287,10 +2287,15 @@ describe Topic do
let(:user) { Fabricate(:user) }
let(:topic) do
Fabricate(:private_message_topic, topic_allowed_users: [
Fabricate.build(:topic_allowed_user, user: robot),
Fabricate.build(:topic_allowed_user, user: user)
])
topic = Fabricate(:private_message_topic,
topic_allowed_users: [
Fabricate.build(:topic_allowed_user, user: robot),
Fabricate.build(:topic_allowed_user, user: user)
]
)
Fabricate(:post, topic: topic)
topic
end
describe 'when PM is between a human and a non human user' do

View File

@ -179,9 +179,7 @@ describe WebHook do
expect do
PostRevisor.new(post, post.topic).revise!(
post.user,
{
category_id: category.id,
}
category_id: category.id,
)
end.to change { Jobs::EmitWebHookEvent.jobs.length }.by(1)

View File

@ -2138,6 +2138,7 @@ RSpec.describe TopicsController do
describe 'converting public topic to private message' do
let(:user) { Fabricate(:user) }
let(:topic) { Fabricate(:topic, user: user) }
let!(:post) { Fabricate(:post, topic: topic) }
it "raises an error when the user doesn't have permission to convert topic" do
sign_in(Fabricate(:user))
@ -2164,6 +2165,7 @@ RSpec.describe TopicsController do
describe 'converting private message to public topic' do
let(:user) { Fabricate(:user) }
let(:topic) { Fabricate(:private_message_topic, user: user) }
let!(:post) { Fabricate(:post, topic: topic) }
it "raises an error when the user doesn't have permission to convert topic" do
sign_in(Fabricate(:user))
@ -2626,6 +2628,7 @@ RSpec.describe TopicsController do
describe "#publish" do
let(:category) { Fabricate(:category) }
let(:topic) { Fabricate(:topic, category: shared_drafts_category, visible: false) }
let!(:post) { Fabricate(:post, topic: topic) }
let(:shared_draft) { Fabricate(:shared_draft, topic: topic, category: category) }
let(:moderator) { Fabricate(:moderator) }