fix spec (#10061)
This commit is contained in:
parent
6caad5c083
commit
9518d6b587
|
@ -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
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue