slugs 1.1.0 → 1.2.3

Sign up to get free protection for your applications and to get access to all the features.
data/test/records_test.rb CHANGED
@@ -2,12 +2,6 @@ require 'test_helper'
2
2
 
3
3
  class RecordsTest < ActiveSupport::TestCase
4
4
 
5
- setup do
6
- @without = Without.create(name: 'name')
7
- @simple = Simple.create(name: 'name', age: 14)
8
- @translatable = Translatable.create(name: 'translatable name', age: 20)
9
- end
10
-
11
5
  test "should not break validation" do
12
6
  assert Without.new.valid?
13
7
  assert Simple.new.valid?
@@ -15,64 +9,97 @@ class RecordsTest < ActiveSupport::TestCase
15
9
  end
16
10
 
17
11
  test "should not break models" do
18
- assert_equal 'name', @without.name
19
- assert_equal @without, Without.find('1')
20
- assert_equal @without, Without.find(1)
12
+ assert_equal 'name', without.name
13
+ assert_equal without, Without.find('1')
14
+ assert_equal without, Without.find(1)
21
15
  end
22
16
 
23
17
  test "should create slug" do
24
- assert_equal 'name', @simple.slug
25
- assert_equal @simple, Simple.find('name')
26
- assert_equal 'translatable-name', @translatable.slug
27
- assert_equal @translatable, Translatable.find('translatable-name')
18
+ assert_equal 'name', simple.slug
19
+ assert_equal simple, Simple.find('name')
20
+
21
+ assert_equal 'translatable-name', translatable.slug
22
+ assert_equal translatable, Translatable.find('translatable-name')
28
23
  end
29
24
 
30
- test "should edit slug" do
31
- @simple.update_attributes name: 'new name'
32
- assert_equal 'new-name', @simple.slug
33
- assert_equal @simple, Simple.find('new-name')
34
- @translatable.update_attributes name: 'new translatable name'
35
- assert_equal 'new-translatable-name', @translatable.slug
36
- assert_equal @translatable, Translatable.find('new-translatable-name')
25
+ test "should update slug" do
26
+ simple.update name: 'new name'
27
+ assert_equal 'new-name', simple.slug
28
+ assert_equal simple, Simple.find('new-name')
29
+
30
+ translatable.update name: 'new translatable name'
31
+ assert_equal 'new-translatable-name', translatable.slug
32
+ assert_equal translatable, Translatable.find('new-translatable-name')
37
33
  end
38
34
 
39
35
  test "should not alter direct assigned slug" do
40
- @simple.update_attributes slug: 'direct slug'
41
- assert_equal 'direct slug', @simple.slug
42
- assert_equal @simple, Simple.find('direct slug')
43
- @translatable.update_attributes slug: 'translatable direct slug'
44
- assert_equal 'translatable direct slug', @translatable.slug
45
- assert_equal @translatable, Translatable.find('translatable direct slug')
36
+ simple.update slug: 'direct slug'
37
+ assert_equal 'direct slug', simple.slug
38
+ assert_equal simple, Simple.find('direct slug')
39
+
40
+ translatable.update slug: 'translatable direct slug'
41
+ assert_equal 'translatable direct slug', translatable.slug
42
+ assert_equal translatable, Translatable.find('translatable direct slug')
43
+ end
44
+
45
+ test "records should not be readonly" do
46
+ Simple.create name: 'editable'
47
+ assert_not Simple.find('editable').readonly?
48
+
49
+ Translatable.create name: 'editable'
50
+ assert_not Translatable.find('editable').readonly?
46
51
  end
47
52
 
48
53
  test "should assign index for same slugs" do
49
54
  first = Simple.create(name: 'same', age: 34)
50
55
  assert_equal 'same', first.slug
56
+
57
+ Simple.create(name: 'same-larger', age: 10) }
58
+ 20.times { Simple.create(name: 'same', age: 10) }
59
+
51
60
  second = Simple.create(name: 'same', age: 45)
52
- assert_equal 'same-1', second.slug
61
+ assert_equal 'same-21', second.slug
53
62
  third = Simple.create(name: 'same', age: 234)
54
- assert_equal 'same-2', third.slug
63
+ assert_equal 'same-22', third.slug
55
64
 
