diff --git a/app/models/problem.rb b/app/models/problem.rb index 62f32fa..bdc8f3c 100644 --- a/app/models/problem.rb +++ b/app/models/problem.rb @@ -2,6 +2,14 @@ # reported as various Errs, but the user has grouped the # Errs together as belonging to the same problem. +## Add methode nan? in Time because needed by #max(:created_at) +# +# Fix on Mongoid > 2.3.x with commit : +# https://github.com/mongoid/mongoid/commit/5481556e24480f0a1783f85d6b5b343b0cef7192 +class Time + def nan?; false ;end +end + class Problem include Mongoid::Document include Mongoid::Timestamps diff --git a/spec/models/problem_spec.rb b/spec/models/problem_spec.rb index c39db3f..f78ccb8 100644 --- a/spec/models/problem_spec.rb +++ b/spec/models/problem_spec.rb @@ -91,6 +91,11 @@ describe Problem do problem = Fabricate(:problem) problem.should_not be_resolved problem.stub!(:valid?).and_return(false) + ## update_attributes not test #valid? but #errors.any? + # https://github.com/mongoid/mongoid/blob/master/lib/mongoid/persistence.rb#L137 + er = ActiveModel::Errors.new(problem) + er.add_on_blank(:resolved) + problem.stub!(:errors).and_return(er) problem.should_not be_valid lambda { problem.resolve! -- libgit2 0.21.2