mirror of
https://github.com/discourse/discourse.git
synced 2025-03-06 22:30:10 +08:00
FIX: change the unlisted/invisible topic state only when unhiding the first post
This commit is contained in:
parent
a036ac7bdc
commit
a8a0be0b34
@ -299,7 +299,7 @@ class Post < ActiveRecord::Base
|
|||||||
|
|
||||||
def unhide!
|
def unhide!
|
||||||
self.update_attributes(hidden: false, hidden_at: nil, hidden_reason_id: nil)
|
self.update_attributes(hidden: false, hidden_at: nil, hidden_reason_id: nil)
|
||||||
self.topic.update_attributes(visible: true)
|
self.topic.update_attributes(visible: true) if post_number == 1
|
||||||
save(validate: false)
|
save(validate: false)
|
||||||
publish_change_to_clients!(:acted)
|
publish_change_to_clients!(:acted)
|
||||||
end
|
end
|
||||||
|
@ -828,8 +828,10 @@ describe Post do
|
|||||||
describe ".unhide!" do
|
describe ".unhide!" do
|
||||||
before { SiteSetting.stubs(:unique_posts_mins).returns(5) }
|
before { SiteSetting.stubs(:unique_posts_mins).returns(5) }
|
||||||
|
|
||||||
it "will unhide the post" do
|
it "will unhide the first post & make the topic visible" do
|
||||||
post = create_post(user: Fabricate(:newuser))
|
hidden_topic = Fabricate(:topic, visible: false)
|
||||||
|
|
||||||
|
post = create_post(topic: hidden_topic)
|
||||||
post.update_columns(hidden: true, hidden_at: Time.now, hidden_reason_id: 1)
|
post.update_columns(hidden: true, hidden_at: Time.now, hidden_reason_id: 1)
|
||||||
post.reload
|
post.reload
|
||||||
|
|
||||||
@ -838,10 +840,30 @@ describe Post do
|
|||||||
post.expects(:publish_change_to_clients!).with(:acted)
|
post.expects(:publish_change_to_clients!).with(:acted)
|
||||||
|
|
||||||
post.unhide!
|
post.unhide!
|
||||||
|
|
||||||
post.reload
|
post.reload
|
||||||
|
hidden_topic.reload
|
||||||
|
|
||||||
post.hidden.should == false
|
post.hidden.should == false
|
||||||
|
hidden_topic.visible.should == true
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it "will unhide the post but will keep the topic invisible/unlisted" do
|
||||||
|
hidden_topic = Fabricate(:topic, visible: false)
|
||||||
|
first_post = create_post(topic: hidden_topic)
|
||||||
|
second_post = create_post(topic: hidden_topic)
|
||||||
|
|
||||||
|
second_post.update_columns(hidden: true, hidden_at: Time.now, hidden_reason_id: 1)
|
||||||
|
second_post.expects(:publish_change_to_clients!).with(:acted)
|
||||||
|
|
||||||
|
second_post.unhide!
|
||||||
|
|
||||||
|
second_post.reload
|
||||||
|
hidden_topic.reload
|
||||||
|
|
||||||
|
second_post.hidden.should == false
|
||||||
|
hidden_topic.visible.should == false
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user