"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "spec/jobs/publish_topic_to_category_spec.rb" between
discourse-2.5.2.tar.gz and discourse-2.5.3.tar.gz

About: Discourse is a "next-generation" forum platform for community discussions.

publish_topic_to_category_spec.rb  (discourse-2.5.2):publish_topic_to_category_spec.rb  (discourse-2.5.3)
skipping to change at line 70 skipping to change at line 70
end end
end end
describe 'when topic is a private message' do describe 'when topic is a private message' do
it 'should publish the topic to the new category' do it 'should publish the topic to the new category' do
freeze_time 1.hour.ago do freeze_time 1.hour.ago do
expect { topic.convert_to_private_message(Discourse.system_user) } expect { topic.convert_to_private_message(Discourse.system_user) }
.to change { topic.private_message? }.to(true) .to change { topic.private_message? }.to(true)
end end
topic.allowed_users << topic.public_topic_timer.user
now = freeze_time now = freeze_time
message = MessageBus.track_publish do message = MessageBus.track_publish do
described_class.new.execute(topic_timer_id: topic.public_topic_timer.id) described_class.new.execute(topic_timer_id: topic.public_topic_timer.id)
end.last end.last
topic.reload topic.reload
expect(topic.category).to eq(another_category) expect(topic.category).to eq(another_category)
expect(topic.visible).to eq(true) expect(topic.visible).to eq(true)
expect(topic.private_message?).to eq(false) expect(topic.private_message?).to eq(false)
%w{created_at bumped_at updated_at last_posted_at}.each do |attribute| %w{created_at bumped_at updated_at last_posted_at}.each do |attribute|
expect(topic.public_send(attribute)).to eq_time(now) expect(topic.public_send(attribute)).to eq_time(now)
end end
expect(message.data[:reload_topic]).to be_present expect(message.data[:reload_topic]).to be_present
expect(message.data[:refresh_stream]).to be_present expect(message.data[:refresh_stream]).to be_present
end end
it "does nothing if the user can't see the PM" do
non_participant_TL4_user = Fabricate(:trust_level_4)
topic.convert_to_private_message(Discourse.system_user)
timer = topic.public_topic_timer
timer.update!(user: non_participant_TL4_user)
described_class.new.execute(topic_timer_id: topic.public_topic_timer.id)
topic.reload
expect(topic.private_message?).to eq(true)
expect(topic.category).not_to eq(another_category)
end
it "works if the user can see the PM" do
tl4_user = Fabricate(:trust_level_4)
topic.convert_to_private_message(Discourse.system_user)
topic.allowed_users << tl4_user
timer = topic.public_topic_timer
timer.update!(user: tl4_user)
described_class.new.execute(topic_timer_id: topic.public_topic_timer.id)
topic.reload
expect(topic.private_message?).to eq(false)
expect(topic.category).to eq(another_category)
end
end end
describe 'when new category has a default auto-close' do describe 'when new category has a default auto-close' do
it 'should apply the auto-close timer upon publishing' do it 'should apply the auto-close timer upon publishing' do
freeze_time freeze_time
another_category.update!(auto_close_hours: 5) another_category.update!(auto_close_hours: 5)
topic topic
described_class.new.execute(topic_timer_id: topic.public_topic_timer.id) described_class.new.execute(topic_timer_id: topic.public_topic_timer.id)
 End of changes. 2 change blocks. 
0 lines changed or deleted 31 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)