FEATURE: remove support for 'suppress_from_latest' category setting. (#8308)

This commit is contained in:
Vinoth Kannan
2019-11-18 12:28:35 +05:30
committed by GitHub
parent 4e4844f4db
commit 3bb7ad4be1
20 changed files with 64 additions and 182 deletions

View File

@ -21,12 +21,6 @@ RSpec.describe ListController do
get "/latest?max_posts=bob"
expect(response.status).to eq(400)
get "/latest?exclude_category_ids=bob"
expect(response.status).to eq(400)
get "/latest?exclude_category_ids[]=bob"
expect(response.status).to eq(400)
get "/latest?max_posts=1111111111111111111111111111111111111111"
expect(response.status).to eq(400)
@ -41,10 +35,7 @@ RSpec.describe ListController do
end
it "returns 200 for legit requests" do
get "/latest.json?exclude_category_ids%5B%5D=69&exclude_category_ids%5B%5D=70&no_definitions=true&no_subcategories=false&page=1&_=1534296100767"
expect(response.status).to eq(200)
get "/latest.json?exclude_category_ids=-1"
get "/latest.json?no_definitions=true&no_subcategories=false&page=1&_=1534296100767"
expect(response.status).to eq(200)
get "/latest.json?max_posts=12"
@ -108,33 +99,6 @@ RSpec.describe ListController do
end
end
describe 'suppress from latest' do
it 'supresses categories' do
topic
get "/latest.json"
data = JSON.parse(response.body)
expect(data["topic_list"]["topics"].length).to eq(1)
get "/categories_and_latest.json"
data = JSON.parse(response.body)
expect(data["topic_list"]["topics"].length).to eq(1)
topic.category.suppress_from_latest = true
topic.category.save
get "/latest.json"
data = JSON.parse(response.body)
expect(data["topic_list"]["topics"].length).to eq(0)
get "/categories_and_latest.json"
data = JSON.parse(response.body)
expect(data["topic_list"]["topics"].length).to eq(0)
end
end
describe 'titles for crawler layout' do
it 'has no title for the default URL' do
topic
@ -650,29 +614,4 @@ RSpec.describe ListController do
expect(ListController.best_periods_for(nil, :daily)).to eq([:daily, :all])
end
end
describe "categories suppression" do
let(:category_one) { Fabricate(:category_with_definition) }
let(:sub_category) { Fabricate(:category_with_definition, parent_category: category_one, suppress_from_latest: true) }
let!(:topic_in_sub_category) { Fabricate(:topic, category: sub_category) }
let(:category_two) { Fabricate(:category_with_definition, suppress_from_latest: true) }
let!(:topic_in_category_two) { Fabricate(:topic, category: category_two) }
it "suppresses categories from the latest list" do
get "/#{SiteSetting.homepage}.json"
expect(response.status).to eq(200)
topic_titles = JSON.parse(response.body)["topic_list"]["topics"].map { |t| t["title"] }
expect(topic_titles).not_to include(topic_in_sub_category.title, topic_in_category_two.title)
end
it "does not suppress" do
get "/#{SiteSetting.homepage}.json", params: { category: category_one.id }
expect(response.status).to eq(200)
topic_titles = JSON.parse(response.body)["topic_list"]["topics"].map { |t| t["title"] }
expect(topic_titles).to include(topic_in_sub_category.title)
end
end
end