Skip to content

Commit

Permalink
Merge pull request #5397 from komidore64/rm10948-unlimited-content-hosts
Browse files Browse the repository at this point in the history
refs #10948 - accounting for unlimited_content_hosts=false, BZ1214675
  • Loading branch information
komidore64 committed Aug 14, 2015
2 parents b2014a5 + d1da84b commit 86a1227
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
2 changes: 2 additions & 0 deletions app/models/katello/host_collection.rb
Expand Up @@ -40,6 +40,8 @@ def validate_max_content_hosts
errors.add :content_host_limit, _("may not be less than the number of content hosts associated with the host collection.")
elsif (max_content_hosts == 0)
errors.add :content_host_limit, _("may not be set to 0.")
elsif (unlimited_content_hosts == false) && (max_content_hosts.nil?)
errors.add :max_content_hosts, _("must be given a value if this host collection is not unlimited.")
end
end
end
Expand Down
7 changes: 7 additions & 0 deletions spec/models/host_collection_spec.rb
Expand Up @@ -40,6 +40,13 @@ module Katello
grp2.new_record?.must_equal(false)
HostCollection.where(:name => "TestHostCollection").count.must_equal(2)
end

it "should not allow unlimited_content_hosts=false and max_content_hosts to be nil at the same time" do
create = lambda do
HostCollection.create!(:name => "TestHostCollection", :organization => @org, :unlimited_content_hosts => false)
end
create.must_raise(ActiveRecord::RecordInvalid)
end
end

describe "delete should" do
Expand Down

0 comments on commit 86a1227

Please sign in to comment.