Commit 77318a62659588fbfff83a2bec00bc7f96cca936

Authored by Arthur Nogueira Neves
2 parents 093fbed2 95c396d2
Exists in master and in 1 other branch production

Merge pull request #768 from errbit/rails4

Rails 4
1 source 'https://rubygems.org' 1 source 'https://rubygems.org'
2 2
3 -RAILS_VERSION = '~> 3.2.21' 3 +RAILS_VERSION = '~> 4.0.12'
4 4
5 gem 'actionmailer', RAILS_VERSION 5 gem 'actionmailer', RAILS_VERSION
6 gem 'actionpack', RAILS_VERSION 6 gem 'actionpack', RAILS_VERSION
7 gem 'railties', RAILS_VERSION 7 gem 'railties', RAILS_VERSION
8 8
9 -gem 'mongoid' 9 +gem 'moped', '~> 2.0.2'
  10 +gem 'mongoid', '~> 4.0.0'
10 11
11 gem 'mongoid_rails_migrations' 12 gem 'mongoid_rails_migrations'
12 gem 'devise' 13 gem 'devise'
@@ -16,7 +17,6 @@ gem 'rack-ssl', :require => 'rack/ssl' # force SSL @@ -16,7 +17,6 @@ gem 'rack-ssl', :require => 'rack/ssl' # force SSL
16 17
17 gem 'useragent' 18 gem 'useragent'
18 gem 'decent_exposure' 19 gem 'decent_exposure'
19 -gem 'strong_parameters'  
20 gem 'actionmailer_inline_css' 20 gem 'actionmailer_inline_css'
21 gem 'kaminari', '>= 0.14.1' 21 gem 'kaminari', '>= 0.14.1'
22 gem 'rack-ssl-enforcer', :require => false 22 gem 'rack-ssl-enforcer', :require => false
@@ -113,5 +113,4 @@ group :assets do @@ -113,5 +113,4 @@ group :assets do
113 gem 'jquery-rails', '~> 2.1.4' 113 gem 'jquery-rails', '~> 2.1.4'
114 gem 'pjax_rails' 114 gem 'pjax_rails'
115 gem 'underscore-rails' 115 gem 'underscore-rails'
116 - gem 'turbo-sprockets-rails3'  
117 end 116 end
1 GEM 1 GEM
2 remote: https://rubygems.org/ 2 remote: https://rubygems.org/
3 specs: 3 specs:
4 - actionmailer (3.2.21)  
5 - actionpack (= 3.2.21)  
6 - mail (~> 2.5.4) 4 + actionmailer (4.0.12)
  5 + actionpack (= 4.0.12)
  6 + mail (~> 2.5, >= 2.5.4)
7 actionmailer_inline_css (1.5.3) 7 actionmailer_inline_css (1.5.3)
8 actionmailer (>= 3.0.0) 8 actionmailer (>= 3.0.0)
9 nokogiri (>= 1.4.4) 9 nokogiri (>= 1.4.4)
10 premailer (>= 1.7.1) 10 premailer (>= 1.7.1)
11 - actionpack (3.2.21)  
12 - activemodel (= 3.2.21)  
13 - activesupport (= 3.2.21)  
14 - builder (~> 3.0.0) 11 + actionpack (4.0.12)
  12 + activesupport (= 4.0.12)
  13 + builder (~> 3.1.0)
15 erubis (~> 2.7.0) 14 erubis (~> 2.7.0)
16 - journey (~> 1.0.4)  
17 - rack (~> 1.4.5)  
18 - rack-cache (~> 1.2)  
19 - rack-test (~> 0.6.1)  
20 - sprockets (~> 2.2.1)  
21 - activemodel (3.2.21)  
22 - activesupport (= 3.2.21)  
23 - builder (~> 3.0.0)  
24 - activerecord (3.2.21)  
25 - activemodel (= 3.2.21)  
26 - activesupport (= 3.2.21)  
27 - arel (~> 3.0.2)  
28 - tzinfo (~> 0.3.29)  
29 - activeresource (3.2.21)  
30 - activemodel (= 3.2.21)  
31 - activesupport (= 3.2.21)  
32 - activesupport (3.2.21)  
33 - i18n (~> 0.6, >= 0.6.4)  
34 - multi_json (~> 1.0)  
35 - addressable (2.3.6) 15 + rack (~> 1.5.2)
  16 + rack-test (~> 0.6.2)
  17 + activemodel (4.0.12)
  18 + activesupport (= 4.0.12)
  19 + builder (~> 3.1.0)
  20 + activerecord (4.0.12)
  21 + activemodel (= 4.0.12)
  22 + activerecord-deprecated_finders (~> 1.0.2)
  23 + activesupport (= 4.0.12)
  24 + arel (~> 4.0.0)
  25 + activerecord-deprecated_finders (1.0.3)
  26 + activeresource (4.0.0)
  27 + activemodel (~> 4.0)
  28 + activesupport (~> 4.0)
  29 + rails-observers (~> 0.1.1)
  30 + activesupport (4.0.12)
  31 + i18n (~> 0.6, >= 0.6.9)
  32 + minitest (~> 4.2)
  33 + multi_json (~> 1.3)
  34 + thread_safe (~> 0.1)
  35 + tzinfo (~> 0.3.37)
  36 + addressable (2.3.5)
