aasm 5.0.5 → 5.1.1

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.
Files changed (53) hide show
  1. checksums.yaml +5 -5
  2. data/.github/ISSUE_TEMPLATE/bug_report.md +27 -0
  3. data/.github/ISSUE_TEMPLATE/feature_request.md +20 -0
  4. data/.travis.yml +26 -23
  5. data/Appraisals +6 -10
  6. data/CHANGELOG.md +30 -0
  7. data/Dockerfile +1 -6
  8. data/Gemfile +1 -1
  9. data/README.md +63 -12
  10. data/aasm.gemspec +2 -0
  11. data/gemfiles/norails.gemfile +1 -1
  12. data/gemfiles/rails_4.2.gemfile +1 -0
  13. data/gemfiles/rails_4.2_mongoid_5.gemfile +1 -0
  14. data/gemfiles/rails_5.0.gemfile +1 -0
  15. data/gemfiles/rails_5.1.gemfile +1 -0
  16. data/gemfiles/rails_5.2.gemfile +1 -0
  17. data/lib/aasm.rb +0 -2
  18. data/lib/aasm/aasm.rb +29 -27
  19. data/lib/aasm/base.rb +19 -0
  20. data/lib/aasm/core/event.rb +3 -3
  21. data/lib/aasm/instance_base.rb +16 -4
  22. data/lib/aasm/persistence/active_record_persistence.rb +18 -0
  23. data/lib/aasm/persistence/orm.rb +23 -19
  24. data/lib/aasm/rspec/transition_from.rb +5 -1
  25. data/lib/aasm/version.rb +1 -1
  26. data/spec/database.rb +6 -1
  27. data/spec/en.yml +0 -3
  28. data/spec/{en_deprecated_style.yml → localizer_test_model_deprecated_style.yml} +0 -4
  29. data/spec/localizer_test_model_new_style.yml +5 -0
  30. data/spec/models/active_record/active_record_callback.rb +93 -0
  31. data/spec/models/active_record/instance_level_skip_validation_example.rb +19 -0
  32. data/spec/models/active_record/localizer_test_model.rb +3 -3
  33. data/spec/models/callbacks/with_state_arg.rb +5 -1
  34. data/spec/models/callbacks/with_state_arg_multiple.rb +4 -1
  35. data/spec/models/default_state.rb +1 -1
  36. data/spec/models/simple_example.rb +6 -0
  37. data/spec/spec_helper.rb +15 -0
  38. data/spec/unit/api_spec.rb +4 -0
  39. data/spec/unit/callback_multiple_spec.rb +4 -0
  40. data/spec/unit/callbacks_spec.rb +4 -0
  41. data/spec/unit/complex_example_spec.rb +0 -1
  42. data/spec/unit/event_spec.rb +13 -0
  43. data/spec/unit/inspection_multiple_spec.rb +9 -5
  44. data/spec/unit/inspection_spec.rb +7 -3
  45. data/spec/unit/localizer_spec.rb +9 -10
  46. data/spec/unit/persistence/active_record_persistence_multiple_spec.rb +4 -4
  47. data/spec/unit/persistence/active_record_persistence_spec.rb +93 -4
  48. data/spec/unit/rspec_matcher_spec.rb +3 -0
  49. data/spec/unit/simple_example_spec.rb +15 -0
  50. data/spec/unit/state_spec.rb +21 -5
  51. metadata +50 -11
  52. data/callbacks.txt +0 -51
  53. data/gemfiles/rails_3.2.gemfile +0 -14
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 6e702f783991a9de8f199c63ef2872f9929cde73
4
- data.tar.gz: 9a1339c1f9e22d9bd7f00f6aabb493e303b1549e
2
+ SHA256:
3
+ metadata.gz: f2f4099a66f8d753c2bd7c06b3c378dcd37b47acf9b2f7487784e7762742c1c4
4
+ data.tar.gz: 8971b36f1b066c08d3a4d278a99d7c1e5386be72182da62b51a82db1e60e9e9f
5
5
  SHA512:
