slugs 2.0.1 → 4.0.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +59 -19
- data/Rakefile +1 -19
- data/lib/generators/slugs/install/install_generator.rb +24 -0
- data/lib/generators/slugs/{templates/configuration.rb → install/templates/initializer.rb} +1 -1
- data/lib/generators/slugs/install/templates/migration.rb +15 -0
- data/lib/slugs.rb +7 -4
- data/lib/slugs/concern.rb +16 -9
- data/lib/slugs/configuration.rb +11 -1
- data/lib/slugs/extensions/action_dispatch/generator.rb +1 -0
- data/lib/slugs/extensions/action_dispatch/optimized_url_helper.rb +1 -0
- data/lib/slugs/extensions/active_record/finders.rb +27 -0
- data/lib/slugs/railtie.rb +10 -4
- data/lib/slugs/slug.rb +9 -0
- data/lib/slugs/version.rb +1 -1
- data/test/dummy/bin/bundle +1 -0
- data/test/dummy/bin/rails +1 -0
- data/test/dummy/bin/rake +1 -0
- data/test/dummy/bin/setup +1 -0
- data/test/dummy/config/database.yml.travis +2 -11
- data/test/dummy/config/environments/development.rb +1 -1
- data/test/dummy/config/environments/production.rb +1 -1
- data/test/dummy/config/environments/test.rb +2 -2
- data/test/dummy/config/initializers/slugs.rb +1 -1
- data/test/dummy/config/secrets.yml +2 -2
- data/test/dummy/db/migrate/20161016174020_create_users.rb +2 -0
- data/test/dummy/db/migrate/20161016174126_create_shops.rb +2 -0
- data/test/dummy/db/migrate/20161016174202_create_products.rb +2 -0
- data/test/dummy/db/migrate/20161016174225_create_categories.rb +2 -0
- data/test/dummy/db/migrate/20161124162802_create_slugs.rb +15 -0
- data/test/dummy/db/schema.rb +33 -13
- data/test/dummy/log/development.log +394 -30
- data/test/dummy/log/test.log +3017 -3978
- data/test/dummy/public/404.html +57 -63
- data/test/dummy/public/422.html +57 -63
- data/test/dummy/public/500.html +56 -62
- data/test/generator_test.rb +3 -4
- data/test/record_test.rb +65 -0
- data/test/{routes_test.rb → route_test.rb} +1 -1
- data/test/test_helper.rb +2 -2
- metadata +14 -9
- data/lib/generators/slugs/install_generator.rb +0 -15
- data/test/records_test.rb +0 -27
data/test/test_helper.rb
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
# Configure Rails Environment
|
2
2
|
ENV['RAILS_ENV'] = 'test'
|
3
3
|
|
4
|
-
require File.expand_path('
|
5
|
-
ActiveRecord::Migrator.migrations_paths = [File.expand_path('
|
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
6
|
require 'rails/test_help'
|
7
7
|
|
8
8
|
# Filter out Minitest backtrace while allowing backtrace from other libraries
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: slugs
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 4.0.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- mmontossi
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-12-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -46,7 +46,7 @@ dependencies:
|
|
46
46
|
version: '0.18'
|
47
47
|
description: Manages slugs for records with minimal efford in rails.
|
48
48
|
email:
|
49
|
-
- mmontossi@
|
49
|
+
- mmontossi@gmail.com
|
50
50
|
executables: []
|
51
51
|
extensions: []
|
52
52
|
extra_rdoc_files: []
|
@@ -54,15 +54,18 @@ files:
|
|
54
54
|
- MIT-LICENSE
|
55
55
|
- README.md
|
56
56
|
- Rakefile
|
57
|
-
- lib/generators/slugs/install_generator.rb
|
58
|
-
- lib/generators/slugs/templates/
|
57
|
+
- lib/generators/slugs/install/install_generator.rb
|
58
|
+
- lib/generators/slugs/install/templates/initializer.rb
|
59
|
+
- lib/generators/slugs/install/templates/migration.rb
|
59
60
|
- lib/slugs.rb
|
60
61
|
- lib/slugs/concern.rb
|
61
62
|
- lib/slugs/configuration.rb
|
62
63
|
- lib/slugs/extensions/action_dispatch/generator.rb
|
63
64
|
- lib/slugs/extensions/action_dispatch/optimized_url_helper.rb
|
64
65
|
- lib/slugs/extensions/active_record/base.rb
|
66
|
+
- lib/slugs/extensions/active_record/finders.rb
|
65
67
|
- lib/slugs/railtie.rb
|
68
|
+
- lib/slugs/slug.rb
|
66
69
|
- lib/slugs/version.rb
|
67
70
|
- test/dummy/Rakefile
|
68
71
|
- test/dummy/app/assets/javascripts/application.js
|
@@ -103,6 +106,7 @@ files:
|
|
103
106
|
- test/dummy/db/migrate/20161016174126_create_shops.rb
|
104
107
|
- test/dummy/db/migrate/20161016174202_create_products.rb
|
105
108
|
- test/dummy/db/migrate/20161016174225_create_categories.rb
|
109
|
+
- test/dummy/db/migrate/20161124162802_create_slugs.rb
|
106
110
|
- test/dummy/db/schema.rb
|
107
111
|
- test/dummy/log/development.log
|
108
112
|
- test/dummy/log/test.log
|
@@ -111,8 +115,8 @@ files:
|
|
111
115
|
- test/dummy/public/500.html
|
112
116
|
- test/dummy/public/favicon.ico
|
113
117
|
- test/generator_test.rb
|
114
|
-
- test/
|
115
|
-
- test/
|
118
|
+
- test/record_test.rb
|
119
|
+
- test/route_test.rb
|
116
120
|
- test/test_helper.rb
|
117
121
|
homepage: https://github.com/mmontossi/slugs
|
118
122
|
licenses:
|
@@ -177,6 +181,7 @@ test_files:
|
|
177
181
|
- test/dummy/db/migrate/20161016174126_create_shops.rb
|
178
182
|
- test/dummy/db/migrate/20161016174202_create_products.rb
|
179
183
|
- test/dummy/db/migrate/20161016174225_create_categories.rb
|
184
|
+
- test/dummy/db/migrate/20161124162802_create_slugs.rb
|
180
185
|
- test/dummy/db/schema.rb
|
181
186
|
- test/dummy/log/development.log
|
182
187
|
- test/dummy/log/test.log
|
@@ -186,6 +191,6 @@ test_files:
|
|
186
191
|
- test/dummy/public/favicon.ico
|
187
192
|
- test/dummy/Rakefile
|
188
193
|
- test/generator_test.rb
|
189
|
-
- test/
|
190
|
-
- test/
|
194
|
+
- test/record_test.rb
|
195
|
+
- test/route_test.rb
|
191
196
|
- test/test_helper.rb
|
@@ -1,15 +0,0 @@
|
|
1
|
-
require 'rails/generators/base'
|
2
|
-
|
3
|
-
module Cronjobs
|
4
|
-
module Generators
|
5
|
-
class InstallGenerator < Rails::Generators::Base
|
6
|
-
|
7
|
-
source_root File.expand_path('../templates', __FILE__)
|
8
|
-
|
9
|
-
def create_definitions_file
|
10
|
-
copy_file 'configuration.rb', 'config/initializers/slugs.rb'
|
11
|
-
end
|
12
|
-
|
13
|
-
end
|
14
|
-
end
|
15
|
-
end
|
data/test/records_test.rb
DELETED
@@ -1,27 +0,0 @@
|
|
1
|
-
require 'test_helper'
|
2
|
-
|
3
|
-
class RecordsTest < ActiveSupport::TestCase
|
4
|
-
|
5
|
-
test 'save' do
|
6
|
-
user = User.create(first_name: 'Zakk', last_name: 'Wylde')
|
7
|
-
assert_equal 'zakk-wylde', user.slug
|
8
|
-
|
9
|
-
user.update slug: 'yngwie-malmsteen'
|
10
|
-
assert_equal 'yngwie-malmsteen', user.slug
|
11
|
-
end
|
12
|
-
|
13
|
-
test 'uniqueness' do
|
14
|
-
2.times { Shop.create(name: 'Guitar Shop') }
|
15
|
-
shop = Shop.last
|
16
|
-
assert_equal "guitar-shop-#{shop.id}", shop.slug
|
17
|
-
|
18
|
-
2.times { Category.create(name: 'Gibson', shop: shop) }
|
19
|
-
category = Category.last
|
20
|
-
assert_equal "gibson-#{category.id}", category.slug
|
21
|
-
|
22
|
-
2.times { Product.create(name: 'Les Paul', shop: shop, category: category) }
|
23
|
-
product = Product.last
|
24
|
-
assert_equal "les-paul-#{product.id}", product.slug
|
25
|
-
end
|
26
|
-
|
27
|
-
end
|