This commit is contained in:
Joffrey JAFFEUX 2020-06-17 15:10:07 +02:00 committed by GitHub
parent 6caad5c083
commit 9518d6b587
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 27 additions and 13 deletions

View File

@ -312,22 +312,36 @@ describe TopicViewSerializer do
context "published_page" do context "published_page" do
fab!(:published_page) { Fabricate(:published_page, topic: topic) } fab!(:published_page) { Fabricate(:published_page, topic: topic) }
it "doesn't return the published page if not enabled" do context "page publishing is disabled" do
json = serialize_topic(topic, admin) before do
expect(json[:published_page]).to be_blank SiteSetting.enable_page_publishing = false
end
it "doesn't return the published page if not enabled" do
json = serialize_topic(topic, admin)
expect(json[:published_page]).to be_blank
end
end end
it "doesn't return the published page unless staff" do context "page publishing is enabled" do
SiteSetting.enable_page_publishing = true before do
json = serialize_topic(topic, user) SiteSetting.enable_page_publishing = true
expect(json[:published_page]).to be_blank end
end
it "returns the published page if enabled and staff" do context "not staff" do
SiteSetting.enable_page_publishing = true it "doesn't return the published page" do
json = serialize_topic(topic, admin) json = serialize_topic(topic, user)
expect(json[:published_page]).to be_present expect(json[:published_page]).to be_blank
expect(json[:published_page][:slug]).to eq("published-page-test") end
end
context "staff" do
it "returns the published page" do
json = serialize_topic(topic, admin)
expect(json[:published_page]).to be_present
expect(json[:published_page][:slug]).to eq(published_page.slug)
end
end
end end
end end