Skip to content
This repository has been archived by the owner on Jul 24, 2020. It is now read-only.

Commit

Permalink
Refactor EquipmentItem Model spec
Browse files Browse the repository at this point in the history
Resolves #1610
  • Loading branch information
Sydney Young committed Sep 20, 2016
1 parent f5eac92 commit 92c0040
Show file tree
Hide file tree
Showing 3 changed files with 232 additions and 119 deletions.
24 changes: 12 additions & 12 deletions app/models/equipment_item.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,18 @@ class EquipmentItem < ActiveRecord::Base

searchable_on(:name, :serial)

def self.for_eq_model(model_id, source_objects)
# count the number of equipment items for a given
# model out of an array of source objects
# 0 queries

count = 0
source_objects.each do |o|
count += 1 if o.equipment_model_id == model_id
end
count
end

def status
if deleted? && deactivation_reason
"Deactivated (#{deactivation_reason})"
Expand All @@ -41,18 +53,6 @@ def available?
status == 'available'
end

def self.for_eq_model(model_id, source_objects)
# count the number of equipment items for a given
# model out of an array of source objects
# 0 queries

count = 0
source_objects.each do |o|
count += 1 if o.equipment_model_id == model_id
end
count
end

def make_reservation_notes(procedure_verb, reservation, handler, new_notes,
time)
new_str = "#### #{reservation.md_link(procedure_verb.capitalize)} by "\
Expand Down
2 changes: 1 addition & 1 deletion spec/factories/equipment_items.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
deactivation_reason nil
notes ''

factory :deactivated do
factory :deactivated_item do
deactivation_reason 'Because I can'
deleted_at '2013-01-01 00:00:00'
end
Expand Down
Loading

0 comments on commit 92c0040

Please sign in to comment.