36 airbrake (3.1.14) 37 airbrake (3.1.14)
37 builder 38 builder
38 json 39 json
39 - arel (3.0.3)  
40 - atomic (1.1.14) 40 + arel (4.0.2)
41 bcrypt-ruby (3.1.2) 41 bcrypt-ruby (3.1.2)
42 better_errors (1.0.1) 42 better_errors (1.0.1)
43 coderay (>= 1.0.0) 43 coderay (>= 1.0.0)
@@ -51,7 +51,8 @@ GEM @@ -51,7 +51,8 @@ GEM
51 multi_json (~> 1.3) 51 multi_json (~> 1.3)
52 nokogiri (>= 1.5.2) 52 nokogiri (>= 1.5.2)
53 simple_oauth 53 simple_oauth
54 - builder (3.0.4) 54 + bson (2.3.0)
  55 + builder (3.1.4)
55 callsite (0.0.11) 56 callsite (0.0.11)
56 campy (1.0.0) 57 campy (1.0.0)
57 capistrano (2.15.5) 58 capistrano (2.15.5)
@@ -68,6 +69,7 @@ GEM @@ -68,6 +69,7 @@ GEM
68 xpath (~> 2.0) 69 xpath (~> 2.0)
69 cliver (0.3.2) 70 cliver (0.3.2)
70 coderay (1.0.9) 71 coderay (1.0.9)
  72 + connection_pool (2.1.0)
71 coveralls (0.7.0) 73 coveralls (0.7.0)
72 multi_json (~> 1.3) 74 multi_json (~> 1.3)
73 rest-client 75 rest-client
@@ -164,7 +166,7 @@ GEM @@ -164,7 +166,7 @@ GEM
164 jira-ruby (0.1.10) 166 jira-ruby (0.1.10)
165 activesupport 167 activesupport
166 oauth 168 oauth
167 - journey (1.0.4) 169 + railties
168 jquery-rails (2.1.4) 170 jquery-rails (2.1.4)
169 railties (>= 3.0, < 5.0) 171 railties (>= 3.0, < 5.0)
170 thor (>= 0.14, < 2.0) 172 thor (>= 0.14, < 2.0)
@@ -182,9 +184,8 @@ GEM @@ -182,9 +184,8 @@ GEM
182 lighthouse-api (2.0) 184 lighthouse-api (2.0)
183 activeresource (>= 3.0.0) 185 activeresource (>= 3.0.0)
184 activesupport (>= 3.0.0) 186 activesupport (>= 3.0.0)
185 - mail (2.5.4)  
186 - mime-types (~> 1.16)  
187 - treetop (~> 1.4.8) 187 + mail (2.6.3)
  188 + mime-types (>= 1.16, < 3)
188 meta_request (0.2.8) 189 meta_request (0.2.8)
189 callsite 190 callsite
190 rack-contrib 191 rack-contrib
@@ -192,11 +193,12 @@ GEM @@ -192,11 +193,12 @@ GEM
192 method_source (0.8.2) 193 method_source (0.8.2)
193 mime-types (1.25.1) 194 mime-types (1.25.1)
194 mini_portile (0.6.1) 195 mini_portile (0.6.1)
195 - mongoid (3.1.5)  
196 - activemodel (~> 3.2)  
197 - moped (~> 1.4)  
198 - origin (~> 1.0)  
199 - tzinfo (~> 0.3.29) 196 + minitest (4.7.5)
  197 + mongoid (4.0.0)
  198 + activemodel (~> 4.0)
  199 + moped (~> 2.0.0)
  200 + origin (~> 2.1)
  201 + tzinfo (>= 0.3.37)
200 mongoid-rspec (1.9.0) 202 mongoid-rspec (1.9.0)
201 mongoid (>= 3.0.1) 203 mongoid (>= 3.0.1)
202 rake 204 rake
@@ -206,7 +208,10 @@ GEM @@ -206,7 +208,10 @@ GEM
206 bundler (>= 1.0.0) 208 bundler (>= 1.0.0)
207 rails (>= 3.2.0) 209 rails (>= 3.2.0)
208 railties (>= 3.2.0) 210 railties (>= 3.2.0)
209 - moped (1.5.1) 211 + moped (2.0.2)
  212 + bson (~> 2.2)
  213 + connection_pool (~> 2.0)
  214 + optionable (~> 0.2.0)
210 multi_json (1.10.1) 215 multi_json (1.10.1)
211 multi_xml (0.5.5) 216 multi_xml (0.5.5)
212 multipart-post (1.2.0) 217 multipart-post (1.2.0)
@@ -239,7 +244,8 @@ GEM @@ -239,7 +244,8 @@ GEM
239 omniauth-oauth2 (1.1.1) 244 omniauth-oauth2 (1.1.1)
240 oauth2 (~> 0.8.0) 245 oauth2 (~> 0.8.0)
241 omniauth (~> 1.0) 246 omniauth (~> 1.0)
242 - origin (1.1.0) 247 + optionable (0.2.0)
  248 + origin (2.1.1)
