Bang methods don't transition new_records when skip_validation_on_save is true
Open
@alto is already working on this.
Since Jul 21, 2015.
bug
persistence
- Dominant language
- Ruby
- Stars
- 5.2k
- Forks
- 644
- PR merge metrics
- No merged PRs in 30d
Description
It will set the value back to old_value as the update_all won't match any records where(self.class.primary_key => self.id) as self.id doesn't exist
See https://github.com/aasm/aasm/blob/master/lib/aasm/persistence/active_record_persistence.rb#L87-L89
Makes some transitions harder from other state machine gems
Example:
class Order < ActiveRecord::Base
aasm(skip_validation_on_save: true) do
state :new, initial: true
state :shipped
event :process do
transitions(from: :new, to: :shipped)
end
end
end
spec
let(:order) { Order.new }
it "should change the status when a bang method is called" do
expect { order.process! }.to change(order, :status).from('new').to('shipped')
end
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.