solidus_static_content 1.0.0 → 2.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +5 -5
- data/.gem_release.yml +5 -0
- data/.github/dependabot.yml +11 -0
- data/.github/workflows/lint.yml +29 -0
- data/.github/workflows/test.yml +25 -0
- data/.gitignore +18 -6
- data/.rspec +2 -3
- data/.standard.yml +6 -0
- data/CHANGELOG.md +110 -0
- data/Gemfile +48 -7
- data/Guardfile +9 -7
- data/README.md +94 -69
- data/Rakefile +4 -13
- data/app/assets/stylesheets/spree/frontend/solidus_static_content.css +7 -0
- data/app/assets/stylesheets/spree/frontend/spree_static_content.css +2 -7
- data/app/helpers/spree/pages_helper.rb +9 -5
- data/app/models/solidus_static_content/permission_sets/page_display.rb +21 -0
- data/app/models/solidus_static_content/permission_sets/page_management.rb +21 -0
- data/app/models/spree/page.rb +36 -37
- data/app/overrides/solidus_static_content/pages_in_footer.rb +11 -0
- data/app/overrides/solidus_static_content/pages_in_header.rb +11 -0
- data/app/overrides/solidus_static_content/pages_in_sidebar.rb +11 -0
- data/bin/console +17 -0
- data/bin/r +9 -0
- data/bin/rails +7 -6
- data/bin/rails-engine +15 -0
- data/bin/rails-sandbox +17 -0
- data/bin/rake +7 -0
- data/bin/sandbox +77 -0
- data/bin/sandbox_rails +9 -0
- data/bin/setup +8 -0
- data/config/locales/de.yml +7 -5
- data/config/locales/en.yml +7 -6
- data/config/locales/es-MX.yml +38 -0
- data/config/locales/es.yml +6 -5
- data/config/locales/et.yml +6 -5
- data/config/locales/fr.yml +7 -5
- data/config/locales/it.yml +6 -5
- data/config/locales/nl.yml +7 -5
- data/config/locales/pl.yml +6 -5
- data/config/locales/pt-BR.yml +6 -5
- data/config/locales/pt.yml +7 -5
- data/config/locales/ro.yml +11 -9
- data/config/locales/ru.yml +7 -5
- data/config/locales/sv.yml +7 -5
- data/config/routes.rb +13 -3
- data/db/migrate/20081216193152_create_pages.rb +3 -1
- data/db/migrate/20090625125735_extend_pages.rb +10 -9
- data/db/migrate/20090814113100_add_visible_to_pages.rb +6 -4
- data/db/migrate/20090814142845_add_default_true_to_visible_for_page.rb +5 -3
- data/db/migrate/20090829000527_add_index_for_page.rb +3 -2
- data/db/migrate/20091219021134_add_meta_fields_to_pages.rb +3 -1
- data/db/migrate/20100204105222_add_layout_to_pages.rb +4 -2
- data/db/migrate/20100323085528_add_show_in_sidebar_option_to_pages.rb +5 -3
- data/db/migrate/20110717103112_add_meta_title_to_page.rb +3 -1
- data/db/migrate/20120723144115_add_render_as_partial_for_layout_for_spree_pages.rb +9 -7
- data/db/migrate/20140926121757_add_pages_stores.rb +3 -3
- data/db/migrate/20180305193240_update_spree_page_position.rb +15 -0
- data/lib/controllers/backend/spree/admin/pages_controller.rb +22 -0
- data/lib/controllers/frontend/spree/static_content_controller.rb +32 -0
- data/lib/generators/solidus_static_content/install/install_generator.rb +35 -5
- data/lib/generators/solidus_static_content/install/templates/app/controllers/static_content_controller.rb +28 -0
- data/lib/generators/solidus_static_content/install/templates/app/views/static_content/show.html.erb +28 -0
- data/lib/solidus_static_content/engine.rb +43 -0
- data/lib/solidus_static_content/route_matcher.rb +15 -0
- data/lib/solidus_static_content/testing_support/factories.rb +18 -0
- data/lib/solidus_static_content/version.rb +5 -0
- data/lib/solidus_static_content.rb +5 -20
- data/lib/views/backend/spree/admin/pages/_form.html.erb +119 -0
- data/lib/views/backend/spree/admin/pages/edit.html.erb +32 -0
- data/lib/views/backend/spree/admin/pages/index.html.erb +68 -0
- data/lib/views/backend/spree/admin/pages/new.html.erb +31 -0
- data/lib/views/backend/spree/admin/shared/_pages_tabs.html.erb +9 -0
- data/{app/views → lib/views/frontend}/spree/static_content/_static_content_sidebar.html.erb +1 -1
- data/lib/views/frontend/spree/static_content/show.html.erb +18 -0
- data/solidus_static_content.gemspec +35 -31
- metadata +75 -184
- data/.travis.yml +0 -21
- data/app/assets/javascripts/spree/backend/spree_static_content.js +0 -1
- data/app/assets/javascripts/spree/frontend/spree_static_content.js +0 -1
- data/app/assets/stylesheets/spree/backend/spree_static_content.css +0 -3
- data/app/controllers/spree/admin/pages_controller.rb +0 -3
- data/app/controllers/spree/static_content_controller.rb +0 -20
- data/app/overrides/pages_in_footer.rb +0 -5
- data/app/overrides/pages_in_header.rb +0 -5
- data/app/overrides/pages_in_menu.rb +0 -5
- data/app/overrides/pages_in_sidebar.rb +0 -5
- data/app/views/spree/admin/pages/_form.html.erb +0 -98
- data/app/views/spree/admin/pages/edit.html.erb +0 -18
- data/app/views/spree/admin/pages/index.html.erb +0 -51
- data/app/views/spree/admin/pages/new.html.erb +0 -18
- data/app/views/spree/static_content/show.html.erb +0 -26
- data/lib/spree_static_content/engine.rb +0 -17
- data/spec/controllers/static_content_controller_spec.rb +0 -37
- data/spec/factories/page_factory.rb +0 -18
- data/spec/features/admin/pages_spec.rb +0 -67
- data/spec/features/static_content_spec.rb +0 -53
- data/spec/helpers/page_helper_spec.rb +0 -14
- data/spec/lib/spree_static.content_spec.rb +0 -34
- data/spec/models/page_spec.rb +0 -46
- data/spec/spec_helper.rb +0 -50
- /data/{LICENSE.md → LICENSE} +0 -0
- /data/{app/views → lib/views/frontend}/spree/static_content/_static_content_footer.html.erb +0 -0
- /data/{app/views → lib/views/frontend}/spree/static_content/_static_content_header.html.erb +0 -0
- /data/{app/views → lib/views/frontend}/spree/static_content/_static_content_list.html.erb +0 -0
|
@@ -1,98 +0,0 @@
|
|
|
1
|
-
<div data-hook="admin_page_form_fields">
|
|
2
|
-
<div class="left eight columns alpha" data-hook="admin_page_form_left">
|
|
3
|
-
|
|
4
|
-
<%= f.field_container :title do %>
|
|
5
|
-
<%= f.label :title %> <span class="required">*</span><br />
|
|
6
|
-
<%= f.text_field :title, :class => 'fullwidth title' %>
|
|
7
|
-
<%= f.error_message_on :title %>
|
|
8
|
-
<% end %>
|
|
9
|
-
|
|
10
|
-
<%= f.field_container :slug do %>
|
|
11
|
-
<%= f.label :slug %> <span class="required">*</span><br />
|
|
12
|
-
<%= f.text_field :slug, :class => 'fullwidth title' %>
|
|
13
|
-
<%= f.error_message_on :slug %>
|
|
14
|
-
<% end %>
|
|
15
|
-
|
|
16
|
-
<%= f.field_container :body do %>
|
|
17
|
-
<%= f.label :body %> <span class="required">*</span><br />
|
|
18
|
-
<%= f.text_area :body, {rows: 12, :class => 'fullwidth'} %>
|
|
19
|
-
<%= f.error_message_on :body %>
|
|
20
|
-
<% end %>
|
|
21
|
-
|
|
22
|
-
</div>
|
|
23
|
-
<div class="right four columns omega" data-hook="admin_page_form_right">
|
|
24
|
-
|
|
25
|
-
<%= f.field_container :layout do %>
|
|
26
|
-
<%= f.label :layout %><br />
|
|
27
|
-
<%= f.text_field :layout, :class => 'fullwidth title' %>
|
|
28
|
-
<% end %>
|
|
29
|
-
|
|
30
|
-
<%= f.field_container :foreign_link do %>
|
|
31
|
-
<%= f.label :foreign_link %><br />
|
|
32
|
-
<%= f.text_field :foreign_link, :class => 'fullwidth title' %>
|
|
33
|
-
<% end %>
|
|
34
|
-
|
|
35
|
-
<%= f.field_container :position do %>
|
|
36
|
-
<%= f.label :position %><br />
|
|
37
|
-
<%= f.number_field :position, :min => 0, :class => 'fullwidth title' %>
|
|
38
|
-
<% end %>
|
|
39
|
-
|
|
40
|
-
<%= f.field_container :show_in_sidebar do %>
|
|
41
|
-
<%= f.check_box :show_in_sidebar %>
|
|
42
|
-
<%= f.label :show_in_sidebar %>
|
|
43
|
-
<% end %>
|
|
44
|
-
|
|
45
|
-
<%= f.field_container :show_in_heade do %>
|
|
46
|
-
<%= f.check_box :show_in_header %>
|
|
47
|
-
<%= f.label :show_in_header %>
|
|
48
|
-
<% end %>
|
|
49
|
-
|
|
50
|
-
<%= f.field_container :show_in_footer do %>
|
|
51
|
-
<%= f.check_box :show_in_footer %>
|
|
52
|
-
<%= f.label :show_in_footer %>
|
|
53
|
-
<% end %>
|
|
54
|
-
|
|
55
|
-
<%= f.field_container :visible do %>
|
|
56
|
-
<%= f.check_box :visible %>
|
|
57
|
-
<%= f.label :visible %>
|
|
58
|
-
<% end %>
|
|
59
|
-
|
|
60
|
-
<%= f.field_container :render_layout_as_partial do %>
|
|
61
|
-
<%= f.check_box :render_layout_as_partial %>
|
|
62
|
-
<%= f.label :render_layout_as_partial %>
|
|
63
|
-
<% end %>
|
|
64
|
-
|
|
65
|
-
<%= f.field_container :stores do %>
|
|
66
|
-
<%= f.label :stores, Spree.t(:stores)%><br />
|
|
67
|
-
<% Spree::Store.all.each do |store| %>
|
|
68
|
-
<%= check_box_tag "page[store_ids][]", store.id, @page.stores.include?(store) %> <%= store.name %>
|
|
69
|
-
<% end %>
|
|
70
|
-
<% end %>
|
|
71
|
-
|
|
72
|
-
</div>
|
|
73
|
-
|
|
74
|
-
<div data-hook="admin_page_form_meta" class="alpha omega twelve columns">
|
|
75
|
-
|
|
76
|
-
<%= f.field_container :meta_title do %>
|
|
77
|
-
<%= f.label :meta_title %><br />
|
|
78
|
-
<%= f.text_field :meta_title, :class => 'fullwidth title' %>
|
|
79
|
-
<%= f.error_message_on :meta_title %>
|
|
80
|
-
<% end %>
|
|
81
|
-
|
|
82
|
-
<%= f.field_container :meta_keywords do %>
|
|
83
|
-
<%= f.label :meta_keywords %><br />
|
|
84
|
-
<%= f.text_field :meta_keywords, :class => 'fullwidth title' %>
|
|
85
|
-
<%= f.error_message_on :meta_keywords %>
|
|
86
|
-
<% end %>
|
|
87
|
-
|
|
88
|
-
<%= f.field_container :meta_description do %>
|
|
89
|
-
<%= f.label :meta_description %><br />
|
|
90
|
-
<%= f.text_field :meta_description, :class => 'fullwidth title' %>
|
|
91
|
-
<%= f.error_message_on :meta_description %>
|
|
92
|
-
<% end %>
|
|
93
|
-
|
|
94
|
-
</div>
|
|
95
|
-
<div class="clear"></div>
|
|
96
|
-
<div data-hook="admin_page_form_additional_fields"></div>
|
|
97
|
-
<div class="clear"></div>
|
|
98
|
-
</div>
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
<%= render 'spree/admin/shared/configuration_menu' %>
|
|
2
|
-
|
|
3
|
-
<% content_for :page_title do %>
|
|
4
|
-
<%= Spree.t("static_content.static_pages") %> <i class="icon-arrow-right"></i> <%= Spree.t("static_content.editing_page") %> "<%= @page.title%>"
|
|
5
|
-
<% end %>
|
|
6
|
-
|
|
7
|
-
<% content_for :page_actions do %>
|
|
8
|
-
<li><%= button_link_to Spree.t(:back_to_static_pages_list), spree.admin_pages_url, :icon => 'icon-arrow-left' %></li>
|
|
9
|
-
<% end %>
|
|
10
|
-
|
|
11
|
-
<%= render "spree/shared/error_messages", :target => @page %>
|
|
12
|
-
|
|
13
|
-
<%= form_for [:admin, @page] do |f| %>
|
|
14
|
-
<fieldset class="no-border-top">
|
|
15
|
-
<%= render :partial => 'form', :locals => { :f => f } %>
|
|
16
|
-
<%= render :partial => 'spree/admin/shared/edit_resource_links' %>
|
|
17
|
-
</fieldset>
|
|
18
|
-
<% end %>
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
<% content_for :page_actions do %>
|
|
2
|
-
<li><%= button_link_to Spree.t("static_content.new_page"), new_object_url, :icon => 'icon-plus', :id => 'admin_new_page' %></li>
|
|
3
|
-
<% end %>
|
|
4
|
-
|
|
5
|
-
<% content_for :page_title do %>
|
|
6
|
-
<%= Spree.t("static_content.static_pages") %>
|
|
7
|
-
<% end %>
|
|
8
|
-
|
|
9
|
-
<% if @pages.any? %>
|
|
10
|
-
<table class="index responsive" id="listing_pages" data-hook>
|
|
11
|
-
<colgroup>
|
|
12
|
-
<col style="width: 40%">
|
|
13
|
-
<col style="width: 35%">
|
|
14
|
-
<col style="width: 10%">
|
|
15
|
-
<col style="width: 15%">
|
|
16
|
-
</colgroup>
|
|
17
|
-
<thead>
|
|
18
|
-
<tr data-hook="admin_pages_index_headers">
|
|
19
|
-
<th><%= Spree::Page.human_attribute_name(:title) %></th>
|
|
20
|
-
<th><%= Spree.t("static_content.link") %></th>
|
|
21
|
-
<th><%= Spree::Page.human_attribute_name(:visible) %></th>
|
|
22
|
-
<th data-hook="admin_pages_index_header_actions" class="actions"></th>
|
|
23
|
-
</tr>
|
|
24
|
-
</thead>
|
|
25
|
-
|
|
26
|
-
<tbody>
|
|
27
|
-
<% @pages.each do |page| %>
|
|
28
|
-
<tr data-hook="admin_pages_index_rows" class="<%= cycle('odd', 'even') %>" id="<%= dom_id page %>">
|
|
29
|
-
<td>
|
|
30
|
-
<%= page.title %>
|
|
31
|
-
</td>
|
|
32
|
-
<td>
|
|
33
|
-
<%= link_to page.link, page.link, :target => '_blank' %>
|
|
34
|
-
</td>
|
|
35
|
-
<td class="align-center">
|
|
36
|
-
<%= content_tag(:i, '', :class => 'icon-ok green') if page.visible %>
|
|
37
|
-
</td>
|
|
38
|
-
<td class="actions" data-hook="admin_pages_index_row_actions">
|
|
39
|
-
<%= link_to_edit page, :no_text => true %>
|
|
40
|
-
<%= link_to_delete page, :no_text => true %>
|
|
41
|
-
</td>
|
|
42
|
-
</tr>
|
|
43
|
-
<% end %>
|
|
44
|
-
</tbody>
|
|
45
|
-
</table>
|
|
46
|
-
<% else %>
|
|
47
|
-
<div class="alpha twelve columns no-objects-found">
|
|
48
|
-
<%= Spree.t(:no_resource_found, resource: I18n.t(:other, scope: 'activerecord.models.spree/page')) %>,
|
|
49
|
-
<%= link_to Spree.t(:add_one), spree.new_admin_page_path %>!
|
|
50
|
-
</div>
|
|
51
|
-
<% end %>
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
<%= render 'spree/admin/shared/configuration_menu' %>
|
|
2
|
-
|
|
3
|
-
<% content_for :page_title do %>
|
|
4
|
-
<%= Spree.t("static_content.static_pages") %> <i class="icon-arrow-right"></i> <%= Spree.t("static_content.new_page") %>
|
|
5
|
-
<% end %>
|
|
6
|
-
|
|
7
|
-
<% content_for :page_actions do %>
|
|
8
|
-
<li><%= button_link_to Spree.t(:back_to_static_pages_list), spree.admin_pages_url, :icon => 'icon-arrow-left' %></li>
|
|
9
|
-
<% end %>
|
|
10
|
-
|
|
11
|
-
<%= render "spree/shared/error_messages", :target => @page %>
|
|
12
|
-
|
|
13
|
-
<%= form_for [:admin, @page] do |f| %>
|
|
14
|
-
<fieldset class="no-border-top">
|
|
15
|
-
<%= render :partial => 'form', :locals => { :f => f } %>
|
|
16
|
-
<%= render :partial => 'spree/admin/shared/new_resource_links' %>
|
|
17
|
-
</fieldset>
|
|
18
|
-
<% end %>
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
<% if @page.layout.present? and @page.render_layout_as_partial? %>
|
|
2
|
-
<%= render :partial => @page.layout %>
|
|
3
|
-
<% else %>
|
|
4
|
-
<% content_for :head do -%>
|
|
5
|
-
<%- if @page.meta_title.present? -%>
|
|
6
|
-
<meta name="title" content="<%=@page.meta_title%>">
|
|
7
|
-
<%- else -%>
|
|
8
|
-
<meta name="title" content="<%=@page.title%>">
|
|
9
|
-
<%- end -%>
|
|
10
|
-
<meta name="keywords" content="<%=@page.meta_keywords%>">
|
|
11
|
-
<meta name="description" content="<%=@page.meta_description%>">
|
|
12
|
-
<% end -%>
|
|
13
|
-
|
|
14
|
-
<% content_for :sidebar do %>
|
|
15
|
-
<% if defined? @products && defined? @taxon %>
|
|
16
|
-
<%= render :partial => "spree/shared/filters" %>
|
|
17
|
-
<% elsif defined? @taxonomies %>
|
|
18
|
-
<%= render :partial => "spree/shared/taxonomies" %>
|
|
19
|
-
<% end %>
|
|
20
|
-
<% end %>
|
|
21
|
-
|
|
22
|
-
<h1><%= @page.title %></h1>
|
|
23
|
-
<div id="page_content">
|
|
24
|
-
<%= raw @page.body %>
|
|
25
|
-
</div>
|
|
26
|
-
<% end %>
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
module SpreeStaticContent
|
|
2
|
-
class Engine < Rails::Engine
|
|
3
|
-
require 'spree/core'
|
|
4
|
-
isolate_namespace Spree
|
|
5
|
-
engine_name 'spree_static_content'
|
|
6
|
-
|
|
7
|
-
config.autoload_paths += %W(#{config.root}/lib)
|
|
8
|
-
|
|
9
|
-
def self.activate
|
|
10
|
-
Dir.glob(File.join(File.dirname(__FILE__), "../../app/overrides/*.rb")) do |c|
|
|
11
|
-
Rails.configuration.cache_classes ? require(c) : load(c)
|
|
12
|
-
end
|
|
13
|
-
end
|
|
14
|
-
|
|
15
|
-
config.to_prepare &method(:activate).to_proc
|
|
16
|
-
end
|
|
17
|
-
end
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
require 'spec_helper'
|
|
2
|
-
|
|
3
|
-
describe Spree::StaticContentController, type: :controller do
|
|
4
|
-
before do
|
|
5
|
-
controller.stub spree_current_user: nil
|
|
6
|
-
end
|
|
7
|
-
|
|
8
|
-
let!(:store) { create(:store, default: true) }
|
|
9
|
-
|
|
10
|
-
context '#show' do
|
|
11
|
-
it 'accepts path as root' do
|
|
12
|
-
page = create(:page, slug: '/', stores: [store])
|
|
13
|
-
request.path = page.slug
|
|
14
|
-
spree_get :show, path: page.slug
|
|
15
|
-
expect(response).to be_success
|
|
16
|
-
end
|
|
17
|
-
|
|
18
|
-
it 'accepts path as string' do
|
|
19
|
-
page = create(:page, slug: 'hello', stores: [store])
|
|
20
|
-
request.path = page.slug
|
|
21
|
-
spree_get :show, path: page.slug
|
|
22
|
-
expect(response).to be_success
|
|
23
|
-
end
|
|
24
|
-
|
|
25
|
-
it 'accepts path as nested' do
|
|
26
|
-
page = create(:page, slug: 'aa/bb/cc', stores: [store])
|
|
27
|
-
request.path = page.slug
|
|
28
|
-
spree_get :show, path: page.slug
|
|
29
|
-
expect(response).to be_success
|
|
30
|
-
end
|
|
31
|
-
|
|
32
|
-
it 'respond with a 404 when no page exists' do
|
|
33
|
-
spree_get :show
|
|
34
|
-
expect(response.response_code).to eq(404)
|
|
35
|
-
end
|
|
36
|
-
end
|
|
37
|
-
end
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
FactoryGirl.define do
|
|
2
|
-
factory :page, class: Spree::Page do
|
|
3
|
-
title { generate(:random_string) }
|
|
4
|
-
body { generate(:random_description) }
|
|
5
|
-
|
|
6
|
-
sequence(:slug) { |n| "/page#{n}" }
|
|
7
|
-
|
|
8
|
-
trait :with_foreign_link do
|
|
9
|
-
foreign_link do
|
|
10
|
-
if defined?(FFaker)
|
|
11
|
-
FFaker::Internet.http_url
|
|
12
|
-
else
|
|
13
|
-
Faker::Internet.http_url
|
|
14
|
-
end
|
|
15
|
-
end
|
|
16
|
-
end
|
|
17
|
-
end
|
|
18
|
-
end
|
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
require 'spec_helper'
|
|
2
|
-
|
|
3
|
-
RSpec.feature 'Admin Static Content', js: true do
|
|
4
|
-
stub_authorization!
|
|
5
|
-
|
|
6
|
-
context 'when no page exists' do
|
|
7
|
-
background do
|
|
8
|
-
visit spree.admin_path
|
|
9
|
-
click_link 'Pages'
|
|
10
|
-
end
|
|
11
|
-
|
|
12
|
-
scenario 'can create new page' do
|
|
13
|
-
expect(page).to have_text /No Pages found, Add One!/i
|
|
14
|
-
|
|
15
|
-
click_link 'New page'
|
|
16
|
-
expect(page).to have_text 'Static pages'
|
|
17
|
-
|
|
18
|
-
fill_in 'page_title', with: 'Contact us'
|
|
19
|
-
fill_in 'page_slug', with: 'contact-us'
|
|
20
|
-
fill_in 'page_body', with: 'hello..'
|
|
21
|
-
|
|
22
|
-
fill_in 'page_meta_title', with: 'Contact us'
|
|
23
|
-
fill_in 'page_meta_keywords', with: 'spree, contact'
|
|
24
|
-
fill_in 'page_meta_description', with: 'Short description for contact page.'
|
|
25
|
-
|
|
26
|
-
check 'page_show_in_sidebar'
|
|
27
|
-
check 'page_show_in_header'
|
|
28
|
-
check 'page_show_in_footer'
|
|
29
|
-
|
|
30
|
-
expect(find('#page_visible')).to be_checked
|
|
31
|
-
|
|
32
|
-
click_button 'Create'
|
|
33
|
-
expect(page).to have_text 'successfully created!'
|
|
34
|
-
end
|
|
35
|
-
end
|
|
36
|
-
|
|
37
|
-
context 'when page exists' do
|
|
38
|
-
given!(:static_page) { create(:page) }
|
|
39
|
-
|
|
40
|
-
background do
|
|
41
|
-
visit spree.admin_path
|
|
42
|
-
click_link 'Pages'
|
|
43
|
-
end
|
|
44
|
-
|
|
45
|
-
scenario 'can be updated' do
|
|
46
|
-
within_row(1) do
|
|
47
|
-
click_icon :edit
|
|
48
|
-
end
|
|
49
|
-
|
|
50
|
-
fill_in 'page_title', with: 'Contact'
|
|
51
|
-
fill_in 'page_slug', with: 'contact'
|
|
52
|
-
|
|
53
|
-
click_button 'Update'
|
|
54
|
-
expect(page).to have_text 'successfully updated!'
|
|
55
|
-
end
|
|
56
|
-
|
|
57
|
-
scenario 'can be deleted' do
|
|
58
|
-
within_row(1) do
|
|
59
|
-
click_icon :trash
|
|
60
|
-
end
|
|
61
|
-
|
|
62
|
-
page.driver.browser.switch_to.alert.accept unless Capybara.javascript_driver == :poltergeist
|
|
63
|
-
|
|
64
|
-
expect(page).not_to have_text static_page.title
|
|
65
|
-
end
|
|
66
|
-
end
|
|
67
|
-
end
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
require 'spec_helper'
|
|
2
|
-
|
|
3
|
-
feature 'Static Content Page', js: true do
|
|
4
|
-
|
|
5
|
-
let!(:store) { create(:store, default: true) }
|
|
6
|
-
|
|
7
|
-
context 'render page' do
|
|
8
|
-
scenario 'is a query string' do
|
|
9
|
-
create(:page, slug: '/page', title: 'Query Test', stores: [store])
|
|
10
|
-
visit '/page?test'
|
|
11
|
-
expect(page).to have_text 'Query Test'
|
|
12
|
-
end
|
|
13
|
-
|
|
14
|
-
scenario 'can have slug not starting by /' do
|
|
15
|
-
create(:page, slug: 'page2', title: 'No Slash Prefix Test', stores: [store])
|
|
16
|
-
visit '/page2'
|
|
17
|
-
expect(page).to have_text 'No Slash Prefix Test'
|
|
18
|
-
end
|
|
19
|
-
|
|
20
|
-
scenario 'can have slug with multiple /' do
|
|
21
|
-
create(:page, slug: '/hello/shoppers/page3', title: 'Multiple Slash Test', stores: [store])
|
|
22
|
-
visit '/hello/shoppers/page3'
|
|
23
|
-
expect(page).to have_text 'Multiple Slash Test'
|
|
24
|
-
end
|
|
25
|
-
|
|
26
|
-
scenario 'can be a custom root page' do
|
|
27
|
-
create(:page, slug: '/', title: 'Root Page Test', stores: [store])
|
|
28
|
-
visit '/'
|
|
29
|
-
expect(page).to have_text 'Root Page Test'
|
|
30
|
-
end
|
|
31
|
-
|
|
32
|
-
scenario 'is limited within its own constraints' do
|
|
33
|
-
create(:page, slug: '/t/categories/page3', title: 'Constraint Test', stores: [store])
|
|
34
|
-
visit '/t/categories/page3'
|
|
35
|
-
expect(page).not_to have_text 'Constraint Test'
|
|
36
|
-
end
|
|
37
|
-
|
|
38
|
-
scenario 'fetch correct page' do
|
|
39
|
-
create(:page, slug: '/', stores: [store])
|
|
40
|
-
create(:page, slug: 'hello', title: 'Hello', stores: [store])
|
|
41
|
-
create(:page, slug: 'somwhere', stores: [store])
|
|
42
|
-
create(:page, :with_foreign_link, slug: 'whatever', stores: [store])
|
|
43
|
-
visit '/hello'
|
|
44
|
-
expect(page).to have_text 'Hello'
|
|
45
|
-
end
|
|
46
|
-
|
|
47
|
-
scenario 'do not effect the rendering of the rest of the site' do
|
|
48
|
-
product = create(:product)
|
|
49
|
-
visit spree.product_path(product)
|
|
50
|
-
expect(page).to have_text product.name
|
|
51
|
-
end
|
|
52
|
-
end
|
|
53
|
-
end
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
require 'spec_helper'
|
|
2
|
-
|
|
3
|
-
RSpec.describe Spree::PagesHelper, type: :helper do
|
|
4
|
-
context '.render_snippet' do
|
|
5
|
-
it 'return body when page exists' do
|
|
6
|
-
page = create(:page)
|
|
7
|
-
expect(render_snippet(page.slug)).to eq page.body
|
|
8
|
-
end
|
|
9
|
-
|
|
10
|
-
it 'return nil when no page exist' do
|
|
11
|
-
expect(render_snippet('hello')).to be_nil
|
|
12
|
-
end
|
|
13
|
-
end
|
|
14
|
-
end
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
require 'spec_helper'
|
|
2
|
-
|
|
3
|
-
describe StaticPage do
|
|
4
|
-
context '.remove_spree_mount_point' do
|
|
5
|
-
specify do
|
|
6
|
-
path = '/hello'
|
|
7
|
-
expect(subject.remove_spree_mount_point(path)).to eq 'hello'
|
|
8
|
-
end
|
|
9
|
-
end
|
|
10
|
-
end
|
|
11
|
-
|
|
12
|
-
describe Spree::StaticPage do
|
|
13
|
-
subject { described_class }
|
|
14
|
-
|
|
15
|
-
context '.matches?' do
|
|
16
|
-
it 'is true when valid page' do
|
|
17
|
-
page = create(:page, slug: 'hello', visible: true)
|
|
18
|
-
request = double('request', path: page.slug)
|
|
19
|
-
expect(subject.matches?(request)).to be true
|
|
20
|
-
end
|
|
21
|
-
|
|
22
|
-
it 'is false when using reserved slug name' do
|
|
23
|
-
page = create(:page, slug: 'login', visible: true)
|
|
24
|
-
request = double('request', path: page.slug)
|
|
25
|
-
expect(subject.matches?(request)).to be false
|
|
26
|
-
end
|
|
27
|
-
|
|
28
|
-
it 'is false when page is not accessible' do
|
|
29
|
-
page = create(:page, slug: 'hello', visible: false)
|
|
30
|
-
request = double('request', path: page.slug)
|
|
31
|
-
expect(subject.matches?(request)).to be false
|
|
32
|
-
end
|
|
33
|
-
end
|
|
34
|
-
end
|
data/spec/models/page_spec.rb
DELETED
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
require 'spec_helper'
|
|
2
|
-
|
|
3
|
-
describe Spree::Page do
|
|
4
|
-
let!(:page) { create(:page) }
|
|
5
|
-
|
|
6
|
-
context 'factory' do
|
|
7
|
-
it 'is valid' do
|
|
8
|
-
expect(page).to be_valid
|
|
9
|
-
end
|
|
10
|
-
end
|
|
11
|
-
|
|
12
|
-
it 'always add / prefix to slug' do
|
|
13
|
-
page = create(:page, slug: 'hello')
|
|
14
|
-
expect(page.slug).to eq '/hello'
|
|
15
|
-
end
|
|
16
|
-
|
|
17
|
-
context '.link' do
|
|
18
|
-
it 'return slug if foreign_link blank' do
|
|
19
|
-
page = create(:page, slug: 'hello')
|
|
20
|
-
expect(page.link).to eq page.slug
|
|
21
|
-
end
|
|
22
|
-
|
|
23
|
-
it 'return foreign_link if set' do
|
|
24
|
-
page = create(:page, :with_foreign_link, slug: 'hello')
|
|
25
|
-
expect(page.link).to eq page.foreign_link
|
|
26
|
-
end
|
|
27
|
-
end
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
context "pages in stores" do
|
|
31
|
-
|
|
32
|
-
before(:each) do
|
|
33
|
-
@store = create(:store)
|
|
34
|
-
@page = create(:page, :stores => [@store])
|
|
35
|
-
@page2 = create(:page)
|
|
36
|
-
end
|
|
37
|
-
|
|
38
|
-
it 'should correctly find pages by store' do
|
|
39
|
-
pages_by_store = Spree::Page.by_store(@store)
|
|
40
|
-
expect(pages_by_store).to include(@page)
|
|
41
|
-
expect(pages_by_store).to_not include(@page2)
|
|
42
|
-
end
|
|
43
|
-
|
|
44
|
-
end
|
|
45
|
-
|
|
46
|
-
end
|
data/spec/spec_helper.rb
DELETED
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
require 'simplecov'
|
|
2
|
-
SimpleCov.start 'rails'
|
|
3
|
-
|
|
4
|
-
ENV["RAILS_ENV"] = "test"
|
|
5
|
-
|
|
6
|
-
require File.expand_path("../dummy/config/environment.rb", __FILE__)
|
|
7
|
-
|
|
8
|
-
require 'ffaker'
|
|
9
|
-
require 'rspec/rails'
|
|
10
|
-
require 'database_cleaner'
|
|
11
|
-
require 'capybara/rspec'
|
|
12
|
-
require 'capybara/rails'
|
|
13
|
-
require 'capybara/poltergeist'
|
|
14
|
-
|
|
15
|
-
Dir[Rails.root.join("spec/support/**/*.rb")].each {|f| require f}
|
|
16
|
-
|
|
17
|
-
require 'spree/testing_support/factories'
|
|
18
|
-
require 'spree/testing_support/url_helpers'
|
|
19
|
-
require 'spree/testing_support/controller_requests'
|
|
20
|
-
require 'spree/testing_support/authorization_helpers'
|
|
21
|
-
require 'spree/testing_support/capybara_ext'
|
|
22
|
-
|
|
23
|
-
FactoryGirl.find_definitions
|
|
24
|
-
|
|
25
|
-
RSpec.configure do |config|
|
|
26
|
-
config.mock_with :rspec
|
|
27
|
-
config.use_transactional_fixtures = false
|
|
28
|
-
|
|
29
|
-
config.include Spree::TestingSupport::ControllerRequests, type: :controller
|
|
30
|
-
config.include Spree::TestingSupport::UrlHelpers
|
|
31
|
-
config.include FactoryGirl::Syntax::Methods
|
|
32
|
-
|
|
33
|
-
config.extend Spree::TestingSupport::AuthorizationHelpers::Request, type: :feature
|
|
34
|
-
|
|
35
|
-
config.before(:suite) do
|
|
36
|
-
DatabaseCleaner.strategy = :transaction
|
|
37
|
-
DatabaseCleaner.clean_with(:truncation)
|
|
38
|
-
end
|
|
39
|
-
|
|
40
|
-
config.before(:each) do
|
|
41
|
-
DatabaseCleaner.strategy = RSpec.current_example.metadata[:js] ? :truncation : :transaction
|
|
42
|
-
DatabaseCleaner.start
|
|
43
|
-
end
|
|
44
|
-
|
|
45
|
-
config.after(:each) do
|
|
46
|
-
DatabaseCleaner.clean
|
|
47
|
-
end
|
|
48
|
-
|
|
49
|
-
Capybara.javascript_driver = :poltergeist
|
|
50
|
-
end
|
/data/{LICENSE.md → LICENSE}
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|