DEV: Add test for categories_breadcrumb (#8791)

This commit is contained in:
Dan Ungureanu 2020-01-28 12:50:27 +02:00 committed by GitHub
parent e0605029dc
commit 6e8a1ac09a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 25 additions and 0 deletions

View File

@ -0,0 +1,25 @@
# frozen_string_literal: true
require 'rails_helper'
describe TopicsHelper do
describe "#categories_breadcrumb" do
let(:user) { Fabricate(:user) }
let(:category) { Fabricate(:category_with_definition) }
let(:subcategory) { Fabricate(:category_with_definition, parent_category_id: category.id) }
let(:subsubcategory) { Fabricate(:category_with_definition, parent_category_id: subcategory.id) }
it "works with sub-sub-categories" do
SiteSetting.max_category_nesting = 3
topic = Fabricate(:topic, category: subsubcategory)
breadcrumbs = helper.categories_breadcrumb(topic)
expect(breadcrumbs.length).to eq(3)
expect(breadcrumbs[0][:name]).to eq(category.name)
expect(breadcrumbs[1][:name]).to eq(subcategory.name)
expect(breadcrumbs[2][:name]).to eq(subsubcategory.name)
end
end
end