6
- metadata.gz: 7b34c93b3e939d6803fb3f7987ba2510fb33be577ac786140474d36305441829ea4b8318ee034dea4a005ed365d4d4930d6d9f3d4847902fdb77a1e85d5210e7
7
- data.tar.gz: 801b5dee037527de96cbf156eeebe6e92e216ce9bea97c9edf2bdd6e52790c66ff0e7186839afcb6d6a91ee3992028206f0b94089753380ba3d5701f68cb7312
6
+ metadata.gz: c24e544b82cfc4616f3e3ff033b7a5ab68bff7bd834b115797e9127ca361effe241ffb1adaedcdb595711a6757f2e0a8e0a8d606a9bc812c28707a1ee845ef40
7
+ data.tar.gz: 421636d1e59e52b8d6b4ddff7dd373fecd9a19ef67b90935e856b1ee980bae9a5a4a8526e62238de9ecc84a7783362e8d5b2005c53b9c7754368be79724c6255
@@ -0,0 +1,27 @@
1
+ ---
2
+ name: Bug report
3
+ about: Create a report to help us improve
4
+ title: ''
5
+ labels: ''
6
+ assignees: ''
7
+
8
+ ---
9
+
10
+ **Describe the bug**
11
+ A clear and concise description of what the bug is.
12
+
13
+ **To Reproduce**
14
+ Steps to reproduce the behavior:
15
+ 1. Go to '...'
16
+ 2. Click on '....'
17
+ 3. Scroll down to '....'
18
+ 4. See error
19
+
20
+ **Expected behavior**
21
+ A clear and concise description of what you expected to happen.
22
+
23
+ **Screenshots**
24
+ If applicable, add screenshots to help explain your problem.
25
+
26
+ **Additional context**
27
+ Add any other context about the problem here.
@@ -0,0 +1,20 @@
1
+ ---
2
+ name: Feature request
3
+ about: Suggest an idea for this project
4
+ title: ''
5
+ labels: ''
6
+ assignees: ''
7
+
8
+ ---
9
+
10
+ **Is your feature request related to a problem? Please describe.**
11
+ A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
12
+
13
+ **Describe the solution you'd like**
14
+ A clear and concise description of what you want to happen.
15
+
16
+ **Describe alternatives you've considered**
17
+ A clear and concise description of any alternative solutions or features you've considered.
18
+
19
+ **Additional context**
20
+ Add any other context or screenshots about the feature request here.
@@ -2,6 +2,9 @@ sudo: false
2
2
  language: ruby
3
3
  cache: bundler
4
4
 
5
+ jdk:
6
+ - openjdk8
7
+
5
8
  before_install:
6
9
  - rvm list
7
10
  - gem uninstall -v '>= 2' -i $(rvm gemdir)@global -ax bundler || true
@@ -9,25 +12,25 @@ before_install:
9
12
  - bundle _1.16.1_ install
10
13
 
11
14
  rvm:
12
- - 2.3.0
13
15
  - 2.5.0
16
+ - 2.6.5
17
+ - 2.7.0
14
18
  - jruby-9.1.12.0
15
19
 
16
20
  services:
17
21
  - mongodb
18
22
  - redis-server
19
23
 
20
- addons:
21
- rethinkdb: '2.3.6'
24
+ #addons:
25
+ # rethinkdb: '2.3.4'
22
26
 
23
27
  gemfile:
24
28
  - gemfiles/norails.gemfile
25
- - gemfiles/rails_3.2.gemfile
26
29
  - gemfiles/rails_4.2.gemfile
27
30
  - gemfiles/rails_4.2_mongoid_5.gemfile
28
- - gemfiles/rails_4.2_nobrainer.gemfile
31
+ # - gemfiles/rails_4.2_nobrainer.gemfile
29
32
  - gemfiles/rails_5.0.gemfile
30
- - gemfiles/rails_5.0_nobrainer.gemfile
33
+ # - gemfiles/rails_5.0_nobrainer.gemfile
31
34
  - gemfiles/rails_5.1.gemfile
32
35
  - gemfiles/rails_5.2.gemfile
33
36
 
@@ -43,24 +46,24 @@ script:
43
46
 
44
47
  matrix:
45
48
  exclude:
46
- - rvm: 2.3.0
47
- gemfile: gemfiles/norails.gemfile
48
- - rvm: 2.3.0
49
- gemfile: gemfiles/rails_5.0.gemfile
50
- - rvm: 2.3.0
51
- gemfile: gemfiles/rails_5.0_nobrainer.gemfile
52
- - rvm: 2.3.0
53
- gemfile: gemfiles/rails_5.1.gemfile
54
- - rvm: 2.3.0
49
+ - rvm: 2.7.0
50
+ gemfile: gemfiles/rails_5.2.gemfile
51
+ - rvm: 2.6.5
55
52
  gemfile: gemfiles/rails_5.2.gemfile
56
53
  - rvm: 2.5.0
