solidus_static_content 2.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 +4 -4
- data/.github/dependabot.yml +11 -0
- data/.github/workflows/lint.yml +29 -0
- data/.github/workflows/test.yml +25 -0
- data/.gitignore +1 -0
- data/.standard.yml +6 -0
- data/CHANGELOG.md +31 -1
- data/Gemfile +37 -16
- data/Guardfile +9 -7
- data/README.md +20 -8
- data/Rakefile +2 -2
- data/app/helpers/spree/pages_helper.rb +9 -5
- data/app/models/solidus_static_content/permission_sets/page_display.rb +10 -0
- data/app/models/solidus_static_content/permission_sets/page_management.rb +10 -0
- data/app/models/spree/page.rb +38 -34
- 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/r +1 -0
- data/bin/rails +1 -0
- data/bin/rails-engine +2 -0
- data/bin/rails-sandbox +2 -1
- data/bin/sandbox +18 -25
- data/bin/sandbox_rails +1 -0
- data/config/locales/en.yml +1 -2
- data/config/routes.rb +5 -2
- data/db/migrate/20081216193152_create_pages.rb +2 -0
- data/db/migrate/20090625125735_extend_pages.rb +9 -8
- data/db/migrate/20090814113100_add_visible_to_pages.rb +5 -3
- data/db/migrate/20090814142845_add_default_true_to_visible_for_page.rb +4 -2
- data/db/migrate/20090829000527_add_index_for_page.rb +2 -1
- data/db/migrate/20091219021134_add_meta_fields_to_pages.rb +2 -0
- data/db/migrate/20100204105222_add_layout_to_pages.rb +3 -1
- data/db/migrate/20100323085528_add_show_in_sidebar_option_to_pages.rb +4 -2
- data/db/migrate/20110717103112_add_meta_title_to_page.rb +2 -0
- data/db/migrate/20120723144115_add_render_as_partial_for_layout_for_spree_pages.rb +8 -6
- data/db/migrate/20140926121757_add_pages_stores.rb +3 -3
- data/db/migrate/20180305193240_update_spree_page_position.rb +8 -6
- data/lib/controllers/backend/spree/admin/pages_controller.rb +17 -11
- data/lib/controllers/frontend/spree/static_content_controller.rb +21 -13
- data/lib/generators/solidus_static_content/install/install_generator.rb +33 -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 +25 -17
- data/lib/solidus_static_content/route_matcher.rb +10 -6
- data/lib/solidus_static_content/{factories.rb → testing_support/factories.rb} +1 -1
- data/lib/solidus_static_content/version.rb +1 -1
- data/lib/solidus_static_content.rb +4 -7
- data/solidus_static_content.gemspec +16 -17
- metadata +23 -40
- data/.circleci/config.yml +0 -35
- data/.rubocop.yml +0 -2
- data/app/overrides/pages_in_footer.rb +0 -5
- data/app/overrides/pages_in_header.rb +0 -5
- data/app/overrides/pages_in_sidebar.rb +0 -5
- data/spec/controllers/spree/admin/pages_controller_spec.rb +0 -11
- data/spec/controllers/spree/static_content_controller_spec.rb +0 -34
- data/spec/features/spree/admin/pages_spec.rb +0 -70
- data/spec/features/spree/static_content_spec.rb +0 -55
- data/spec/helpers/spree/page_helper_spec.rb +0 -14
- data/spec/lib/solidus_static_content/engine_spec.rb +0 -14
- data/spec/lib/solidus_static_content/route_matcher_spec.rb +0 -25
- data/spec/models/spree/page_spec.rb +0 -61
- data/spec/spec_helper.rb +0 -27
metadata
CHANGED
|
@@ -1,15 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: solidus_static_content
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 2.
|
|
4
|
+
version: 2.1.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Peter Berkenbosch
|
|
8
8
|
- Roman Smirnov
|
|
9
|
-
autorequire:
|
|
10
9
|
bindir: exe
|
|
11
10
|
cert_chain: []
|
|
12
|
-
date:
|
|
11
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
|
13
12
|
dependencies:
|
|
14
13
|
- !ruby/object:Gem::Dependency
|
|
15
14
|
name: deface
|
|
@@ -34,7 +33,7 @@ dependencies:
|
|
|
34
33
|
version: 2.0.0
|
|
35
34
|
- - "<"
|
|
36
35
|
- !ruby/object:Gem::Version
|
|
37
|
-
version: '
|
|
36
|
+
version: '5'
|
|
38
37
|
type: :runtime
|
|
39
38
|
prerelease: false
|
|
40
39
|
version_requirements: !ruby/object:Gem::Requirement
|
|
@@ -44,35 +43,35 @@ dependencies:
|
|
|
44
43
|
version: 2.0.0
|
|
45
44
|
- - "<"
|
|
46
45
|
- !ruby/object:Gem::Version
|
|
47
|
-
version: '
|
|
46
|
+
version: '5'
|
|
48
47
|
- !ruby/object:Gem::Dependency
|
|
49
48
|
name: solidus_support
|
|
50
49
|
requirement: !ruby/object:Gem::Requirement
|
|
51
50
|
requirements:
|
|
52
51
|
- - "~>"
|
|
53
52
|
- !ruby/object:Gem::Version
|
|
54
|
-
version: '0.
|
|
53
|
+
version: '0.8'
|
|
55
54
|
type: :runtime
|
|
56
55
|
prerelease: false
|
|
57
56
|
version_requirements: !ruby/object:Gem::Requirement
|
|
58
57
|
requirements:
|
|
59
58
|
- - "~>"
|
|
60
59
|
- !ruby/object:Gem::Version
|
|
61
|
-
version: '0.
|
|
60
|
+
version: '0.8'
|
|
62
61
|
- !ruby/object:Gem::Dependency
|
|
63
62
|
name: solidus_dev_support
|
|
64
63
|
requirement: !ruby/object:Gem::Requirement
|
|
65
64
|
requirements:
|
|
66
|
-
- - "
|
|
65
|
+
- - "~>"
|
|
67
66
|
- !ruby/object:Gem::Version
|
|
68
|
-
version: '
|
|
67
|
+
version: '2.7'
|
|
69
68
|
type: :development
|
|
70
69
|
prerelease: false
|
|
71
70
|
version_requirements: !ruby/object:Gem::Requirement
|
|
72
71
|
requirements:
|
|
73
|
-
- - "
|
|
72
|
+
- - "~>"
|
|
74
73
|
- !ruby/object:Gem::Version
|
|
75
|
-
version: '
|
|
74
|
+
version: '2.7'
|
|
76
75
|
description: Manage the static pages of your Solidus store or replace existing pages
|
|
77
76
|
with a static version
|
|
78
77
|
email: peter@pero-ict.nl
|
|
@@ -80,11 +79,13 @@ executables: []
|
|
|
80
79
|
extensions: []
|
|
81
80
|
extra_rdoc_files: []
|
|
82
81
|
files:
|
|
83
|
-
- ".circleci/config.yml"
|
|
84
82
|
- ".gem_release.yml"
|
|
83
|
+
- ".github/dependabot.yml"
|
|
84
|
+
- ".github/workflows/lint.yml"
|
|
85
|
+
- ".github/workflows/test.yml"
|
|
85
86
|
- ".gitignore"
|
|
86
87
|
- ".rspec"
|
|
87
|
-
- ".
|
|
88
|
+
- ".standard.yml"
|
|
88
89
|
- CHANGELOG.md
|
|
89
90
|
- Gemfile
|
|
90
91
|
- Guardfile
|
|
@@ -97,9 +98,9 @@ files:
|
|
|
97
98
|
- app/models/solidus_static_content/permission_sets/page_display.rb
|
|
98
99
|
- app/models/solidus_static_content/permission_sets/page_management.rb
|
|
99
100
|
- app/models/spree/page.rb
|
|
100
|
-
- app/overrides/pages_in_footer.rb
|
|
101
|
-
- app/overrides/pages_in_header.rb
|
|
102
|
-
- app/overrides/pages_in_sidebar.rb
|
|
101
|
+
- app/overrides/solidus_static_content/pages_in_footer.rb
|
|
102
|
+
- app/overrides/solidus_static_content/pages_in_header.rb
|
|
103
|
+
- app/overrides/solidus_static_content/pages_in_sidebar.rb
|
|
103
104
|
- bin/console
|
|
104
105
|
- bin/r
|
|
105
106
|
- bin/rails
|
|
@@ -139,10 +140,12 @@ files:
|
|
|
139
140
|
- lib/controllers/backend/spree/admin/pages_controller.rb
|
|
140
141
|
- lib/controllers/frontend/spree/static_content_controller.rb
|
|
141
142
|
- lib/generators/solidus_static_content/install/install_generator.rb
|
|
143
|
+
- lib/generators/solidus_static_content/install/templates/app/controllers/static_content_controller.rb
|
|
144
|
+
- lib/generators/solidus_static_content/install/templates/app/views/static_content/show.html.erb
|
|
142
145
|
- lib/solidus_static_content.rb
|
|
143
146
|
- lib/solidus_static_content/engine.rb
|
|
144
|
-
- lib/solidus_static_content/factories.rb
|
|
145
147
|
- lib/solidus_static_content/route_matcher.rb
|
|
148
|
+
- lib/solidus_static_content/testing_support/factories.rb
|
|
146
149
|
- lib/solidus_static_content/version.rb
|
|
147
150
|
- lib/views/backend/spree/admin/pages/_form.html.erb
|
|
148
151
|
- lib/views/backend/spree/admin/pages/edit.html.erb
|
|
@@ -155,15 +158,6 @@ files:
|
|
|
155
158
|
- lib/views/frontend/spree/static_content/_static_content_sidebar.html.erb
|
|
156
159
|
- lib/views/frontend/spree/static_content/show.html.erb
|
|
157
160
|
- solidus_static_content.gemspec
|
|
158
|
-
- spec/controllers/spree/admin/pages_controller_spec.rb
|
|
159
|
-
- spec/controllers/spree/static_content_controller_spec.rb
|
|
160
|
-
- spec/features/spree/admin/pages_spec.rb
|
|
161
|
-
- spec/features/spree/static_content_spec.rb
|
|
162
|
-
- spec/helpers/spree/page_helper_spec.rb
|
|
163
|
-
- spec/lib/solidus_static_content/engine_spec.rb
|
|
164
|
-
- spec/lib/solidus_static_content/route_matcher_spec.rb
|
|
165
|
-
- spec/models/spree/page_spec.rb
|
|
166
|
-
- spec/spec_helper.rb
|
|
167
161
|
homepage: https://github.com/solidusio-contrib/solidus_static_content#readme
|
|
168
162
|
licenses:
|
|
169
163
|
- BSD-3-Clause
|
|
@@ -171,13 +165,12 @@ metadata:
|
|
|
171
165
|
homepage_uri: https://github.com/solidusio-contrib/solidus_static_content#readme
|
|
172
166
|
source_code_uri: https://github.com/solidusio-contrib/solidus_static_content#readme
|
|
173
167
|
changelog_uri: https://github.com/solidusio-contrib/solidus_static_content/releases
|
|
174
|
-
post_install_message:
|
|
175
168
|
rdoc_options: []
|
|
176
169
|
require_paths:
|
|
177
170
|
- lib
|
|
178
171
|
required_ruby_version: !ruby/object:Gem::Requirement
|
|
179
172
|
requirements:
|
|
180
|
-
- - "
|
|
173
|
+
- - ">="
|
|
181
174
|
- !ruby/object:Gem::Version
|
|
182
175
|
version: '2.5'
|
|
183
176
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
@@ -186,17 +179,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
186
179
|
- !ruby/object:Gem::Version
|
|
187
180
|
version: '0'
|
|
188
181
|
requirements: []
|
|
189
|
-
rubygems_version:
|
|
190
|
-
signing_key:
|
|
182
|
+
rubygems_version: 4.0.17
|
|
191
183
|
specification_version: 4
|
|
192
184
|
summary: Extension to manage the static pages for your Solidus store.
|
|
193
|
-
test_files:
|
|
194
|
-
- spec/controllers/spree/admin/pages_controller_spec.rb
|
|
195
|
-
- spec/controllers/spree/static_content_controller_spec.rb
|
|
196
|
-
- spec/features/spree/admin/pages_spec.rb
|
|
197
|
-
- spec/features/spree/static_content_spec.rb
|
|
198
|
-
- spec/helpers/spree/page_helper_spec.rb
|
|
199
|
-
- spec/lib/solidus_static_content/engine_spec.rb
|
|
200
|
-
- spec/lib/solidus_static_content/route_matcher_spec.rb
|
|
201
|
-
- spec/models/spree/page_spec.rb
|
|
202
|
-
- spec/spec_helper.rb
|
|
185
|
+
test_files: []
|
data/.circleci/config.yml
DELETED
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
version: 2.1
|
|
2
|
-
|
|
3
|
-
orbs:
|
|
4
|
-
# Always take the latest version of the orb, this allows us to
|
|
5
|
-
# run specs against Solidus supported versions only without the need
|
|
6
|
-
# to change this configuration every time a Solidus version is released
|
|
7
|
-
# or goes EOL.
|
|
8
|
-
solidusio_extensions: solidusio/extensions@volatile
|
|
9
|
-
|
|
10
|
-
jobs:
|
|
11
|
-
run-specs-with-postgres:
|
|
12
|
-
executor: solidusio_extensions/postgres
|
|
13
|
-
steps:
|
|
14
|
-
- solidusio_extensions/run-tests
|
|
15
|
-
run-specs-with-mysql:
|
|
16
|
-
executor: solidusio_extensions/mysql
|
|
17
|
-
steps:
|
|
18
|
-
- solidusio_extensions/run-tests
|
|
19
|
-
|
|
20
|
-
workflows:
|
|
21
|
-
"Run specs on supported Solidus versions":
|
|
22
|
-
jobs:
|
|
23
|
-
- run-specs-with-postgres
|
|
24
|
-
- run-specs-with-mysql
|
|
25
|
-
"Weekly run specs against master":
|
|
26
|
-
triggers:
|
|
27
|
-
- schedule:
|
|
28
|
-
cron: "0 0 * * 4" # every Thursday
|
|
29
|
-
filters:
|
|
30
|
-
branches:
|
|
31
|
-
only:
|
|
32
|
-
- master
|
|
33
|
-
jobs:
|
|
34
|
-
- run-specs-with-postgres
|
|
35
|
-
- run-specs-with-mysql
|
data/.rubocop.yml
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
require 'spec_helper'
|
|
2
|
-
|
|
3
|
-
RSpec.describe Spree::Admin::PagesController do
|
|
4
|
-
describe '.build_resource' do
|
|
5
|
-
it 'pre-assigns the default store' do
|
|
6
|
-
default_store = create(:store, default: true)
|
|
7
|
-
|
|
8
|
-
expect(subject.send(:build_resource).stores).to eq([default_store])
|
|
9
|
-
end
|
|
10
|
-
end
|
|
11
|
-
end
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
require 'spec_helper'
|
|
2
|
-
|
|
3
|
-
describe Spree::StaticContentController, type: :controller do
|
|
4
|
-
let!(:store) { create(:store, default: true) }
|
|
5
|
-
|
|
6
|
-
context '#show' do
|
|
7
|
-
it 'accepts path as root' do
|
|
8
|
-
page = create(:page, slug: '/', stores: [store])
|
|
9
|
-
request.path = page.slug
|
|
10
|
-
get :show, params: { path: page.slug }
|
|
11
|
-
expect(response).to be_successful
|
|
12
|
-
end
|
|
13
|
-
|
|
14
|
-
it 'accepts path as string' do
|
|
15
|
-
page = create(:page, slug: 'hello', stores: [store])
|
|
16
|
-
request.path = page.slug
|
|
17
|
-
get :show, params: { path: page.slug }
|
|
18
|
-
expect(response).to be_successful
|
|
19
|
-
end
|
|
20
|
-
|
|
21
|
-
it 'accepts path as nested' do
|
|
22
|
-
page = create(:page, slug: 'aa/bb/cc', stores: [store])
|
|
23
|
-
request.path = page.slug
|
|
24
|
-
get :show, params: { path: page.slug }
|
|
25
|
-
expect(response).to be_successful
|
|
26
|
-
end
|
|
27
|
-
|
|
28
|
-
it 'respond with a 404 when no page exists' do
|
|
29
|
-
expect {
|
|
30
|
-
get :show
|
|
31
|
-
}.to raise_error(ActiveRecord::RecordNotFound)
|
|
32
|
-
end
|
|
33
|
-
end
|
|
34
|
-
end
|
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
require 'spec_helper'
|
|
2
|
-
|
|
3
|
-
RSpec.feature 'Admin Static Content', js: true do
|
|
4
|
-
stub_authorization!
|
|
5
|
-
|
|
6
|
-
background do
|
|
7
|
-
create :store, default: true
|
|
8
|
-
end
|
|
9
|
-
|
|
10
|
-
context 'when no page exists' do
|
|
11
|
-
background do
|
|
12
|
-
visit spree.admin_path
|
|
13
|
-
click_link 'Pages'
|
|
14
|
-
end
|
|
15
|
-
|
|
16
|
-
scenario 'can create new page' do
|
|
17
|
-
expect(page).to have_text /No Pages found/i
|
|
18
|
-
|
|
19
|
-
click_link 'New page'
|
|
20
|
-
|
|
21
|
-
expect(page).to have_text 'New page'
|
|
22
|
-
|
|
23
|
-
fill_in 'page_title', with: 'Contact us'
|
|
24
|
-
fill_in 'page_slug', with: 'contact-us'
|
|
25
|
-
fill_in 'page_body', with: 'hello..'
|
|
26
|
-
|
|
27
|
-
fill_in 'page_meta_title', with: 'Contact us'
|
|
28
|
-
fill_in 'page_meta_keywords', with: 'spree, contact'
|
|
29
|
-
fill_in 'page_meta_description', with: 'Short description for contact page.'
|
|
30
|
-
|
|
31
|
-
check 'page_show_in_sidebar'
|
|
32
|
-
check 'page_show_in_header'
|
|
33
|
-
check 'page_show_in_footer'
|
|
34
|
-
|
|
35
|
-
expect(find('#page_visible')).to be_checked
|
|
36
|
-
|
|
37
|
-
click_button 'Create'
|
|
38
|
-
expect(page).to have_text 'successfully created!'
|
|
39
|
-
end
|
|
40
|
-
end
|
|
41
|
-
|
|
42
|
-
context 'when page exists' do
|
|
43
|
-
given!(:static_page) { create(:page) }
|
|
44
|
-
|
|
45
|
-
background do
|
|
46
|
-
visit spree.admin_path
|
|
47
|
-
click_link 'Pages'
|
|
48
|
-
end
|
|
49
|
-
|
|
50
|
-
scenario 'can be updated' do
|
|
51
|
-
within_row(1) do
|
|
52
|
-
click_icon :edit
|
|
53
|
-
end
|
|
54
|
-
|
|
55
|
-
fill_in 'page_title', with: 'Contact'
|
|
56
|
-
fill_in 'page_slug', with: 'contact'
|
|
57
|
-
|
|
58
|
-
click_button 'Update'
|
|
59
|
-
expect(page).to have_text 'successfully updated!'
|
|
60
|
-
end
|
|
61
|
-
|
|
62
|
-
scenario 'can be deleted' do
|
|
63
|
-
within_row(1) do
|
|
64
|
-
accept_confirm { click_icon :trash }
|
|
65
|
-
end
|
|
66
|
-
|
|
67
|
-
expect(page).not_to have_text static_page.title
|
|
68
|
-
end
|
|
69
|
-
end
|
|
70
|
-
end
|
|
@@ -1,55 +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', js: false do
|
|
33
|
-
create(:taxon, permalink: 'test', name: 'The Taxon')
|
|
34
|
-
create(:page, slug: '/t/test', title: 'The Page', stores: [store])
|
|
35
|
-
visit '/t/test'
|
|
36
|
-
expect(page).to have_content('The Taxon')
|
|
37
|
-
expect(page).not_to have_content('The Page')
|
|
38
|
-
end
|
|
39
|
-
|
|
40
|
-
scenario 'fetch correct page' do
|
|
41
|
-
create(:page, slug: '/', stores: [store])
|
|
42
|
-
create(:page, slug: 'hello', title: 'Hello', stores: [store])
|
|
43
|
-
create(:page, slug: 'somwhere', stores: [store])
|
|
44
|
-
create(:page, :with_foreign_link, slug: 'whatever', stores: [store])
|
|
45
|
-
visit '/hello'
|
|
46
|
-
expect(page).to have_text 'Hello'
|
|
47
|
-
end
|
|
48
|
-
|
|
49
|
-
scenario 'do not effect the rendering of the rest of the site' do
|
|
50
|
-
product = create(:product)
|
|
51
|
-
visit spree.product_path(product)
|
|
52
|
-
expect(page).to have_text product.name
|
|
53
|
-
end
|
|
54
|
-
end
|
|
55
|
-
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,14 +0,0 @@
|
|
|
1
|
-
require 'spec_helper'
|
|
2
|
-
|
|
3
|
-
RSpec.describe SolidusStaticContent::Engine do
|
|
4
|
-
describe '.activate_menu_item' do
|
|
5
|
-
it 'adds the menu item only once' do
|
|
6
|
-
described_class.activate_menu_items
|
|
7
|
-
|
|
8
|
-
expect {
|
|
9
|
-
described_class.activate_menu_items
|
|
10
|
-
described_class.activate_menu_items
|
|
11
|
-
}.not_to change(Spree::Backend::Config.menu_items, :size)
|
|
12
|
-
end
|
|
13
|
-
end
|
|
14
|
-
end
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
require 'spec_helper'
|
|
2
|
-
|
|
3
|
-
describe SolidusStaticContent::RouteMatcher do
|
|
4
|
-
subject { described_class }
|
|
5
|
-
|
|
6
|
-
context '.matches?' do
|
|
7
|
-
it 'is true when valid page' do
|
|
8
|
-
page = create(:page, slug: 'hello', visible: true)
|
|
9
|
-
request = instance_double(Rack::Request, path_info: page.slug)
|
|
10
|
-
expect(subject.matches?(request)).to be true
|
|
11
|
-
end
|
|
12
|
-
|
|
13
|
-
it 'is false when using reserved slug name' do
|
|
14
|
-
page = create(:page, slug: 'login', visible: true)
|
|
15
|
-
request = instance_double(Rack::Request, path_info: page.slug)
|
|
16
|
-
expect(subject.matches?(request)).to be false
|
|
17
|
-
end
|
|
18
|
-
|
|
19
|
-
it 'is false when page is not accessible' do
|
|
20
|
-
page = create(:page, slug: 'hello', visible: false)
|
|
21
|
-
request = instance_double(Rack::Request, path_info: page.slug)
|
|
22
|
-
expect(subject.matches?(request)).to be false
|
|
23
|
-
end
|
|
24
|
-
end
|
|
25
|
-
end
|
|
@@ -1,61 +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
|
-
context '.link' do
|
|
13
|
-
it 'return slug if foreign_link blank' do
|
|
14
|
-
page = create(:page, slug: 'hello')
|
|
15
|
-
expect(page.link).to eq page.slug
|
|
16
|
-
end
|
|
17
|
-
|
|
18
|
-
it 'return foreign_link if set' do
|
|
19
|
-
page = create(:page, :with_foreign_link, slug: 'hello')
|
|
20
|
-
expect(page.link).to eq page.foreign_link
|
|
21
|
-
end
|
|
22
|
-
end
|
|
23
|
-
|
|
24
|
-
context "pages in stores" do
|
|
25
|
-
before(:each) do
|
|
26
|
-
@store = create(:store)
|
|
27
|
-
@page = create(:page, :stores => [@store])
|
|
28
|
-
@page2 = create(:page)
|
|
29
|
-
end
|
|
30
|
-
|
|
31
|
-
it 'should correctly find pages by store' do
|
|
32
|
-
pages_by_store = Spree::Page.by_store(@store)
|
|
33
|
-
expect(pages_by_store).to include(@page)
|
|
34
|
-
expect(pages_by_store).to_not include(@page2)
|
|
35
|
-
end
|
|
36
|
-
end
|
|
37
|
-
|
|
38
|
-
describe '#slug' do
|
|
39
|
-
it 'always adds a "/" (slash) prefix to the slug' do
|
|
40
|
-
page = create(:page, slug: 'hello')
|
|
41
|
-
expect(page.slug).to eq '/hello'
|
|
42
|
-
end
|
|
43
|
-
|
|
44
|
-
context 'when a title is present' do
|
|
45
|
-
it 'is generated from the title' do
|
|
46
|
-
page = create(:page, slug: nil, title: 'Hello World!')
|
|
47
|
-
|
|
48
|
-
expect(page).to be_valid
|
|
49
|
-
expect(page.slug).to eq('/hello-world')
|
|
50
|
-
end
|
|
51
|
-
end
|
|
52
|
-
end
|
|
53
|
-
|
|
54
|
-
describe '.meta_title' do
|
|
55
|
-
it 'falls back to title' do
|
|
56
|
-
page = build(:page, title: "Foo Bar", meta_title: nil)
|
|
57
|
-
|
|
58
|
-
expect(page.meta_title).to eq("Foo Bar")
|
|
59
|
-
end
|
|
60
|
-
end
|
|
61
|
-
end
|
data/spec/spec_helper.rb
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
# Configure Rails Environment
|
|
4
|
-
ENV['RAILS_ENV'] = 'test'
|
|
5
|
-
|
|
6
|
-
# Run Coverage report
|
|
7
|
-
require 'solidus_dev_support/rspec/coverage'
|
|
8
|
-
|
|
9
|
-
require File.expand_path('dummy/config/environment.rb', __dir__).tap { |file|
|
|
10
|
-
# Create the dummy app if it's still missing.
|
|
11
|
-
system 'bin/rake extension:test_app' unless File.exist? file
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
# Requires factories and other useful helpers defined in spree_core.
|
|
15
|
-
require 'solidus_dev_support/rspec/feature_helper'
|
|
16
|
-
|
|
17
|
-
# Requires supporting ruby files with custom matchers and macros, etc,
|
|
18
|
-
# in spec/support/ and its subdirectories.
|
|
19
|
-
Dir[File.join(File.dirname(__FILE__), 'support/**/*.rb')].each { |f| require f }
|
|
20
|
-
|
|
21
|
-
# Requires factories defined in lib/solidus_static_content/factories.rb
|
|
22
|
-
require 'solidus_static_content/factories'
|
|
23
|
-
|
|
24
|
-
RSpec.configure do |config|
|
|
25
|
-
config.infer_spec_type_from_file_location!
|
|
26
|
-
config.use_transactional_fixtures = false
|
|
27
|
-
end
|