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