public_uid 2.1.1 → 2.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +5 -0
- data/README.md +24 -1
- data/lib/public_uid/model.rb +9 -0
- data/lib/public_uid/version.rb +1 -1
- data/test/models/custom_public_uid_column_test.rb +22 -1
- data/test/models/model_with_generator_defaults_test.rb +22 -1
- data/test/models/model_with_public_uid_concern_test.rb +20 -0
- metadata +6 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b9f535dd58ffefeceb1c162b838cd6bfc152d12d5d0c3036ccf3377d15a5d25f
|
4
|
+
data.tar.gz: a65e4856004a370828706d678a55be3a5940ff7f5a288ba8a4e5849060bc4da4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f7ae3ce54c0dfaa21d192937c9c6aec75da1aaae789a2261a55dcfabcfc3e740c43b7ae646f2ca601d9139008108e69d6635eef058c35c18b135496d68a79d07
|
7
|
+
data.tar.gz: b4e1daa515802166ea148c14a1fa3352f871f7a7725e77e74af37ea9d726e365545ad398e23c4e08a7dce06c38f0741513ed12a7ca4c8fdc53b37cdcfe2cf1ed
|
data/.travis.yml
CHANGED
data/README.md
CHANGED
@@ -57,7 +57,21 @@ Create database column for public unique ID.
|
|
57
57
|
class AddPublicUidToUsers < ActiveRecord::Migration
|
58
58
|
def change
|
59
59
|
add_column :users, :public_uid, :string
|
60
|
-
add_index :users, :public_uid
|
60
|
+
add_index :users, :public_uid, unique: true
|
61
|
+
end
|
62
|
+
end
|
63
|
+
```
|
64
|
+
|
65
|
+
or if you are creating table
|
66
|
+
|
67
|
+
```ruby
|
68
|
+
class CreateEntries < ActiveRecord::Migration[7.1]
|
69
|
+
def change
|
70
|
+
create_table :entries do |t|
|
71
|
+
# ...
|
72
|
+
t.string :public_uid, index: { unique: true }
|
73
|
+
# ...
|
74
|
+
end
|
61
75
|
end
|
62
76
|
end
|
63
77
|
```
|
@@ -381,3 +395,12 @@ If anyone want to see public_uid v 2.0 to support other data mappers (e.g. mongo
|
|
381
395
|
|
382
396
|
Sorry for any inconvenience
|
383
397
|
|
398
|
+
##### 2022-11-03
|
399
|
+
|
400
|
+
Version 2.2.0 released
|
401
|
+
|
402
|
+
|
403
|
+
`model.dup` will now not copy the public_uid value (same as `model.id` )
|
404
|
+
|
405
|
+
more: https://github.com/equivalent/public_uid/pull/21
|
406
|
+
|
data/lib/public_uid/model.rb
CHANGED
@@ -14,6 +14,15 @@ module PublicUid
|
|
14
14
|
pub_uid.generate self.class.public_uid_generator
|
15
15
|
pub_uid.set
|
16
16
|
end
|
17
|
+
|
18
|
+
def initialize_dup(*)
|
19
|
+
super
|
20
|
+
_clear_public_uid_column
|
21
|
+
end
|
22
|
+
|
23
|
+
def _clear_public_uid_column
|
24
|
+
self.send("#{self.class.public_uid_column}=", nil)
|
25
|
+
end
|
17
26
|
end
|
18
27
|
|
19
28
|
module ClassMethods
|
data/lib/public_uid/version.rb
CHANGED
@@ -3,7 +3,8 @@ require 'test_helper'
|
|
3
3
|
TestConf.orm_modules.each do |orm_module|
|
4
4
|
describe orm_module.description do
|
5
5
|
context 'Model with custom public uid column' do
|
6
|
-
let(:
|
6
|
+
let(:model_class) { "#{orm_module}::CustomPublicUidColumnModel".constantize }
|
7
|
+
let(:user) { model_class.new }
|
7
8
|
|
8
9
|
describe '#custom_uid' do
|
9
10
|
subject{ user.custom_uid }
|
@@ -31,6 +32,26 @@ TestConf.orm_modules.each do |orm_module|
|
|
31
32
|
it{ expect(subject.length).must_equal(8) }
|
32
33
|
end
|
33
34
|
end
|
35
|
+
|
36
|
+
describe '#dup' do
|
37
|
+
let(:user) { model_class.new(:custom_uid => 'abcdefg') }
|
38
|
+
|
39
|
+
it do
|
40
|
+
dup_user = user.dup
|
41
|
+
expect(user.custom_uid).must_equal('abcdefg')
|
42
|
+
expect(dup_user.custom_uid).must_equal(nil)
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
describe '#clone' do
|
47
|
+
let(:user) { model_class.new(:custom_uid => 'abcdefg') }
|
48
|
+
|
49
|
+
it do
|
50
|
+
clone_user = user.clone
|
51
|
+
expect(user.custom_uid).must_equal('abcdefg')
|
52
|
+
expect(clone_user.custom_uid).must_equal('abcdefg')
|
53
|
+
end
|
54
|
+
end
|
34
55
|
end
|
35
56
|
end
|
36
57
|
end
|
@@ -3,7 +3,8 @@ require 'test_helper'
|
|
3
3
|
TestConf.orm_modules.each do |orm_module|
|
4
4
|
describe orm_module.description do
|
5
5
|
context 'Model with default generator' do
|
6
|
-
let(:
|
6
|
+
let(:model_class) { "#{orm_module}::ModelWithGeneratorDefaults".constantize }
|
7
|
+
let(:user) { model_class.new }
|
7
8
|
|
8
9
|
describe '#public_uid' do
|
9
10
|
subject{ user.public_uid }
|
@@ -31,6 +32,26 @@ TestConf.orm_modules.each do |orm_module|
|
|
31
32
|
it{ expect(subject.length).must_equal(8) }
|
32
33
|
end
|
33
34
|
end
|
35
|
+
|
36
|
+
describe '#dup' do
|
37
|
+
let(:user) { model_class.new(:public_uid => 'abcdefg') }
|
38
|
+
|
39
|
+
it do
|
40
|
+
dup_user = user.dup
|
41
|
+
expect(user.public_uid).must_equal('abcdefg')
|
42
|
+
expect(dup_user.public_uid).must_equal(nil)
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
describe '#clone' do
|
47
|
+
let(:user) { model_class.new(:public_uid => 'abcdefg') }
|
48
|
+
|
49
|
+
it do
|
50
|
+
clone_user = user.clone
|
51
|
+
expect(user.public_uid).must_equal('abcdefg')
|
52
|
+
expect(clone_user.public_uid).must_equal('abcdefg')
|
53
|
+
end
|
54
|
+
end
|
34
55
|
end
|
35
56
|
end
|
36
57
|
end
|
@@ -44,6 +44,26 @@ TestConf.orm_modules.each do |orm_module|
|
|
44
44
|
end
|
45
45
|
end
|
46
46
|
end
|
47
|
+
|
48
|
+
describe '#dup' do
|
49
|
+
let(:user) { model_class.new(:public_uid => 'abcdefg') }
|
50
|
+
|
51
|
+
it do
|
52
|
+
dup_user = user.dup
|
53
|
+
expect(user.public_uid).must_equal('abcdefg')
|
54
|
+
expect(dup_user.public_uid).must_equal(nil)
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
describe '#clone' do
|
59
|
+
let(:user) { model_class.new(:public_uid => 'abcdefg') }
|
60
|
+
|
61
|
+
it do
|
62
|
+
clone_user = user.clone
|
63
|
+
expect(user.public_uid).must_equal('abcdefg')
|
64
|
+
expect(clone_user.public_uid).must_equal('abcdefg')
|
65
|
+
end
|
66
|
+
end
|
47
67
|
end
|
48
68
|
end
|
49
69
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: public_uid
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tomas Valent
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-11-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|
@@ -165,7 +165,7 @@ homepage: https://github.com/equivalent/public_uid
|
|
165
165
|
licenses:
|
166
166
|
- MIT
|
167
167
|
metadata: {}
|
168
|
-
post_install_message:
|
168
|
+
post_install_message:
|
169
169
|
rdoc_options: []
|
170
170
|
require_paths:
|
171
171
|
- lib
|
@@ -180,8 +180,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
180
180
|
- !ruby/object:Gem::Version
|
181
181
|
version: '0'
|
182
182
|
requirements: []
|
183
|
-
rubygems_version: 3.
|
184
|
-
signing_key:
|
183
|
+
rubygems_version: 3.3.7
|
184
|
+
signing_key:
|
185
185
|
specification_version: 4
|
186
186
|
summary: Automatic generates public UID column
|
187
187
|
test_files:
|