workarea-sitemaps 2.1.6
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 +7 -0
- data/.editorconfig +20 -0
- data/.github/ISSUE_TEMPLATE/bug_report.md +37 -0
- data/.github/ISSUE_TEMPLATE/documentation-request.md +17 -0
- data/.github/ISSUE_TEMPLATE/feature_request.md +20 -0
- data/.gitignore +15 -0
- data/.rspec +2 -0
- data/.yardopts +1 -0
- data/CHANGELOG.md +228 -0
- data/CODE_OF_CONDUCT.md +3 -0
- data/CONTRIBUTING.md +3 -0
- data/Gemfile +6 -0
- data/LICENSE +52 -0
- data/README.md +40 -0
- data/Rakefile +32 -0
- data/app/models/workarea/navigation/taxon.decorator +7 -0
- data/app/models/workarea/sitemap/link.rb +53 -0
- data/app/models/workarea/sitemap.rb +20 -0
- data/app/views/workarea/storefront/pages/_robots_sitemaps.text.erb +1 -0
- data/app/workers/workarea/generate_sitemaps.rb +71 -0
- data/bin/rails +18 -0
- data/config/initializers/appends.rb +4 -0
- data/config/initializers/dragonfly.rb +9 -0
- data/config/initializers/scheduled_jobs.rb +6 -0
- data/config/routes.rb +9 -0
- data/lib/workarea/asset_endpoints/sitemaps.rb +9 -0
- data/lib/workarea/sitemaps/engine.rb +8 -0
- data/lib/workarea/sitemaps/version.rb +5 -0
- data/lib/workarea/sitemaps.rb +13 -0
- data/test/dummy/README.rdoc +28 -0
- data/test/dummy/Rakefile +6 -0
- data/test/dummy/app/assets/images/.keep +0 -0
- data/test/dummy/app/assets/javascripts/application.js +13 -0
- data/test/dummy/app/assets/stylesheets/application.css +15 -0
- data/test/dummy/app/controllers/application_controller.rb +5 -0
- data/test/dummy/app/controllers/concerns/.keep +0 -0
- data/test/dummy/app/helpers/application_helper.rb +2 -0
- data/test/dummy/app/mailers/.keep +0 -0
- data/test/dummy/app/models/.keep +0 -0
- data/test/dummy/app/models/concerns/.keep +0 -0
- data/test/dummy/app/views/layouts/application.html.erb +14 -0
- data/test/dummy/bin/bundle +3 -0
- data/test/dummy/bin/rails +4 -0
- data/test/dummy/bin/rake +4 -0
- data/test/dummy/bin/setup +34 -0
- data/test/dummy/bin/update +29 -0
- data/test/dummy/config/application.rb +22 -0
- data/test/dummy/config/boot.rb +5 -0
- data/test/dummy/config/cable.yml +9 -0
- data/test/dummy/config/environment.rb +5 -0
- data/test/dummy/config/environments/development.rb +54 -0
- data/test/dummy/config/environments/production.rb +86 -0
- data/test/dummy/config/environments/test.rb +43 -0
- data/test/dummy/config/initializers/application_controller_renderer.rb +6 -0
- data/test/dummy/config/initializers/assets.rb +11 -0
- data/test/dummy/config/initializers/backtrace_silencers.rb +7 -0
- data/test/dummy/config/initializers/cookies_serializer.rb +5 -0
- data/test/dummy/config/initializers/filter_parameter_logging.rb +4 -0
- data/test/dummy/config/initializers/inflections.rb +16 -0
- data/test/dummy/config/initializers/mime_types.rb +4 -0
- data/test/dummy/config/initializers/new_framework_defaults.rb +17 -0
- data/test/dummy/config/initializers/session_store.rb +3 -0
- data/test/dummy/config/initializers/workarea.rb +8 -0
- data/test/dummy/config/initializers/wrap_parameters.rb +14 -0
- data/test/dummy/config/locales/en.yml +23 -0
- data/test/dummy/config/puma.rb +47 -0
- data/test/dummy/config/routes.rb +5 -0
- data/test/dummy/config/secrets.yml +22 -0
- data/test/dummy/config/spring.rb +6 -0
- data/test/dummy/config.ru +4 -0
- data/test/dummy/lib/assets/.keep +0 -0
- data/test/dummy/log/.keep +0 -0
- data/test/dummy/public/404.html +67 -0
- data/test/dummy/public/422.html +67 -0
- data/test/dummy/public/500.html +66 -0
- data/test/dummy/public/favicon.ico +1 -0
- data/test/integration/workarea/storefront/sitemaps_integration_test.rb +53 -0
- data/test/models/workarea/navigation/taxon_test.decorator +22 -0
- data/test/models/workarea/sitemap/link_test.rb +58 -0
- data/test/test_helper.rb +10 -0
- data/test/workers/workarea/generate_sitemaps_test.rb +81 -0
- data/workarea-sitemaps.gemspec +22 -0
- metadata +153 -0
@@ -0,0 +1,47 @@
|
|
1
|
+
# Puma can serve each request in a thread from an internal thread pool.
|
2
|
+
# The `threads` method setting takes two numbers a minimum and maximum.
|
3
|
+
# Any libraries that use thread pools should be configured to match
|
4
|
+
# the maximum value specified for Puma. Default is set to 5 threads for minimum
|
5
|
+
# and maximum, this matches the default thread size of Active Record.
|
6
|
+
#
|
7
|
+
threads_count = ENV.fetch('RAILS_MAX_THREADS') { 5 }.to_i
|
8
|
+
threads threads_count, threads_count
|
9
|
+
|
10
|
+
# Specifies the `port` that Puma will listen on to receive requests, default is 3000.
|
11
|
+
#
|
12
|
+
port ENV.fetch('PORT') { 3000 }
|
13
|
+
|
14
|
+
# Specifies the `environment` that Puma will run in.
|
15
|
+
#
|
16
|
+
environment ENV.fetch('RAILS_ENV') { 'development' }
|
17
|
+
|
18
|
+
# Specifies the number of `workers` to boot in clustered mode.
|
19
|
+
# Workers are forked webserver processes. If using threads and workers together
|
20
|
+
# the concurrency of the application would be max `threads` * `workers`.
|
21
|
+
# Workers do not work on JRuby or Windows (both of which do not support
|
22
|
+
# processes).
|
23
|
+
#
|
24
|
+
# workers ENV.fetch("WEB_CONCURRENCY") { 2 }
|
25
|
+
|
26
|
+
# Use the `preload_app!` method when specifying a `workers` number.
|
27
|
+
# This directive tells Puma to first boot the application and load code
|
28
|
+
# before forking the application. This takes advantage of Copy On Write
|
29
|
+
# process behavior so workers use less memory. If you use this option
|
30
|
+
# you need to make sure to reconnect any threads in the `on_worker_boot`
|
31
|
+
# block.
|
32
|
+
#
|
33
|
+
# preload_app!
|
34
|
+
|
35
|
+
# The code in the `on_worker_boot` will be called if you are using
|
36
|
+
# clustered mode by specifying a number of `workers`. After each worker
|
37
|
+
# process is booted this block will be run, if you are using `preload_app!`
|
38
|
+
# option you will want to use this block to reconnect to any threads
|
39
|
+
# or connections that may have been created at application boot, Ruby
|
40
|
+
# cannot share connections between processes.
|
41
|
+
#
|
42
|
+
# on_worker_boot do
|
43
|
+
# ActiveRecord::Base.establish_connection if defined?(ActiveRecord)
|
44
|
+
# end
|
45
|
+
|
46
|
+
# Allow puma to be restarted by `rails restart` command.
|
47
|
+
plugin :tmp_restart
|
@@ -0,0 +1,22 @@
|
|
1
|
+
# Be sure to restart your server when you modify this file.
|
2
|
+
|
3
|
+
# Your secret key is used for verifying the integrity of signed cookies.
|
4
|
+
# If you change this key, all old signed cookies will become invalid!
|
5
|
+
|
6
|
+
# Make sure the secret is at least 30 characters and all random,
|
7
|
+
# no regular words or you'll be exposed to dictionary attacks.
|
8
|
+
# You can use `rails secret` to generate a secure secret key.
|
9
|
+
|
10
|
+
# Make sure the secrets in this file are kept private
|
11
|
+
# if you're sharing your code publicly.
|
12
|
+
|
13
|
+
development:
|
14
|
+
secret_key_base: f02bb38df30a4450a062a761c00e2c537fe80b2dde6e2896682720bc1c7ba6e009b48488790065ebd9410391390b62e6d35f881b887e24d2ddf92c2d083a95d7
|
15
|
+
|
16
|
+
test:
|
17
|
+
secret_key_base: 2eb74b7e24c45e52269da795c8591fb8f5b197184bc604b8329c57a7a1f1b595920827191443f30969180fccf5f8e53d2e735cd3b6caf7edb64d32d473ea7dca
|
18
|
+
|
19
|
+
# Do not keep production secrets in the repository,
|
20
|
+
# instead read values from the environment.
|
21
|
+
production:
|
22
|
+
secret_key_base: <%= ENV["SECRET_KEY_BASE"] %>
|
File without changes
|
File without changes
|
@@ -0,0 +1,67 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<title>The page you were looking for doesn't exist (404)</title>
|
5
|
+
<meta name="viewport" content="width=device-width,initial-scale=1">
|
6
|
+
<style>
|
7
|
+
body {
|
8
|
+
background-color: #EFEFEF;
|
9
|
+
color: #2E2F30;
|
10
|
+
text-align: center;
|
11
|
+
font-family: arial, sans-serif;
|
12
|
+
margin: 0;
|
13
|
+
}
|
14
|
+
|
15
|
+
div.dialog {
|
16
|
+
width: 95%;
|
17
|
+
max-width: 33em;
|
18
|
+
margin: 4em auto 0;
|
19
|
+
}
|
20
|
+
|
21
|
+
div.dialog > div {
|
22
|
+
border: 1px solid #CCC;
|
23
|
+
border-right-color: #999;
|
24
|
+
border-left-color: #999;
|
25
|
+
border-bottom-color: #BBB;
|
26
|
+
border-top: #B00100 solid 4px;
|
27
|
+
border-top-left-radius: 9px;
|
28
|
+
border-top-right-radius: 9px;
|
29
|
+
background-color: white;
|
30
|
+
padding: 7px 12% 0;
|
31
|
+
box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
|
32
|
+
}
|
33
|
+
|
34
|
+
h1 {
|
35
|
+
font-size: 100%;
|
36
|
+
color: #730E15;
|
37
|
+
line-height: 1.5em;
|
38
|
+
}
|
39
|
+
|
40
|
+
div.dialog > p {
|
41
|
+
margin: 0 0 1em;
|
42
|
+
padding: 1em;
|
43
|
+
background-color: #F7F7F7;
|
44
|
+
border: 1px solid #CCC;
|
45
|
+
border-right-color: #999;
|
46
|
+
border-left-color: #999;
|
47
|
+
border-bottom-color: #999;
|
48
|
+
border-bottom-left-radius: 4px;
|
49
|
+
border-bottom-right-radius: 4px;
|
50
|
+
border-top-color: #DADADA;
|
51
|
+
color: #666;
|
52
|
+
box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
|
53
|
+
}
|
54
|
+
</style>
|
55
|
+
</head>
|
56
|
+
|
57
|
+
<body>
|
58
|
+
<!-- This file lives in public/404.html -->
|
59
|
+
<div class="dialog">
|
60
|
+
<div>
|
61
|
+
<h1>The page you were looking for doesn't exist.</h1>
|
62
|
+
<p>You may have mistyped the address or the page may have moved.</p>
|
63
|
+
</div>
|
64
|
+
<p>If you are the application owner check the logs for more information.</p>
|
65
|
+
</div>
|
66
|
+
</body>
|
67
|
+
</html>
|
@@ -0,0 +1,67 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<title>The change you wanted was rejected (422)</title>
|
5
|
+
<meta name="viewport" content="width=device-width,initial-scale=1">
|
6
|
+
<style>
|
7
|
+
body {
|
8
|
+
background-color: #EFEFEF;
|
9
|
+
color: #2E2F30;
|
10
|
+
text-align: center;
|
11
|
+
font-family: arial, sans-serif;
|
12
|
+
margin: 0;
|
13
|
+
}
|
14
|
+
|
15
|
+
div.dialog {
|
16
|
+
width: 95%;
|
17
|
+
max-width: 33em;
|
18
|
+
margin: 4em auto 0;
|
19
|
+
}
|
20
|
+
|
21
|
+
div.dialog > div {
|
22
|
+
border: 1px solid #CCC;
|
23
|
+
border-right-color: #999;
|
24
|
+
border-left-color: #999;
|
25
|
+
border-bottom-color: #BBB;
|
26
|
+
border-top: #B00100 solid 4px;
|
27
|
+
border-top-left-radius: 9px;
|
28
|
+
border-top-right-radius: 9px;
|
29
|
+
background-color: white;
|
30
|
+
padding: 7px 12% 0;
|
31
|
+
box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
|
32
|
+
}
|
33
|
+
|
34
|
+
h1 {
|
35
|
+
font-size: 100%;
|
36
|
+
color: #730E15;
|
37
|
+
line-height: 1.5em;
|
38
|
+
}
|
39
|
+
|
40
|
+
div.dialog > p {
|
41
|
+
margin: 0 0 1em;
|
42
|
+
padding: 1em;
|
43
|
+
background-color: #F7F7F7;
|
44
|
+
border: 1px solid #CCC;
|
45
|
+
border-right-color: #999;
|
46
|
+
border-left-color: #999;
|
47
|
+
border-bottom-color: #999;
|
48
|
+
border-bottom-left-radius: 4px;
|
49
|
+
border-bottom-right-radius: 4px;
|
50
|
+
border-top-color: #DADADA;
|
51
|
+
color: #666;
|
52
|
+
box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
|
53
|
+
}
|
54
|
+
</style>
|
55
|
+
</head>
|
56
|
+
|
57
|
+
<body>
|
58
|
+
<!-- This file lives in public/422.html -->
|
59
|
+
<div class="dialog">
|
60
|
+
<div>
|
61
|
+
<h1>The change you wanted was rejected.</h1>
|
62
|
+
<p>Maybe you tried to change something you didn't have access to.</p>
|
63
|
+
</div>
|
64
|
+
<p>If you are the application owner check the logs for more information.</p>
|
65
|
+
</div>
|
66
|
+
</body>
|
67
|
+
</html>
|
@@ -0,0 +1,66 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<title>We're sorry, but something went wrong (500)</title>
|
5
|
+
<meta name="viewport" content="width=device-width,initial-scale=1">
|
6
|
+
<style>
|
7
|
+
body {
|
8
|
+
background-color: #EFEFEF;
|
9
|
+
color: #2E2F30;
|
10
|
+
text-align: center;
|
11
|
+
font-family: arial, sans-serif;
|
12
|
+
margin: 0;
|
13
|
+
}
|
14
|
+
|
15
|
+
div.dialog {
|
16
|
+
width: 95%;
|
17
|
+
max-width: 33em;
|
18
|
+
margin: 4em auto 0;
|
19
|
+
}
|
20
|
+
|
21
|
+
div.dialog > div {
|
22
|
+
border: 1px solid #CCC;
|
23
|
+
border-right-color: #999;
|
24
|
+
border-left-color: #999;
|
25
|
+
border-bottom-color: #BBB;
|
26
|
+
border-top: #B00100 solid 4px;
|
27
|
+
border-top-left-radius: 9px;
|
28
|
+
border-top-right-radius: 9px;
|
29
|
+
background-color: white;
|
30
|
+
padding: 7px 12% 0;
|
31
|
+
box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
|
32
|
+
}
|
33
|
+
|
34
|
+
h1 {
|
35
|
+
font-size: 100%;
|
36
|
+
color: #730E15;
|
37
|
+
line-height: 1.5em;
|
38
|
+
}
|
39
|
+
|
40
|
+
div.dialog > p {
|
41
|
+
margin: 0 0 1em;
|
42
|
+
padding: 1em;
|
43
|
+
background-color: #F7F7F7;
|
44
|
+
border: 1px solid #CCC;
|
45
|
+
border-right-color: #999;
|
46
|
+
border-left-color: #999;
|
47
|
+
border-bottom-color: #999;
|
48
|
+
border-bottom-left-radius: 4px;
|
49
|
+
border-bottom-right-radius: 4px;
|
50
|
+
border-top-color: #DADADA;
|
51
|
+
color: #666;
|
52
|
+
box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
|
53
|
+
}
|
54
|
+
</style>
|
55
|
+
</head>
|
56
|
+
|
57
|
+
<body>
|
58
|
+
<!-- This file lives in public/500.html -->
|
59
|
+
<div class="dialog">
|
60
|
+
<div>
|
61
|
+
<h1>We're sorry, but something went wrong.</h1>
|
62
|
+
</div>
|
63
|
+
<p>If you are the application owner check the logs for more information.</p>
|
64
|
+
</div>
|
65
|
+
</body>
|
66
|
+
</html>
|
@@ -0,0 +1 @@
|
|
1
|
+
|
@@ -0,0 +1,53 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
module Workarea
|
4
|
+
module Storefront
|
5
|
+
class SitemapsIntegrationTest < Workarea::IntegrationTest
|
6
|
+
setup :create_index
|
7
|
+
teardown :reset_index
|
8
|
+
|
9
|
+
def create_index
|
10
|
+
@create_index = SitemapGenerator::Sitemap.create_index
|
11
|
+
end
|
12
|
+
|
13
|
+
def reset_index
|
14
|
+
SitemapGenerator::Sitemap.create_index = @create_index
|
15
|
+
end
|
16
|
+
|
17
|
+
def test_returns_200_status_code
|
18
|
+
GenerateSitemaps.new.perform
|
19
|
+
get '/sitemap.xml.gz'
|
20
|
+
|
21
|
+
assert_equal(200, response.status)
|
22
|
+
end
|
23
|
+
|
24
|
+
def test_handles_multiple_sitemaps_via_an_index_file
|
25
|
+
SitemapGenerator::Sitemap.create_index = true
|
26
|
+
GenerateSitemaps.new.perform
|
27
|
+
|
28
|
+
get '/sitemap.xml.gz'
|
29
|
+
assert_equal(200, response.status)
|
30
|
+
|
31
|
+
get '/sitemap1.xml.gz'
|
32
|
+
assert_equal(200, response.status)
|
33
|
+
end
|
34
|
+
|
35
|
+
def test_sets_the_cache_control_to_1_day
|
36
|
+
Workarea.with_config do |config|
|
37
|
+
config.strip_http_caching_in_tests = false
|
38
|
+
|
39
|
+
GenerateSitemaps.new.perform
|
40
|
+
get '/sitemap.xml.gz'
|
41
|
+
assert_equal('public, max-age=86400', response.headers['Cache-Control'])
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
def test_viewing_robots_txt
|
46
|
+
GenerateSitemaps.new.perform
|
47
|
+
get storefront.robots_txt_path
|
48
|
+
assert_includes(response.body, Workarea.config.host)
|
49
|
+
assert_includes(response.body, 'sitemap.xml.gz')
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
module Workarea
|
4
|
+
decorate Navigation::TaxonTest, with: :sitemaps do
|
5
|
+
def test_show_in_sitemap?
|
6
|
+
new_taxon = Navigation::Taxon.new
|
7
|
+
nav_taxon = create_taxon(navigable: create_page)
|
8
|
+
url_taxon = create_taxon(url: 'http://example.com')
|
9
|
+
eml_taxon = create_taxon(url: 'mailto:noreply@example.com')
|
10
|
+
tel_taxon = create_taxon(url: 'tel:+16108675309')
|
11
|
+
rel_taxon = create_taxon(url: '/foo')
|
12
|
+
|
13
|
+
assert(new_taxon.placeholder?)
|
14
|
+
refute(new_taxon.show_in_sitemap?)
|
15
|
+
assert(nav_taxon.show_in_sitemap?)
|
16
|
+
assert(url_taxon.show_in_sitemap?)
|
17
|
+
assert(rel_taxon.show_in_sitemap?)
|
18
|
+
refute(eml_taxon.show_in_sitemap?)
|
19
|
+
refute(tel_taxon.show_in_sitemap?)
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,58 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
module Workarea
|
4
|
+
class Sitemap
|
5
|
+
class LinkTest < TestCase
|
6
|
+
def test_host
|
7
|
+
page = create_page
|
8
|
+
navigable = Link.new(
|
9
|
+
taxon: create_taxon(navigable: page),
|
10
|
+
generator: GenerateSitemaps.new
|
11
|
+
)
|
12
|
+
external_https = Link.new(
|
13
|
+
taxon: create_taxon(url: 'https://alt.example.com/foo/bar'),
|
14
|
+
generator: GenerateSitemaps.new
|
15
|
+
)
|
16
|
+
external_http = Link.new(
|
17
|
+
taxon: create_taxon(url: 'http://alt.example.com/foo/bar'),
|
18
|
+
generator: GenerateSitemaps.new
|
19
|
+
)
|
20
|
+
external_path = Link.new(
|
21
|
+
taxon: create_taxon(url: '/foo/bar'),
|
22
|
+
generator: GenerateSitemaps.new
|
23
|
+
)
|
24
|
+
|
25
|
+
|
26
|
+
assert_equal('https://alt.example.com', external_https.host)
|
27
|
+
assert_equal('http://alt.example.com', external_http.host)
|
28
|
+
assert_equal("http://#{Workarea.config.host}", navigable.host)
|
29
|
+
assert_equal("http://#{Workarea.config.host}", external_path.host)
|
30
|
+
Rails.configuration.force_ssl = true
|
31
|
+
assert_equal("https://#{Workarea.config.host}", navigable.host)
|
32
|
+
assert_equal("https://#{Workarea.config.host}", external_path.host)
|
33
|
+
ensure
|
34
|
+
Rails.configuration.force_ssl = false
|
35
|
+
end
|
36
|
+
|
37
|
+
def test_path
|
38
|
+
page = create_page
|
39
|
+
navigable = Link.new(
|
40
|
+
taxon: create_taxon(navigable: page),
|
41
|
+
generator: GenerateSitemaps.new
|
42
|
+
)
|
43
|
+
external_url = Link.new(
|
44
|
+
taxon: create_taxon(url: 'https://alt.example.com/foo/bar'),
|
45
|
+
generator: GenerateSitemaps.new
|
46
|
+
)
|
47
|
+
external_path = Link.new(
|
48
|
+
taxon: create_taxon(url: '/foo/bar'),
|
49
|
+
generator: GenerateSitemaps.new
|
50
|
+
)
|
51
|
+
|
52
|
+
assert_equal('/foo/bar', external_url.path)
|
53
|
+
assert_equal('/foo/bar', external_path.path)
|
54
|
+
assert_equal("/pages/#{page.slug}", navigable.path)
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
data/test/test_helper.rb
ADDED
@@ -0,0 +1,10 @@
|
|
1
|
+
# Configure Rails Environment
|
2
|
+
ENV['RAILS_ENV'] = 'test'
|
3
|
+
|
4
|
+
require File.expand_path('../../test/dummy/config/environment.rb', __FILE__)
|
5
|
+
require 'rails/test_help'
|
6
|
+
require 'workarea/test_help'
|
7
|
+
|
8
|
+
# Filter out Minitest backtrace while allowing backtrace from other libraries
|
9
|
+
# to be shown.
|
10
|
+
Minitest.backtrace_filter = Minitest::BacktraceFilter.new
|
@@ -0,0 +1,81 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
module Workarea
|
4
|
+
class GenerateSitemapsTest < Workarea::TestCase
|
5
|
+
def test_does_not_add_mailto_link_to_sitemap
|
6
|
+
url = 'mailto:noreply@example.com'
|
7
|
+
create_taxon(url: url)
|
8
|
+
GenerateSitemaps.new.perform
|
9
|
+
contents = Zlib::GzipReader.new(Sitemap.first.file.file).read
|
10
|
+
|
11
|
+
refute_includes(contents, url)
|
12
|
+
end
|
13
|
+
|
14
|
+
def test_adds_product_to_sitemap
|
15
|
+
product = create_product(slug: 'test-product')
|
16
|
+
GenerateSitemaps.new.perform
|
17
|
+
|
18
|
+
contents = Zlib::GzipReader.new(Sitemap.first.file.file).read
|
19
|
+
assert_includes(contents, "https://#{Workarea.config.host}/products/test-product")
|
20
|
+
|
21
|
+
product.variants.destroy_all
|
22
|
+
GenerateSitemaps.new.perform
|
23
|
+
contents = Zlib::GzipReader.new(Sitemap.first.file.file).read
|
24
|
+
|
25
|
+
refute_includes(contents, "https://#{Workarea.config.host}/products/test-product")
|
26
|
+
end
|
27
|
+
|
28
|
+
def test_adds_navigation_link_with_url
|
29
|
+
parent = create_taxon
|
30
|
+
url = 'https://alt.example.com/hello'
|
31
|
+
create_taxon(url: url, parent: parent)
|
32
|
+
GenerateSitemaps.new.perform
|
33
|
+
|
34
|
+
contents = Zlib::GzipReader.new(Sitemap.first.file.file).read
|
35
|
+
assert_includes(contents, url)
|
36
|
+
end
|
37
|
+
|
38
|
+
def test_adds_navigation_link_with_relative_path
|
39
|
+
parent = create_taxon
|
40
|
+
url = '/hello'
|
41
|
+
create_taxon(url: url, parent: parent)
|
42
|
+
GenerateSitemaps.new.perform
|
43
|
+
|
44
|
+
contents = Zlib::GzipReader.new(Sitemap.first.file.file).read
|
45
|
+
assert_includes(contents, "http://#{Workarea.config.host}" + url)
|
46
|
+
refute_includes(contents, '<loc>://')
|
47
|
+
end
|
48
|
+
|
49
|
+
def test_adds_navigation_link_with_navigable
|
50
|
+
create_taxon(
|
51
|
+
navigable: create_page(slug: 'test-page'),
|
52
|
+
parent: create_taxon
|
53
|
+
)
|
54
|
+
|
55
|
+
GenerateSitemaps.new.perform
|
56
|
+
|
57
|
+
contents = Zlib::GzipReader.new(Sitemap.first.file.file).read
|
58
|
+
assert_includes(contents, 'test-page')
|
59
|
+
end
|
60
|
+
|
61
|
+
def test_does_not_add_link_for_inactive_taxon
|
62
|
+
create_taxon(navigable: create_page(slug: 'foo', active: false))
|
63
|
+
GenerateSitemaps.new.perform
|
64
|
+
|
65
|
+
contents = Zlib::GzipReader.new(Sitemap.first.file.file).read
|
66
|
+
refute_includes(contents, 'foo')
|
67
|
+
end
|
68
|
+
|
69
|
+
def test_cleans_up_tmp_directory
|
70
|
+
GenerateSitemaps.new.perform
|
71
|
+
refute(Dir.exists?(Rails.root.join('tmp', 'sitemaps')))
|
72
|
+
end
|
73
|
+
|
74
|
+
def test_overwrites_existing_sitemap
|
75
|
+
GenerateSitemaps.new.perform
|
76
|
+
GenerateSitemaps.new.perform
|
77
|
+
|
78
|
+
assert_equal(1, Sitemap.count)
|
79
|
+
end
|
80
|
+
end
|
81
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
$:.push File.expand_path('../lib', __FILE__)
|
2
|
+
|
3
|
+
require 'workarea/sitemaps/version'
|
4
|
+
|
5
|
+
Gem::Specification.new do |s|
|
6
|
+
s.name = 'workarea-sitemaps'
|
7
|
+
s.version = Workarea::Sitemaps::VERSION
|
8
|
+
s.authors = ['Ben Crouse']
|
9
|
+
s.email = ['bcrouse@workarea.com']
|
10
|
+
s.homepage = 'https://github.com/workarea-commerce/workarea-sitemaps'
|
11
|
+
s.summary = 'Sitemaps plugin for the Workarea Commerce Platform'
|
12
|
+
s.description = 'Adds a sitemap XML to Workarea Commerce Platform. Handles generating the sitemap and routing to it.'
|
13
|
+
|
14
|
+
s.files = `git ls-files`.split("\n")
|
15
|
+
|
16
|
+
s.license = 'Business Software License'
|
17
|
+
|
18
|
+
s.required_ruby_version = '>= 2.3.0'
|
19
|
+
|
20
|
+
s.add_dependency 'sitemap_generator', '~> 5.3.1'
|
21
|
+
s.add_dependency 'workarea', '~> 3.x'
|
22
|
+
end
|