243 orm_adapter (0.4.0) 249 orm_adapter (0.4.0)
244 oruen_redmine_client (0.0.1) 250 oruen_redmine_client (0.0.1)
245 activeresource (>= 2.3.0) 251 activeresource (>= 2.3.0)
@@ -260,7 +266,6 @@ GEM @@ -260,7 +266,6 @@ GEM
260 cliver (~> 0.3.1) 266 cliver (~> 0.3.1)
261 multi_json (~> 1.0) 267 multi_json (~> 1.0)
262 websocket-driver (>= 0.2.0) 268 websocket-driver (>= 0.2.0)
263 - polyglot (0.3.5)  
264 premailer (1.7.3) 269 premailer (1.7.3)
265 css_parser (>= 1.1.9) 270 css_parser (>= 1.1.9)
266 htmlentities (>= 4.0.0) 271 htmlentities (>= 4.0.0)
@@ -274,36 +279,39 @@ GEM @@ -274,36 +279,39 @@ GEM
274 rack (>= 1.1, < 2.0) 279 rack (>= 1.1, < 2.0)
275 quiet_assets (1.0.2) 280 quiet_assets (1.0.2)
276 railties (>= 3.1, < 5.0) 281 railties (>= 3.1, < 5.0)
277 - rack (1.4.5)  
278 - rack-cache (1.2)  
279 - rack (>= 0.4) 282 + rack (1.5.2)
280 rack-contrib (1.1.0) 283 rack-contrib (1.1.0)
281 rack (>= 0.9.1) 284 rack (>= 0.9.1)
282 - rack-ssl (1.3.4) 285 + rack-ssl (1.4.0)
283 rack 286 rack
284 rack-ssl-enforcer (0.2.6) 287 rack-ssl-enforcer (0.2.6)
285 rack-test (0.6.2) 288 rack-test (0.6.2)
286 rack (>= 1.0) 289 rack (>= 1.0)
287 - rails (3.2.21)  
288 - actionmailer (= 3.2.21)  
289 - actionpack (= 3.2.21)  
290 - activerecord (= 3.2.21)  
291 - activeresource (= 3.2.21)  
292 - activesupport (= 3.2.21)  
293 - bundler (~> 1.0)  
294 - rails_autolink (1.1.4) 290 + rails (4.0.12)
  291 + actionmailer (= 4.0.12)
  292 + actionpack (= 4.0.12)
  293 + activerecord (= 4.0.12)
  294 + activesupport (= 4.0.12)
  295 + bundler (>= 1.3.0, < 2.0)
  296 + railties (= 4.0.12)
  297 + sprockets-rails (~> 2.0)
  298 + rails-observers (0.1.2)
  299 + activemodel (~> 4.0)
  300 + rails_12factor (0.0.3)
  301 + rails_serve_static_assets
  302 + rails_stdout_logging
  303 + rails_autolink (1.1.6)
295 rails (> 3.1) 304 rails (> 3.1)
296 - railties (= 3.2.21)  
297 - railties (3.2.21)  
298 - actionpack (= 3.2.21)  
299 - activesupport (= 3.2.21)  
300 - rack-ssl (~> 1.3.2) 305 + rails_serve_static_assets (0.0.2)
  306 + rails_stdout_logging (0.0.3)
  307 + railties (4.0.12)
  308 + actionpack (= 4.0.12)
  309 + activesupport (= 4.0.12)
301 rake (>= 0.8.7) 310 rake (>= 0.8.7)
302 - rdoc (~> 3.4)  
303 - thor (>= 0.14.6, < 2.0) 311 + thor (>= 0.18.1, < 2.0)
304 raindrops (0.12.0) 312 raindrops (0.12.0)
305 - rake (10.3.2)  
306 - rdoc (3.12.2) 313 + rake (10.4.2)
  314 + rdoc (4.1.2)
307 json (~> 1.4) 315 json (~> 1.4)
308 ref (1.0.5) 316 ref (1.0.5)
309 request_store (1.0.6) 317 request_store (1.0.6)
@@ -341,33 +349,26 @@ GEM @@ -341,33 +349,26 @@ GEM
341 simplecov-html (~> 0.7.1) 349 simplecov-html (~> 0.7.1)
342 simplecov-html (0.7.1) 350 simplecov-html (0.7.1)
343 slop (3.4.6) 351 slop (3.4.6)
344 - sprockets (2.2.2) 352 + sprockets (2.12.3)
345 hike (~> 1.2) 353 hike (~> 1.2)
346 multi_json (~> 1.0) 354 multi_json (~> 1.0)
347 rack (~> 1.0) 355 rack (~> 1.0)
348 tilt (~> 1.1, != 1.3.0) 356 tilt (~> 1.1, != 1.3.0)
349 - strong_parameters (0.2.1)  
350 - actionpack (~> 3.0)  
351 - activemodel (~> 3.0)  
352 - railties (~> 3.0) 357 + sprockets-rails (2.2.2)
  358 + actionpack (>= 3.0)
  359 + activesupport (>= 3.0)
  360 + sprockets (>= 2.8, < 4.0)
