Remove ruby 2.3 support and fix human_state to use display option
This commit is contained in:
parent
916cd1de1a
commit
985cd1e79b
11
.travis.yml
11
.travis.yml
|
@ -12,7 +12,6 @@ before_install:
|
|||
- bundle _1.16.1_ install
|
||||
|
||||
rvm:
|
||||
- 2.3.0
|
||||
- 2.5.0
|
||||
- 2.6.5
|
||||
- 2.7.0
|
||||
|
@ -47,16 +46,6 @@ script:
|
|||
|
||||
matrix:
|
||||
exclude:
|
||||
- rvm: 2.3.0
|
||||
gemfile: gemfiles/norails.gemfile
|
||||
- rvm: 2.3.0
|
||||
gemfile: gemfiles/rails_5.0.gemfile
|
||||
# - rvm: 2.3.0
|
||||
# gemfile: gemfiles/rails_5.0_nobrainer.gemfile
|
||||
- rvm: 2.3.0
|
||||
gemfile: gemfiles/rails_5.1.gemfile
|
||||
- rvm: 2.3.0
|
||||
gemfile: gemfiles/rails_5.2.gemfile
|
||||
- rvm: 2.7.0
|
||||
gemfile: gemfiles/rails_5.2.gemfile
|
||||
- rvm: 2.6.5
|
||||
|
|
19
README.md
19
README.md
|
@ -434,6 +434,25 @@ job.stage1_completed
|
|||
job.aasm.current_state # stage3
|
||||
```
|
||||
|
||||
### Display name for state
|
||||
|
||||
You can define display name for state using :display option
|
||||
|
||||
```ruby
|
||||
class Job
|
||||
include AASM
|
||||
|
||||
aasm do
|
||||
state :stage1, initial: true, display: 'First Stage'
|
||||
state :stage2
|
||||
state :stage3
|
||||
end
|
||||
end
|
||||
|
||||
job = Job.new
|
||||
job.aasm.human_state
|
||||
|
||||
```
|
||||
|
||||
### Multiple state machines per class
|
||||
|
||||
|
|
|
@ -28,7 +28,7 @@ module AASM
|
|||
end
|
||||
|
||||
def human_state
|
||||
AASM::Localizer.new.human_state_name(@instance.class, state_object_for_name(current_state))
|
||||
state_object_for_name(current_state).display_name
|
||||
end
|
||||
|
||||
def states(options={}, *args)
|
||||
|
|
|
@ -2,7 +2,7 @@ class DefaultState
|
|||
attr_accessor :transient_store, :persisted_store
|
||||
include AASM
|
||||
aasm do
|
||||
state :alpha, :initial => true
|
||||
state :alpha, :initial => true, display: 'ALPHA'
|
||||
state :beta
|
||||
state :gamma
|
||||
event :release do
|
||||
|
|
|
@ -13,6 +13,10 @@ if defined?(ActiveRecord)
|
|||
expect(DefaultState.new.aasm.current_state).to eql :alpha
|
||||
end
|
||||
|
||||
it "uses display option" do
|
||||
expect(DefaultState.new.aasm.human_state).to eql "ALPHA"
|
||||
end
|
||||
|
||||
it "uses the provided method" do
|
||||
expect(ProvidedState.new.aasm.current_state).to eql :beta
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue