Revision 9fb80abe
Added by Ondřej Pražák over 7 years ago
test/foreman_pipeline_plugin_test_helper.rb | ||
---|---|---|
1 | 1 |
require "test_helper" |
2 | 2 |
|
3 |
def katello_root |
|
4 |
"#{ForemanPipeline::Engine::Railties.engines |
|
5 |
.select {|engine| engine.railtie_name == "katello"} |
|
6 |
.first.config.root}" |
|
7 |
end |
|
8 |
|
|
9 |
require "#{katello_root}/spec/models/model_spec_helper" |
|
10 |
FactoryGirl.definition_file_paths << File.join(katello_root, 'test', 'factories') |
|
3 |
FactoryGirl.definition_file_paths << File.join(Katello::Engine.root, 'test', 'factories') |
|
11 | 4 |
FactoryGirl.definition_file_paths << File.join(File.dirname(__FILE__), 'factories') |
12 | 5 |
FactoryGirl.reload |
13 | 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 |
# load_permissions |
|
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 |
|
|
14 | 40 |
class ActiveSupport::TestCase |
41 |
include FixtureTestCase |
|
15 | 42 |
|
16 | 43 |
def get_organization(org = nil) |
17 | 44 |
saved_user = User.current |
... | ... | |
24 | 51 |
User.current = saved_user |
25 | 52 |
organization |
26 | 53 |
end |
27 |
|
|
28 | 54 |
end |
Also available in: Unified diff
making promoting decisions more robust