56
- first.update_attributes name: 'other'
57
- assert_equal 'other', first.slug
58
- second.update_attributes name: 'other'
59
- assert_equal 'other-1', second.slug
60
- third.update_attributes name: 'other'
61
- assert_equal 'other-2', third.slug
65
+ first.update name: 'same'
66
+ assert_equal 'same', first.slug
67
+ second.update name: 'same'
68
+ assert_equal 'same-23', second.slug
69
+ third.update name: 'other'
70
+ assert_equal 'other', third.slug
62
71
 
63
72
  first = Translatable.create(name: 'same', age: 34)
64
73
  assert_equal 'same', first.slug
74
+
75
+ Simple.create(name: 'same-larger', age: 10) }
76
+ 20.times { Translatable.create(name: 'same', age: 10) }
77
+
65
78
  second = Translatable.create(name: 'same', age: 45)
66
- assert_equal 'same-1', second.slug
79
+ assert_equal 'same-21', second.slug
67
80
  third = Translatable.create(name: 'same', age: 234)
68
- assert_equal 'same-2', third.slug
69
-
70
- first.update_attributes name: 'other'
71
- assert_equal 'other', first.slug
72
- second.update_attributes name: 'other'
73
- assert_equal 'other-1', second.slug
74
- third.update_attributes name: 'other'
75
- assert_equal 'other-2', third.slug
81
+ assert_equal 'same-22', third.slug
82
+
83
+ first.update name: 'same'
84
+ assert_equal 'same', first.slug
85
+ second.update name: 'same'
86
+ assert_equal 'same-23', second.slug
87
+ third.update name: 'other'
88
+ assert_equal 'other', third.slug
89
+ end
90
+
91
+ private
92
+
93
+ def simple
94
+ @simple ||= Simple.create(name: 'name', age: 14)
95
+ end
96
+
97
+ def without
98
+ @without ||= Without.create(name: 'name')
99
+ end
100
+
101
+ def translatable
102
+ @translatable ||= Translatable.create(name: 'translatable name', age: 20)
76
103
  end
77
104
 
78
105
  end
data/test/test_helper.rb CHANGED
@@ -1,8 +1,8 @@
1
1
  # Configure Rails Environment
2
- ENV["RAILS_ENV"] = "test"
2
+ ENV['RAILS_ENV'] = 'test'
3
3
 
4
- require File.expand_path("../dummy/config/environment.rb", __FILE__)
5
- require "rails/test_help"
4
+ require File.expand_path('../dummy/config/environment.rb', __FILE__)
5
+ require 'rails/test_help'
6
6
 
7
7
  Rails.backtrace_cleaner.remove_silencers!
8
8
 
@@ -11,7 +11,7 @@ Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each { |f| require f }
11
11
 
12
12
  # Load fixtures from the engine
13
13
  if ActiveSupport::TestCase.method_defined?(:fixture_path=)
14
- ActiveSupport::TestCase.fixture_path = File.expand_path("../fixtures", __FILE__)
14
+ ActiveSupport::TestCase.fixture_path = File.expand_path('../fixtures', __FILE__)
15
15
  end
16
16
 
17
17
  # Load database
metadata CHANGED
@@ -1,60 +1,76 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: slugs
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 1.2.3
5
5
  platform: ruby
6
6
  authors:
7
- - Mattways
7
+ - Museways
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-08-19 00:00:00.000000000 Z
11
+ date: 2014-02-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - '>='
17
+ - - ">="
18
18
  - !ruby/object:Gem::Version
19
19
  version: 3.0.0
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - '>='
24
+ - - ">="
25
25
  - !ruby/object:Gem::Version
26
26
  version: 3.0.0
27
+ - !ruby/object:Gem::Dependency
28
+ name: translatable_records
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
27
41
  - !ruby/object:Gem::Dependency
28
42
  name: sqlite3
29
43
  requirement: !ruby/object:Gem::Requirement
30
44
  requirements:
31
- - - '>='
45
+ - - ">="
32
46
  - !ruby/object:Gem::Version
33
47
  version: '0'
34
48
  type: :development
35
49
  prerelease: false
36
50
  version_requirements: !ruby/object:Gem::Requirement
37
51
  requirements:
38
- - - '>='
52
+ - - ">="
39
53
  - !ruby/object:Gem::Version
40
54
  version: '0'
41
55
  description: Inspired in friendly_id but more minimalistic.
42
56
  email:
43
- - contact@mattways.com
57
+ - contact@museways.com
44
58
  executables: []
