Commit b6736b62c393dd3a7c5ecd79fb84046b2de958f7

Authored by Nathan B
2 parents 4b7804e4 b82ca590
Exists in master and in 1 other branch production

Merge pull request #135 from shingara/upgrade_mongoid

Upgrade mongoid to 2.2.4
@@ -2,7 +2,7 @@ source 'http://rubygems.org' @@ -2,7 +2,7 @@ source 'http://rubygems.org'
2 2
3 gem 'rails', '3.0.10' 3 gem 'rails', '3.0.10'
4 gem 'nokogiri' 4 gem 'nokogiri'
5 -gem 'mongoid', '2.1.2' 5 +gem 'mongoid', '~> 2.2.2'
6 6
7 gem 'haml' 7 gem 'haml'
8 gem 'htmlentities', "~> 4.3.0" 8 gem 'htmlentities', "~> 4.3.0"
@@ -94,7 +94,7 @@ GEM @@ -94,7 +94,7 @@ GEM
94 mime-types (1.16) 94 mime-types (1.16)
95 mongo (1.3.1) 95 mongo (1.3.1)
96 bson (>= 1.3.1) 96 bson (>= 1.3.1)
97 - mongoid (2.1.2) 97 + mongoid (2.2.4)
98 activemodel (~> 3.0) 98 activemodel (~> 3.0)
99 mongo (~> 1.3) 99 mongo (~> 1.3)
100 tzinfo (~> 0.3.22) 100 tzinfo (~> 0.3.22)
@@ -224,7 +224,7 @@ DEPENDENCIES @@ -224,7 +224,7 @@ DEPENDENCIES
224 kaminari 224 kaminari
225 lighthouse-api 225 lighthouse-api
226 mongo (= 1.3.1) 226 mongo (= 1.3.1)
227 - mongoid (= 2.1.2) 227 + mongoid (~> 2.2.2)
228 mongoid_rails_migrations 228 mongoid_rails_migrations
229 nokogiri 229 nokogiri
230 octokit 230 octokit
app/models/problem.rb
@@ -2,6 +2,14 @@ @@ -2,6 +2,14 @@
2 # reported as various Errs, but the user has grouped the 2 # reported as various Errs, but the user has grouped the
3 # Errs together as belonging to the same problem. 3 # Errs together as belonging to the same problem.
4 4
  5 +## Add methode nan? in Time because needed by #max(:created_at)
  6 +#
  7 +# Fix on Mongoid > 2.3.x with commit :
  8 +# https://github.com/mongoid/mongoid/commit/5481556e24480f0a1783f85d6b5b343b0cef7192
  9 +class Time
  10 + def nan?; false ;end
  11 +end
  12 +
5 class Problem 13 class Problem
6 include Mongoid::Document 14 include Mongoid::Document
7 include Mongoid::Timestamps 15 include Mongoid::Timestamps
spec/models/problem_spec.rb
@@ -91,6 +91,11 @@ describe Problem do @@ -91,6 +91,11 @@ describe Problem do
91 problem = Fabricate(:problem) 91 problem = Fabricate(:problem)
92 problem.should_not be_resolved 92 problem.should_not be_resolved
93 problem.stub!(:valid?).and_return(false) 93 problem.stub!(:valid?).and_return(false)
  94 + ## update_attributes not test #valid? but #errors.any?
  95 + # https://github.com/mongoid/mongoid/blob/master/lib/mongoid/persistence.rb#L137
  96 + er = ActiveModel::Errors.new(problem)
  97 + er.add_on_blank(:resolved)
  98 + problem.stub!(:errors).and_return(er)
94 problem.should_not be_valid 99 problem.should_not be_valid
95 lambda { 100 lambda {
96 problem.resolve! 101 problem.resolve!