353 term-ansicolor (1.2.2) 361 term-ansicolor (1.2.2)
354 tins (~> 0.8) 362 tins (~> 0.8)
355 therubyracer (0.12.1) 363 therubyracer (0.12.1)
356 libv8 (~> 3.16.14.0) 364 libv8 (~> 3.16.14.0)
357 ref 365 ref
358 thor (0.19.1) 366 thor (0.19.1)
359 - thread_safe (0.1.3)  
360 - atomic 367 + thread_safe (0.3.4)
361 tilt (1.4.1) 368 tilt (1.4.1)
362 timecop (0.6.3) 369 timecop (0.6.3)
363 tins (0.12.0) 370 tins (0.12.0)
364 - treetop (1.4.15)  
365 - polyglot  
366 - polyglot (>= 0.3.1)  
367 - turbo-sprockets-rails3 (0.3.10)  
368 - railties (> 3.2.8, < 4.0.0)  
369 - sprockets (>= 2.0.0)  
370 - tzinfo (0.3.41) 371 + tzinfo (0.3.42)
371 uglifier (2.2.1) 372 uglifier (2.2.1)
372 execjs (>= 0.3.0) 373 execjs (>= 0.3.0)
373 json (>= 1.8.0) 374 json (>= 1.8.0)
@@ -392,9 +393,9 @@ PLATFORMS @@ -392,9 +393,9 @@ PLATFORMS
392 ruby 393 ruby
393 394
394 DEPENDENCIES 395 DEPENDENCIES
395 - actionmailer (~> 3.2.21) 396 + actionmailer (~> 4.0.12)
396 actionmailer_inline_css 397 actionmailer_inline_css
397 - actionpack (~> 3.2.21) 398 + actionpack (~> 4.0.12)
398 airbrake 399 airbrake
399 better_errors 400 better_errors
400 binding_of_caller 401 binding_of_caller
@@ -431,9 +432,10 @@ DEPENDENCIES @@ -431,9 +432,10 @@ DEPENDENCIES
431 kaminari (>= 0.14.1) 432 kaminari (>= 0.14.1)
432 launchy 433 launchy
433 meta_request 434 meta_request
434 - mongoid 435 + mongoid (~> 4.0.0)
435 mongoid-rspec 436 mongoid-rspec
436 mongoid_rails_migrations 437 mongoid_rails_migrations
  438 + moped (~> 2.0.2)
437 omniauth-github 439 omniauth-github
438 pjax_rails 440 pjax_rails
439 poltergeist 441 poltergeist
@@ -443,14 +445,12 @@ DEPENDENCIES @@ -443,14 +445,12 @@ DEPENDENCIES
443 rack-ssl 445 rack-ssl
444 rack-ssl-enforcer 446 rack-ssl-enforcer
445 rails_autolink 447 rails_autolink
446 - railties (~> 3.2.21) 448 + railties (~> 4.0.12)
447 ri_cal 449 ri_cal
448 rspec-rails 450 rspec-rails
449 rushover 451 rushover
450 - strong_parameters  
451 therubyracer 452 therubyracer
452 timecop 453 timecop
453 - turbo-sprockets-rails3  
454 uglifier (>= 1.0.3) 454 uglifier (>= 1.0.3)
455 underscore-rails 455 underscore-rails
456 unicorn 456 unicorn
app/controllers/api/v1/problems_controller.rb
1 class Api::V1::ProblemsController < ApplicationController 1 class Api::V1::ProblemsController < ApplicationController
2 respond_to :json, :xml 2 respond_to :json, :xml
3 - FIELDS = %w{app_id app_name environment message where first_notice_at last_notice_at resolved resolved_at notices_count} 3 + FIELDS = %w{_id app_id app_name environment message where first_notice_at last_notice_at resolved resolved_at notices_count}
4 4
5 def show 5 def show
6 result = benchmark("[api/v1/problems_controller/show] query time") do 6 result = benchmark("[api/v1/problems_controller/show] query time") do
app/controllers/application_controller.rb
@@ -15,9 +15,8 @@ class ApplicationController &lt; ActionController::Base @@ -15,9 +15,8 @@ class ApplicationController &lt; ActionController::Base
15 rescue_from ActionController::RedirectBackError, :with => :redirect_to_root 15 rescue_from ActionController::RedirectBackError, :with => :redirect_to_root
16 16
17 class StrongParametersWithEagerAttributesStrategy < DecentExposure::StrongParametersStrategy 17 class StrongParametersWithEagerAttributesStrategy < DecentExposure::StrongParametersStrategy
18 - def attributes  
19 - super  
20 - @attributes ||= params[inflector.param_key] || {} 18 + def assign_attributes?
  19 + singular? && !get? && !delete? && (params[options[:param_key] || inflector.param_key]).present?
21 end 20 end
22 end 21 end
23 22
app/controllers/apps_controller.rb
@@ -15,7 +15,8 @@ class AppsController &lt; ApplicationController @@ -15,7 +15,8 @@ class AppsController &lt; ApplicationController
15 app_scope.all.sort.to_a 15 app_scope.all.sort.to_a
16 } 16 }
17 17
18 - expose(:app, :ancestor => :app_scope) 18 + expose(:app, ancestor: :app_scope, attributes: :app_params)
  19 +
