aasm 4.0.4 → 4.0.5

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
  SHA1:
3
- metadata.gz: 4f80e2467a731eee5737b3c74cfb3d4236be0df5
4
- data.tar.gz: 7175348561bd968b2208bb1a54b382dc4d72d2e8
3
+ metadata.gz: 0fd3025d299701a391be90b67871d0110925522e
4
+ data.tar.gz: d56adcb31986d0bc257e4c4a32e79462a6715709
5
5
  SHA512:
6
- metadata.gz: 4b435f505dc2a2f30302ac902fa1264d70f8c40f5d4101ac669dc8bac1ddddc34c9b67aca1ea5c899074814a3ef8fdb272c008ed10480c156bdaacd5adcb4a77
7
- data.tar.gz: 50ac955db2fda8ca2bf711f0e2dcabf648996c021bb3921ace2793cef1ea71402407e00326674505e5c5bacf35d8b3d99f09d9acb8eedd7791fc6f3d6d022b6e
6
+ metadata.gz: f2e8c7bd2e7ce8f614b8b72a48ffbf396c9194c5369a128bbe6d201443e067a48caea69b9f3f9ec4c6af30956b358deb4d8544172599fe7120bd4edbc4c9717d
7
+ data.tar.gz: b6d9db8e0f1cd99e263d3cb9e16ff837adab1ce57faf918ca222f48a9bb674ebf29bbdae640d4987bd6f676d35896dec9d3060347e709229ad831160702b11a4
data/CHANGELOG.md CHANGED
@@ -5,6 +5,10 @@
5
5
  * `aasm_column` has been removed. Use `aasm.attribute_name` instead
6
6
  * `aasm_human_event_name` has been removed. Use `aasm.human_event_name` instead
7
7
 
8
+ ## 4.0.5
9
+
10
+ * bugfix: initialize the aasm state column after initialization of the _ActiveRecord_ instance only if the attribute has been loaded (see [issue #193](https://github.com/aasm/aasm/issues/193) for details)
11
+
8
12
  ## 4.0.4
9
13
 
10
14
  * corrected callback order in README
data/README.md CHANGED
@@ -347,7 +347,9 @@ job.run! # saved
347
347
 
348
348
  Saving includes running all validations on the `Job` class. If you want make sure
349
349
  the state gets saved without running validations (and thereby maybe persisting an
350
- invalid object state), simply tell AASM to skip the validations:
350
+ invalid object state), simply tell AASM to skip the validations. Be aware, that
351
+ when skipping validations, only the state column will be updated in the database
352
+ (just like ActiveRecord `change_column` is working).
351
353
 
352
354
  ```ruby
353
355
  class Job < ActiveRecord::Base
data/aasm.gemspec CHANGED
@@ -19,7 +19,7 @@ Gem::Specification.new do |s|
19
19
 
20
20
  # debugging
21
21
  # s.add_development_dependency 'debugger'
22
- # s.add_development_dependency 'pry'
22
+ s.add_development_dependency 'pry'
23
23
 
24
24
  # test coverage
25
25
  # s.add_development_dependency 'mime-types', '~> 1.25' # needed by coveralls (>= 2.0 needs Ruby >=1.9.2)
@@ -164,7 +164,11 @@ module AASM
164
164
  # foo.aasm_state # => nil
165
165
  #
166
166
  def aasm_ensure_initial_state
167
- aasm.enter_initial_state if send(self.class.aasm.attribute_name).blank?
167
+ # checking via respond_to? does not work in Rails <= 3
168
+ # if respond_to?(self.class.aasm.attribute_name) && send(self.class.aasm.attribute_name).blank? # Rails 4
169
+ if attributes.key?(self.class.aasm.attribute_name.to_s) && send(self.class.aasm.attribute_name).blank?
170
+ aasm.enter_initial_state
171
+ end
168
172
  end
169
173
 
170
174
  def aasm_fire_event(name, options, *args, &block)
data/lib/aasm/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module AASM
2
- VERSION = "4.0.4"
2
+ VERSION = "4.0.5"
3
3
  end
@@ -252,9 +252,20 @@ describe "instance methods" do
252
252
  expect(gate.aasm.current_state).to be_nil
253
253
  end
254
254
 
255
- it "should initialize the aasm state on instantiation" do
256
- expect(Gate.new.aasm_state).to eql 'opened'
257
- expect(Gate.new.aasm.current_state).to eql :opened
255
+ context 'on initialization' do
256
+ it "should initialize the aasm state" do
257
+ expect(Gate.new.aasm_state).to eql 'opened'
258
+ expect(Gate.new.aasm.current_state).to eql :opened
259
+ end
260
+
261
+ it "should not initialize the aasm state if it has not been loaded" do
262
+ # we have to create a gate in the database, for which we only want to
263
+ # load the id, and not the state
264
+ gate = Gate.create!
265
+
266
+ # then we just load the gate ids
267
+ Gate.select(:id).where(id: gate.id).first
268
+ end
258
269
  end
259
270
 
260
271
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: aasm
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.0.4
4
+ version: 4.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Scott Barron
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2014-12-05 00:00:00.000000000 Z
13
+ date: 2014-12-06 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: rake
@@ -60,6 +60,20 @@ dependencies:
60
60
  - - "<"
61
61
  - !ruby/object:Gem::Version
62
62
  version: '2.99'
63
+ - !ruby/object:Gem::Dependency
64
+ name: pry
65
+ requirement: !ruby/object:Gem::Requirement
66
+ requirements:
67
+ - - ">="
68
+ - !ruby/object:Gem::Version
69
+ version: '0'
70
+ type: :development
71
+ prerelease: false
72
+ version_requirements: !ruby/object:Gem::Requirement
73
+ requirements:
74
+ - - ">="
75
+ - !ruby/object:Gem::Version
76
+ version: '0'
63
77
  description: AASM is a continuation of the acts as state machine rails plugin, built
64
78
  for plain Ruby objects.
65
79
  email: scott@elitists.net, ttilley@gmail.com, aasm@mt7.de