45
59
  extensions: []
46
60
  extra_rdoc_files: []
47
61
  files:
62
+ - MIT-LICENSE
63
+ - README.rdoc
64
+ - Rakefile
65
+ - lib/slugs.rb
48
66
  - lib/slugs/active_record/base.rb
49
67
  - lib/slugs/active_record/non_translatable.rb
50
68
  - lib/slugs/active_record/relation.rb
51
69
  - lib/slugs/active_record/translatable.rb
52
70
  - lib/slugs/railtie.rb
53
71
  - lib/slugs/version.rb
54
- - lib/slugs.rb
55
- - MIT-LICENSE
56
- - Rakefile
57
- - README.rdoc
72
+ - test/dummy/README.rdoc
73
+ - test/dummy/Rakefile
58
74
  - test/dummy/app/assets/javascripts/application.js
59
75
  - test/dummy/app/assets/stylesheets/application.css
60
76
  - test/dummy/app/controllers/application_controller.rb
@@ -67,6 +83,7 @@ files:
67
83
  - test/dummy/bin/bundle
68
84
  - test/dummy/bin/rails
69
85
  - test/dummy/bin/rake
86
+ - test/dummy/config.ru
70
87
  - test/dummy/config/application.rb
71
88
  - test/dummy/config/boot.rb
72
89
  - test/dummy/config/database.yml
@@ -83,25 +100,20 @@ files:
83
100
  - test/dummy/config/initializers/wrap_parameters.rb
84
101
  - test/dummy/config/locales/en.yml
85
102
  - test/dummy/config/routes.rb
86
- - test/dummy/config.ru
87
- - test/dummy/db/development.sqlite3
88
103
  - test/dummy/db/migrate/20130819183013_create_simples.rb
89
104
  - test/dummy/db/migrate/20130819183047_create_withouts.rb
90
105
  - test/dummy/db/migrate/20130819183119_create_translatables.rb
91
106
  - test/dummy/db/migrate/20130819183257_create_translatable_translations.rb
92
107
  - test/dummy/db/schema.rb
93
- - test/dummy/db/test.sqlite3
94
108
  - test/dummy/log/development.log
95
109
  - test/dummy/log/test.log
96
110
  - test/dummy/public/404.html
97
111
  - test/dummy/public/422.html
98
112
  - test/dummy/public/500.html
99
113
  - test/dummy/public/favicon.ico
100
- - test/dummy/Rakefile
101
- - test/dummy/README.rdoc
102
114
  - test/records_test.rb
103
115
  - test/test_helper.rb
104
- homepage: https://github.com/mattways/slugs
116
+ homepage: https://github.com/museways/slugs
105
117
  licenses:
106
118
  - MIT
107
119
  metadata: {}
@@ -111,17 +123,17 @@ require_paths:
111
123
  - lib
112
124
  required_ruby_version: !ruby/object:Gem::Requirement
113
125
  requirements:
114
- - - '>='
126
+ - - ">="
115
127
  - !ruby/object:Gem::Version
116
128
  version: '0'
117
129
  required_rubygems_version: !ruby/object:Gem::Requirement
118
130
  requirements:
119
- - - '>='
131
+ - - ">="
120
132
  - !ruby/object:Gem::Version
121
133
  version: '0'
122
134
  requirements: []
123
135
  rubyforge_project:
124
- rubygems_version: 2.0.3
136
+ rubygems_version: 2.2.2
125
137
  signing_key:
126
138
  specification_version: 4
127
139
  summary: Slugs for Rails.
@@ -155,13 +167,11 @@ test_files:
155
167
  - test/dummy/config/locales/en.yml
156
168
  - test/dummy/config/routes.rb
157
169
  - test/dummy/config.ru
158
- - test/dummy/db/development.sqlite3
159
170
  - test/dummy/db/migrate/20130819183013_create_simples.rb
160
171
  - test/dummy/db/migrate/20130819183047_create_withouts.rb
161
172
  - test/dummy/db/migrate/20130819183119_create_translatables.rb
162
173
  - test/dummy/db/migrate/20130819183257_create_translatable_translations.rb
163
174
  - test/dummy/db/schema.rb
164
- - test/dummy/db/test.sqlite3
165
175
  - test/dummy/log/development.log
166
176
  - test/dummy/log/test.log
167
177
  - test/dummy/public/404.html
Binary file
Binary file