19 expose(:app_decorate) do 20 expose(:app_decorate) do
20 AppDecorator.new(app) 21 AppDecorator.new(app)
21 end 22 end
@@ -23,6 +24,7 @@ class AppsController &lt; ApplicationController @@ -23,6 +24,7 @@ class AppsController &lt; ApplicationController
23 expose(:all_errs) { 24 expose(:all_errs) {
24 !!params[:all_errs] 25 !!params[:all_errs]
25 } 26 }
  27 +
26 expose(:problems) { 28 expose(:problems) {
27 if request.format == :atom 29 if request.format == :atom
28 app.problems.unresolved.ordered 30 app.problems.unresolved.ordered
@@ -140,4 +142,9 @@ class AppsController &lt; ApplicationController @@ -140,4 +142,9 @@ class AppsController &lt; ApplicationController
140 end 142 end
141 end 143 end
142 end 144 end
  145 +
  146 + private
  147 + def app_params
  148 + params.require(:app).permit!
  149 + end
143 end 150 end
app/controllers/comments_controller.rb
@@ -3,7 +3,7 @@ class CommentsController &lt; ApplicationController @@ -3,7 +3,7 @@ class CommentsController &lt; ApplicationController
3 before_filter :find_problem 3 before_filter :find_problem
4 4
5 def create 5 def create
6 - @comment = Comment.new(params[:comment].merge(:user_id => current_user.id)) 6 + @comment = Comment.new(comment_params.merge(:user_id => current_user.id))
7 if @comment.valid? 7 if @comment.valid?
8 @problem.comments << @comment 8 @problem.comments << @comment
9 @problem.save 9 @problem.save
@@ -36,5 +36,8 @@ class CommentsController &lt; ApplicationController @@ -36,5 +36,8 @@ class CommentsController &lt; ApplicationController
36 def find_problem 36 def find_problem
37 @problem = @app.problems.find(params[:problem_id]) 37 @problem = @app.problems.find(params[:problem_id])
38 end 38 end
39 -end  
40 39
  40 + def comment_params
  41 + params.require(:comment).permit!
  42 + end
  43 +end
app/controllers/problems_controller.rb
@@ -153,4 +153,3 @@ class ProblemsController &lt; ApplicationController @@ -153,4 +153,3 @@ class ProblemsController &lt; ApplicationController
153 end 153 end
154 end 154 end
155 end 155 end
156 -  
app/interactors/problem_updater_cache.rb
@@ -22,7 +22,7 @@ class ProblemUpdaterCache @@ -22,7 +22,7 @@ class ProblemUpdaterCache
22 22
23 def update_notices_count 23 def update_notices_count
24 if @notice 24 if @notice
25 - problem.inc(:notices_count, 1) 25 + problem.inc(notices_count: 1)
26 else 26 else
27 problem.update_attribute( 27 problem.update_attribute(
28 :notices_count, problem.notices.count 28 :notices_count, problem.notices.count
app/models/app.rb
@@ -21,7 +21,7 @@ class App @@ -21,7 +21,7 @@ class App
21 field :_id, 21 field :_id,
22 type: String, 22 type: String,
23 pre_processed: true, 23 pre_processed: true,
24 - default: ->{ Moped::BSON::ObjectId.new.to_s } 24 + default: ->{ BSON::ObjectId.new.to_s }
25 25
26 26
27 embeds_many :watchers 27 embeds_many :watchers
@@ -172,7 +172,7 @@ class App @@ -172,7 +172,7 @@ class App
172 end 172 end
173 173
174 def regenerate_api_key! 174 def regenerate_api_key!
175 - set(:api_key, SecureRandom.hex) 175 + update_attribute(:api_key, SecureRandom.hex)
176 end 176 end
177 177
178 ## 178 ##
app/models/backtrace_line.rb
@@ -10,7 +10,7 @@ class BacktraceLine @@ -10,7 +10,7 @@ class BacktraceLine
10 10
11 embedded_in :backtrace 11 embedded_in :backtrace
12 12
13 - scope :in_app, where(:file => IN_APP_PATH) 13 + scope :in_app, ->{ where(:file => IN_APP_PATH) }
14 14
15 delegate :app, :to => :backtrace 15 delegate :app, :to => :backtrace
16 16
@@ -40,4 +40,3 @@ class BacktraceLine @@ -40,4 +40,3 @@ class BacktraceLine
40 end 40 end
41 41
42 end 42 end
43 -  
app/models/comment.rb
@@ -30,11 +30,11 @@ class Comment @@ -30,11 +30,11 @@ class Comment
30 30
31 protected 31 protected
32 def increase_counter_cache 32 def increase_counter_cache
33 - err.inc(:comments_count, 1) 33 + err.inc(comments_count: 1)
34 end 34 end
35 35
36 def decrease_counter_cache 36 def decrease_counter_cache
37 - err.inc(:comments_count, -1) if err 37 + err.inc(comments_count: -1) if err
38 end 38 end
39 39
40 end 40 end
app/models/notice.rb
@@ -28,9 +28,13 @@ class Notice @@ -28,9 +28,13 @@ class Notice
28 28
29 validates_presence_of :backtrace, :server_environment, :notifier 29 validates_presence_of :backtrace, :server_environment, :notifier
30 30
31 - scope :ordered, order_by(:created_at.asc)  
32 - scope :reverse_ordered, order_by(:created_at.desc)  
33 - scope :for_errs, lambda {|errs| where(:err_id.in => errs.all.map(&:id))} 31 + scope :ordered, ->{ order_by(:created_at.asc) }
  32 + scope :reverse_ordered, ->{ order_by(:created_at.desc) }
  33 + scope :for_errs, Proc.new { |errs|
  34 + if (ids = errs.all.map(&:id)) && ids.present?
  35 + where(:err_id.in => ids)
  36 + end
  37 + }
34 38
35 def user_agent 39 def user_agent
36 agent_string = env_vars['HTTP_USER_AGENT'] 40 agent_string = env_vars['HTTP_USER_AGENT']
@@ -139,7 +143,7 @@ class Notice @@ -139,7 +143,7 @@ class Notice
139 protected 143 protected
140 144
141 def decrease_counter_cache 145 def decrease_counter_cache
142 - problem.inc(:notices_count, -1) if err 146 + problem.inc(notices_count: -1) if err
143 end 147 end
144 148
145 def remove_cached_attributes_from_problem 149 def remove_cached_attributes_from_problem
@@ -162,8 +166,8 @@ class Notice @@ -162,8 +166,8 @@ class Notice
162 166
163 167
164 def sanitize_hash(h) 168 def sanitize_hash(h)
165 - h.recurse do  
166 - |h| h.inject({}) do |h,(k,v)| 169 + h.recurse do |h|
  170 + h.inject({}) do |h,(k,v)|
167 if k.is_a?(String) 171 if k.is_a?(String)
168 h[k.gsub(/\./,'&#46;').gsub(/^\$/,'&#36;')] = v 172 h[k.gsub(/\./,'&#46;').gsub(/^\$/,'&#36;')] = v
169 else 173 else
@@ -195,4 +199,3 @@ class Notice @@ -195,4 +199,3 @@ class Notice
195 end 199 end
196 200
197 end 201 end
198 -  
app/models/problem.rb
@@ -43,9 +43,9 @@ class Problem @@ -43,9 +43,9 @@ class Problem
43 43
44 before_create :cache_app_attributes 44 before_create :cache_app_attributes
45 45
46 - scope :resolved, where(:resolved => true)  
47 - scope :unresolved, where(:resolved => false)  
48 - scope :ordered, order_by(:last_notice_at.desc) 46 + scope :resolved, ->{ where(:resolved => true) }
  47 + scope :unresolved, ->{ where(:resolved => false) }
  48 + scope :ordered, ->{ order_by(:last_notice_at.desc) }
49 scope :for_apps, lambda {|apps| where(:app_id.in => apps.all.map(&:id))} 49 scope :for_apps, lambda {|apps| where(:app_id.in => apps.all.map(&:id))}
50 50
51 validates_presence_of :last_notice_at, :first_notice_at 51 validates_presence_of :last_notice_at, :first_notice_at
@@ -184,4 +184,3 @@ class Problem @@ -184,4 +184,3 @@ class Problem
184 Digest::MD5.hexdigest(value.to_s) 184 Digest::MD5.hexdigest(value.to_s)
185 end 185 end
186 end 186 end
187 -  
config/application.rb
@@ -47,9 +47,6 @@ module Errbit @@ -47,9 +47,6 @@ module Errbit
47 g.fixture_replacement :fabrication 47 g.fixture_replacement :fabrication
48 end 48 end
49 49
50 - # Enable the mongoid identity map for performance  
51 - Mongoid.identity_map_enabled = true  
52 -  
53 # IssueTracker subclasses use inheritance, so preloading models provides querying consistency in dev mode. 50 # IssueTracker subclasses use inheritance, so preloading models provides querying consistency in dev mode.
54 config.mongoid.preload_models = true 51 config.mongoid.preload_models = true
55 52
@@ -73,4 +70,3 @@ module Errbit @@ -73,4 +70,3 @@ module Errbit
73 config.assets.version = '1.0' 70 config.assets.version = '1.0'
74 end 71 end
75 end 72 end
76 -  
config/environments/development.rb
@@ -6,8 +6,7 @@ Errbit::Application.configure do @@ -6,8 +6,7 @@ Errbit::Application.configure do
6 # since you don't have to restart the webserver when you make code changes. 6 # since you don't have to restart the webserver when you make code changes.
7 config.cache_classes = false 7 config.cache_classes = false
8 8
9 - # Log error messages when you accidentally call methods on nil.  
10 - config.whiny_nils = true 9 + config.eager_load = false
11 10
12 # Show full error reports and disable caching 11 # Show full error reports and disable caching
13 config.consider_all_requests_local = true 12 config.consider_all_requests_local = true
config/environments/production.rb
@@ -5,6 +5,8 @@ Errbit::Application.configure do @@ -5,6 +5,8 @@ Errbit::Application.configure do
5 # Code is not reloaded between requests 5 # Code is not reloaded between requests
6 config.cache_classes = true 6 config.cache_classes = true
7 7
  8 + config.eager_load = true
  9 +
8 # Shows or hides all error details if something goes wrong inside Errbit 10 # Shows or hides all error details if something goes wrong inside Errbit
9 config.consider_all_requests_local = false 11 config.consider_all_requests_local = false
10 # Caching is turned on 12 # Caching is turned on
config/environments/test.rb
@@ -7,8 +7,7 @@ Errbit::Application.configure do @@ -7,8 +7,7 @@ Errbit::Application.configure do
7 # and recreated between test runs. Don't rely on the data there! 7 # and recreated between test runs. Don't rely on the data there!
8 config.cache_classes = true 8 config.cache_classes = true
9 9
10 - # Log error messages when you accidentally call methods on nil.  
11 - config.whiny_nils = true 10 + config.eager_load = false
12 11
13 # Show full error reports and disable caching 12 # Show full error reports and disable caching
14 config.consider_all_requests_local = true 13 config.consider_all_requests_local = true
config/initializers/mongo.rb
@@ -39,6 +39,4 @@ elsif ENV[&#39;HEROKU&#39;] || ENV[&#39;USE_ENV&#39;] @@ -39,6 +39,4 @@ elsif ENV[&#39;HEROKU&#39;] || ENV[&#39;USE_ENV&#39;]
39 end 39 end
40 end 40 end
41 41
42 -Mongoid.allow_dynamic_fields = false  
43 Mongoid.use_activesupport_time_zone = true 42 Mongoid.use_activesupport_time_zone = true
44 -Mongoid.identity_map_enabled = true  
config/initializers/overrides.rb
1 require Rails.root.join('lib/overrides/devise/failure_app') 1 require Rails.root.join('lib/overrides/devise/failure_app')
2 require Rails.root.join('lib/overrides/hoptoad_notifier/hoptoad_notifier') 2 require Rails.root.join('lib/overrides/hoptoad_notifier/hoptoad_notifier')
  3 +
  4 +class BSON::ObjectId
  5 + def as_json(*args)
  6 + to_s
  7 + end
  8 +end
config/mongoid.example.yml
@@ -14,7 +14,6 @@ development: @@ -14,7 +14,6 @@ development:
14 hosts: 14 hosts:
15 - localhost:27017 15 - localhost:27017
16 options: 16 options:
17 - identity_map_enabled: true  
18 use_utc: true 17 use_utc: true
19 18
20 test: 19 test:
@@ -24,7 +23,6 @@ test: @@ -24,7 +23,6 @@ test:
24 - localhost:27017 23 - localhost:27017
25 database: errbit_test 24 database: errbit_test
26 options: 25 options:
27 - identity_map_enabled: true  
28 use_utc: true 26 use_utc: true
29 27
30 # set these environment variables on your prod server 28 # set these environment variables on your prod server
@@ -37,4 +35,4 @@ production: @@ -37,4 +35,4 @@ production:
37 username: <%= ENV['MONGOID_USERNAME'] %> 35 username: <%= ENV['MONGOID_USERNAME'] %>
38 password: <%= ENV['MONGOID_PASSWORD'] %> 36 password: <%= ENV['MONGOID_PASSWORD'] %>
39 options: 37 options:
40 - identity_map_enabled: true 38 + use_utc: true
41 \ No newline at end of file 39 \ No newline at end of file
spec/controllers/api/v1/problems_controller_spec.rb
@@ -33,7 +33,7 @@ describe Api::V1::ProblemsController do @@ -33,7 +33,7 @@ describe Api::V1::ProblemsController do
33 get :show, :auth_token => @user.authentication_token, :format => "json", :id => @problem.id 33 get :show, :auth_token => @user.authentication_token, :format => "json", :id => @problem.id
34 34
35 returned_problem = JSON.parse(response.body) 35 returned_problem = JSON.parse(response.body)
36 - expect( returned_problem["_id"] ).to eq(@problem.id.to_s) 36 + expect(returned_problem["_id"]).to eq(@problem.id.to_s)
37 end 37 end
38 38
39 it "should return only the correct fields" do 39 it "should return only the correct fields" do
@@ -43,24 +43,14 @@ describe Api::V1::ProblemsController do @@ -43,24 +43,14 @@ describe Api::V1::ProblemsController do
43 expect( returned_problem.keys ).to match_array([ 43 expect( returned_problem.keys ).to match_array([
44 "app_name", 44 "app_name",
45 "first_notice_at", 45 "first_notice_at",
46 - "error_class",  
47 - "messages",  
48 - "hosts",  
49 - "created_at", 46 + "message",
50 "app_id", 47 "app_id",
51 "last_notice_at", 48 "last_notice_at",
52 "_id", 49 "_id",
53 - "issue_link",  
54 "resolved", 50 "resolved",
55 - "updated_at",  
56 "resolved_at", 51 "resolved_at",
57 - "last_deploy_at",  
58 "where", 52 "where",
59 - "issue_type",  
60 "notices_count", 53 "notices_count",
61 - "user_agents",  
62 - "comments_count",  
63 - "message",  
64 "environment" 54 "environment"
65 ]) 55 ])
66 end 56 end
spec/controllers/apps_controller_spec.rb
@@ -358,8 +358,10 @@ describe AppsController do @@ -358,8 +358,10 @@ describe AppsController do
358 end 358 end
359 359
360 it "should destroy the app" do 360 it "should destroy the app" do
361 - expect(@app).to receive(:destroy)  
362 delete :destroy, :id => @app.id 361 delete :destroy, :id => @app.id
  362 + expect {
  363 + @app.reload
  364 + }.to raise_error(Mongoid::Errors::DocumentNotFound)
363 end 365 end
364 366
365 it "should display a message" do 367 it "should display a message" do
@@ -397,10 +399,8 @@ describe AppsController do @@ -397,10 +399,8 @@ describe AppsController do
397 expect do 399 expect do
398 post :regenerate_api_key, :id => app.id 400 post :regenerate_api_key, :id => app.id
399 expect(request).to redirect_to edit_app_path(app) 401 expect(request).to redirect_to edit_app_path(app)
400 - end.to change { app.api_key } 402 + end.to change { app.reload.api_key }
401 end 403 end
402 end 404 end
403 -  
404 end 405 end
405 -  
406 end 406 end
spec/controllers/problems_controller_spec.rb
@@ -250,7 +250,7 @@ describe ProblemsController do @@ -250,7 +250,7 @@ describe ProblemsController do
250 end 250 end
251 251
252 it "should redirect back to problems page" do 252 it "should redirect back to problems page" do
253 - request.env["Referer"] = problems_path 253 + request.env["HTTP_REFERER"] = problems_path
254 put :resolve, :app_id => @problem.app.id, :id => @problem.problem.id 254 put :resolve, :app_id => @problem.app.id, :id => @problem.problem.id
255 expect(response).to redirect_to(problems_path) 255 expect(response).to redirect_to(problems_path)
256 end 256 end
@@ -437,7 +437,7 @@ describe ProblemsController do @@ -437,7 +437,7 @@ describe ProblemsController do
437 end 437 end
438 438
439 it "should redirect back to the app page" do 439 it "should redirect back to the app page" do
440 - request.env["Referer"] = edit_app_path(@app) 440 + request.env["HTTP_REFERER"] = edit_app_path(@app)
441 put :destroy_all, :app_id => @app.id 441 put :destroy_all, :app_id => @app.id
442 expect(response).to redirect_to(edit_app_path(@app)) 442 expect(response).to redirect_to(edit_app_path(@app))
443 end 443 end
@@ -446,4 +446,3 @@ describe ProblemsController do @@ -446,4 +446,3 @@ describe ProblemsController do
446 end 446 end
447 447
448 end 448 end
449 -  
spec/controllers/users_controller_spec.rb
@@ -190,7 +190,7 @@ describe UsersController do @@ -190,7 +190,7 @@ describe UsersController do
190 context "with normal params" do 190 context "with normal params" do
191 let(:user_params) { {:name => 'Kermit'} } 191 let(:user_params) { {:name => 'Kermit'} }
192 it "sets a message to display" do 192 it "sets a message to display" do
193 - expect(request.flash[:success]).to eq I18n.t('controllers.users.flash.update.success', :name => user.name) 193 + expect(request.flash[:success]).to eq I18n.t('controllers.users.flash.update.success', :name => user.reload.name)
194 expect(response).to redirect_to(user_path(user)) 194 expect(response).to redirect_to(user_path(user))
195 end 195 end
196 end 196 end
spec/models/app_spec.rb
@@ -6,7 +6,7 @@ describe App do @@ -6,7 +6,7 @@ describe App do
6 it { should have_field(:_id).of_type(String) } 6 it { should have_field(:_id).of_type(String) }
7 it { should have_field(:name).of_type(String) } 7 it { should have_field(:name).of_type(String) }
8 it { should have_fields(:api_key, :github_repo, :bitbucket_repo, :asset_host, :repository_branch) } 8 it { should have_fields(:api_key, :github_repo, :bitbucket_repo, :asset_host, :repository_branch) }
9 - it { should have_fields(:resolve_errs_on_deploy, :notify_all_users, :notify_on_errs, :notify_on_deploys).of_type(Boolean) } 9 + it { should have_fields(:resolve_errs_on_deploy, :notify_all_users, :notify_on_errs, :notify_on_deploys).of_type(Mongoid::Boolean) }
10 it { should have_field(:email_at_notices).of_type(Array).with_default_value_of(Errbit::Config.email_at_notices) } 10 it { should have_field(:email_at_notices).of_type(Array).with_default_value_of(Errbit::Config.email_at_notices) }
11 end 11 end
12 12
@@ -243,4 +243,3 @@ describe App do @@ -243,4 +243,3 @@ describe App do
243 end 243 end
244 244
245 end 245 end
246 -