Commit 039744a1bb25e6b9ed1bd287554f039ebdc2df60
1 parent
3ec3956f
Exists in
master
and in
1 other branch
Upgrade to Mongoid 3.1.4 version
Showing
22 changed files
with
112 additions
and
127 deletions
Show diff stats
Gemfile
1 | 1 | source 'http://rubygems.org' |
2 | 2 | |
3 | 3 | gem 'rails', '3.2.13' |
4 | -gem 'mongoid', '~> 2.7.1' | |
4 | +gem 'mongoid', '~> 3.1.4' | |
5 | 5 | |
6 | 6 | # Mongoid rails migration > 0.0.14 is not compatible to Mongoid 2.x |
7 | 7 | gem 'mongoid_rails_migrations', '~> 0.0.14' |
... | ... | @@ -75,13 +75,6 @@ gem 'flowdock' |
75 | 75 | # GitHub OAuth |
76 | 76 | gem 'omniauth-github' |
77 | 77 | |
78 | - | |
79 | -platform :ruby do | |
80 | - gem 'mongo' | |
81 | - gem 'bson' | |
82 | - gem 'bson_ext' | |
83 | -end | |
84 | - | |
85 | 78 | gem 'ri_cal' |
86 | 79 | gem 'yajl-ruby', :require => "yajl" |
87 | 80 | ... | ... |
Gemfile.lock
1 | 1 | GIT |
2 | 2 | remote: https://github.com/NARKOZ/gitlab.git |
3 | - revision: 53d7a8a86dfed63e56eeb16ea496bb7a82de337e | |
3 | + revision: 7a00d38c53335010d2fb8a233247fe2c97338903 | |
4 | 4 | specs: |
5 | 5 | gitlab (2.2.0) |
6 | 6 | httparty |
... | ... | @@ -41,8 +41,7 @@ GEM |
41 | 41 | i18n (= 0.6.1) |
42 | 42 | multi_json (~> 1.0) |
43 | 43 | addressable (2.3.5) |
44 | - airbrake (3.1.12) | |
45 | - activesupport | |
44 | + airbrake (3.1.13) | |
46 | 45 | builder |
47 | 46 | json |
48 | 47 | arel (3.0.2) |
... | ... | @@ -59,9 +58,6 @@ GEM |
59 | 58 | multi_json (~> 1.3) |
60 | 59 | nokogiri (~> 1.5.2) |
61 | 60 | simple_oauth |
62 | - bson (1.8.6) | |
63 | - bson_ext (1.8.6) | |
64 | - bson (~> 1.8.6) | |
65 | 61 | builder (3.0.4) |
66 | 62 | callsite (0.0.11) |
67 | 63 | campy (0.1.3) |
... | ... | @@ -104,7 +100,7 @@ GEM |
104 | 100 | debugger-linecache (1.2.0) |
105 | 101 | debugger-ruby_core_source (1.2.3) |
106 | 102 | decent_exposure (2.2.1) |
107 | - devise (2.2.6) | |
103 | + devise (2.2.7) | |
108 | 104 | bcrypt-ruby (~> 3.0) |
109 | 105 | orm_adapter (~> 0.1) |
110 | 106 | railties (~> 3.1) |
... | ... | @@ -137,7 +133,7 @@ GEM |
137 | 133 | hashie (1.2.0) |
138 | 134 | highline (1.6.19) |
139 | 135 | hike (1.2.3) |
140 | - hipchat (0.10.0) | |
136 | + hipchat (0.11.0) | |
141 | 137 | httparty |
142 | 138 | hoi (0.0.6) |
143 | 139 | httparty (> 0.6.0) |
... | ... | @@ -168,8 +164,8 @@ GEM |
168 | 164 | kgio (2.8.0) |
169 | 165 | launchy (2.3.0) |
170 | 166 | addressable (~> 2.3) |
171 | - libv8 (3.11.8.17) | |
172 | - libxml-ruby (2.6.0) | |
167 | + libv8 (3.16.14.3) | |
168 | + libxml-ruby (2.7.0) | |
173 | 169 | lighthouse-api (2.0) |
174 | 170 | activeresource (>= 3.0.0) |
175 | 171 | activesupport (>= 3.0.0) |
... | ... | @@ -178,24 +174,24 @@ GEM |
178 | 174 | mail (2.5.4) |
179 | 175 | mime-types (~> 1.16) |
180 | 176 | treetop (~> 1.4.8) |
181 | - meta_request (0.2.7) | |
177 | + meta_request (0.2.8) | |
182 | 178 | callsite |
183 | 179 | rack-contrib |
184 | 180 | railties |
185 | 181 | method_source (0.8.2) |
186 | - mime-types (1.23) | |
187 | - mongo (1.8.6) | |
188 | - bson (~> 1.8.6) | |
189 | - mongoid (2.7.1) | |
190 | - activemodel (~> 3.1) | |
191 | - mongo (~> 1.8) | |
182 | + mime-types (1.24) | |
183 | + mongoid (3.1.4) | |
184 | + activemodel (~> 3.2) | |
185 | + moped (~> 1.4) | |
186 | + origin (~> 1.0) | |
192 | 187 | tzinfo (~> 0.3.22) |
193 | 188 | mongoid_rails_migrations (0.0.14) |
194 | 189 | activesupport (>= 3.0.0) |
195 | 190 | bundler (>= 1.0.0) |
196 | 191 | rails (>= 3.0.0) |
197 | 192 | railties (>= 3.0.0) |
198 | - multi_json (1.7.8) | |
193 | + moped (1.5.1) | |
194 | + multi_json (1.7.9) | |
199 | 195 | multi_xml (0.5.5) |
200 | 196 | multipart-post (1.2.0) |
201 | 197 | net-scp (1.1.2) |
... | ... | @@ -230,19 +226,18 @@ GEM |
230 | 226 | omniauth-oauth2 (1.1.1) |
231 | 227 | oauth2 (~> 0.8.0) |
232 | 228 | omniauth (~> 1.0) |
229 | + origin (1.1.0) | |
233 | 230 | orm_adapter (0.4.0) |
234 | 231 | oruen_redmine_client (0.0.1) |
235 | 232 | activeresource (>= 2.3.0) |
236 | 233 | pivotal-tracker (0.5.10) |
237 | 234 | builder |
238 | - builder | |
239 | 235 | crack |
240 | 236 | happymapper (>= 0.3.2) |
241 | 237 | nokogiri (>= 1.4.3) |
242 | 238 | nokogiri (>= 1.5.5) |
243 | 239 | nokogiri-happymapper (>= 0.5.4) |
244 | 240 | rest-client (~> 1.6.0) |
245 | - rest-client (~> 1.6.0) | |
246 | 241 | pjax_rails (0.3.4) |
247 | 242 | jquery-rails |
248 | 243 | polyglot (0.3.3) |
... | ... | @@ -293,8 +288,8 @@ GEM |
293 | 288 | rest-client (1.6.7) |
294 | 289 | mime-types (>= 1.16) |
295 | 290 | ri_cal (0.8.8) |
296 | - rspec-core (2.14.4) | |
297 | - rspec-expectations (2.14.1) | |
291 | + rspec-core (2.14.5) | |
292 | + rspec-expectations (2.14.2) | |
298 | 293 | diff-lcs (>= 1.1.3, < 2.0) |
299 | 294 | rspec-mocks (2.14.3) |
300 | 295 | rspec-rails (2.14.0) |
... | ... | @@ -316,7 +311,7 @@ GEM |
316 | 311 | json |
317 | 312 | rest-client |
318 | 313 | safe_yaml (0.9.5) |
319 | - selenium-webdriver (2.34.0) | |
314 | + selenium-webdriver (2.35.0) | |
320 | 315 | childprocess (>= 0.2.5) |
321 | 316 | multi_json (~> 1.0) |
322 | 317 | rubyzip |
... | ... | @@ -343,8 +338,8 @@ GEM |
343 | 338 | taskmapper-unfuddle (0.7.0) |
344 | 339 | addressable (~> 2.2) |
345 | 340 | taskmapper (~> 0.8) |
346 | - therubyracer (0.11.4) | |
347 | - libv8 (~> 3.11.8.12) | |
341 | + therubyracer (0.12.0) | |
342 | + libv8 (~> 3.16.14.0) | |
348 | 343 | ref |
349 | 344 | thin (1.5.1) |
350 | 345 | daemons (>= 1.0.9) |
... | ... | @@ -353,10 +348,10 @@ GEM |
353 | 348 | thor (0.18.1) |
354 | 349 | tilt (1.4.1) |
355 | 350 | timecop (0.6.1) |
356 | - treetop (1.4.14) | |
351 | + treetop (1.4.15) | |
357 | 352 | polyglot |
358 | 353 | polyglot (>= 0.3.1) |
359 | - turbo-sprockets-rails3 (0.3.6) | |
354 | + turbo-sprockets-rails3 (0.3.9) | |
360 | 355 | railties (> 3.2.8, < 4.0.0) |
361 | 356 | sprockets (>= 2.0.0) |
362 | 357 | tzinfo (0.3.37) |
... | ... | @@ -390,8 +385,6 @@ DEPENDENCIES |
390 | 385 | better_errors |
391 | 386 | binding_of_caller |
392 | 387 | bitbucket_rest_api |
393 | - bson | |
394 | - bson_ext | |
395 | 388 | campy (= 0.1.3) |
396 | 389 | capistrano |
397 | 390 | capybara (~> 2.0.1) |
... | ... | @@ -418,8 +411,7 @@ DEPENDENCIES |
418 | 411 | launchy |
419 | 412 | lighthouse-api |
420 | 413 | meta_request |
421 | - mongo | |
422 | - mongoid (~> 2.7.1) | |
414 | + mongoid (~> 3.1.4) | |
423 | 415 | mongoid_rails_migrations (~> 0.0.14) |
424 | 416 | octokit |
425 | 417 | omniauth-github | ... | ... |
app/controllers/api/v1/notices_controller.rb
... | ... | @@ -11,7 +11,9 @@ class Api::V1::NoticesController < ApplicationController |
11 | 11 | query = {:created_at => {"$lte" => end_date, "$gte" => start_date}} |
12 | 12 | end |
13 | 13 | |
14 | - results = benchmark("[api/v1/notices_controller] query time") { Mongoid.master["notices"].find(query, :fields => fields).to_a } | |
14 | + results = benchmark("[api/v1/notices_controller] query time") do | |
15 | + Notice.where(query).with(:consistency => :strong).only(fields).to_a | |
16 | + end | |
15 | 17 | |
16 | 18 | respond_to do |format| |
17 | 19 | format.html { render :json => Yajl.dump(results) } # render JSON if no extension specified on path | ... | ... |
app/controllers/api/v1/problems_controller.rb
1 | 1 | class Api::V1::ProblemsController < ApplicationController |
2 | 2 | respond_to :json, :xml |
3 | - | |
3 | + | |
4 | 4 | def index |
5 | 5 | query = {} |
6 | 6 | fields = %w{app_id app_name environment message where first_notice_at last_notice_at resolved resolved_at notices_count} |
7 | - | |
7 | + | |
8 | 8 | if params.key?(:start_date) && params.key?(:end_date) |
9 | 9 | start_date = Time.parse(params[:start_date]).utc |
10 | 10 | end_date = Time.parse(params[:end_date]).utc |
11 | 11 | query = {:first_notice_at=>{"$lte"=>end_date}, "$or"=>[{:resolved_at=>nil}, {:resolved_at=>{"$gte"=>start_date}}]} |
12 | 12 | end |
13 | - | |
14 | - results = benchmark("[api/v1/problems_controller] query time") { Mongoid.master["problems"].find(query, :fields => fields).to_a } | |
15 | - | |
13 | + | |
14 | + results = benchmark("[api/v1/problems_controller] query time") do | |
15 | + Problem.where(query).with(:consistency => :strong).only(fields).to_a | |
16 | + end | |
17 | + | |
16 | 18 | respond_to do |format| |
17 | 19 | format.html { render :json => Yajl.dump(results) } # render JSON if no extension specified on path |
18 | 20 | format.json { render :json => Yajl.dump(results) } |
19 | 21 | format.xml { render :xml => results } |
20 | 22 | end |
21 | 23 | end |
22 | - | |
24 | + | |
23 | 25 | end | ... | ... |
app/interactors/problem_destroy.rb
... | ... | @@ -37,12 +37,12 @@ class ProblemDestroy |
37 | 37 | end |
38 | 38 | |
39 | 39 | def delete_errs |
40 | - Notice.collection.remove(:err_id => { '$in' => errs_id }) | |
41 | - Err.collection.remove(:_id => { '$in' => errs_id }) | |
40 | + Notice.delete_all(:err_id => { '$in' => errs_id }) | |
41 | + Err.delete_all(:_id => { '$in' => errs_id }) | |
42 | 42 | end |
43 | 43 | |
44 | 44 | def delete_comments |
45 | - Comment.collection.remove(:_id => { '$in' => comments_id }) | |
45 | + Comment.delete_all(:_id => { '$in' => comments_id }) | |
46 | 46 | end |
47 | 47 | |
48 | 48 | end | ... | ... |
app/interactors/resolved_problem_clearer.rb
app/models/app.rb
... | ... | @@ -15,9 +15,6 @@ class App |
15 | 15 | field :notify_on_deploys, :type => Boolean, :default => false |
16 | 16 | field :email_at_notices, :type => Array, :default => Errbit::Config.email_at_notices |
17 | 17 | |
18 | - # Some legacy apps may have string as key instead of BSON::ObjectID | |
19 | - identity :type => String | |
20 | - | |
21 | 18 | embeds_many :watchers |
22 | 19 | embeds_many :deploys |
23 | 20 | embeds_one :issue_tracker |
... | ... | @@ -61,7 +58,7 @@ class App |
61 | 58 | end |
62 | 59 | |
63 | 60 | def self.find_by_api_key!(key) |
64 | - where(:api_key => key).first || raise(Mongoid::Errors::DocumentNotFound.new(self,key)) | |
61 | + find_by(:api_key => key) | |
65 | 62 | end |
66 | 63 | |
67 | 64 | def last_deploy_at | ... | ... |
app/models/backtrace.rb
... | ... | @@ -3,7 +3,7 @@ class Backtrace |
3 | 3 | include Mongoid::Timestamps |
4 | 4 | |
5 | 5 | field :fingerprint |
6 | - index :fingerprint | |
6 | + index :fingerprint => 1 | |
7 | 7 | |
8 | 8 | has_many :notices |
9 | 9 | has_one :notice |
... | ... | @@ -19,7 +19,7 @@ class Backtrace |
19 | 19 | end |
20 | 20 | |
21 | 21 | def similar |
22 | - Backtrace.first(:conditions => { :fingerprint => fingerprint } ) | |
22 | + Backtrace.find_by(:fingerprint => fingerprint) rescue nil | |
23 | 23 | end |
24 | 24 | |
25 | 25 | def raw=(raw) | ... | ... |
app/models/comment.rb
app/models/deploy.rb
app/models/err.rb
app/models/notice.rb
... | ... | @@ -16,14 +16,9 @@ class Notice |
16 | 16 | |
17 | 17 | belongs_to :err |
18 | 18 | belongs_to :backtrace, :index => true |
19 | - index :created_at | |
20 | - index( | |
21 | - [ | |
22 | - [ :err_id, Mongo::ASCENDING ], | |
23 | - [ :created_at, Mongo::ASCENDING ], | |
24 | - [ :_id, Mongo::ASCENDING ] | |
25 | - ] | |
26 | - ) | |
19 | + | |
20 | + index(:created_at => 1) | |
21 | + index(:err_id => 1, :created_at => 1, :_id => 1) | |
27 | 22 | |
28 | 23 | after_create :cache_attributes_on_problem, :unresolve_problem |
29 | 24 | before_save :sanitize | ... | ... |
app/models/problem.rb
... | ... | @@ -26,14 +26,14 @@ class Problem |
26 | 26 | field :hosts, :type => Hash, :default => {} |
27 | 27 | field :comments_count, :type => Integer, :default => 0 |
28 | 28 | |
29 | - index :app_id | |
30 | - index :app_name | |
31 | - index :message | |
32 | - index :last_notice_at | |
33 | - index :first_notice_at | |
34 | - index :last_deploy_at | |
35 | - index :resolved_at | |
36 | - index :notices_count | |
29 | + index :app_id => 1 | |
30 | + index :app_name => 1 | |
31 | + index :message => 1 | |
32 | + index :last_notice_at => 1 | |
33 | + index :first_notice_at => 1 | |
34 | + index :last_deploy_at => 1 | |
35 | + index :resolved_at => 1 | |
36 | + index :notices_count => 1 | |
37 | 37 | |
38 | 38 | belongs_to :app |
39 | 39 | has_many :errs, :inverse_of => :problem, :dependent => :destroy |
... | ... | @@ -51,9 +51,9 @@ class Problem |
51 | 51 | validates_presence_of :last_notice_at, :first_notice_at |
52 | 52 | |
53 | 53 | |
54 | - def self.all_else_unresolved all | |
55 | - if all | |
56 | - find(:all) | |
54 | + def self.all_else_unresolved(fetch_all) | |
55 | + if fetch_all | |
56 | + all | |
57 | 57 | else |
58 | 58 | where(:resolved => false) |
59 | 59 | end |
... | ... | @@ -132,8 +132,8 @@ class Problem |
132 | 132 | self.last_deploy_at = if (last_deploy = app.deploys.where(:environment => self.environment).last) |
133 | 133 | last_deploy.created_at.utc |
134 | 134 | end |
135 | - collection.update({'_id' => self.id}, | |
136 | - {'$set' => {'app_name' => self.app_name, | |
135 | + collection.find('_id' => self.id) | |
136 | + .update({'$set' => {'app_name' => self.app_name, | |
137 | 137 | 'last_deploy_at' => self.last_deploy_at.try(:utc)}}) |
138 | 138 | end |
139 | 139 | end |
... | ... | @@ -153,7 +153,7 @@ class Problem |
153 | 153 | end |
154 | 154 | |
155 | 155 | def self.search(value) |
156 | - where.or(:error_class => /#{value}/i).or(:where => /#{value}/i).or(:message => /#{value}/i).or(:app_name => /#{value}/i).or(:environment => /#{value}/i) | |
156 | + any_of({:error_class => /#{value}/i}, {:message => /#{value}/i}, {:app_name => /#{value}/i}, {:environment => /#{value}/i}) | |
157 | 157 | end |
158 | 158 | |
159 | 159 | private | ... | ... |
config/mongoid.example.yml
... | ... | @@ -7,29 +7,34 @@ |
7 | 7 | # `cap deploy:setup` is ran the first time. Be sure |
8 | 8 | # to place production specific settings there |
9 | 9 | |
10 | -defaults: &defaults | |
11 | - host: localhost | |
12 | - identity_map_enabled: true | |
13 | - | |
14 | - # slaves: | |
15 | - # - host: slave1.local | |
16 | - # port: 27018 | |
17 | - # - host: slave2.local | |
18 | - # port: 27019 | |
19 | - | |
20 | 10 | development: |
21 | - <<: *defaults | |
22 | - database: errbit_development | |
11 | + sessions: | |
12 | + default: | |
13 | + database: errbit_development | |
14 | + hosts: | |
15 | + - localhost:27017 | |
16 | + options: | |
17 | + identity_map_enabled: true | |
18 | + use_utc: true | |
23 | 19 | |
24 | 20 | test: |
25 | - <<: *defaults | |
26 | - database: errbit_test | |
21 | + sessions: | |
22 | + default: | |
23 | + hosts: | |
24 | + - localhost:27017 | |
25 | + database: errbit_test | |
26 | + options: | |
27 | + identity_map_enabled: true | |
28 | + use_utc: true | |
27 | 29 | |
28 | 30 | # set these environment variables on your prod server |
29 | 31 | production: |
30 | - <<: *defaults | |
31 | - host: <%= ENV['MONGOID_HOST'] %> | |
32 | - port: <%= ENV['MONGOID_PORT'] %> | |
33 | - username: <%= ENV['MONGOID_USERNAME'] %> | |
34 | - password: <%= ENV['MONGOID_PASSWORD'] %> | |
35 | - database: <%= ENV['MONGOID_DATABASE'] %> | |
32 | + sessions: | |
33 | + default: | |
34 | + database: <%= ENV['MONGOID_DATABASE'] %> | |
35 | + hosts: | |
36 | + - <%=ENV["MONGOID_HOST"]%><%=ENV["MONGOID_PORT"]%> | |
37 | + username: <%= ENV['MONGOID_USERNAME'] %> | |
38 | + password: <%= ENV['MONGOID_PASSWORD'] %> | |
39 | + options: | |
40 | + identity_map_enabled: true | ... | ... |
db/seeds.rb
... | ... | @@ -12,12 +12,11 @@ puts "-- email: #{admin_email}" |
12 | 12 | puts "-- password: #{admin_pass}" |
13 | 13 | puts "" |
14 | 14 | puts "Be sure to change these credentials ASAP!" |
15 | -user = User.where(:email => admin_email).first || User.new({ | |
16 | - :name => 'Errbit Admin', | |
17 | - :email => admin_email, | |
18 | - :password => admin_pass, | |
19 | - :password_confirmation => admin_pass | |
20 | -}) | |
15 | +user = User.find_or_initialize_by(:email => admin_email) do |u| | |
16 | + u.name = 'Errbit Admin' | |
17 | + u.password = admin_pass | |
18 | + u.password_confirmation = admin_pass | |
19 | +end | |
21 | 20 | user.username = admin_username if Errbit::Config.user_has_username |
22 | 21 | |
23 | 22 | user.admin = true | ... | ... |
spec/controllers/api/v1/notices_controller_spec.rb
... | ... | @@ -9,10 +9,10 @@ describe Api::V1::NoticesController do |
9 | 9 | |
10 | 10 | describe "GET /api/v1/notices" do |
11 | 11 | before do |
12 | - Fabricate(:notice, :created_at => DateTime.new(2012, 8, 01)) | |
13 | - Fabricate(:notice, :created_at => DateTime.new(2012, 8, 01)) | |
14 | - Fabricate(:notice, :created_at => DateTime.new(2012, 8, 21)) | |
15 | - Fabricate(:notice, :created_at => DateTime.new(2012, 8, 30)) | |
12 | + Fabricate(:notice, :created_at => Time.new(2012, 8, 01)) | |
13 | + Fabricate(:notice, :created_at => Time.new(2012, 8, 01)) | |
14 | + Fabricate(:notice, :created_at => Time.new(2012, 8, 21)) | |
15 | + Fabricate(:notice, :created_at => Time.new(2012, 8, 30)) | |
16 | 16 | end |
17 | 17 | |
18 | 18 | it "should return JSON if JSON is requested" do | ... | ... |
spec/controllers/apps_controller_spec.rb
spec/controllers/problems_controller_spec.rb
... | ... | @@ -195,13 +195,13 @@ describe ProblemsController do |
195 | 195 | sign_in Fabricate(:admin) |
196 | 196 | |
197 | 197 | @problem = Fabricate(:err) |
198 | - App.stub(:find).with(@problem.app.id).and_return(@problem.app) | |
198 | + App.stub(:find).with(@problem.app.id.to_s).and_return(@problem.app) | |
199 | 199 | @problem.app.problems.stub(:find).and_return(@problem.problem) |
200 | 200 | @problem.problem.stub(:resolve!) |
201 | 201 | end |
202 | 202 | |
203 | 203 | it 'finds the app and the problem' do |
204 | - App.should_receive(:find).with(@problem.app.id).and_return(@problem.app) | |
204 | + App.should_receive(:find).with(@problem.app.id.to_s).and_return(@problem.app) | |
205 | 205 | @problem.app.problems.should_receive(:find).and_return(@problem.problem) |
206 | 206 | put :resolve, :app_id => @problem.app.id, :id => @problem.problem.id |
207 | 207 | controller.app.should == @problem.app | ... | ... |
spec/interactors/problem_destroy_spec.rb
... | ... | @@ -32,17 +32,17 @@ describe ProblemDestroy do |
32 | 32 | end |
33 | 33 | |
34 | 34 | it 'delete all errs associate' do |
35 | - Err.collection.should_receive(:remove).with(:_id => { '$in' => [err_1.id, err_2.id] }) | |
35 | + Err.should_receive(:delete_all).with(:_id => { '$in' => [err_1.id, err_2.id] }) | |
36 | 36 | problem_destroy.execute |
37 | 37 | end |
38 | 38 | |
39 | 39 | it 'delete all comments associate' do |
40 | - Comment.collection.should_receive(:remove).with(:_id => { '$in' => [comment_1.id, comment_2.id] }) | |
40 | + Comment.should_receive(:delete_all).with(:_id => { '$in' => [comment_1.id, comment_2.id] }) | |
41 | 41 | problem_destroy.execute |
42 | 42 | end |
43 | 43 | |
44 | 44 | it 'delete all notice of associate to this errs' do |
45 | - Notice.collection.should_receive(:remove).with({:err_id => { '$in' => [err_1.id, err_2.id] }}) | |
45 | + Notice.should_receive(:delete_all).with({:err_id => { '$in' => [err_1.id, err_2.id] }}) | |
46 | 46 | problem_destroy.execute |
47 | 47 | end |
48 | 48 | end | ... | ... |
spec/interactors/problem_merge_spec.rb
... | ... | @@ -38,7 +38,7 @@ describe ProblemMerge do |
38 | 38 | |
39 | 39 | it 'move all err in one problem' do |
40 | 40 | problem_merge.merge |
41 | - problem.reload.errs.should eq (first_errs | merged_errs) | |
41 | + expect(problem.reload.errs.map(&:id).sort).to eq (first_errs | merged_errs).map(&:id).sort | |
42 | 42 | end |
43 | 43 | |
44 | 44 | it 'update problem cache' do | ... | ... |
spec/interactors/problem_updater_cache_spec.rb
... | ... | @@ -31,11 +31,11 @@ describe ProblemUpdaterCache do |
31 | 31 | end |
32 | 32 | |
33 | 33 | it 'update first_notice_at' do |
34 | - expect(problem.first_notice_at).to eq notice.created_at | |
34 | + expect(problem.first_notice_at).to eq notice.reload.created_at | |
35 | 35 | end |
36 | 36 | |
37 | 37 | it 'update last_notice_at' do |
38 | - expect(problem.last_notice_at).to eq notice.created_at | |
38 | + expect(problem.last_notice_at).to eq notice.reload.created_at | |
39 | 39 | end |
40 | 40 | |
41 | 41 | it 'update stats messages' do | ... | ... |
spec/interactors/resolved_problem_clearer_spec.rb
... | ... | @@ -21,16 +21,16 @@ describe ResolvedProblemClearer do |
21 | 21 | } |
22 | 22 | end |
23 | 23 | it 'not repair database' do |
24 | - Mongoid.config.master.should_receive(:command).and_call_original | |
25 | - Mongoid.config.master.should_not_receive(:command).with({:repairDatabase => 1}) | |
24 | + Mongoid.default_session.stub(:command).and_call_original | |
25 | + Mongoid.default_session.should_not_receive(:command).with({:repairDatabase => 1}) | |
26 | 26 | resolved_problem_clearer.execute |
27 | 27 | end |
28 | 28 | end |
29 | 29 | |
30 | 30 | context "with problem resolve" do |
31 | 31 | before do |
32 | - Mongoid.config.master.stub(:command).and_call_original | |
33 | - Mongoid.config.master.stub(:command).with({:repairDatabase => 1}) | |
32 | + Mongoid.default_session.stub(:command).and_call_original | |
33 | + Mongoid.default_session.stub(:command).with({:repairDatabase => 1}) | |
34 | 34 | problems.first.resolve! |
35 | 35 | problems.second.resolve! |
36 | 36 | end |
... | ... | @@ -46,8 +46,8 @@ describe ResolvedProblemClearer do |
46 | 46 | end |
47 | 47 | |
48 | 48 | it 'repair database' do |
49 | - Mongoid.config.master.should_receive(:command).and_call_original | |
50 | - Mongoid.config.master.should_receive(:command).with({:repairDatabase => 1}) | |
49 | + Mongoid.default_session.stub(:command).and_call_original | |
50 | + Mongoid.default_session.should_receive(:command).with({:repairDatabase => 1}) | |
51 | 51 | resolved_problem_clearer.execute |
52 | 52 | end |
53 | 53 | end | ... | ... |
-
mentioned in commit 5364d94301beea4919d977dc566a475a9811ca54
-
mentioned in commit a07c943bfe29184e4c0456168a3dfbf1c6db400b