acts_as_hashids 0.1.6 → 0.1.8

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c5b2d3eb197bd3107dd4ddfea07983d1d630caa4ee38826d26d2fef4f304b072
4
- data.tar.gz: f25d68793d382f453f28ffe86cc56382719b93de6062fcbd924d0c8ef1402d33
3
+ metadata.gz: 92ccec5715b0a4a426d6e1e07a6b6fa9b11745b67cc0bafb0c80c250c5811b3d
4
+ data.tar.gz: ee9a2fb503e7deb91145d9ddf3941f20f13d74464269592687931c206bc62e40
5
5
  SHA512:
6
- metadata.gz: 435ab3722ecb4a43578463c93296c7bd9759f416ef85df10cfb11558f8e49be3759f8e2a825e388776af773f0d4d908606653a53eea3414fac9a32e86d445a11
7
- data.tar.gz: a9251eee6f872cf9a99529049d74fec714f7473afb8e8092f0090535a8cf9ae95193912216c0b1c1a6c2b1293399eb88beea02012a38fd5b8f89addec320e173
6
+ metadata.gz: 16fedb61fad08ef6178334bdde02ec9fef11d59c8a33faf9d55d112392b4ab1190b51eaccee999bb5e792f6e0d3ed9336e7f2125365ed9c7e06477299003df3f
7
+ data.tar.gz: cb8ab63791d6f1a00cea289854777f8cdd5afa8c7a9c5988f76db3baf15a7bb55925095eb61e8229399d42d8c78a6d19fcf23fbab72e6065ccc3704229d0a82b
@@ -1,26 +1,33 @@
1
1
  language: ruby
2
2
  sudo: false
3
3
  rvm:
4
- - 2.2
5
- - 2.3
6
4
  - 2.4
7
5
  - 2.5
6
+ - 2.6
8
7
  env:
8
+ jobs:
9
9
  -
10
- - ACTIVE_RECORD_VERSION=4.0.0
11
- - ACTIVE_RECORD_VERSION=4.1.0
12
- - ACTIVE_RECORD_VERSION=4.2.0
13
- - ACTIVE_RECORD_VERSION=5.0.0
10
+ - ACTIVE_RECORD_VERSION=4.0.0 SQLITE3_VERSION=1.3.13
11
+ - ACTIVE_RECORD_VERSION=4.1.0 SQLITE3_VERSION=1.3.13
12
+ - ACTIVE_RECORD_VERSION=4.2.0 SQLITE3_VERSION=1.3.13
13
+ - ACTIVE_RECORD_VERSION=5.0.0 SQLITE3_VERSION=1.3.13
14
+ - ACTIVE_RECORD_VERSION=6.0.0
14
15
  matrix:
15
16
  allow_failures:
16
17
  - rvm: 2.4
17
- env: ACTIVE_RECORD_VERSION=4.0.0
18
+ env: ACTIVE_RECORD_VERSION=4.0.0 SQLITE3_VERSION=1.3.13
18
19
  - rvm: 2.4
19
- env: ACTIVE_RECORD_VERSION=4.1.0
20
+ env: ACTIVE_RECORD_VERSION=4.1.0 SQLITE3_VERSION=1.3.13
20
21
  - rvm: 2.5
21
- env: ACTIVE_RECORD_VERSION=4.0.0
22
+ env: ACTIVE_RECORD_VERSION=4.0.0 SQLITE3_VERSION=1.3.13
22
23
  - rvm: 2.5
23
- env: ACTIVE_RECORD_VERSION=4.1.0
24
+ env: ACTIVE_RECORD_VERSION=4.1.0 SQLITE3_VERSION=1.3.13
25
+ - rvm: 2.6
26
+ env: ACTIVE_RECORD_VERSION=4.0.0 SQLITE3_VERSION=1.3.13
27
+ - rvm: 2.6
28
+ env: ACTIVE_RECORD_VERSION=4.1.0 SQLITE3_VERSION=1.3.13
29
+ - rvm: 2.4
30
+ env: ACTIVE_RECORD_VERSION=6.0.0
24
31
  before_install:
25
32
  - gem update --system
26
33
  - gem --version
data/Gemfile CHANGED
@@ -6,3 +6,4 @@ gem 'gem-release'
6
6
  gem 'pry'
7
7
 
8
8
  gem 'activerecord', "~> #{ENV['ACTIVE_RECORD_VERSION']}" if ENV['ACTIVE_RECORD_VERSION'].to_s != ''
9
+ gem 'sqlite3', "~> #{ENV['SQLITE3_VERSION']}" if ENV['SQLITE3_VERSION'].to_s != ''
@@ -19,9 +19,9 @@ Gem::Specification.new do |spec|
19
19
  spec.executables = `git ls-files -- bin/*`.split("\n").map { |f| File.basename(f) }
20
20
  spec.require_paths = ['lib']
21
21
 
22
- spec.required_ruby_version = ['>= 2.2.2', '< 2.6']
22
+ spec.required_ruby_version = ['>= 2.2.2', '< 2.7']
23
23
 