57
- gemfile: gemfiles/rails_3.2.gemfile
58
- - rvm: 2.5.0
54
+ gemfile: gemfiles/rails_4.2.gemfile
55
+ - rvm: 2.6.5
56
+ gemfile: gemfiles/rails_4.2.gemfile
57
+ - rvm: 2.7.0
59
58
  gemfile: gemfiles/rails_4.2.gemfile
60
59
  - rvm: 2.5.0
61
60
  gemfile: gemfiles/rails_4.2_mongoid_5.gemfile
62
- - rvm: 2.5.0
63
- gemfile: gemfiles/rails_4.2_nobrainer.gemfile
61
+ - rvm: 2.6.5
62
+ gemfile: gemfiles/rails_4.2_mongoid_5.gemfile
63
+ - rvm: 2.7.0
64
+ gemfile: gemfiles/rails_4.2_mongoid_5.gemfile
65
+ # - rvm: 2.5.0
66
+ # gemfile: gemfiles/rails_4.2_nobrainer.gemfile
64
67
  - rvm: jruby-9.1.12.0
65
68
  gemfile: gemfiles/norails.gemfile
66
69
  - rvm: jruby-9.1.12.0
@@ -69,10 +72,10 @@ matrix:
69
72
  gemfile: gemfiles/rails_5.1.gemfile
70
73
  - rvm: jruby-9.1.12.0
71
74
  gemfile: gemfiles/rails_5.2.gemfile
72
- - rvm: jruby-9.1.12.0
73
- gemfile: gemfiles/rails_4.2_nobrainer.gemfile
74
- - rvm: jruby-9.1.12.0
75
- gemfile: gemfiles/rails_5.0_nobrainer.gemfile
75
+ # - rvm: jruby-9.1.12.0
76
+ # gemfile: gemfiles/rails_4.2_nobrainer.gemfile
77
+ # - rvm: jruby-9.1.12.0
78
+ # gemfile: gemfiles/rails_5.0_nobrainer.gemfile
76
79
 
77
80
  notifications:
78
81
  slack:
data/Appraisals CHANGED
@@ -1,13 +1,3 @@
1
- appraise 'rails_3.2' do
2
- gem 'rails', '~> 3.2.22'
3
- gem 'mongoid', '~> 3.1'
4
- gem 'sequel'
5
- gem 'bson_ext', platforms: :ruby
6
- gem 'test-unit', '~> 3.0'
7
- gem 'minitest'
8
- gem 'activerecord-jdbcsqlite3-adapter', '1.3.24', platforms: :jruby
9
- end
10
-
11
1
  appraise 'rails_4.2' do
12
2
  gem 'nokogiri', '1.6.8.1', platforms: %i[ruby_19]
13
3
  gem 'mime-types', '~> 2', platforms: %i[ruby_19 jruby]
@@ -18,6 +8,7 @@ appraise 'rails_4.2' do
18
8
  gem 'aws-sdk', '~> 2', platforms: :ruby
19
9
  gem 'redis-objects'
20
10
  gem 'activerecord-jdbcsqlite3-adapter', '1.3.24', platforms: :jruby
11
+ gem "after_commit_everywhere", "~> 0.1", ">= 0.1.5"
21
12
  end
22
13
 
23
14
  appraise 'rails_4.2_nobrainer' do
@@ -30,6 +21,7 @@ appraise 'rails_4.2_mongoid_5' do
30
21
  gem 'rails', '4.2.5'
31
22
  gem 'mongoid', '~> 5.0'
32
23
  gem 'activerecord-jdbcsqlite3-adapter', '1.3.24', platforms: :jruby
24
+ gem "after_commit_everywhere", "~> 0.1", ">= 0.1.5"
33
25
  end
34
26
 
35
27
  appraise 'rails_5.0' do
@@ -39,6 +31,7 @@ appraise 'rails_5.0' do
39
31
  gem 'dynamoid', '~> 1.3', platforms: :ruby
40
32
  gem 'aws-sdk', '~> 2', platforms: :ruby
41
33
  gem 'redis-objects'
34
+ gem "after_commit_everywhere", "~> 0.1", ">= 0.1.5"
42
35
  end
43
36
 
44
37
  appraise 'rails_5.0_nobrainer' do
@@ -53,6 +46,7 @@ appraise 'rails_5.1' do
53
46
  gem 'dynamoid', '~> 1.3', platforms: :ruby
54
47
  gem 'aws-sdk', '~>2', platforms: :ruby
55
48
  gem 'redis-objects'
