Skip to content

Commit

Permalink
Merge pull request #3325 from daviddavis/temp/20131106092704
Browse files Browse the repository at this point in the history
Engine: Fixing content view tests refs #3585
  • Loading branch information
David Davis committed Nov 6, 2013
2 parents c8dc128 + d0c9d21 commit 876f13b
Show file tree
Hide file tree
Showing 7 changed files with 32 additions and 25 deletions.
2 changes: 1 addition & 1 deletion app/models/katello/changeset.rb
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ class Changeset < ActiveRecord::Base
validates_with Validators::KatelloNameFormatValidator, :attributes => :name

has_many :users, :class_name => "ChangesetUser", :inverse_of => :changeset, :dependent => :destroy
belongs_to :environment, :class_name => "KTEnvironment"
belongs_to :environment, :class_name => "Katello::KTEnvironment"
belongs_to :task_status
has_many :changeset_content_views, :dependent => :destroy
has_many :content_views, :through => :changeset_content_views
Expand Down
2 changes: 1 addition & 1 deletion app/models/katello/kt_environment.rb
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,7 @@ def create_default_content_view_version
# we can't look it up via a query (org.default_content_view)
content_view = self.organization.default_content_view
if content_view.nil?
content_view = ContentView.new(:default => true, :name => "Default Organization View",
content_view = Katello::ContentView.new(:default => true, :name => "Default Organization View",
:organization => self.organization)
end

Expand Down
2 changes: 2 additions & 0 deletions lib/katello/tasks/test.rake
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ namespace :test do
"#{Katello::Engine.root}/test/models/repository_test.rb",
"#{Katello::Engine.root}/test/models/activation_key_test.rb",
"#{Katello::Engine.root}/test/models/changeset_test.rb",
"#{Katello::Engine.root}/test/models/content_view_test.rb",
"#{Katello::Engine.root}/test/models/content_view_version_test.rb",
"#{Katello::Engine.root}/spec/models/activation_key_spec.rb"
]
t.verbose = true
Expand Down
2 changes: 1 addition & 1 deletion test/fixtures/models/katello_content_views.yml
Original file line number Diff line number Diff line change
Expand Up @@ -74,5 +74,5 @@ composite_view:
default: false
created_at: <%= Time.now %>
updated_at: <%= Time.now %>
content_view_definition: <%= ActiveRecord::Fixtures.identify(:composite_def) %>
content_view_definition_id: <%= ActiveRecord::Fixtures.identify(:composite_def) %>
organization_id: <%= ActiveRecord::Fixtures.identify(:acme_corporation) %>
26 changes: 14 additions & 12 deletions test/models/content_view_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@
# have received a copy of GPLv2 along with this software; if not, see
# http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt.

require 'minitest_helper'
require 'katello_test_helper'

class ContentViewTest < MiniTest::Rails::ActiveSupport::TestCase
fixtures :all
module Katello
class ContentViewTest < ActiveSupport::TestCase

def self.before_suite
models = ["Organization", "KTEnvironment", "User", "ContentViewEnvironment","ContentViewDefinitionBase",
Expand All @@ -25,12 +25,12 @@ def self.before_suite

def setup
User.current = User.find(users(:admin))
@library = KTEnvironment.find(environments(:library).id)
@dev = KTEnvironment.find(environments(:dev).id)
@acme_corporation = Organization.find(organizations(:acme_corporation).id)
@default_view = ContentView.find(content_views(:acme_default))
@library_view = ContentView.find(content_views(:library_view))
@library_dev_view = ContentView.find(content_views(:library_dev_view))
@library = KTEnvironment.find(katello_environments(:library).id)
@dev = KTEnvironment.find(katello_environments(:dev).id)
@acme_corporation = Organization.find(katello_organizations(:acme_corporation).id)
@default_view = ContentView.find(katello_content_views(:acme_default))
@library_view = ContentView.find(katello_content_views(:library_view))
@library_dev_view = ContentView.find(katello_content_views(:library_dev_view))
end

def test_create
Expand Down Expand Up @@ -177,17 +177,18 @@ def test_all_version_library_instances_empty
end

def test_components_not_in_env
composite_view = content_views(:composite_view)
composite_view = katello_content_views(:composite_view)

assert_equal 2, composite_view.components_not_in_env(@dev).length
assert_equal composite_view.content_view_definition.component_content_views.sort,
composite_view.components_not_in_env(@dev).sort
end

def test_refresh
composite_view = content_views(:composite_view)
composite_view = katello_content_views(:composite_view)

mock_definition = mock(:ready_to_publish? => false)
mock_definition = mock()
mock_definition.expects(:ready_to_publish?).returns(false)
composite_view.stubs(:content_view_definition).returns(mock_definition)

assert_raises(RuntimeError) do
Expand All @@ -196,3 +197,4 @@ def test_refresh
end

end
end
6 changes: 4 additions & 2 deletions test/models/content_view_version_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,10 @@
# have received a copy of GPLv2 along with this software; if not, see
# http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt.

require 'minitest_helper'
require 'katello_test_helper'

class ContentViewVersionTest < MiniTest::Rails::ActiveSupport::TestCase
module Katello
class ContentViewVersionTest < ActiveSupport::TestCase

def self.before_suite
models = ["Organization", "KTEnvironment", "User", "ContentViewEnvironment"]
Expand All @@ -37,3 +38,4 @@ def test_create_archived_definition
end

end
end
17 changes: 9 additions & 8 deletions test/models/kt_environment_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,13 @@
# have received a copy of GPLv2 along with this software; if not, see
# http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt.

require 'minitest_helper'
require 'katello_test_helper'

class KTEnvironmentTestBase < MiniTest::Rails::ActiveSupport::TestCase
module Katello
class KTEnvironmentTestBase < ActiveSupport::TestCase

extend ActiveRecord::TestFixtures

fixtures :all

def self.before_suite
services = ['Candlepin', 'Pulp', 'ElasticSearch', 'Foreman']
models = ['Repository', 'KTEnvironment', 'ContentView',
Expand All @@ -28,14 +27,15 @@ def self.before_suite
end

def setup
@library = KTEnvironment.find(environments(:library).id)
@dev = KTEnvironment.find(environments(:dev).id)
@staging = KTEnvironment.find(environments(:staging).id)
@acme_corporation = Organization.find(organizations(:acme_corporation).id)
@library = KTEnvironment.find(katello_environments(:library).id)
@dev = KTEnvironment.find(katello_environments(:dev).id)
@staging = KTEnvironment.find(katello_environments(:staging).id)
@acme_corporation = Organization.find(katello_organizations(:acme_corporation).id)
end

end


class KTEnvironmentTest < KTEnvironmentTestBase

def test_create_and_validate_default_content_view
Expand Down Expand Up @@ -72,3 +72,4 @@ def test_products_are_unique
assert_operator @library.repositories.map(&:product).length, :>, @library.products.length
end
end
end

0 comments on commit 876f13b

Please sign in to comment.