Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
21 changed files
with
160 additions
and
17 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,26 @@ | ||
class CollectionProfile < ActiveRecord::Base | ||
|
||
include Housekeeping | ||
include SoftValidation | ||
|
||
belongs_to :container | ||
belongs_to :otu | ||
|
||
validates_presence_of :conservation_status, message: 'Conservation status is not selected' | ||
validates_presence_of :processing_state, message: 'Processing state is not selected' | ||
validates_presence_of :container_condition, message: 'Container condition is not selected' | ||
validates_presence_of :condition_of_labels, message: 'Condition of labels is not selected' | ||
validates_presence_of :identification_level, message: 'Identification level is not selected' | ||
validates_presence_of :arrangement_level, message: 'Arrangement level is not selected' | ||
validates_presence_of :data_quality, message: 'Data quality is not selected' | ||
validates_presence_of :computerization_level, message: 'Computerization_level is not selected' | ||
|
||
before_validation :validate_number | ||
|
||
def validate_number | ||
if self.number_of_collection_objects.nil? && self.number_of_containers.nil? | ||
errors.add(:number_of_collection_objects, 'At least one number of specimens or number of containers should be specified') if self.parent_id.blank? | ||
errors.add(:number_of_containers, 'At least one number of specimens or number of containers should be specified') if self.parent_id.blank? | ||
end | ||
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 |
---|---|---|
@@ -1,10 +1,53 @@ | ||
class Container < ActiveRecord::Base | ||
acts_as_nested_set | ||
acts_as_nested_set scope: [:project_id] | ||
|
||
include Housekeeping | ||
include Shared::Identifiable | ||
include Shared::Containable | ||
|
||
has_many :physical_collection_objects | ||
belongs_to :otu | ||
|
||
|
||
#has_many :physical_collection_objects | ||
has_many :collection_profiles | ||
has_many :collection_items | ||
|
||
before_validation :check_type | ||
|
||
#CONTAINER_TYPES = %w(dry wet slide) | ||
|
||
# Return a String with the "common" name for this class. | ||
def self.class_name | ||
self.type_name.demodulize.underscore.humanize.downcase | ||
end | ||
|
||
def type_name | ||
r = self.type.to_s | ||
CONTAINER_TYPE_NAMES.include?(r) ? r : nil | ||
end | ||
|
||
def type_class=(value) | ||
write_attribute(:type, value.to_s) | ||
end | ||
|
||
def type_class | ||
r = read_attribute(:type).to_s | ||
r = CONTAINER_TYPE_NAMES.include?(r) ? r.safe_constantize : nil | ||
r | ||
end | ||
|
||
|
||
protected | ||
|
||
#region Validation | ||
|
||
def check_type | ||
unless CONTAINER_TYPES.include?(self.type) | ||
errors.add(:type, 'Not a legal type of container') | ||
end | ||
end | ||
|
||
#endregion | ||
|
||
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,2 @@ | ||
class Container::Box < Container | ||
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,2 @@ | ||
class Container::Cabinet < Container | ||
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,2 @@ | ||
class Container::Drawer < Container | ||
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,2 @@ | ||
class Container::Folder < Container | ||
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 |
---|---|---|
@@ -1,2 +1,2 @@ | ||
class Container::Virtual < Container | ||
class Container::Pin < Container | ||
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,2 @@ | ||
class Container::Slide < Container | ||
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,2 @@ | ||
class Container::SlideBox < Container | ||
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 |
---|---|---|
@@ -1,2 +1,2 @@ | ||
class Container::Virtual < Container | ||
class Container::Vial < Container | ||
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,2 @@ | ||
class Container::VialRack < Container | ||
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
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
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,7 @@ | ||
# Be sure to restart your server when you modify this file. | ||
|
||
# All assignable container types | ||
CONTAINER_TYPES = Container.descendants | ||
|
||
# All assignable container type names | ||
CONTAINER_TYPE_NAMES = CONTAINER_TYPES.collect{|i| i.to_s} |
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,6 @@ | ||
class ContainerName < ActiveRecord::Migration | ||
def change | ||
add_column :containers, :name, :string | ||
add_column :containers, :disposition, :string | ||
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,5 @@ | ||
class AddContainterItem < ActiveRecord::Migration | ||
def change | ||
add_column :loan_items, :container_id, :integer | ||
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
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 |
---|---|---|
@@ -1,5 +1,43 @@ | ||
require 'spec_helper' | ||
|
||
describe CollectionProfile do | ||
pending "add some examples to (or delete) #{__FILE__}" | ||
before(:all) do | ||
@collection_profile = FactoryGirl.build_stubbed(:collection_profile) | ||
end | ||
|
||
context 'associations' do | ||
context 'belongs_to' do | ||
specify 'conservation_status' do | ||
expect(@collection_profile).to respond_to(:conservation_status) | ||
end | ||
specify 'processing_state' do | ||
expect(@collection_profile).to respond_to(:processing_state) | ||
end | ||
specify 'container_condition' do | ||
expect(@collection_profile).to respond_to(:container_condition) | ||
end | ||
specify 'condition_of_labels' do | ||
expect(@collection_profile).to respond_to(:condition_of_labels) | ||
end | ||
specify 'identification_level' do | ||
expect(@collection_profile).to respond_to(:identification_level) | ||
end | ||
specify 'arrangement_level' do | ||
expect(@collection_profile).to respond_to(:arrangement_level) | ||
end | ||
specify 'data_quality' do | ||
expect(@collection_profile).to respond_to(:data_quality) | ||
end | ||
specify 'computerization_level' do | ||
expect(@collection_profile).to respond_to(:computerization_level) | ||
end | ||
|
||
specify 'otu' do | ||
expect(@collection_profile).to respond_to(:otu) | ||
end | ||
specify 'container' do | ||
expect(@collection_profile).to respond_to(:container) | ||
end | ||
end | ||
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