Skip to content

Commit

Permalink
Fixes #12885 - Remove forcing 'no whitespace' from policy name
Browse files Browse the repository at this point in the history
  • Loading branch information
shlomizadok committed May 24, 2016
1 parent cd59dd8 commit e3af523
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
2 changes: 1 addition & 1 deletion app/models/foreman_openscap/policy.rb
Expand Up @@ -21,7 +21,7 @@ class Policy < ActiveRecord::Base
SERVER_CLASS_PARAMETER = 'server'
PORT_CLASS_PARAMETER = 'port'

validates :name, :presence => true, :uniqueness => true, :format => { :without => /\s/ }
validates :name, :presence => true, :uniqueness => true
validate :ensure_needed_puppetclasses
validates :period, :inclusion => {:in => %w(weekly monthly custom)},
:if => Proc.new { |policy| policy.new_record? ? policy.step_index > 3 : !policy.id.blank? }
Expand Down
Expand Up @@ -31,7 +31,7 @@ class Api::V2::Compliance::PoliciesControllerTest < ActionController::TestCase

test "should not update invalid" do
policy = FactoryGirl.create(:policy)
put :update, {:id => policy.id, :policy => {:name => 'say my name'}}
put :update, {:id => policy.id, :policy => {:name => ''}}
assert_response :unprocessable_entity
end

Expand Down
8 changes: 8 additions & 0 deletions test/unit/policy_test.rb
@@ -0,0 +1,8 @@
require 'test_helper'

class PolicyTest < ActiveSupport::TestCase
it 'can have spaces in name' do
policy = FactoryGirl.build(:policy, name: "My spaced policy")
assert policy.valid?
end
end

0 comments on commit e3af523

Please sign in to comment.