idy 1.0.0 → 1.1.0
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 +4 -4
- data/CHANGELOG.md +7 -0
- data/lib/idy/version.rb +1 -1
- data/spec/lib/idy/extension/findy_bump_spec.rb +3 -3
- data/spec/lib/idy/extension/findy_spec.rb +3 -3
- data/spec/lib/idy/extension/idy_decode_spec.rb +4 -4
- data/spec/lib/idy/extension/idy_default_salt_spec.rb +1 -1
- data/spec/lib/idy/extension/idy_encode_spec.rb +4 -4
- data/spec/lib/idy/extension/idy_spec.rb +1 -1
- data/spec/lib/idy/extension/options_spec.rb +1 -1
- data/spec/lib/idy/extension/salt_spec.rb +4 -4
- data/spec/lib/idy/extension/to_param_spec.rb +1 -1
- metadata +12 -19
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 48f9d830da49d857d4e7a933837f63a82be37a0bf8b79bb254ce9894e929c778
|
4
|
+
data.tar.gz: 7d564312480c2cd78a406669d90eb3e1b9a2f7a6a9d0675b131851c1aff1cfe0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f20232384684b4aed106783643f6561ce92bc657430f24f15a34f8f0c38fe6ab7b706cbe5238bfa6e85636494470c0d78ab7c0e8635809eaaaab80508997d10b
|
7
|
+
data.tar.gz: 96ed2ff410876d03c33b74c6337df37e0a454d4a1602581384ce3d13ef0cb7a6ffc71ad4254f9498353e25c513bef612a5017fcf20905cce64fcf48f48cb7eb3
|
data/CHANGELOG.md
CHANGED
data/lib/idy/version.rb
CHANGED
@@ -5,11 +5,11 @@ require 'rails_helper'
|
|
5
5
|
RSpec.describe Article, '#findy!' do
|
6
6
|
context 'when a hash is given' do
|
7
7
|
context 'when record is found' do
|
8
|
-
let!(:record) {
|
8
|
+
let!(:record) { described_class.create id: 1 }
|
9
9
|
let!(:hash) { 'My' }
|
10
10
|
|
11
11
|
it 'finds the record' do
|
12
|
-
expect(
|
12
|
+
expect(described_class.findy!(hash)).to eq record
|
13
13
|
end
|
14
14
|
end
|
15
15
|
|
@@ -19,7 +19,7 @@ RSpec.describe Article, '#findy!' do
|
|
19
19
|
it 'raises' do
|
20
20
|
message = %(Couldn't find User with 'idy'="My")
|
21
21
|
|
22
|
-
expect {
|
22
|
+
expect { described_class.findy!(hash) }.to raise_error ActiveRecord::RecordNotFound, message
|
23
23
|
end
|
24
24
|
end
|
25
25
|
end
|
@@ -5,11 +5,11 @@ require 'rails_helper'
|
|
5
5
|
RSpec.describe Article, '#findy' do
|
6
6
|
context 'when a hash is given' do
|
7
7
|
context 'when record is found' do
|
8
|
-
let!(:record) {
|
8
|
+
let!(:record) { described_class.create id: 1 }
|
9
9
|
let!(:hash) { 'My' }
|
10
10
|
|
11
11
|
it 'finds the record' do
|
12
|
-
expect(
|
12
|
+
expect(described_class.findy(hash)).to eq record
|
13
13
|
end
|
14
14
|
end
|
15
15
|
|
@@ -17,7 +17,7 @@ RSpec.describe Article, '#findy' do
|
|
17
17
|
let!(:hash) { 'My' }
|
18
18
|
|
19
19
|
it 'returns nil' do
|
20
|
-
expect(
|
20
|
+
expect(described_class.findy(hash)).to be_nil
|
21
21
|
end
|
22
22
|
end
|
23
23
|
end
|
@@ -5,7 +5,7 @@ require 'rails_helper'
|
|
5
5
|
RSpec.describe Article, '#idy_decode' do
|
6
6
|
context 'with no given salt' do
|
7
7
|
it 'undos the obfuscation of id with default class salt' do
|
8
|
-
expect(
|
8
|
+
expect(described_class.idy_decode('My')).to eq 1
|
9
9
|
end
|
10
10
|
end
|
11
11
|
|
@@ -13,7 +13,7 @@ RSpec.describe Article, '#idy_decode' do
|
|
13
13
|
let!(:salt) { '' }
|
14
14
|
|
15
15
|
it 'undos the obfuscation of id with given salt' do
|
16
|
-
expect(
|
16
|
+
expect(described_class.idy_decode('jR', salt: salt)).to eq 1
|
17
17
|
end
|
18
18
|
end
|
19
19
|
|
@@ -22,7 +22,7 @@ RSpec.describe Article, '#idy_decode' do
|
|
22
22
|
let!(:salt) { 'salt' }
|
23
23
|
|
24
24
|
it 'undos the obfuscation of id with given salt' do
|
25
|
-
expect(
|
25
|
+
expect(described_class.idy_decode('XG', salt: salt)).to eq 1
|
26
26
|
end
|
27
27
|
end
|
28
28
|
|
@@ -30,7 +30,7 @@ RSpec.describe Article, '#idy_decode' do
|
|
30
30
|
let!(:salt) { 1 }
|
31
31
|
|
32
32
|
it 'undos the obfuscation of id with given salt as string' do
|
33
|
-
expect(
|
33
|
+
expect(described_class.idy_decode('kL', salt: 1)).to eq 1
|
34
34
|
end
|
35
35
|
end
|
36
36
|
end
|
@@ -5,7 +5,7 @@ require 'rails_helper'
|
|
5
5
|
RSpec.describe Abcdefghijklm, '#idy_default_salt' do
|
6
6
|
context 'when class name has a big length' do
|
7
7
|
it 'is bases on the first 10 class letter position index on alphabet' do
|
8
|
-
expect(
|
8
|
+
expect(described_class.idy_default_salt).to eq '12345678910'
|
9
9
|
end
|
10
10
|
end
|
11
11
|
end
|
@@ -4,7 +4,7 @@ require 'rails_helper'
|
|
4
4
|
|
5
5
|
RSpec.describe Article, '#idy_encode' do
|
6
6
|
context 'with no given salt' do
|
7
|
-
let!(:model) {
|
7
|
+
let!(:model) { described_class.new id: 1 }
|
8
8
|
|
9
9
|
it 'obfuscates the id with default class salt' do
|
10
10
|
expect(model.class.idy_encode(model.id)).to eq 'My'
|
@@ -12,7 +12,7 @@ RSpec.describe Article, '#idy_encode' do
|
|
12
12
|
end
|
13
13
|
|
14
14
|
context 'with empty salt' do
|
15
|
-
let!(:model) {
|
15
|
+
let!(:model) { described_class.new id: 1 }
|
16
16
|
let!(:salt) { '' }
|
17
17
|
|
18
18
|
it 'obfuscates the id with empty salt' do
|
@@ -21,7 +21,7 @@ RSpec.describe Article, '#idy_encode' do
|
|
21
21
|
end
|
22
22
|
|
23
23
|
context 'with salt' do
|
24
|
-
let!(:model) {
|
24
|
+
let!(:model) { described_class.new id: 1 }
|
25
25
|
|
26
26
|
context 'when is string' do
|
27
27
|
let!(:salt) { 'salt' }
|
@@ -41,7 +41,7 @@ RSpec.describe Article, '#idy_encode' do
|
|
41
41
|
end
|
42
42
|
|
43
43
|
context 'with nil id' do
|
44
|
-
let!(:model) {
|
44
|
+
let!(:model) { described_class.new }
|
45
45
|
|
46
46
|
it 'returns nil' do
|
47
47
|
expect(model.class.idy_encode(model.id)).to be_nil
|
@@ -5,7 +5,7 @@ require 'rails_helper'
|
|
5
5
|
RSpec.describe Article, '.idy_options' do
|
6
6
|
context 'when options is not given' do
|
7
7
|
it 'returns a default options with a salt generated based on model name' do
|
8
|
-
expect(
|
8
|
+
expect(described_class.idy_options).to eq(salt: article_default_salt)
|
9
9
|
end
|
10
10
|
end
|
11
11
|
|
@@ -4,18 +4,18 @@ require 'rails_helper'
|
|
4
4
|
|
5
5
|
RSpec.describe Clean, ':salt' do
|
6
6
|
describe '#salt' do
|
7
|
-
before { allow(
|
7
|
+
before { allow(described_class).to receive(:idy_options).and_return(salt: :salty) }
|
8
8
|
|
9
9
|
it 'fetchs the salt options' do
|
10
|
-
expect(
|
10
|
+
expect(described_class.salt).to eq(:salty)
|
11
11
|
end
|
12
12
|
end
|
13
13
|
|
14
14
|
describe '.salt' do
|
15
|
-
before { allow(
|
15
|
+
before { allow(described_class).to receive(:salt).and_return :salt }
|
16
16
|
|
17
17
|
it 'delegates to class method' do
|
18
|
-
expect(
|
18
|
+
expect(described_class.new.salt).to eq :salt
|
19
19
|
end
|
20
20
|
end
|
21
21
|
end
|
metadata
CHANGED
@@ -1,49 +1,43 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: idy
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Washington Botelho
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2019-10-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
|
-
name:
|
14
|
+
name: activerecord
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - "
|
17
|
+
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '
|
19
|
+
version: '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
|
-
version: '
|
26
|
+
version: '0'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
|
-
name:
|
28
|
+
name: hashids
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
31
|
- - ">="
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: '
|
34
|
-
- - "<"
|
35
|
-
- !ruby/object:Gem::Version
|
36
|
-
version: '6'
|
33
|
+
version: '0'
|
37
34
|
type: :runtime
|
38
35
|
prerelease: false
|
39
36
|
version_requirements: !ruby/object:Gem::Requirement
|
40
37
|
requirements:
|
41
38
|
- - ">="
|
42
39
|
- !ruby/object:Gem::Version
|
43
|
-
version: '
|
44
|
-
- - "<"
|
45
|
-
- !ruby/object:Gem::Version
|
46
|
-
version: '6'
|
40
|
+
version: '0'
|
47
41
|
- !ruby/object:Gem::Dependency
|
48
42
|
name: database_cleaner
|
49
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -87,7 +81,7 @@ dependencies:
|
|
87
81
|
- !ruby/object:Gem::Version
|
88
82
|
version: '0'
|
89
83
|
- !ruby/object:Gem::Dependency
|
90
|
-
name: rubocop
|
84
|
+
name: rubocop-performance
|
91
85
|
requirement: !ruby/object:Gem::Requirement
|
92
86
|
requirements:
|
93
87
|
- - ">="
|
@@ -179,8 +173,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
179
173
|
- !ruby/object:Gem::Version
|
180
174
|
version: '0'
|
181
175
|
requirements: []
|
182
|
-
|
183
|
-
rubygems_version: 2.7.3
|
176
|
+
rubygems_version: 3.0.6
|
184
177
|
signing_key:
|
185
178
|
specification_version: 4
|
186
179
|
summary: An ID obfuscator for ActiveRecord.
|