1
|
require "test_helper"
|
2
|
|
3
|
FactoryGirl.definition_file_paths << File.join(Katello::Engine.root, 'test', 'factories')
|
4
|
FactoryGirl.definition_file_paths << File.join(File.dirname(__FILE__), 'factories')
|
5
|
FactoryGirl.reload
|
6
|
|
7
|
require "#{Katello::Engine.root}/test/support/fixtures_support"
|
8
|
|
9
|
module FixtureTestCase
|
10
|
extend ActiveSupport::Concern
|
11
|
|
12
|
included do
|
13
|
extend ActiveRecord::TestFixtures
|
14
|
|
15
|
self.use_transactional_fixtures = true
|
16
|
self.use_instantiated_fixtures = false
|
17
|
self.pre_loaded_fixtures = true
|
18
|
|
19
|
Katello::FixturesSupport.set_fixture_classes(self)
|
20
|
|
21
|
self.fixture_path = Dir.mktmpdir("katello_fixtures")
|
22
|
FileUtils.cp(Dir.glob("#{Katello::Engine.root}/test/fixtures/models/*"), self.fixture_path)
|
23
|
FileUtils.cp(Dir.glob("#{Rails.root}/test/fixtures/*"), self.fixture_path)
|
24
|
fixtures(:all)
|
25
|
FIXTURES = load_fixtures
|
26
|
|
27
|
|
28
|
|
29
|
Setting::Katello.load_defaults
|
30
|
end
|
31
|
|
32
|
module ClassMethods
|
33
|
def before_suite
|
34
|
@@admin = ::User.find(FIXTURES['users']['admin']['id'])
|
35
|
User.current = @@admin
|
36
|
end
|
37
|
end
|
38
|
end
|
39
|
|
40
|
class ActiveSupport::TestCase
|
41
|
include FixtureTestCase
|
42
|
|
43
|
def get_organization(org = nil)
|
44
|
saved_user = User.current
|
45
|
User.current = User.find(users(:admin))
|
46
|
org = org.nil? ? :empty_organization : org
|
47
|
organization = Organization.find(taxonomies(org.to_sym))
|
48
|
organization.stubs(:label_not_changed).returns(true)
|
49
|
organization.setup_label_from_name
|
50
|
organization.save!
|
51
|
User.current = saved_user
|
52
|
organization
|
53
|
end
|
54
|
end
|