Commit b6736b62c393dd3a7c5ecd79fb84046b2de958f7
Exists in
master
and in
1 other branch
Merge pull request #135 from shingara/upgrade_mongoid
Upgrade mongoid to 2.2.4
Showing
4 changed files
with
16 additions
and
3 deletions
Show diff stats
Gemfile
Gemfile.lock
... | ... | @@ -94,7 +94,7 @@ GEM |
94 | 94 | mime-types (1.16) |
95 | 95 | mongo (1.3.1) |
96 | 96 | bson (>= 1.3.1) |
97 | - mongoid (2.1.2) | |
97 | + mongoid (2.2.4) | |
98 | 98 | activemodel (~> 3.0) |
99 | 99 | mongo (~> 1.3) |
100 | 100 | tzinfo (~> 0.3.22) |
... | ... | @@ -224,7 +224,7 @@ DEPENDENCIES |
224 | 224 | kaminari |
225 | 225 | lighthouse-api |
226 | 226 | mongo (= 1.3.1) |
227 | - mongoid (= 2.1.2) | |
227 | + mongoid (~> 2.2.2) | |
228 | 228 | mongoid_rails_migrations |
229 | 229 | nokogiri |
230 | 230 | octokit | ... | ... |
app/models/problem.rb
... | ... | @@ -2,6 +2,14 @@ |
2 | 2 | # reported as various Errs, but the user has grouped the |
3 | 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 | 13 | class Problem |
6 | 14 | include Mongoid::Document |
7 | 15 | include Mongoid::Timestamps | ... | ... |
spec/models/problem_spec.rb
... | ... | @@ -91,6 +91,11 @@ describe Problem do |
91 | 91 | problem = Fabricate(:problem) |
92 | 92 | problem.should_not be_resolved |
93 | 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 | 99 | problem.should_not be_valid |
95 | 100 | lambda { |
96 | 101 | problem.resolve! | ... | ... |