24
- spec.add_runtime_dependency 'activerecord', '>= 4.0', '< 6.0'
24
+ spec.add_runtime_dependency 'activerecord', '>= 4.0', '< 6.1'
25
25
  spec.add_runtime_dependency 'hashids', '~> 1.0'
26
26
 
27
27
  spec.add_development_dependency 'codeclimate-test-reporter', '~> 0.5'
@@ -15,7 +15,7 @@ module ActsAsHashids
15
15
 
16
16
  encoded_ids = Array(ids).map do |id|
17
17
  begin
18
- id = id.to_i if Float(id)
18
+ id = id.to_i if Integer(id)
19
19
  hashids.encode(id)
20
20
  rescue TypeError, ArgumentError
21
21
  id
@@ -1,3 +1,3 @@
1
1
  module ActsAsHashids
2
- VERSION = '0.1.6'.freeze
2
+ VERSION = '0.1.8'.freeze
3
3
  end
@@ -19,7 +19,7 @@ RSpec.describe ActsAsHashids::Core do
19
19
 
20
20
  class Base < ActiveRecord::Base
21
21
  self.abstract_class = true
22
- acts_as_hashids
22
+ acts_as_hashids length: 4
23
23
  end
24
24
 
25
25
  class CoreFoo < Base
@@ -42,11 +42,24 @@ RSpec.describe ActsAsHashids::Core do
42
42
  end
43
43
  context 'with unexisting hash id' do
44
44
  it 'raises an exception' do
45
- expect { model.find('GXbMabNA') }.to raise_error(
46
- ActiveRecord::RecordNotFound, "Couldn't find CoreFoo with 'id'=\"GXbMabNA\""
45
+ expect { model.find('bMab') }.to raise_error(
46
+ ActiveRecord::RecordNotFound, "Couldn't find CoreFoo with 'id'=\"bMab\""
47
47
  )
48
48
  end
49
49
  end
50
+ context 'with hash id which looks like a logarithm' do
51
+ let!(:foo1) { CoreFoo.create(id: CoreFoo.hashids.decode('4E93')[0]) }
52
+ let!(:foo2) { CoreFoo.create(id: '4') }
53
+
54
+ it 'decodes hash id which looks like a logarithm and returns the record' do
55
+ expect(model.find('4E93')).to eq foo1
56
+ expect(model.find('4')).not_to eq foo1
57
+ end
58
+ it 'decodes hash id and returns the record' do
59
+ expect(model.find('4E93')).not_to eq foo2
60
+ expect(model.find('4')).to eq foo2
61
+ end
62
+ end
50
63
  it 'returns the record when finding by string id' do
51
64
  expect(model.find(foo1.id.to_s)).to eq foo1
52
65
  end
@@ -57,9 +70,9 @@ RSpec.describe ActsAsHashids::Core do
57
70
  end
58
71
  context 'with unexisting hash id' do
59
72
  it 'raises an exception' do
60
- expect { model.find(%w[GXbMabNA ePQgabdg]) }.to raise_error(
73
+ expect { model.find(%w[bMab Qgab]) }.to raise_error(
61
74
  ActiveRecord::RecordNotFound,
62
- "Couldn't find all CoreFoos with 'id': (\"GXbMabNA\", \"ePQgabdg\") (found 1 results, but was looking for 2)"
75
+ "Couldn't find all CoreFoos with 'id': (\"bMab\", \"Qgab\") (found 1 results, but was looking for 2)"
63
76
  )
64
77
  end
65
78
  end
@@ -118,7 +131,7 @@ RSpec.describe ActsAsHashids::Core do
118
131
  subject(:model) { CoreFoo.create id: 5 }
119
132
 
120
133
  it 'returns hash id' do
121
- expect(model.to_param).to eq 'GXbMabNA'
134
+ expect(model.to_param).to eq 'bMab'
122
135
  end
123
136
  end
124
137
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: acts_as_hashids
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.6
4
+ version: 0.1.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - dtaniwaki
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-03-31 00:00:00.000000000 Z
11
+ date: 2019-10-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord
@@ -19,7 +19,7 @@ dependencies:
19
19
  version: '4.0'
20
20
  - - "<"
21
21
  - !ruby/object:Gem::Version
22
- version: '6.0'
22
+ version: '6.1'
23
23
  type: :runtime
24
24
  prerelease: false
25
25
  version_requirements: !ruby/object:Gem::Requirement
@@ -29,7 +29,7 @@ dependencies:
29
29
  version: '4.0'
30
30
  - - "<"
31
31
  - !ruby/object:Gem::Version
32
- version: '6.0'
32
+ version: '6.1'
33
33
  - !ruby/object:Gem::Dependency
34
34
  name: hashids
35
35
  requirement: !ruby/object:Gem::Requirement
@@ -201,7 +201,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
201
201
  version: 2.2.2
202
202
  - - "<"
203
203
  - !ruby/object:Gem::Version
204
- version: '2.6'
204
+ version: '2.7'
205
205
  required_rubygems_version: !ruby/object:Gem::Requirement
206
206
  requirements:
207
207
  - - ">="