require 'spec_helper'

describe MiqAeMethodService::MiqAeServiceClassification do
  before do
    FactoryGirl.create(:classification_department_with_tags)
    @cc_cat = FactoryGirl.create(:classification_cost_center_with_tags)
  end

  let(:user) { FactoryGirl.create(:user_with_group) }
  let(:categories) { MiqAeMethodService::MiqAeServiceClassification.categories }

  it "get a list of categories" do
    cat_array = Classification.categories.collect(&:name)
    expect(categories.collect(&:name)).to match_array(cat_array)
  end

  it "check the tags" do
    tags_array = @cc_cat.entries.collect(&:name)
    cc = categories.detect { |c| c.name == 'cc' }
    tags = cc.entries
    expect(tags.collect(&:name)).to match_array(tags_array)
  end
end

require 'spec_helper'

describe MiqAeMethodService::MiqAeServiceClassification do
  before do
    @cat1 = FactoryGirl.create(:classification_department_with_tags)
    @cat2 = FactoryGirl.create(:classification_cost_center_with_tags)
    @cat_array = Classification.categories.collect(&:name)
    @tags_array = @cat2.entries.collect(&:name)
  end

  let(:user) { FactoryGirl.create(:user_with_group) }
  let(:categories) { MiqAeMethodService::MiqAeServiceClassification.categories }

  it "get a list of categories" do
    expect(categories.collect(&:name)).to match_array(@cat_array)
  end

  it "check the tags" do
    cc = categories.detect { |c| c.name == 'cc' }
    tags = cc.entries
    expect(tags.collect(&:name)).to match_array(@tags_array)
  end
end

--- 
+++ 
@@ -2,22 +2,22 @@
 
 describe MiqAeMethodService::MiqAeServiceClassification do
   before do
-    @cat1 = FactoryGirl.create(:classification_department_with_tags)
-    @cat2 = FactoryGirl.create(:classification_cost_center_with_tags)
-    @cat_array = Classification.categories.collect(&:name)
-    @tags_array = @cat2.entries.collect(&:name)
+    FactoryGirl.create(:classification_department_with_tags)
+    @cc_cat = FactoryGirl.create(:classification_cost_center_with_tags)
   end
 
   let(:user) { FactoryGirl.create(:user_with_group) }
   let(:categories) { MiqAeMethodService::MiqAeServiceClassification.categories }
 
   it "get a list of categories" do
-    expect(categories.collect(&:name)).to match_array(@cat_array)
+    cat_array = Classification.categories.collect(&:name)
+    expect(categories.collect(&:name)).to match_array(cat_array)
   end
 
   it "check the tags" do
+    tags_array = @cc_cat.entries.collect(&:name)
     cc = categories.detect { |c| c.name == 'cc' }
     tags = cc.entries
-    expect(tags.collect(&:name)).to match_array(@tags_array)
+    expect(tags.collect(&:name)).to match_array(tags_array)
   end
 end
Automate methods can access categories and entries

https://bugzilla.redhat.com/show_bug.cgi?id=1254953

PR feedback


(transferred from ManageIQ/manageiq@06d79ecb7c45c39ae1009925199461b7f6c95b94)
