Skip to content

Commit

Permalink
fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
dorner committed Nov 3, 2024
1 parent 66c4a38 commit af15745
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 18 deletions.
25 changes: 13 additions & 12 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,7 @@ GEM
image_processing (1.13.0)
mini_magick (>= 4.9.5, < 5)
ruby-vips (>= 2.0.17, < 3)
importmap-rails (2.0.1)
importmap-rails (2.0.3)
actionpack (>= 6.0.0)
activesupport (>= 6.0.0)
railties (>= 6.0.0)
Expand Down Expand Up @@ -482,16 +482,16 @@ GEM
puma (6.4.3)
nio4r (~> 2.0)
racc (1.8.1)
rack (2.2.10)
rack-protection (3.1.0)
rack (~> 2.2, >= 2.2.4)
rack-session (1.0.2)
rack (< 3)
rack (3.1.8)
rack-protection (4.0.0)
base64 (>= 0.1.0)
rack (>= 3.0.0, < 4)
rack-session (2.0.0)
rack (>= 3.0.0)
rack-test (2.1.0)
rack (>= 1.3)
rackup (1.0.1)
rack (< 3)
webrick
rackup (2.2.0)
rack (>= 3)
rails (7.2.2)
actioncable (= 7.2.2)
actionmailbox (= 7.2.2)
Expand Down Expand Up @@ -629,10 +629,11 @@ GEM
simplecov_json_formatter (~> 0.1)
simplecov-html (0.12.3)
simplecov_json_formatter (0.1.4)
sinatra (3.1.0)
sinatra (4.0.0)
mustermann (~> 3.0)
rack (~> 2.2, >= 2.2.4)
rack-protection (= 3.1.0)
rack (>= 3.0.0, < 4)
rack-protection (= 4.0.0)
rack-session (>= 2.0.0, < 3)
tilt (~> 2.0)
slop (3.6.0)
smart_properties (1.17.0)
Expand Down
2 changes: 1 addition & 1 deletion app/models/account_request.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class AccountRequest < ApplicationRecord

has_one :organization, dependent: :nullify

enum status: %w[started user_confirmed admin_approved rejected admin_closed].map { |v| [v, v] }.to_h
enum :status, %w[started user_confirmed admin_approved rejected admin_closed].map { |v| [v, v] }.to_h

scope :requested, -> { where(status: %w[started user_confirmed]) }
scope :closed, -> { where(status: %w[admin_approved rejected admin_closed]) }
Expand Down
4 changes: 2 additions & 2 deletions app/models/distribution.rb
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ class Distribution < ApplicationRecord

before_save :combine_distribution, :reset_shipping_cost

enum state: { scheduled: 5, complete: 10 }
enum delivery_method: { pick_up: 0, delivery: 1, shipped: 2 }
enum :state, { scheduled: 5, complete: 10 }
enum :delivery_method, { pick_up: 0, delivery: 1, shipped: 2 }
scope :active, -> { joins(:line_items).joins(:items).where(items: { active: true }) }
# add item_id scope to allow filtering distributions by item
scope :by_item_id, ->(item_id) { joins(:items).where(items: { id: item_id }) }
Expand Down
2 changes: 1 addition & 1 deletion app/models/partner.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class Partner < ApplicationRecord
"application/vnd.openxmlformats-officedocument.wordprocessingml.document"
].freeze

enum status: { uninvited: 0, invited: 1, awaiting_review: 2, approved: 3, error: 4, recertification_required: 5, deactivated: 6 }
enum :status, { uninvited: 0, invited: 1, awaiting_review: 2, approved: 3, error: 4, recertification_required: 5, deactivated: 6 }

belongs_to :organization
belongs_to :partner_group, optional: true
Expand Down
2 changes: 1 addition & 1 deletion app/models/request.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class Request < ApplicationRecord
accepts_nested_attributes_for :item_requests, allow_destroy: true, reject_if: proc { |attributes| attributes["quantity"].blank? }
has_many :child_item_requests, through: :item_requests

enum status: { pending: 0, started: 1, fulfilled: 2, discarded: 3 }, _prefix: true
enum :status, { pending: 0, started: 1, fulfilled: 2, discarded: 3 }, _prefix: true

validates :distribution_id, uniqueness: true, allow_nil: true
validate :item_requests_uniqueness_by_item_id
Expand Down
1 change: 0 additions & 1 deletion spec/models/item_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@

it { should validate_presence_of(:name) }
it { should belong_to(:organization) }
it { should belong_to(:base_item).counter_cache(:item_count).with_primary_key(:partner_key).with_foreign_key(:partner_key).inverse_of(:items) }
it { should validate_numericality_of(:distribution_quantity).is_greater_than(0) }
it { should validate_numericality_of(:on_hand_minimum_quantity).is_greater_than_or_equal_to(0) }
it { should validate_numericality_of(:on_hand_recommended_quantity).is_greater_than_or_equal_to(0) }
Expand Down

0 comments on commit af15745

Please sign in to comment.