slugs 4.0.0.3 → 5.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/MIT-LICENSE +1 -1
- data/README.md +5 -5
- data/Rakefile +1 -3
- data/lib/slugs/extensions/action_dispatch/optimized_url_helper.rb +6 -6
- data/lib/slugs/slug.rb +1 -1
- data/lib/slugs/version.rb +1 -1
- metadata +13 -127
- data/test/dummy/Rakefile +0 -5
- data/test/dummy/app/assets/javascripts/application.js +0 -13
- data/test/dummy/app/assets/stylesheets/application.css +0 -15
- data/test/dummy/app/controllers/application_controller.rb +0 -5
- data/test/dummy/app/helpers/application_helper.rb +0 -2
- data/test/dummy/app/models/category.rb +0 -7
- data/test/dummy/app/models/domain.rb +0 -2
- data/test/dummy/app/models/product.rb +0 -8
- data/test/dummy/app/models/shop.rb +0 -5
- data/test/dummy/app/models/user.rb +0 -5
- data/test/dummy/app/views/layouts/application.html.erb +0 -12
- data/test/dummy/bin/bundle +0 -4
- data/test/dummy/bin/rails +0 -5
- data/test/dummy/bin/rake +0 -5
- data/test/dummy/bin/setup +0 -30
- data/test/dummy/config.ru +0 -4
- data/test/dummy/config/application.rb +0 -25
- data/test/dummy/config/boot.rb +0 -5
- data/test/dummy/config/database.yml +0 -10
- data/test/dummy/config/database.yml.travis +0 -3
- data/test/dummy/config/environment.rb +0 -5
- data/test/dummy/config/environments/development.rb +0 -41
- data/test/dummy/config/environments/production.rb +0 -79
- data/test/dummy/config/environments/test.rb +0 -42
- data/test/dummy/config/initializers/assets.rb +0 -11
- data/test/dummy/config/initializers/backtrace_silencers.rb +0 -7
- data/test/dummy/config/initializers/cookies_serializer.rb +0 -3
- data/test/dummy/config/initializers/filter_parameter_logging.rb +0 -4
- data/test/dummy/config/initializers/inflections.rb +0 -16
- data/test/dummy/config/initializers/mime_types.rb +0 -4
- data/test/dummy/config/initializers/session_store.rb +0 -3
- data/test/dummy/config/initializers/slugs.rb +0 -7
- data/test/dummy/config/initializers/wrap_parameters.rb +0 -14
- data/test/dummy/config/locales/en.yml +0 -23
- data/test/dummy/config/routes.rb +0 -5
- data/test/dummy/config/secrets.yml +0 -22
- data/test/dummy/db/migrate/20161016174020_create_users.rb +0 -11
- data/test/dummy/db/migrate/20161016174126_create_shops.rb +0 -10
- data/test/dummy/db/migrate/20161016174202_create_products.rb +0 -12
- data/test/dummy/db/migrate/20161016174225_create_categories.rb +0 -11
- data/test/dummy/db/migrate/20161124162802_create_slugs.rb +0 -15
- data/test/dummy/db/migrate/20161208062832_create_domains.rb +0 -8
- data/test/dummy/db/schema.rb +0 -68
- data/test/dummy/log/development.log +0 -726
- data/test/dummy/log/test.log +0 -5870
- data/test/dummy/public/404.html +0 -61
- data/test/dummy/public/422.html +0 -61
- data/test/dummy/public/500.html +0 -60
- data/test/dummy/public/favicon.ico +0 -0
- data/test/generator_test.rb +0 -18
- data/test/record_test.rb +0 -71
- data/test/route_test.rb +0 -17
- data/test/task_test.rb +0 -17
- data/test/test_helper.rb +0 -13
data/test/dummy/public/404.html
DELETED
@@ -1,61 +0,0 @@
|
|
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
|
-
div.dialog {
|
15
|
-
width: 95%;
|
16
|
-
max-width: 33em;
|
17
|
-
margin: 4em auto 0;
|
18
|
-
}
|
19
|
-
div.dialog > div {
|
20
|
-
border: 1px solid #CCC;
|
21
|
-
border-right-color: #999;
|
22
|
-
border-left-color: #999;
|
23
|
-
border-bottom-color: #BBB;
|
24
|
-
border-top: #B00100 solid 4px;
|
25
|
-
border-top-left-radius: 9px;
|
26
|
-
border-top-right-radius: 9px;
|
27
|
-
background-color: white;
|
28
|
-
padding: 7px 12% 0;
|
29
|
-
box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
|
30
|
-
}
|
31
|
-
h1 {
|
32
|
-
font-size: 100%;
|
33
|
-
color: #730E15;
|
34
|
-
line-height: 1.5em;
|
35
|
-
}
|
36
|
-
div.dialog > p {
|
37
|
-
margin: 0 0 1em;
|
38
|
-
padding: 1em;
|
39
|
-
background-color: #F7F7F7;
|
40
|
-
border: 1px solid #CCC;
|
41
|
-
border-right-color: #999;
|
42
|
-
border-left-color: #999;
|
43
|
-
border-bottom-color: #999;
|
44
|
-
border-bottom-left-radius: 4px;
|
45
|
-
border-bottom-right-radius: 4px;
|
46
|
-
border-top-color: #DADADA;
|
47
|
-
color: #666;
|
48
|
-
box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
|
49
|
-
}
|
50
|
-
</style>
|
51
|
-
</head>
|
52
|
-
<body>
|
53
|
-
<div class="dialog">
|
54
|
-
<div>
|
55
|
-
<h1>The page you were looking for doesn't exist.</h1>
|
56
|
-
<p>You may have mistyped the address or the page may have moved.</p>
|
57
|
-
</div>
|
58
|
-
<p>If you are the application owner check the logs for more information.</p>
|
59
|
-
</div>
|
60
|
-
</body>
|
61
|
-
</html>
|
data/test/dummy/public/422.html
DELETED
@@ -1,61 +0,0 @@
|
|
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
|
-
div.dialog {
|
15
|
-
width: 95%;
|
16
|
-
max-width: 33em;
|
17
|
-
margin: 4em auto 0;
|
18
|
-
}
|
19
|
-
div.dialog > div {
|
20
|
-
border: 1px solid #CCC;
|
21
|
-
border-right-color: #999;
|
22
|
-
border-left-color: #999;
|
23
|
-
border-bottom-color: #BBB;
|
24
|
-
border-top: #B00100 solid 4px;
|
25
|
-
border-top-left-radius: 9px;
|
26
|
-
border-top-right-radius: 9px;
|
27
|
-
background-color: white;
|
28
|
-
padding: 7px 12% 0;
|
29
|
-
box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
|
30
|
-
}
|
31
|
-
h1 {
|
32
|
-
font-size: 100%;
|
33
|
-
color: #730E15;
|
34
|
-
line-height: 1.5em;
|
35
|
-
}
|
36
|
-
div.dialog > p {
|
37
|
-
margin: 0 0 1em;
|
38
|
-
padding: 1em;
|
39
|
-
background-color: #F7F7F7;
|
40
|
-
border: 1px solid #CCC;
|
41
|
-
border-right-color: #999;
|
42
|
-
border-left-color: #999;
|
43
|
-
border-bottom-color: #999;
|
44
|
-
border-bottom-left-radius: 4px;
|
45
|
-
border-bottom-right-radius: 4px;
|
46
|
-
border-top-color: #DADADA;
|
47
|
-
color: #666;
|
48
|
-
box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
|
49
|
-
}
|
50
|
-
</style>
|
51
|
-
</head>
|
52
|
-
<body>
|
53
|
-
<div class="dialog">
|
54
|
-
<div>
|
55
|
-
<h1>The change you wanted was rejected.</h1>
|
56
|
-
<p>Maybe you tried to change something you didn't have access to.</p>
|
57
|
-
</div>
|
58
|
-
<p>If you are the application owner check the logs for more information.</p>
|
59
|
-
</div>
|
60
|
-
</body>
|
61
|
-
</html>
|
data/test/dummy/public/500.html
DELETED
@@ -1,60 +0,0 @@
|
|
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
|
-
div.dialog {
|
15
|
-
width: 95%;
|
16
|
-
max-width: 33em;
|
17
|
-
margin: 4em auto 0;
|
18
|
-
}
|
19
|
-
div.dialog > div {
|
20
|
-
border: 1px solid #CCC;
|
21
|
-
border-right-color: #999;
|
22
|
-
border-left-color: #999;
|
23
|
-
border-bottom-color: #BBB;
|
24
|
-
border-top: #B00100 solid 4px;
|
25
|
-
border-top-left-radius: 9px;
|
26
|
-
border-top-right-radius: 9px;
|
27
|
-
background-color: white;
|
28
|
-
padding: 7px 12% 0;
|
29
|
-
box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
|
30
|
-
}
|
31
|
-
h1 {
|
32
|
-
font-size: 100%;
|
33
|
-
color: #730E15;
|
34
|
-
line-height: 1.5em;
|
35
|
-
}
|
36
|
-
div.dialog > p {
|
37
|
-
margin: 0 0 1em;
|
38
|
-
padding: 1em;
|
39
|
-
background-color: #F7F7F7;
|
40
|
-
border: 1px solid #CCC;
|
41
|
-
border-right-color: #999;
|
42
|
-
border-left-color: #999;
|
43
|
-
border-bottom-color: #999;
|
44
|
-
border-bottom-left-radius: 4px;
|
45
|
-
border-bottom-right-radius: 4px;
|
46
|
-
border-top-color: #DADADA;
|
47
|
-
color: #666;
|
48
|
-
box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
|
49
|
-
}
|
50
|
-
</style>
|
51
|
-
</head>
|
52
|
-
<body>
|
53
|
-
<div class="dialog">
|
54
|
-
<div>
|
55
|
-
<h1>We're sorry, but something went wrong.</h1>
|
56
|
-
</div>
|
57
|
-
<p>If you are the application owner check the logs for more information.</p>
|
58
|
-
</div>
|
59
|
-
</body>
|
60
|
-
</html>
|
File without changes
|
data/test/generator_test.rb
DELETED
@@ -1,18 +0,0 @@
|
|
1
|
-
require 'test_helper'
|
2
|
-
require 'rails/generators'
|
3
|
-
require 'generators/slugs/install/install_generator'
|
4
|
-
|
5
|
-
class GeneratorsTest < Rails::Generators::TestCase
|
6
|
-
destination Rails.root.join('tmp')
|
7
|
-
|
8
|
-
teardown do
|
9
|
-
FileUtils.rm_rf destination_root
|
10
|
-
end
|
11
|
-
|
12
|
-
test 'install' do
|
13
|
-
self.class.tests Slugs::Generators::InstallGenerator
|
14
|
-
run_generator
|
15
|
-
assert_file 'config/initializers/slugs.rb'
|
16
|
-
end
|
17
|
-
|
18
|
-
end
|
data/test/record_test.rb
DELETED
@@ -1,71 +0,0 @@
|
|
1
|
-
require 'test_helper'
|
2
|
-
|
3
|
-
class RecordTest < ActiveSupport::TestCase
|
4
|
-
|
5
|
-
test 'finders' do
|
6
|
-
user = User.create(first_name: 'Zakk', last_name: 'Wylde')
|
7
|
-
assert_equal 'zakk-wylde', user.slug
|
8
|
-
assert User.exists?('zakk-wylde')
|
9
|
-
assert User.exists?(user.id)
|
10
|
-
assert User.exists?(user.id.to_s)
|
11
|
-
assert_equal user, User.find('zakk-wylde')
|
12
|
-
assert_equal user, User.find(user.id)
|
13
|
-
assert_equal user, User.find(user.id.to_s)
|
14
|
-
|
15
|
-
user.update first_name: 'Yngwie', last_name: 'Malmsteen'
|
16
|
-
assert_equal 'yngwie-malmsteen', user.slug
|
17
|
-
assert User.exists?('zakk-wylde')
|
18
|
-
assert_equal user, User.find('zakk-wylde')
|
19
|
-
assert User.exists?('yngwie-malmsteen')
|
20
|
-
assert_equal user, User.find('yngwie-malmsteen')
|
21
|
-
assert_equal user, User.find(user.id)
|
22
|
-
assert_equal user, User.find(user.id.to_s)
|
23
|
-
|
24
|
-
user = User.create(first_name: 'Zakk', last_name: 'Wylde')
|
25
|
-
assert_equal 'zakk-wylde', user.slug
|
26
|
-
assert User.exists?('zakk-wylde')
|
27
|
-
assert User.exists?(user.id)
|
28
|
-
assert User.exists?(user.id.to_s)
|
29
|
-
assert_equal user, User.find('zakk-wylde')
|
30
|
-
assert_equal user, User.find(user.id)
|
31
|
-
assert_equal user, User.find(user.id.to_s)
|
32
|
-
|
33
|
-
domain = Domain.create
|
34
|
-
assert_nothing_raised do
|
35
|
-
Domain.find domain.id
|
36
|
-
Domain.exists? domain.id+1
|
37
|
-
end
|
38
|
-
end
|
39
|
-
|
40
|
-
test 'indices' do
|
41
|
-
3.times.each do |index|
|
42
|
-
shop = Shop.create(name: 'Guitar Shop')
|
43
|
-
if index == 0
|
44
|
-
assert_equal 'guitar-shop', shop.slug
|
45
|
-
else
|
46
|
-
assert_equal "guitar-shop-#{index}", shop.slug
|
47
|
-
end
|
48
|
-
end
|
49
|
-
|
50
|
-
shop = Shop.first
|
51
|
-
3.times.each do |index|
|
52
|
-
product = Product.create(name: 'Les Paul', shop: shop)
|
53
|
-
if index == 0
|
54
|
-
assert_equal 'les-paul', product.slug
|
55
|
-
else
|
56
|
-
assert_equal "les-paul-#{index}", product.slug
|
57
|
-
end
|
58
|
-
end
|
59
|
-
|
60
|
-
shop = Shop.last
|
61
|
-
3.times.each do |index|
|
62
|
-
product = Product.create(name: 'Les Paul', shop: shop)
|
63
|
-
if index == 0
|
64
|
-
assert_equal 'les-paul', product.slug
|
65
|
-
else
|
66
|
-
assert_equal "les-paul-#{index}", product.slug
|
67
|
-
end
|
68
|
-
end
|
69
|
-
end
|
70
|
-
|
71
|
-
end
|
data/test/route_test.rb
DELETED
@@ -1,17 +0,0 @@
|
|
1
|
-
require 'test_helper'
|
2
|
-
|
3
|
-
class RouteTest < ActionDispatch::IntegrationTest
|
4
|
-
|
5
|
-
setup do
|
6
|
-
@shop = Shop.create(name: 'Guitar Shop')
|
7
|
-
end
|
8
|
-
|
9
|
-
test 'generator' do
|
10
|
-
assert_equal '/shops/guitar-shop?page=3', shop_path(@shop, page: 3)
|
11
|
-
end
|
12
|
-
|
13
|
-
test 'optimized url helper' do
|
14
|
-
assert_equal '/shops/guitar-shop', shop_path(@shop)
|
15
|
-
end
|
16
|
-
|
17
|
-
end
|
data/test/task_test.rb
DELETED
@@ -1,17 +0,0 @@
|
|
1
|
-
require 'test_helper'
|
2
|
-
|
3
|
-
class TaskTest < ActiveSupport::TestCase
|
4
|
-
|
5
|
-
setup do
|
6
|
-
Dummy::Application.load_tasks
|
7
|
-
end
|
8
|
-
|
9
|
-
test 'import' do
|
10
|
-
shop = Shop.create(name: 'Guitar shop')
|
11
|
-
category = Category.create(name: 'Electric', shop: shop)
|
12
|
-
Slugs::Slug.destroy_all
|
13
|
-
Rake::Task['slugs:migrate'].invoke
|
14
|
-
assert_equal %w(guitar-shop electric), Slugs::Slug.pluck(:value)
|
15
|
-
end
|
16
|
-
|
17
|
-
end
|
data/test/test_helper.rb
DELETED
@@ -1,13 +0,0 @@
|
|
1
|
-
# Configure Rails Environment
|
2
|
-
ENV['RAILS_ENV'] = 'test'
|
3
|
-
|
4
|
-
require File.expand_path('../../test/dummy/config/environment.rb', __FILE__)
|
5
|
-
ActiveRecord::Migrator.migrations_paths = [File.expand_path('../../test/dummy/db/migrate', __FILE__)]
|
6
|
-
require 'rails/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
|
11
|
-
|
12
|
-
# Load support files
|
13
|
-
Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each { |f| require f }
|