mad_id 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 1f7151e5b6b6e1b85ce61310bee3e7261af373bc
4
- data.tar.gz: 4d3a29c03becf7d3c0447889d2aeb488fd5be28e
3
+ metadata.gz: 4042c8ec49b11bb1ef84bacc35e97c27424c456d
4
+ data.tar.gz: cb50809eca16ed50ca04513e41e7d20e8819ba9c
5
5
  SHA512:
6
- metadata.gz: 3b9cdc1473f81f082551ee543b891ae1d383971d90bd5868e2c50f0275c7dbfd3975429f30a9c15f8e05507023c7e6f7f2398f448e422ebd2d06fa43929c88f2
7
- data.tar.gz: 2d210548a728c1a9fc96bdbfef3b47448873a640e400463878496861e204f7669be7deb3dccb97e0fc7e6dc2fe6efb386d70ca2a6109da51cc085abd336db45a
6
+ metadata.gz: 214384a13864dec0349b7bc89b2b6dfc21299a673e83c1432aace4bf6188fcd64f9ee3887fa85b692ba937b3893ea37cdc90a98d0d6703f8b55bf73751786e36
7
+ data.tar.gz: 345ea0ed4b9e90e9f4bdd472a88c02c0496e185687a619002b9e6798342f6119f1a59a713910d426d6485b9ba63a0ea29f95a92318420dccc6b073db87678933
@@ -4,7 +4,8 @@ module MadId
4
4
  extend ActiveSupport::Concern
5
5
 
6
6
  included do
7
- before_save :set_identifier, on: :create
7
+ before_create :set_identifier
8
+ attr_readonly :identifier
8
9
 
9
10
  def self.object_identifier_prefix
10
11
  @identifier
@@ -1,3 +1,3 @@
1
1
  module MadId
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
data/spec/mad_id_spec.rb CHANGED
@@ -15,14 +15,14 @@ describe MadId do
15
15
  end
16
16
 
17
17
  it 'wont set any callbacks' do
18
- expect(Pony._save_callbacks.select {|cb| cb.filter == :set_identifier}).to be_empty
18
+ expect(Pony._create_callbacks.select {|cb| cb.filter == :set_identifier}).to be_empty
19
19
  end
20
20
 
21
21
  describe 'when #identify_with is called' do
22
22
  subject { LittlePony.new }
23
23
 
24
24
  it 'inserts the #set_identifier callback' do
25
- expect(LittlePony._save_callbacks.select {|cb| cb.filter == :set_identifier}).to have(1).item
25
+ expect(LittlePony._create_callbacks.select {|cb| cb.filter == :set_identifier}).to have(1).item
26
26
  end
27
27
 
28
28
  describe '#to_param' do
@@ -52,6 +52,18 @@ describe MadId do
52
52
  it 'will set the identifier upon create' do
53
53
  expect{ subject.save! }.to change{ subject.identifier }.from(nil)
54
54
  end
55
+
56
+ describe 'persisted object' do
57
+ subject { LittlePony.create }
58
+
59
+ it 'will not set the identifier upon update' do
60
+ expect{ subject.save! }.not_to change{ subject.reload.identifier }
61
+ end
62
+
63
+ it 'makes identifier readonly' do
64
+ expect{ subject.update(identifier: 'FOOBAR')}.not_to change{ subject.reload.identifier }
65
+ end
66
+ end
55
67
  end
56
68
 
57
69
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mad_id
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Lars Brillert