The previous error was just:

    Host has already been taken

The problem is that host by itself isn't unique, but the error message
would lead you to believe it is.  Instead, mention that the host, kind,
time combo needs to be unique.

Paired-with: Jacob Helwig <ja...@puppetlabs.com>
Signed-off-by: Matt Robinson <m...@puppetlabs.com>
---
Local-branch: ticket/1.2rc/8686
 app/models/report.rb       |    5 ++++-
 spec/models/report_spec.rb |    2 +-
 2 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/app/models/report.rb b/app/models/report.rb
index 95a5809..f97fb4e 100644
--- a/app/models/report.rb
+++ b/app/models/report.rb
@@ -11,7 +11,10 @@ class Report < ActiveRecord::Base
 
   before_validation :assign_to_node
   validates_presence_of :host, :time, :kind
-  validates_uniqueness_of :host, :scope => [:time, :kind], :allow_nil => true
+  validates_uniqueness_of :host,
+    :scope     => [:time, :kind],
+    :allow_nil => true,
+    :message   => "already has a report for time and kind"
   after_save :update_node
   after_destroy :replace_last_report
 
diff --git a/spec/models/report_spec.rb b/spec/models/report_spec.rb
index 06dda9c..1df4616 100644
--- a/spec/models/report_spec.rb
+++ b/spec/models/report_spec.rb
@@ -39,7 +39,7 @@ describe Report do
       Report.create_from_yaml(@report_yaml)
       lambda {
         Report.create_from_yaml(@report_yaml)
-      }.should raise_error(ActiveRecord::RecordInvalid)
+      }.should raise_error(ActiveRecord::RecordInvalid, 'Validation failed: 
Host already has a report for time and kind')
       Report.count.should == 1
     end
 
-- 
1.7.3.1

-- 
You received this message because you are subscribed to the Google Groups 
"Puppet Developers" group.
To post to this group, send email to puppet-dev@googlegroups.com.
To unsubscribe from this group, send email to 
puppet-dev+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/puppet-dev?hl=en.

Reply via email to