-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix CI: prevent models mutations in auto_save_spec
- Loading branch information
1 parent
bbbd82b
commit 89c3ed7
Showing
4 changed files
with
301 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
# frozen_string_literal: true | ||
|
||
class AccountAuto | ||
include Mongoid::Document | ||
|
||
field :_id, type: String, overwrite: true, default: -> { name.try(:parameterize) } | ||
|
||
field :number, type: String | ||
field :balance, type: Integer | ||
field :nickname, type: String | ||
field :name, type: String | ||
field :balanced, type: Mongoid::Boolean, default: -> { balance? } | ||
|
||
field :overridden, type: String | ||
|
||
embeds_many :memberships | ||
belongs_to :creator, class_name: 'User' | ||
belongs_to :person, class_name: 'PersonAuto' | ||
has_many :alerts, autosave: false | ||
has_and_belongs_to_many :agents | ||
has_one :comment, validate: false | ||
|
||
validates_presence_of :name | ||
validates_presence_of :nickname, on: :upsert | ||
validates_length_of :name, maximum: 10, on: :create | ||
|
||
def overridden | ||
self[:overridden] = 'not recommended' | ||
end | ||
|
||
# MONGOID-3365 | ||
field :period_started_at, type: Time | ||
has_many :consumption_periods, dependent: :destroy, validate: false | ||
|
||
def current_consumption | ||
consumption_periods.find_or_create_by(started_at: period_started_at) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
# frozen_string_literal: true | ||
|
||
class DrugAuto | ||
include Mongoid::Document | ||
field :name, type: String | ||
field :generic, type: Mongoid::Boolean | ||
belongs_to :person, class_name: 'PersonAuto', inverse_of: nil, counter_cache: true | ||
end |
Oops, something went wrong.