Skip to content

Commit

Permalink
Fix specs to be compliant with recent changes on solidus
Browse files Browse the repository at this point in the history
The specs on `solidus_starter_frontend` were failing due
to recent improvements with taxon/taxonomy factories made
in the solidus repository, specifically related to:
solidusio/solidus#4851
This commit updates the specs to be compatible with the
latest changes and ensures that the test suite passes
successfully.
  • Loading branch information
rainerdema committed Mar 22, 2023
1 parent b10bd0e commit 0a24c9d
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 27 deletions.
29 changes: 7 additions & 22 deletions templates/spec/components/breadcrumbs_component_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,7 @@
end

context 'when the taxon is present' do
let(:parent) { nil }
let(:grandparent) { nil }
let(:taxon) { create(:taxon, name: 'some taxon', parent: parent) }
let(:taxon) { create(:taxon, name: 'some taxon') }

context 'when the current page is the root page' do
let(:request_url) { '/' }
Expand All @@ -43,25 +41,12 @@
context 'when the current page is not the root page' do
let(:request_url) { '/products' }

context 'when the taxon has no ancestors' do
let(:parent) { nil }

it 'renders a breadcrumb for the taxon' do
expect(breadcrumb_items.size).to eq(3)
expect(breadcrumb_items.last).to eq(taxon.name)
end
end

context 'when the taxon has ancestors' do
let(:grandparent) { create(:taxon, name: 'some grandparent', parent: nil) }
let(:parent) { create(:taxon, name: 'some parent', parent: grandparent) }

it 'renders a breadcrumb for the taxon and its ancestors' do
expect(breadcrumb_items.size).to eq(5)
expect(breadcrumb_items[-3]).to eq(grandparent.name)
expect(breadcrumb_items[-2]).to eq(parent.name)
expect(breadcrumb_items[-1]).to eq(taxon.name)
end
it 'renders a breadcrumb for the taxon and its ancestors' do
expect(breadcrumb_items.size).to eq(4)
expect(breadcrumb_items[-4]).to eq('Home')
expect(breadcrumb_items[-3]).to eq('Products')
expect(breadcrumb_items[-2]).to eq(taxon.parent.name) # default taxonomy taxon root
expect(breadcrumb_items[-1]).to eq(taxon.name)
end
end
end
Expand Down
6 changes: 4 additions & 2 deletions templates/spec/helpers/spree/base_helper_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@
RSpec.describe Spree::BaseHelper, type: :helper do
# Regression test for https://github.com/spree/spree/issues/2759
it "nested_taxons_path works with a Taxon object" do
taxon = create(:taxon, name: "iphone")
expect(nested_taxons_path(taxon)).to eq("/t/iphone")
taxonomy = create(:taxonomy, name: 'smartphone')
taxon = create(:taxon, taxonomy: taxonomy, name: "iphone")

expect(nested_taxons_path(taxon)).to eq("/t/smartphone/iphone")
end
end
6 changes: 3 additions & 3 deletions templates/spec/helpers/taxons_helper_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@

RSpec.describe TaxonsHelper, type: :helper do
describe '#taxon_seo_url' do
let(:taxon_permalink) { 'ruby-on-rails' }
let(:taxon) { create(:taxon, permalink: taxon_permalink) }
let(:taxonomy) { create(:taxonomy, name: 'Categories') }
let(:taxon) { create(:taxon, name: 'Clothing', taxonomy: taxonomy) }

it 'is the nested taxons path for the taxon' do
expect(taxon_seo_url(taxon)).to eq("/t/#{taxon_permalink}")
expect(taxon_seo_url(taxon)).to eq("/t/categories/clothing")
end
end
end

0 comments on commit 0a24c9d

Please sign in to comment.