mirror of
https://github.com/discourse/discourse.git
synced 2024-11-25 10:20:58 -06:00
493d437e79
* Remove outdated option
04078317ba
* Use the non-globally exposed RSpec syntax
https://github.com/rspec/rspec-core/pull/2803
* Use the non-globally exposed RSpec syntax, cont
https://github.com/rspec/rspec-core/pull/2803
* Comply to strict predicate matchers
See:
- https://github.com/rspec/rspec-expectations/pull/1195
- https://github.com/rspec/rspec-expectations/pull/1196
- https://github.com/rspec/rspec-expectations/pull/1277
25 lines
970 B
Ruby
25 lines
970 B
Ruby
# frozen_string_literal: true
|
|
|
|
RSpec.describe CategoryDetailedSerializer do
|
|
|
|
describe "counts" do
|
|
it "works for categories with no subcategories" do
|
|
no_subcats = Fabricate(:category, topics_year: 10, topics_month: 5, topics_day: 2)
|
|
json = CategoryDetailedSerializer.new(no_subcats, scope: Guardian.new, root: false).as_json
|
|
expect(json[:topics_year]).to eq(10)
|
|
expect(json[:topics_month]).to eq(5)
|
|
expect(json[:topics_day]).to eq(2)
|
|
end
|
|
|
|
it "includes counts from subcategories" do
|
|
parent = Fabricate(:category, topics_year: 10, topics_month: 5, topics_day: 2)
|
|
subcategory = Fabricate(:category, parent_category_id: parent.id, topics_year: 1, topics_month: 1, topics_day: 1)
|
|
json = CategoryDetailedSerializer.new(parent, scope: Guardian.new, root: false).as_json
|
|
expect(json[:topics_year]).to eq(11)
|
|
expect(json[:topics_month]).to eq(6)
|
|
expect(json[:topics_day]).to eq(3)
|
|
end
|
|
end
|
|
|
|
end
|