From 3a974ad1bb36ac1d582704a5a206f2419d11ca71 Mon Sep 17 00:00:00 2001 From: Keenan Brock Date: Fri, 23 Mar 2018 13:34:14 -0400 Subject: [PATCH] convert tag.category to a regular association --- app/models/tag.rb | 6 +----- .../ems_refresh/save_inventory/save_tags_inventory_spec.rb | 2 +- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/app/models/tag.rb b/app/models/tag.rb index e618c5006f49..43cb38c4fafe 100644 --- a/app/models/tag.rb +++ b/app/models/tag.rb @@ -1,7 +1,7 @@ class Tag < ApplicationRecord has_many :taggings, :dependent => :destroy has_one :classification - virtual_has_one :category, :class_name => "Classification" + has_one :category, :through => :classification, :source => :parent virtual_has_one :categorization, :class_name => "Hash" has_many :container_label_tag_mappings @@ -133,10 +133,6 @@ def ==(comparison_object) super || name.downcase == comparison_object.to_s.downcase end - def category - @category ||= Classification.find_by_name(name_path.split('/').first, nil) - end - def show category.try(:show) end diff --git a/spec/models/ems_refresh/save_inventory/save_tags_inventory_spec.rb b/spec/models/ems_refresh/save_inventory/save_tags_inventory_spec.rb index ed85c149cf10..670b7e3bb0f8 100644 --- a/spec/models/ems_refresh/save_inventory/save_tags_inventory_spec.rb +++ b/spec/models/ems_refresh/save_inventory/save_tags_inventory_spec.rb @@ -6,7 +6,7 @@ def mapped_tag(category_name, tag_name) mapping = FactoryGirl.create(:tag_mapping_with_category, :category_name => category_name, :category_description => category_name) - category = mapping.tag.category + category = mapping.tag.classification entry = category.add_entry(:name => tag_name, :description => tag_name) entry.tag end