49
+ gem "after_commit_everywhere", "~> 0.1", ">= 0.1.5"
56
50
  end
57
51
 
58
52
  appraise 'rails_5.2' do
@@ -62,9 +56,11 @@ appraise 'rails_5.2' do
62
56
  gem 'dynamoid', '~>2.2', platforms: :ruby
63
57
  gem 'aws-sdk', '~>2', platforms: :ruby
64
58
  gem 'redis-objects'
59
+ gem "after_commit_everywhere", "~> 0.1", ">= 0.1.5"
65
60
  end
66
61
 
67
62
  appraise 'norails' do
63
+ gem 'sqlite3', '~> 1.3', '>= 1.3.5', platforms: :ruby
68
64
  gem 'rails', install_if: false
69
65
  gem 'sequel'
70
66
  gem 'redis-objects'
@@ -2,6 +2,36 @@
2
2
 
3
3
  ## unreleased
4
4
 
5
+ ## 5.1.0
6
+
7
+ * Fix Depreciation message for after_commit_everywhere [#695](https://github.com/aasm/aasm/issues/695) in PR [#696](https://github.com/aasm/aasm/pull/696)
8
+ * Fix human_state to use display option [#684](https://github.com/aasm/aasm/issues/684) in PR [#697](https://github.com/aasm/aasm/pull/697)
9
+ * Remove support for ruby 2.3
10
+
11
+ ## 5.1.0
12
+
13
+ * Fix after_commit in nested transactions [#536](https://github.com/aasm/aasm/issues/536) without explicit AR dependency in PR [#668](https://github.com/aasm/aasm/pull/668), thanks to [stokarenko](https://github.com/stokarenko)
14
+ * Remove support for Rails 3.2
15
+
16
+ ## 5.0.8
17
+
18
+ * Revert Fix for :after_commit within nested transaction because it adds after_commit_action dependency which is dependent on many gems.
19
+
20
+ ## 5.0.7
21
+
22
+ * Fix :after_commit within nested transaction [#666](https://github.com/aasm/aasm/pull/666), thanks to [stokarenko](https://github.com/stokarenko)
23
+ * Add permitted_transitions to group permitted event with state [#664](https://github.com/aasm/aasm/pull/664), thanks to [dnamsons](https://github.com/dnamsons)
24
+ * Add Ruby 2.7.0 & 2.6.5 to Travis CI Test Matrix [#661](https://github.com/aasm/aasm/pull/661), thanks to [the-spectator](https://github.com/the-spectator)
25
+ * Handle InvalidTransition in transition_from matcher [#653](https://github.com/aasm/aasm/pull/653), thanks to [ryanwood](https://github.com/ryanwood)
26
+
27
+ ## 5.0.6
28
+
29
+ * Fix no_direct_assignment, couldn't be turned off pragmatically [#636](https://github.com/aasm/aasm/issues/636)
30
+ * Add instance level validation skip option [#644](https://github.com/aasm/aasm/pull/644), thanks to [Nitin-Salunke](https://github.com/Nitin-Salunke)
31
+ * Fixed aasm.current_event incorrectly yields nil when calling aasm.fire!(:event) [#551](https://github.com/aasm/aasm/issues/551) in [#638](https://github.com/aasm/aasm/pull/638), thanks to [DoubleJarvis](https://github.com/DoubleJarvis)
32
+ * Code Refactor [#634](https://github.com/aasm/aasm/pull/634) , thanks to [rahulknojha](https://github.com/rahulknojha)
33
+ * Fixed callback argument for :before_success & :success callback, [#630](https://github.com/aasm/aasm/pull/630)
34
+
5
35
  ## 5.0.5
6
36
 
7
37
  * Independent of ActiveSupport methods, [#627](https://github.com/aasm/aasm/pull/627),
data/Dockerfile CHANGED
@@ -1,9 +1,4 @@
1
- ARG RVM_RUBY_VERSIONS="2.4.0 2.5.0"
2
- ARG RVM_RUBY_DEFAULT="2.4.0"
3
- FROM msati/docker-rvm
4
-
5
- # After Ruby versions are installed we continue as non-root rvm user
6
- USER ${RVM_USER}
1
+ FROM ruby:2.3.4-slim
7
2
 
8
3
  LABEL maintainer="AASM"
9
4
 
data/Gemfile CHANGED
@@ -3,4 +3,4 @@ source "https://rubygems.org"
3
3
  gemspec
4
4
 
5
5
  gem 'sqlite3', '~> 1.3.5', :platforms => :ruby
6
- gem 'rails', '5.1.4'
6
+ gem 'rails', '5.1.4'
data/README.md CHANGED
@@ -3,6 +3,7 @@
3
3
  [![Gem Version](https://badge.fury.io/rb/aasm.svg)](http://badge.fury.io/rb/aasm)
4
4
  [![Build Status](https://travis-ci.org/aasm/aasm.svg?branch=master)](https://travis-ci.org/aasm/aasm)
5
5
  [![Code Climate](https://codeclimate.com/github/aasm/aasm/badges/gpa.svg)](https://codeclimate.com/github/aasm/aasm)
6
+ [![codecov](https://codecov.io/gh/aasm/aasm/branch/master/graph/badge.svg)](https://codecov.io/gh/aasm/aasm)
6
7
 
7
8
  ## Index
8
9
  - [Upgrade from version 3 to 4](#upgrade-from-version-3-to-4)
@@ -29,6 +30,7 @@
29
30
  - [Transaction support](#transaction-support)
30
31
  - [Pessimistic Locking](#pessimistic-locking)
31
32
  - [Column name & migration](#column-name--migration)
33
+ - [Log State Changes](#log-state-changes)
32
34
  - [Inspection](#inspection)
33
35
  - [Warning output](#warning-output)
34
36
  - [RubyMotion support](#rubymotion-support)
@@ -214,13 +216,11 @@ Also, you can pass parameters to events:
214
216
 
215
217
  ```ruby
216
218
  job = Job.new
217
- job.run(:running, :defragmentation)
219
+ job.run(:defragmentation)
218
220
  ```
219
221
 
220
222
  In this case the `set_process` would be called with `:defragmentation` argument.
221
223
 
222
- Note that when passing arguments to a state transition, the first argument should be the desired end state. In the above example, we wish to transition to `:running` state and run the callback with `:defragmentation` argument. You can also omit or pass in `nil` as the desired end state, and AASM will try to transition to the first end state defined for that event.
223
-
224
224
  In case of an error during the event processing the error is rescued and passed to `:error`
225
225
  callback, which can handle it or re-raise it for further propagation.
226
226
 
@@ -260,8 +260,8 @@ begin
260
260
  new_state enter
261
261
  ...update state...
262
262
  event before_success # if persist successful
263
- transition success # if persist successful
264
- event success # if persist successful
263
+ transition success # if persist successful, database update not guaranteed
264
+ event success # if persist successful, database update not guaranteed
265
265
  old_state after_exit
266
266
  new_state after_enter
267
267
  event after
@@ -275,6 +275,8 @@ ensure
275
275
  end
276
276
  ```
277
277
 
278
+ Use event's `after_commit` callback if it should be fired after database update.
279
+
278
280
  #### The current event triggered
279
281
 
280
282
  While running the callbacks you can easily retrieve the name of the event triggered
@@ -432,16 +434,35 @@ job.stage1_completed
432
434
  job.aasm.current_state # stage3
433
435
  ```
434
436
 
437
+ ### Display name for state
438
+
439
+ You can define display name for state using :display option
440
+
441
+ ```ruby
442
+ class Job
443
+ include AASM
444
+
445
+ aasm do
446
+ state :stage1, initial: true, display: 'First Stage'
447
+ state :stage2
448
+ state :stage3
449
+ end
450
+ end
451
+
452
+ job = Job.new
453
+ job.aasm.human_state
454
+
455
+ ```
435
456
 
436
457
  ### Multiple state machines per class
437
458
 
438
459
  Multiple state machines per class are supported. Be aware though that _AASM_ has been
439
- built with one state machine per class in mind. Nonetheless, here's how to do it:
460
+ built with one state machine per class in mind. Nonetheless, here's how to do it (see below). Please note that you will need to specify database columns for where your pertinent states will be stored - we have specified two columns `move_state` and `work_state` in the example below. See the [Column name & migration](https://github.com/aasm/aasm#column-name--migration) section for further info.
440
461
 
441
462
  ```ruby
442
463
  class SimpleMultipleExample
443
464
  include AASM
444
- aasm(:move) do
465
+ aasm(:move, column: 'move_state') do
445
466
  state :standing, initial: true
446
467
  state :walking
447
468
  state :running
@@ -457,7 +478,7 @@ class SimpleMultipleExample
457
478
  end
458
479
  end
459
480
 
460
- aasm(:work) do
481
+ aasm(:work, column: 'work_state') do
461
482
  state :sleeping, initial: true
462
483
  state :processing
463
484
 
@@ -677,6 +698,8 @@ end
677
698
  AASM comes with support for ActiveRecord and allows automatic persisting of the object's
678
699
  state in the database.
679
700
 
701
+ Add `gem 'after_commit_everywhere', '~> 0.1', '>= 0.1.5'` to your Gemfile
702
+
680
703
  ```ruby
681
704
  class Job < ActiveRecord::Base
682
705
  include AASM
@@ -741,6 +764,14 @@ class Job < ActiveRecord::Base
741
764
  end
742
765
  ```
743
766
 
767
+ Also You can skip the validation at instance level with `some_event_name_without_validation!` method.
768
+ With this you have the flexibility of having validation for all your transitions by default and then skip it wherever required.
769
+ Please note that only state column will be updated as mentioned in the above example.
770
+
771
+ ```ruby
772
+ job.run_without_validation!
773
+ ```
774
+
744
775
  If you want to make sure that the _AASM_ column for storing the state is not directly assigned,
745
776
  configure _AASM_ to not allow direct assignment, like this:
746
777
 
@@ -973,6 +1004,12 @@ job.run
973
1004
  job.save! #notify_about_running_job is not run
974
1005
  ```
975
1006
 
1007
+ Please note that `:after_commit` AASM callbacks behaves around custom implementation
1008
+ of transaction pattern rather than a real-life DB transaction. This fact still causes
1009
+ the race conditions and redundant callback calls within nested transaction. In order
1010
+ to fix that it's highly recommended to add `gem 'after_commit_everywhere', '~> 0.1', '>= 0.1.5'`
1011
+ to your `Gemfile`.
1012
+
976
1013
  If you want to encapsulate state changes within an own transaction, the behavior
977
1014
  of this nested transaction might be confusing. Take a look at
978
1015
  [ActiveRecord Nested Transactions](http://api.rubyonrails.org/classes/ActiveRecord/Transactions/ClassMethods.html)
@@ -1057,18 +1094,21 @@ this by defining your favorite column name, using `:column` like this:
1057
1094
  class Job < ActiveRecord::Base
1058
1095
  include AASM
1059
1096
 
1060
- aasm column: 'my_state' do
1097
+ aasm column: :my_state do
1061
1098
  ...
1062
1099
  end
1063
1100
 
1064
- aasm :another_state_machine, column: 'second_state' do
1101
+ aasm :another_state_machine, column: :second_state do
1065
1102
  ...
1066
1103
  end
1067
1104
  end
1068
1105
  ```
1069
1106
 
1070
1107
  Whatever column name is used, make sure to add a migration to provide this column
1071
- (of type `string`):
1108
+ (of type `string`).
1109
+ Do not add default value for column at the database level. If you add default
1110
+ value in database then AASM callbacks on the initial state will not be fired upon
1111
+ instantiation of the model.
1072
1112
 
1073
1113
  ```ruby
1074
1114
  class AddJobState < ActiveRecord::Migration
@@ -1082,6 +1122,13 @@ class AddJobState < ActiveRecord::Migration
1082
1122
  end
1083
1123
  ```
1084
1124
 
1125
+ ### Log State Changes
1126
+
1127
+ Logging state change can be done using [paper_trail](https://github.com/paper-trail-gem/paper_trail) gem
1128
+
1129
+ Example of implementation can be found here [https://github.com/nitsujri/aasm-papertrail-example](https://github.com/nitsujri/aasm-papertrail-example)
1130
+
1131
+
1085
1132
  ### Inspection
1086
1133
 
1087
1134
  AASM supports query methods for states and events
@@ -1126,6 +1173,10 @@ job = Job.new
1126
1173
  job.aasm.states(permitted: true).map(&:name)
1127
1174
  #=> [:running]
1128
1175
 
1176
+ # List all the permitted transitions(event and state pairs) from initial state
1177
+ job.aasm.permitted_transitions
1178
+ #=> [{ :event => :run, :state => :running }]
1179
+
1129
1180
  job.run
1130
1181
  job.aasm.states(permitted: true).map(&:name)
1131
1182
  #=> [:sleeping]
@@ -1193,7 +1244,7 @@ the 'instance method symbol / string' way whenever possible when defining guardi
1193
1244
  #### RSpec
1194
1245
 
1195
1246
  AASM provides some matchers for [RSpec](http://rspec.info):
1196
- *`transition_from`,
1247
+ * `transition_from`,
1197
1248
  * `have_state`, `allow_event`
1198
1249
  * and `allow_transition_to`.
1199
1250