Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor SolidusDefaults#add_pages via #add_page #15

Merged
merged 1 commit into from
Jun 21, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions lib/solidus_sitemap/solidus_defaults.rb
Original file line number Diff line number Diff line change
Expand Up @@ -47,17 +47,21 @@ def add_product(product, options = {})
end

def add_pages(options = {})
# TODO: this should be refactored to add_pages & add_page

Spree::Page.active.each do |page|
add(page.path, options.merge(lastmod: page.updated_at))
add_page(page, options.merge(attr: :path))
end if gem_available? 'spree_essential_cms'

Spree::Page.visible.each do |page|
add(page.slug, options.merge(lastmod: page.updated_at))
add_page(page, options.merge(attr: :slug))
end if gem_available? 'spree_static_content'
end

def add_page(page, options = {})
opts = options.merge(lastmod: page.updated_at)
attr = opts.delete(:attr)
add(page.send(attr), opts)
end

def add_taxons(options = {})
Spree::Taxon.roots.each { |taxon| add_taxon(taxon, options) }
end
Expand Down
2 changes: 1 addition & 1 deletion spec/lib/solidus_sitemap/solidus_defaults_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ def add(url, options)
expect(subject.entries).to include("/products")
end

it "includes avilable products" do
it "includes available products" do
subject.add_products

expect(subject.entries).to include("/products/#{available.slug}")
Expand Down