-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #12 from nebulab/vassalloandrea/add-solidus-static…
…-content-provider Add solidus static content content provider
- Loading branch information
Showing
7 changed files
with
68 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 11 additions & 0 deletions
11
lib/solidus_content/content_providers/solidus_static_content.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
# frozen_string_literal: true | ||
|
||
module SolidusContent::ContentProviders::SolidusStaticContent | ||
def self.call(input) | ||
slug = input.dig(:options, :slug) || input[:slug] | ||
|
||
input.merge(data: Spree::Page.find_by!(slug: slug).attributes.symbolize_keys) | ||
end | ||
|
||
SolidusContent.config.content_providers[:solidus_static_content] = self | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 28 additions & 0 deletions
28
spec/solidus_content/content_providers/solidus_static_content_spec.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
# frozen_string_literal: true | ||
|
||
require 'spec_helper' | ||
|
||
RSpec.describe SolidusContent::ContentProviders::SolidusStaticContent do | ||
let(:page) { create(:page) } | ||
|
||
context 'passing the slug in the options' do | ||
it 'returns static content data' do | ||
expect( | ||
described_class.call(slug: page.slug)[:data] | ||
).to eq(page.reload.attributes.symbolize_keys) | ||
end | ||
end | ||
|
||
context 'using the entry slug' do | ||
it 'returns static content data' do | ||
expect( | ||
described_class.call( | ||
slug: page.slug, | ||
options: { | ||
slug: page.slug | ||
} | ||
)[:data] | ||
).to eq(page.reload.attributes.symbolize_keys) | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters