Skip to content
Open
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
5 changes: 3 additions & 2 deletions plugins/ShinyCMS/lib/tasks/demo_site.rake
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,11 @@ namespace :shinycms do

load_demo_site_data_file

load_demo_site_extras

ShinyCMS::FeatureFlag.enable :user_login

puts 'Loaded demo site data and created admin account.'
puts "You can log in as '#{@shiny_admin.username}' now."
puts "Loaded demo site data and created admin account. You can log in as '#{@shiny_admin.username}' now."
# :nocov:
end

Expand Down
8 changes: 8 additions & 0 deletions plugins/ShinyCMS/lib/tasks/support/demo_site_task.rb
Original file line number Diff line number Diff line change
Expand Up @@ -139,5 +139,13 @@ def fix_primary_key_sequence( table_name )
COMMIT;
SQL
end

def load_demo_site_extras
ActiveStorage::Attachment.find_each do |attached|
name = attached.filename.to_s
file = Rails.public_path( 'public', 'images', name ).open
attached.record.image.attach io: file, filename: name
end
end
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ def stash_template
def strong_params
return if params[ :template ].blank?

params.expect( template: %i[ name description filename elements_attributes: {} ] )
params.expect( template: [ :name, :description, :filename, { elements_attributes: {} } ] )
end

def sort_elements
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ def stash_template_with_elements
def strong_params
return if params[ :template ].blank?

params.expect( template: %i[ name description filename elements_attributes: {} ] )
params.expect( template: [ :name, :description, :filename, { elements_attributes: {} } ] )
end

def sort_elements
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ def stash_template_with_elements
def strong_params
return if params[ :template ].blank?

params.expect( template: %i[ name description filename elements_attributes: {} ] )
params.expect( template: [ :name, :description, :filename, { elements_attributes: {} } ] )
end

def sort_elements
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,21 @@ def show
if just_purchased?
confirm_order
else
render 'show'
show_product
end
end

private

# Render the product with the appropriate template
def show_product
if @product.template.file_exists?
render template: "shiny_shop/products/#{@product.template.filename}", locals: @product.elements_hash
else
render status: :failed_dependency, inline: I18n.t( 'shiny_shop.products.template_file_missing' )
end
end

def find_section( path_parts, error: true )
section_scope = Section.top_level_sections

Expand Down
1 change: 1 addition & 0 deletions plugins/ShinyShop/app/models/shiny_shop/product.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ class Product < ApplicationRecord
include ShinyCMS::HasPublicName
include ShinyCMS::HasReadableName
include ShinyCMS::HasSlug
include ShinyCMS::HasTemplate

include ShinyCMS::ProvidesDemoSiteData

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,11 +69,10 @@
product = create( :product, active: true )

get shiny_shop.product_or_section_path( product.slug )

expect( response ).to have_http_status :ok
expect( response.body ).to have_title product.name

expect( response.body ).to have_css 'h2', text: product.name
expect( response.body ).to have_css 'h1', text: product.name
end

it 'displays products in different sections with same slug' do
Expand All @@ -88,14 +87,14 @@
expect( response ).to have_http_status :ok
expect( response.body ).to have_title product1.name

expect( response.body ).to have_css 'h2', text: product1.name
expect( response.body ).to have_css 'h1', text: product1.name

get shiny_shop.product_or_section_path( [ section2.slug, product2.slug ] )

expect( response ).to have_http_status :ok
expect( response.body ).to have_title product2.name

expect( response.body ).to have_css 'h2', text: product2.name
expect( response.body ).to have_css 'h1', text: product2.name
end

it 'displays product in deeply-nested sections' do
Expand All @@ -109,7 +108,7 @@
expect( response ).to have_http_status :ok
expect( response.body ).to have_title product1.name

expect( response.body ).to have_css 'h2', text: product1.name
expect( response.body ).to have_css 'h1', text: product1.name
end

it 'thanks user after successful checkout' do
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,12 @@
<h3><%= subheading %></h3>
</header>

<%#= sanitize html_content %>
<%= simple_format text_content %>
<%= sanitize html_content %>

<h1>
<%= html_content %>
</h1>
<%#= simple_format text_content %>
</section>

</div>
Expand Down