Commit 46aadb58946834b93a708890227ab93579041014
1 parent
fe3f623c
Exists in
master
and in
1 other branch
Rubocop: hashes: format neatly with symbols for keys and aligned values
Showing
141 changed files
with
947 additions
and
958 deletions
Show diff stats
.rubocop.yml
@@ -36,6 +36,9 @@ Style/DotPosition: | @@ -36,6 +36,9 @@ Style/DotPosition: | ||
36 | Style/IndentHash: | 36 | Style/IndentHash: |
37 | EnforcedStyle: consistent | 37 | EnforcedStyle: consistent |
38 | 38 | ||
39 | +Style/AlignHash: | ||
40 | + EnforcedColonStyle: table | ||
41 | + | ||
39 | Style/SpaceAroundOperators: | 42 | Style/SpaceAroundOperators: |
40 | MultiSpaceAllowedForOperators: | 43 | MultiSpaceAllowedForOperators: |
41 | - '=' | 44 | - '=' |
.rubocop_todo.yml
@@ -53,17 +53,6 @@ Rails/Validation: | @@ -53,17 +53,6 @@ Rails/Validation: | ||
53 | - 'app/models/problem.rb' | 53 | - 'app/models/problem.rb' |
54 | - 'app/models/user.rb' | 54 | - 'app/models/user.rb' |
55 | 55 | ||
56 | -# Offense count: 8 | ||
57 | -# Cop supports --auto-correct. | ||
58 | -# Configuration parameters: EnforcedHashRocketStyle, EnforcedColonStyle, EnforcedLastArgumentHashStyle, SupportedLastArgumentHashStyles. | ||
59 | -Style/AlignHash: | ||
60 | - Exclude: | ||
61 | - - 'app/models/app.rb' | ||
62 | - - 'spec/controllers/apps_controller_spec.rb' | ||
63 | - - 'spec/controllers/comments_controller_spec.rb' | ||
64 | - - 'spec/controllers/problems_controller_spec.rb' | ||
65 | - - 'spec/models/problem_spec.rb' | ||
66 | - | ||
67 | # Offense count: 105 | 56 | # Offense count: 105 |
68 | # Cop supports --auto-correct. | 57 | # Cop supports --auto-correct. |
69 | # Configuration parameters: EnforcedStyle, SupportedStyles, ProceduralMethods, FunctionalMethods, IgnoredMethods. | 58 | # Configuration parameters: EnforcedStyle, SupportedStyles, ProceduralMethods, FunctionalMethods, IgnoredMethods. |
@@ -141,12 +130,6 @@ Style/FormatString: | @@ -141,12 +130,6 @@ Style/FormatString: | ||
141 | Style/GuardClause: | 130 | Style/GuardClause: |
142 | Enabled: false | 131 | Enabled: false |
143 | 132 | ||
144 | -# Offense count: 1168 | ||
145 | -# Cop supports --auto-correct. | ||
146 | -# Configuration parameters: EnforcedStyle, SupportedStyles, UseHashRocketsWithSymbolValues. | ||
147 | -Style/HashSyntax: | ||
148 | - Enabled: false | ||
149 | - | ||
150 | # Offense count: 6 | 133 | # Offense count: 6 |
151 | # Cop supports --auto-correct. | 134 | # Cop supports --auto-correct. |
152 | # Configuration parameters: MaxLineLength. | 135 | # Configuration parameters: MaxLineLength. |
Gemfile
@@ -29,8 +29,8 @@ gem 'htmlentities' | @@ -29,8 +29,8 @@ gem 'htmlentities' | ||
29 | gem 'kaminari', '>= 0.14.1' | 29 | gem 'kaminari', '>= 0.14.1' |
30 | gem 'mongoid', '5.0.0' | 30 | gem 'mongoid', '5.0.0' |
31 | gem 'mongoid_rails_migrations' | 31 | gem 'mongoid_rails_migrations' |
32 | -gem 'rack-ssl', :require => 'rack/ssl' # force SSL | ||
33 | -gem 'rack-ssl-enforcer', :require => false | 32 | +gem 'rack-ssl', require: 'rack/ssl' # force SSL |
33 | +gem 'rack-ssl-enforcer', require: false | ||
34 | gem 'rails_autolink' | 34 | gem 'rails_autolink' |
35 | gem 'useragent' | 35 | gem 'useragent' |
36 | 36 | ||
@@ -44,7 +44,7 @@ gem 'campy' | @@ -44,7 +44,7 @@ gem 'campy' | ||
44 | # Hipchat | 44 | # Hipchat |
45 | gem 'hipchat' | 45 | gem 'hipchat' |
46 | # Google Talk | 46 | # Google Talk |
47 | -gem 'xmpp4r', :require => ["xmpp4r", "xmpp4r/muc"] | 47 | +gem 'xmpp4r', require: ["xmpp4r", "xmpp4r/muc"] |
48 | # Hoiio (SMS) | 48 | # Hoiio (SMS) |
49 | gem 'hoi' | 49 | gem 'hoi' |
50 | # Pushover (iOS Push notifications) | 50 | # Pushover (iOS Push notifications) |
@@ -64,7 +64,7 @@ gem 'yajl-ruby', platform: 'ruby' | @@ -64,7 +64,7 @@ gem 'yajl-ruby', platform: 'ruby' | ||
64 | gem 'json', platform: 'jruby' | 64 | gem 'json', platform: 'jruby' |
65 | 65 | ||
66 | group :development, :test do | 66 | group :development, :test do |
67 | - gem 'airbrake', :require => false | 67 | + gem 'airbrake', require: false |
68 | gem 'pry-rails' | 68 | gem 'pry-rails' |
69 | gem 'pry-byebug', platforms: [:mri] | 69 | gem 'pry-byebug', platforms: [:mri] |
70 | gem 'quiet_assets' | 70 | gem 'quiet_assets' |
@@ -103,7 +103,7 @@ group :heroku, :production do | @@ -103,7 +103,7 @@ group :heroku, :production do | ||
103 | gem 'unicorn', require: false, platform: 'ruby' | 103 | gem 'unicorn', require: false, platform: 'ruby' |
104 | end | 104 | end |
105 | 105 | ||
106 | -gem 'therubyracer', :platform => :ruby # C Ruby (MRI) or Rubinius, but NOT Windows | 106 | +gem 'therubyracer', platform: :ruby # C Ruby (MRI) or Rubinius, but NOT Windows |
107 | gem 'sass-rails' | 107 | gem 'sass-rails' |
108 | gem 'uglifier' | 108 | gem 'uglifier' |
109 | # We can't upgrade because not compatible to jquery >= 1.9. | 109 | # We can't upgrade because not compatible to jquery >= 1.9. |
Rakefile
@@ -8,7 +8,7 @@ Rails.application.load_tasks | @@ -8,7 +8,7 @@ Rails.application.load_tasks | ||
8 | begin | 8 | begin |
9 | require 'rspec/core/rake_task' | 9 | require 'rspec/core/rake_task' |
10 | RSpec::Core::RakeTask.new(:spec) | 10 | RSpec::Core::RakeTask.new(:spec) |
11 | - task :default => :spec | 11 | + task default: :spec |
12 | rescue LoadError | 12 | rescue LoadError |
13 | warn "Notice: no rspec tasks available in this environment" | 13 | warn "Notice: no rspec tasks available in this environment" |
14 | end | 14 | end |
app/controllers/api/v1/notices_controller.rb
@@ -8,16 +8,16 @@ class Api::V1::NoticesController < ApplicationController | @@ -8,16 +8,16 @@ class Api::V1::NoticesController < ApplicationController | ||
8 | if params.key?(:start_date) && params.key?(:end_date) | 8 | if params.key?(:start_date) && params.key?(:end_date) |
9 | start_date = Time.zone.parse(params[:start_date]).utc | 9 | start_date = Time.zone.parse(params[:start_date]).utc |
10 | end_date = Time.zone.parse(params[:end_date]).utc | 10 | end_date = Time.zone.parse(params[:end_date]).utc |
11 | - query = { :created_at => { "$lte" => end_date, "$gte" => start_date } } | 11 | + query = { created_at: { "$lte" => end_date, "$gte" => start_date } } |
12 | end | 12 | end |
13 | 13 | ||
14 | results = benchmark("[api/v1/notices_controller] query time") do | 14 | results = benchmark("[api/v1/notices_controller] query time") do |
15 | - Notice.where(query).with(:consistency => :strong).only(fields).to_a | 15 | + Notice.where(query).with(consistency: :strong).only(fields).to_a |
16 | end | 16 | end |
17 | 17 | ||
18 | respond_to do |format| | 18 | respond_to do |format| |
19 | - format.any(:html, :json) { render :json => JSON.dump(results) } # render JSON if no extension specified on path | ||
20 | - format.xml { render :xml => results } | 19 | + format.any(:html, :json) { render json: JSON.dump(results) } # render JSON if no extension specified on path |
20 | + format.xml { render xml: results } | ||
21 | end | 21 | end |
22 | end | 22 | end |
23 | end | 23 | end |
app/controllers/api/v1/problems_controller.rb
@@ -13,8 +13,8 @@ class Api::V1::ProblemsController < ApplicationController | @@ -13,8 +13,8 @@ class Api::V1::ProblemsController < ApplicationController | ||
13 | end | 13 | end |
14 | 14 | ||
15 | respond_to do |format| | 15 | respond_to do |format| |
16 | - format.any(:html, :json) { render :json => result } # render JSON if no extension specified on path | ||
17 | - format.xml { render :xml => result } | 16 | + format.any(:html, :json) { render json: result } # render JSON if no extension specified on path |
17 | + format.xml { render xml: result } | ||
18 | end | 18 | end |
19 | end | 19 | end |
20 | 20 | ||
@@ -24,16 +24,16 @@ class Api::V1::ProblemsController < ApplicationController | @@ -24,16 +24,16 @@ class Api::V1::ProblemsController < ApplicationController | ||
24 | if params.key?(:start_date) && params.key?(:end_date) | 24 | if params.key?(:start_date) && params.key?(:end_date) |
25 | start_date = Time.parse(params[:start_date]).utc | 25 | start_date = Time.parse(params[:start_date]).utc |
26 | end_date = Time.parse(params[:end_date]).utc | 26 | end_date = Time.parse(params[:end_date]).utc |
27 | - query = { :first_notice_at => { "$lte" => end_date }, "$or" => [{ :resolved_at => nil }, { :resolved_at => { "$gte" => start_date } }] } | 27 | + query = { :first_notice_at => { "$lte" => end_date }, "$or" => [{ resolved_at: nil }, { resolved_at: { "$gte" => start_date } }] } |
28 | end | 28 | end |
29 | 29 | ||
30 | results = benchmark("[api/v1/problems_controller/index] query time") do | 30 | results = benchmark("[api/v1/problems_controller/index] query time") do |
31 | - Problem.where(query).with(:consistency => :strong).only(FIELDS).to_a | 31 | + Problem.where(query).with(consistency: :strong).only(FIELDS).to_a |
32 | end | 32 | end |
33 | 33 | ||
34 | respond_to do |format| | 34 | respond_to do |format| |
35 | - format.any(:html, :json) { render :json => JSON.dump(results) } # render JSON if no extension specified on path | ||
36 | - format.xml { render :xml => results } | 35 | + format.any(:html, :json) { render json: JSON.dump(results) } # render JSON if no extension specified on path |
36 | + format.xml { render xml: results } | ||
37 | end | 37 | end |
38 | end | 38 | end |
39 | end | 39 | end |
app/controllers/api/v1/stats_controller.rb
@@ -11,21 +11,21 @@ class Api::V1::StatsController < ApplicationController | @@ -11,21 +11,21 @@ class Api::V1::StatsController < ApplicationController | ||
11 | end | 11 | end |
12 | 12 | ||
13 | stats = { | 13 | stats = { |
14 | - :name => @app.name, | ||
15 | - :id => @app.id, | ||
16 | - :last_error_time => @last_error_time, | ||
17 | - :unresolved_errors => @app.unresolved_count | 14 | + name: @app.name, |
15 | + id: @app.id, | ||
16 | + last_error_time: @last_error_time, | ||
17 | + unresolved_errors: @app.unresolved_count | ||
18 | } | 18 | } |
19 | 19 | ||
20 | respond_to do |format| | 20 | respond_to do |format| |
21 | - format.any(:html, :json) { render :json => JSON.dump(stats) } # render JSON if no extension specified on path | ||
22 | - format.xml { render :xml => stats } | 21 | + format.any(:html, :json) { render json: JSON.dump(stats) } # render JSON if no extension specified on path |
22 | + format.xml { render xml: stats } | ||
23 | end | 23 | end |
24 | end | 24 | end |
25 | 25 | ||
26 | protected def require_api_key_or_authenticate_user! | 26 | protected def require_api_key_or_authenticate_user! |
27 | if params[:api_key].present? | 27 | if params[:api_key].present? |
28 | - if (@app = App.where(:api_key => params[:api_key]).first) | 28 | + if (@app = App.where(api_key: params[:api_key]).first) |
29 | return true | 29 | return true |
30 | end | 30 | end |
31 | end | 31 | end |
app/controllers/api/v3/notices_controller.rb
@@ -15,7 +15,7 @@ class Api::V3::NoticesController < ApplicationController | @@ -15,7 +15,7 @@ class Api::V3::NoticesController < ApplicationController | ||
15 | if report.should_keep? | 15 | if report.should_keep? |
16 | report.generate_notice! | 16 | report.generate_notice! |
17 | render json: { | 17 | render json: { |
18 | - id: report.notice.id, | 18 | + id: report.notice.id, |
19 | url: app_problem_url( | 19 | url: app_problem_url( |
20 | report.app, | 20 | report.app, |
21 | report.error.problem_id) | 21 | report.error.problem_id) |
app/controllers/application_controller.rb
@@ -5,7 +5,7 @@ class ApplicationController < ActionController::Base | @@ -5,7 +5,7 @@ class ApplicationController < ActionController::Base | ||
5 | before_action :authenticate_user! | 5 | before_action :authenticate_user! |
6 | before_action :set_time_zone | 6 | before_action :set_time_zone |
7 | 7 | ||
8 | - rescue_from ActionController::RedirectBackError, :with => :redirect_to_root | 8 | + rescue_from ActionController::RedirectBackError, with: :redirect_to_root |
9 | 9 | ||
10 | class StrongParametersWithEagerAttributesStrategy < DecentExposure::StrongParametersStrategy | 10 | class StrongParametersWithEagerAttributesStrategy < DecentExposure::StrongParametersStrategy |
11 | def assign_attributes? | 11 | def assign_attributes? |
app/controllers/apps_controller.rb
1 | class AppsController < ApplicationController | 1 | class AppsController < ApplicationController |
2 | include ProblemsSearcher | 2 | include ProblemsSearcher |
3 | 3 | ||
4 | - before_action :require_admin!, :except => [:index, :show] | ||
5 | - before_action :parse_email_at_notices_or_set_default, :only => [:create, :update] | ||
6 | - before_action :parse_notice_at_notices_or_set_default, :only => [:create, :update] | 4 | + before_action :require_admin!, except: [:index, :show] |
5 | + before_action :parse_email_at_notices_or_set_default, only: [:create, :update] | ||
6 | + before_action :parse_notice_at_notices_or_set_default, only: [:create, :update] | ||
7 | respond_to :html | 7 | respond_to :html |
8 | 8 | ||
9 | expose(:app_scope) { App } | 9 | expose(:app_scope) { App } |
@@ -55,7 +55,7 @@ class AppsController < ApplicationController | @@ -55,7 +55,7 @@ class AppsController < ApplicationController | ||
55 | def create | 55 | def create |
56 | initialize_subclassed_notification_service | 56 | initialize_subclassed_notification_service |
57 | if app.save | 57 | if app.save |
58 | - redirect_to app_url(app), :flash => { :success => I18n.t('controllers.apps.flash.create.success') } | 58 | + redirect_to app_url(app), flash: { success: I18n.t('controllers.apps.flash.create.success') } |
59 | else | 59 | else |
60 | flash[:error] = I18n.t('controllers.apps.flash.create.error') | 60 | flash[:error] = I18n.t('controllers.apps.flash.create.error') |
61 | render :new | 61 | render :new |
@@ -65,7 +65,7 @@ class AppsController < ApplicationController | @@ -65,7 +65,7 @@ class AppsController < ApplicationController | ||
65 | def update | 65 | def update |
66 | initialize_subclassed_notification_service | 66 | initialize_subclassed_notification_service |
67 | if app.save | 67 | if app.save |
68 | - redirect_to app_url(app), :flash => { :success => I18n.t('controllers.apps.flash.update.success') } | 68 | + redirect_to app_url(app), flash: { success: I18n.t('controllers.apps.flash.update.success') } |
69 | else | 69 | else |
70 | flash[:error] = I18n.t('controllers.apps.flash.update.error') | 70 | flash[:error] = I18n.t('controllers.apps.flash.update.error') |
71 | render :edit | 71 | render :edit |
@@ -78,7 +78,7 @@ class AppsController < ApplicationController | @@ -78,7 +78,7 @@ class AppsController < ApplicationController | ||
78 | 78 | ||
79 | def destroy | 79 | def destroy |
80 | if app.destroy | 80 | if app.destroy |
81 | - redirect_to apps_url, :flash => { :success => I18n.t('controllers.apps.flash.destroy.success') } | 81 | + redirect_to apps_url, flash: { success: I18n.t('controllers.apps.flash.destroy.success') } |
82 | else | 82 | else |
83 | flash[:error] = I18n.t('controllers.apps.flash.destroy.error') | 83 | flash[:error] = I18n.t('controllers.apps.flash.destroy.error') |
84 | render :show | 84 | render :show |
app/controllers/comments_controller.rb
@@ -3,7 +3,7 @@ class CommentsController < ApplicationController | @@ -3,7 +3,7 @@ class CommentsController < ApplicationController | ||
3 | before_action :find_problem | 3 | before_action :find_problem |
4 | 4 | ||
5 | def create | 5 | def create |
6 | - @comment = Comment.new(comment_params.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 |
app/controllers/deploys_controller.rb
1 | class DeploysController < ApplicationController | 1 | class DeploysController < ApplicationController |
2 | - protect_from_forgery :except => :create | 2 | + protect_from_forgery except: :create |
3 | 3 | ||
4 | - skip_before_action :verify_authenticity_token, :only => :create | ||
5 | - skip_before_action :authenticate_user!, :only => :create | 4 | + skip_before_action :verify_authenticity_token, only: :create |
5 | + skip_before_action :authenticate_user!, only: :create | ||
6 | 6 | ||
7 | def create | 7 | def create |
8 | @app = App.find_by_api_key!(params[:api_key]) | 8 | @app = App.find_by_api_key!(params[:api_key]) |
9 | @deploy = @app.deploys.create!(default_deploy || heroku_deploy) | 9 | @deploy = @app.deploys.create!(default_deploy || heroku_deploy) |
10 | - render :xml => @deploy | 10 | + render xml: @deploy |
11 | end | 11 | end |
12 | 12 | ||
13 | def index | 13 | def index |
@@ -21,11 +21,11 @@ private | @@ -21,11 +21,11 @@ private | ||
21 | def default_deploy | 21 | def default_deploy |
22 | if params[:deploy] | 22 | if params[:deploy] |
23 | { | 23 | { |
24 | - :username => params[:deploy][:local_username], | ||
25 | - :environment => params[:deploy][:rails_env], | ||
26 | - :repository => params[:deploy][:scm_repository], | ||
27 | - :revision => params[:deploy][:scm_revision], | ||
28 | - :message => params[:deploy][:message] | 24 | + username: params[:deploy][:local_username], |
25 | + environment: params[:deploy][:rails_env], | ||
26 | + repository: params[:deploy][:scm_repository], | ||
27 | + revision: params[:deploy][:scm_revision], | ||
28 | + message: params[:deploy][:message] | ||
29 | } | 29 | } |
30 | end | 30 | end |
31 | end | 31 | end |
@@ -33,10 +33,10 @@ private | @@ -33,10 +33,10 @@ private | ||
33 | # handle Heroku's HTTP post deployhook format | 33 | # handle Heroku's HTTP post deployhook format |
34 | def heroku_deploy | 34 | def heroku_deploy |
35 | { | 35 | { |
36 | - :username => params[:user], | ||
37 | - :environment => params[:rack_env].try(:downcase) || params[:app], | ||
38 | - :repository => "git@heroku.com:#{params[:app]}.git", | ||
39 | - :revision => params[:head] | 36 | + username: params[:user], |
37 | + environment: params[:rack_env].try(:downcase) || params[:app], | ||
38 | + repository: "git@heroku.com:#{params[:app]}.git", | ||
39 | + revision: params[:head] | ||
40 | } | 40 | } |
41 | end | 41 | end |
42 | end | 42 | end |
app/controllers/notices_controller.rb
@@ -4,7 +4,7 @@ class NoticesController < ApplicationController | @@ -4,7 +4,7 @@ class NoticesController < ApplicationController | ||
4 | skip_before_action :authenticate_user!, only: :create | 4 | skip_before_action :authenticate_user!, only: :create |
5 | skip_before_action :verify_authenticity_token, only: :create | 5 | skip_before_action :verify_authenticity_token, only: :create |
6 | 6 | ||
7 | - rescue_from ParamsError, :with => :bad_params | 7 | + rescue_from ParamsError, with: :bad_params |
8 | 8 | ||
9 | def create | 9 | def create |
10 | # params[:data] if the notice came from a GET request, raw_post if it came via POST | 10 | # params[:data] if the notice came from a GET request, raw_post if it came via POST |
@@ -13,18 +13,18 @@ class NoticesController < ApplicationController | @@ -13,18 +13,18 @@ class NoticesController < ApplicationController | ||
13 | if report.valid? | 13 | if report.valid? |
14 | if report.should_keep? | 14 | if report.should_keep? |
15 | report.generate_notice! | 15 | report.generate_notice! |
16 | - api_xml = report.notice.to_xml(:only => false, :methods => [:id]) do |xml| | ||
17 | - xml.url locate_url(report.notice.id, :host => Errbit::Config.host) | 16 | + api_xml = report.notice.to_xml(only: false, methods: [:id]) do |xml| |
17 | + xml.url locate_url(report.notice.id, host: Errbit::Config.host) | ||
18 | end | 18 | end |
19 | - render :xml => api_xml | 19 | + render xml: api_xml |
20 | else | 20 | else |
21 | - render :text => "Notice for old app version ignored" | 21 | + render text: "Notice for old app version ignored" |
22 | end | 22 | end |
23 | else | 23 | else |
24 | - render :text => "Your API key is unknown", :status => 422 | 24 | + render text: "Your API key is unknown", status: 422 |
25 | end | 25 | end |
26 | rescue Nokogiri::XML::SyntaxError | 26 | rescue Nokogiri::XML::SyntaxError |
27 | - render :text => 'The provided XML was not well-formed', :status => 422 | 27 | + render text: 'The provided XML was not well-formed', status: 422 |
28 | end | 28 | end |
29 | 29 | ||
30 | # Redirects a notice to the problem page. Useful when using User Information at Airbrake gem. | 30 | # Redirects a notice to the problem page. Useful when using User Information at Airbrake gem. |
@@ -45,6 +45,6 @@ private | @@ -45,6 +45,6 @@ private | ||
45 | end | 45 | end |
46 | 46 | ||
47 | def bad_params(exception) | 47 | def bad_params(exception) |
48 | - render :text => exception.message, :status => :bad_request | 48 | + render text: exception.message, status: :bad_request |
49 | end | 49 | end |
50 | end | 50 | end |
app/controllers/problems_controller.rb
@@ -7,12 +7,12 @@ | @@ -7,12 +7,12 @@ | ||
7 | class ProblemsController < ApplicationController | 7 | class ProblemsController < ApplicationController |
8 | include ProblemsSearcher | 8 | include ProblemsSearcher |
9 | 9 | ||
10 | - before_action :need_selected_problem, :only => [ | 10 | + before_action :need_selected_problem, only: [ |
11 | :resolve_several, :unresolve_several, :unmerge_several | 11 | :resolve_several, :unresolve_several, :unmerge_several |
12 | ] | 12 | ] |
13 | 13 | ||
14 | expose(:app_scope) { | 14 | expose(:app_scope) { |
15 | - params[:app_id] ? App.where(:_id => params[:app_id]) : App.all | 15 | + params[:app_id] ? App.where(_id: params[:app_id]) : App.all |
16 | } | 16 | } |
17 | 17 | ||
18 | expose(:app) { | 18 | expose(:app) { |
@@ -80,13 +80,13 @@ class ProblemsController < ApplicationController | @@ -80,13 +80,13 @@ class ProblemsController < ApplicationController | ||
80 | 80 | ||
81 | def resolve_several | 81 | def resolve_several |
82 | selected_problems.each(&:resolve!) | 82 | selected_problems.each(&:resolve!) |
83 | - flash[:success] = "Great news everyone! #{I18n.t(:n_errs_have, :count => selected_problems.count)} been resolved." | 83 | + flash[:success] = "Great news everyone! #{I18n.t(:n_errs_have, count: selected_problems.count)} been resolved." |
84 | redirect_to :back | 84 | redirect_to :back |
85 | end | 85 | end |
86 | 86 | ||
87 | def unresolve_several | 87 | def unresolve_several |
88 | selected_problems.each(&:unresolve!) | 88 | selected_problems.each(&:unresolve!) |
89 | - flash[:success] = "#{I18n.t(:n_errs_have, :count => selected_problems.count)} been unresolved." | 89 | + flash[:success] = "#{I18n.t(:n_errs_have, count: selected_problems.count)} been unresolved." |
90 | redirect_to :back | 90 | redirect_to :back |
91 | end | 91 | end |
92 | 92 | ||
@@ -100,26 +100,26 @@ class ProblemsController < ApplicationController | @@ -100,26 +100,26 @@ class ProblemsController < ApplicationController | ||
100 | flash[:notice] = I18n.t('controllers.problems.flash.need_two_errors_merge') | 100 | flash[:notice] = I18n.t('controllers.problems.flash.need_two_errors_merge') |
101 | else | 101 | else |
102 | ProblemMerge.new(selected_problems).merge | 102 | ProblemMerge.new(selected_problems).merge |
103 | - flash[:notice] = I18n.t('controllers.problems.flash.merge_several.success', :nb => selected_problems.count) | 103 | + flash[:notice] = I18n.t('controllers.problems.flash.merge_several.success', nb: selected_problems.count) |
104 | end | 104 | end |
105 | redirect_to :back | 105 | redirect_to :back |
106 | end | 106 | end |
107 | 107 | ||
108 | def unmerge_several | 108 | def unmerge_several |
109 | all = selected_problems.map(&:unmerge!).flatten | 109 | all = selected_problems.map(&:unmerge!).flatten |
110 | - flash[:success] = "#{I18n.t(:n_errs_have, :count => all.length)} been unmerged." | 110 | + flash[:success] = "#{I18n.t(:n_errs_have, count: all.length)} been unmerged." |
111 | redirect_to :back | 111 | redirect_to :back |
112 | end | 112 | end |
113 | 113 | ||
114 | def destroy_several | 114 | def destroy_several |
115 | nb_problem_destroy = ProblemDestroy.execute(selected_problems) | 115 | nb_problem_destroy = ProblemDestroy.execute(selected_problems) |
116 | - flash[:notice] = "#{I18n.t(:n_errs_have, :count => nb_problem_destroy)} been deleted." | 116 | + flash[:notice] = "#{I18n.t(:n_errs_have, count: nb_problem_destroy)} been deleted." |
117 | redirect_to :back | 117 | redirect_to :back |
118 | end | 118 | end |
119 | 119 | ||
120 | def destroy_all | 120 | def destroy_all |
121 | nb_problem_destroy = ProblemDestroy.execute(app.problems) | 121 | nb_problem_destroy = ProblemDestroy.execute(app.problems) |
122 | - flash[:success] = "#{I18n.t(:n_errs_have, :count => nb_problem_destroy)} been deleted." | 122 | + flash[:success] = "#{I18n.t(:n_errs_have, count: nb_problem_destroy)} been deleted." |
123 | redirect_to :back | 123 | redirect_to :back |
124 | rescue ActionController::RedirectBackError | 124 | rescue ActionController::RedirectBackError |
125 | redirect_to app_path(app) | 125 | redirect_to app_path(app) |
app/controllers/users/omniauth_callbacks_controller.rb
@@ -2,7 +2,7 @@ class Users::OmniauthCallbacksController < Devise::OmniauthCallbacksController | @@ -2,7 +2,7 @@ class Users::OmniauthCallbacksController < Devise::OmniauthCallbacksController | ||
2 | def github | 2 | def github |
3 | github_login = env["omniauth.auth"].extra.raw_info.login | 3 | github_login = env["omniauth.auth"].extra.raw_info.login |
4 | github_token = env["omniauth.auth"].credentials.token | 4 | github_token = env["omniauth.auth"].credentials.token |
5 | - github_user = User.where(:github_login => github_login).first | 5 | + github_user = User.where(github_login: github_login).first |
6 | github_site_title = Errbit::Config.github_site_title | 6 | github_site_title = Errbit::Config.github_site_title |
7 | 7 | ||
8 | if github_user.nil? && (github_org_id = Errbit::Config.github_org_id) | 8 | if github_user.nil? && (github_org_id = Errbit::Config.github_org_id) |
@@ -31,8 +31,8 @@ class Users::OmniauthCallbacksController < Devise::OmniauthCallbacksController | @@ -31,8 +31,8 @@ class Users::OmniauthCallbacksController < Devise::OmniauthCallbacksController | ||
31 | elsif github_user | 31 | elsif github_user |
32 | # Store OAuth token | 32 | # Store OAuth token |
33 | update_user_with_github_attributes(github_user, github_login, github_token) | 33 | update_user_with_github_attributes(github_user, github_login, github_token) |
34 | - flash[:success] = I18n.t "devise.omniauth_callbacks.success", :kind => github_site_title | ||
35 | - sign_in_and_redirect github_user, :event => :authentication | 34 | + flash[:success] = I18n.t "devise.omniauth_callbacks.success", kind: github_site_title |
35 | + sign_in_and_redirect github_user, event: :authentication | ||
36 | else | 36 | else |
37 | flash[:error] = "There are no authorized users with #{github_site_title} login '#{github_login}'. Please ask an administrator to register your user account." | 37 | flash[:error] = "There are no authorized users with #{github_site_title} login '#{github_login}'. Please ask an administrator to register your user account." |
38 | redirect_to new_user_session_path | 38 | redirect_to new_user_session_path |
@@ -41,8 +41,8 @@ class Users::OmniauthCallbacksController < Devise::OmniauthCallbacksController | @@ -41,8 +41,8 @@ class Users::OmniauthCallbacksController < Devise::OmniauthCallbacksController | ||
41 | 41 | ||
42 | private def update_user_with_github_attributes(user, login, token) | 42 | private def update_user_with_github_attributes(user, login, token) |
43 | user.update_attributes( | 43 | user.update_attributes( |
44 | - :github_login => login, | ||
45 | - :github_oauth_token => token | 44 | + github_login: login, |
45 | + github_oauth_token: token | ||
46 | ) | 46 | ) |
47 | end | 47 | end |
48 | end | 48 | end |
app/controllers/users_controller.rb
1 | class UsersController < ApplicationController | 1 | class UsersController < ApplicationController |
2 | respond_to :html | 2 | respond_to :html |
3 | 3 | ||
4 | - before_action :require_admin!, :except => [:edit, :update] | ||
5 | - before_action :require_user_edit_priviledges, :only => [:edit, :update] | 4 | + before_action :require_admin!, except: [:edit, :update] |
5 | + before_action :require_user_edit_priviledges, only: [:edit, :update] | ||
6 | 6 | ||
7 | - expose(:user, :attributes => :user_params) | 7 | + expose(:user, attributes: :user_params) |
8 | expose(:users) { | 8 | expose(:users) { |
9 | User.all.page(params[:page]).per(current_user.per_page) | 9 | User.all.page(params[:page]).per(current_user.per_page) |
10 | } | 10 | } |
@@ -24,7 +24,7 @@ class UsersController < ApplicationController | @@ -24,7 +24,7 @@ class UsersController < ApplicationController | ||
24 | 24 | ||
25 | def update | 25 | def update |
26 | if user.update_attributes(user_params) | 26 | if user.update_attributes(user_params) |
27 | - flash[:success] = I18n.t('controllers.users.flash.update.success', :name => user.name) | 27 | + flash[:success] = I18n.t('controllers.users.flash.update.success', name: user.name) |
28 | redirect_to user_path(user) | 28 | redirect_to user_path(user) |
29 | else | 29 | else |
30 | render :edit | 30 | render :edit |
@@ -41,13 +41,13 @@ class UsersController < ApplicationController | @@ -41,13 +41,13 @@ class UsersController < ApplicationController | ||
41 | flash[:error] = I18n.t('controllers.users.flash.destroy.error') | 41 | flash[:error] = I18n.t('controllers.users.flash.destroy.error') |
42 | else | 42 | else |
43 | UserDestroy.new(user).destroy | 43 | UserDestroy.new(user).destroy |
44 | - flash[:success] = I18n.t('controllers.users.flash.destroy.success', :name => user.name) | 44 | + flash[:success] = I18n.t('controllers.users.flash.destroy.success', name: user.name) |
45 | end | 45 | end |
46 | redirect_to users_path | 46 | redirect_to users_path |
47 | end | 47 | end |
48 | 48 | ||
49 | def unlink_github | 49 | def unlink_github |
50 | - user.update_attributes :github_login => nil, :github_oauth_token => nil | 50 | + user.update_attributes github_login: nil, github_oauth_token: nil |
51 | redirect_to user_path(user) | 51 | redirect_to user_path(user) |
52 | end | 52 | end |
53 | 53 |
app/controllers/watchers_controller.rb
@@ -6,7 +6,7 @@ class WatchersController < ApplicationController | @@ -6,7 +6,7 @@ class WatchersController < ApplicationController | ||
6 | end | 6 | end |
7 | 7 | ||
8 | def destroy | 8 | def destroy |
9 | - watcher = app.watchers.where(:user_id => params[:id]).first | 9 | + watcher = app.watchers.where(user_id: params[:id]).first |
10 | app.watchers.delete(watcher) | 10 | app.watchers.delete(watcher) |
11 | flash[:success] = t('.success', app: app.name) | 11 | flash[:success] = t('.success', app: app.name) |
12 | redirect_to app_path(app) | 12 | redirect_to app_path(app) |
app/decorators/app_decorator.rb
1 | class AppDecorator < Draper::Decorator | 1 | class AppDecorator < Draper::Decorator |
2 | decorates_association :watchers | 2 | decorates_association :watchers |
3 | - decorates_association :issue_tracker, :with => IssueTrackerDecorator | 3 | + decorates_association :issue_tracker, with: IssueTrackerDecorator |
4 | delegate_all | 4 | delegate_all |
5 | 5 | ||
6 | def email_at_notices | 6 | def email_at_notices |
app/decorators/backtrace_line_decorator.rb
@@ -67,25 +67,25 @@ private | @@ -67,25 +67,25 @@ private | ||
67 | 67 | ||
68 | def link_to_hosted_javascript(app, text) | 68 | def link_to_hosted_javascript(app, text) |
69 | if app.asset_host? | 69 | if app.asset_host? |
70 | - h.link_to(text, "#{app.asset_host}/#{file_relative}", :target => '_blank') | 70 | + h.link_to(text, "#{app.asset_host}/#{file_relative}", target: '_blank') |
71 | end | 71 | end |
72 | end | 72 | end |
73 | 73 | ||
74 | def link_to_github(app, text = nil) | 74 | def link_to_github(app, text = nil) |
75 | return unless app.github_repo? | 75 | return unless app.github_repo? |
76 | href = "%s#L%s" % [app.github_url_to_file(decorated_path + file_name), number] | 76 | href = "%s#L%s" % [app.github_url_to_file(decorated_path + file_name), number] |
77 | - h.link_to(text || file_name, href, :target => '_blank') | 77 | + h.link_to(text || file_name, href, target: '_blank') |
78 | end | 78 | end |
79 | 79 | ||
80 | def link_to_bitbucket(app, text = nil) | 80 | def link_to_bitbucket(app, text = nil) |
81 | return unless app.bitbucket_repo? | 81 | return unless app.bitbucket_repo? |
82 | href = "%s#%s-%s" % [app.bitbucket_url_to_file(decorated_path + file_name), file_name, number] | 82 | href = "%s#%s-%s" % [app.bitbucket_url_to_file(decorated_path + file_name), file_name, number] |
83 | - h.link_to(text || file_name, href, :target => '_blank') | 83 | + h.link_to(text || file_name, href, target: '_blank') |
84 | end | 84 | end |
85 | 85 | ||
86 | def link_to_issue_tracker_file(app, text = nil) | 86 | def link_to_issue_tracker_file(app, text = nil) |
87 | return unless app.issue_tracker && app.issue_tracker.respond_to?(:url_to_file) | 87 | return unless app.issue_tracker && app.issue_tracker.respond_to?(:url_to_file) |
88 | href = app.issue_tracker.url_to_file(file_relative, number) | 88 | href = app.issue_tracker.url_to_file(file_relative, number) |
89 | - h.link_to(text || file_name, href, :target => '_blank') | 89 | + h.link_to(text || file_name, href, target: '_blank') |
90 | end | 90 | end |
91 | end | 91 | end |
app/decorators/issue_tracker_field_decorator.rb
@@ -13,8 +13,8 @@ class IssueTrackerFieldDecorator < Draper::Decorator | @@ -13,8 +13,8 @@ class IssueTrackerFieldDecorator < Draper::Decorator | ||
13 | 13 | ||
14 | def input(form, issue_tracker) | 14 | def input(form, issue_tracker) |
15 | form.send(input_field, key.to_s, | 15 | form.send(input_field, key.to_s, |
16 | - :placeholder => field_info[:placeholder], | ||
17 | - :value => issue_tracker.options[key.to_s]) | 16 | + placeholder: field_info[:placeholder], |
17 | + value: issue_tracker.options[key.to_s]) | ||
18 | end | 18 | end |
19 | 19 | ||
20 | private def input_field | 20 | private def input_field |
app/helpers/application_helper.rb
@@ -13,7 +13,7 @@ module ApplicationHelper | @@ -13,7 +13,7 @@ module ApplicationHelper | ||
13 | event.dtend = notice.created_at.utc + 60.minutes | 13 | event.dtend = notice.created_at.utc + 60.minutes |
14 | event.organizer = notice.server_environment && notice.server_environment["hostname"] | 14 | event.organizer = notice.server_environment && notice.server_environment["hostname"] |
15 | event.location = notice.project_root | 15 | event.location = notice.project_root |
16 | - event.url = app_problem_url(:app_id => notice.problem.app.id, :id => notice.problem) | 16 | + event.url = app_problem_url(app_id: notice.problem.app.id, id: notice.problem) |
17 | end | 17 | end |
18 | end | 18 | end |
19 | end.to_s | 19 | end.to_s |
@@ -58,7 +58,7 @@ module ApplicationHelper | @@ -58,7 +58,7 @@ module ApplicationHelper | ||
58 | percent = 100.0 / total.to_f | 58 | percent = 100.0 / total.to_f |
59 | rows = tallies.map { |value, count| [(count.to_f * percent), value] }. \ | 59 | rows = tallies.map { |value, count| [(count.to_f * percent), value] }. \ |
60 | sort { |a, b| b[0] <=> a[0] } | 60 | sort { |a, b| b[0] <=> a[0] } |
61 | - render "problems/tally_table", :rows => rows | 61 | + render "problems/tally_table", rows: rows |
62 | end | 62 | end |
63 | 63 | ||
64 | def head(collection) | 64 | def head(collection) |
app/helpers/apps_helper.rb
@@ -2,11 +2,11 @@ module AppsHelper | @@ -2,11 +2,11 @@ module AppsHelper | ||
2 | def link_to_copy_attributes_from_other_app | 2 | def link_to_copy_attributes_from_other_app |
3 | if App.count > 1 | 3 | if App.count > 1 |
4 | html = link_to('copy settings from another app', '#', | 4 | html = link_to('copy settings from another app', '#', |
5 | - :class => 'button copy_config') | 5 | + class: 'button copy_config') |
6 | html << select("duplicate", "app", | 6 | html << select("duplicate", "app", |
7 | App.all.asc(:name).reject { |a| a == @app }. | 7 | App.all.asc(:name).reject { |a| a == @app }. |
8 | - collect { |p| [p.name, p.id] }, { :include_blank => "[choose app]" }, | ||
9 | - { :class => "choose_other_app", :style => "display: none;" }) | 8 | + collect { |p| [p.name, p.id] }, { include_blank: "[choose app]" }, |
9 | + { class: "choose_other_app", style: "display: none;" }) | ||
10 | return html | 10 | return html |
11 | end | 11 | end |
12 | end | 12 | end |
app/helpers/form_helper.rb
@@ -2,7 +2,7 @@ module FormHelper | @@ -2,7 +2,7 @@ module FormHelper | ||
2 | def errors_for(document) | 2 | def errors_for(document) |
3 | return unless document.errors.any? | 3 | return unless document.errors.any? |
4 | 4 | ||
5 | - content_tag(:div, :class => 'error-messages') do | 5 | + content_tag(:div, class: 'error-messages') do |
6 | body = content_tag(:h2, 'Dang. The following errors are keeping this from being a success.') | 6 | body = content_tag(:h2, 'Dang. The following errors are keeping this from being a success.') |
7 | body + content_tag(:ul) do | 7 | body + content_tag(:ul) do |
8 | document.errors.full_messages.inject('') do |errs, msg| | 8 | document.errors.full_messages.inject('') do |errs, msg| |
app/helpers/notices_helper.rb
app/helpers/problems_helper.rb
@@ -6,21 +6,21 @@ module ProblemsHelper | @@ -6,21 +6,21 @@ module ProblemsHelper | ||
6 | def truncated_problem_message(problem) | 6 | def truncated_problem_message(problem) |
7 | unless (msg = problem.message).blank? | 7 | unless (msg = problem.message).blank? |
8 | # Truncate & insert invisible chars so that firefox can emulate 'word-wrap: break-word' CSS rule | 8 | # Truncate & insert invisible chars so that firefox can emulate 'word-wrap: break-word' CSS rule |
9 | - truncate(msg, :length => 300, :escape => false).scan(/.{1,5}/).map { |s| h(s) }.join("​").html_safe | 9 | + truncate(msg, length: 300, escape: false).scan(/.{1,5}/).map { |s| h(s) }.join("​").html_safe |
10 | end | 10 | end |
11 | end | 11 | end |
12 | 12 | ||
13 | def gravatar_tag(email, options = {}) | 13 | def gravatar_tag(email, options = {}) |
14 | return nil unless email.present? | 14 | return nil unless email.present? |
15 | 15 | ||
16 | - image_tag gravatar_url(email, options), :alt => email, :class => 'gravatar' | 16 | + image_tag gravatar_url(email, options), alt: email, class: 'gravatar' |
17 | end | 17 | end |
18 | 18 | ||
19 | def gravatar_url(email, options = {}) | 19 | def gravatar_url(email, options = {}) |
20 | return nil unless email.present? | 20 | return nil unless email.present? |
21 | 21 | ||
22 | default_options = { | 22 | default_options = { |
23 | - :d => Errbit::Config.gravatar_default | 23 | + d: Errbit::Config.gravatar_default |
24 | } | 24 | } |
25 | options.reverse_merge! default_options | 25 | options.reverse_merge! default_options |
26 | params = options.extract!(:s, :d).delete_if { |_k, v| v.blank? } | 26 | params = options.extract!(:s, :d).delete_if { |_k, v| v.blank? } |
app/helpers/sort_helper.rb
@@ -6,7 +6,7 @@ module SortHelper | @@ -6,7 +6,7 @@ module SortHelper | ||
6 | order = (current && (params_order == "asc")) ? "desc" : "asc" | 6 | order = (current && (params_order == "asc")) ? "desc" : "asc" |
7 | url = request.path + "?sort=#{field}&order=#{order}" | 7 | url = request.path + "?sort=#{field}&order=#{order}" |
8 | options = {} | 8 | options = {} |
9 | - options.merge!(:class => "current #{order}") if current | 9 | + options.merge!(class: "current #{order}") if current |
10 | link_to(name, url, options) | 10 | link_to(name, url, options) |
11 | end | 11 | end |
12 | end | 12 | end |
app/interactors/problem_destroy.rb
@@ -36,11 +36,11 @@ private | @@ -36,11 +36,11 @@ private | ||
36 | end | 36 | end |
37 | 37 | ||
38 | def delete_errs | 38 | def delete_errs |
39 | - Notice.delete_all(:err_id => { '$in' => errs_id }) | ||
40 | - Err.delete_all(:_id => { '$in' => errs_id }) | 39 | + Notice.delete_all(err_id: { '$in' => errs_id }) |
40 | + Err.delete_all(_id: { '$in' => errs_id }) | ||
41 | end | 41 | end |
42 | 42 | ||
43 | def delete_comments | 43 | def delete_comments |
44 | - Comment.delete_all(:_id => { '$in' => comments_id }) | 44 | + Comment.delete_all(_id: { '$in' => comments_id }) |
45 | end | 45 | end |
46 | end | 46 | end |
app/interactors/resolved_problem_clearer.rb
app/mailers/mailer.rb
@@ -23,8 +23,8 @@ class Mailer < ActionMailer::Base | @@ -23,8 +23,8 @@ class Mailer < ActionMailer::Base | ||
23 | 'Environment' => @notice.environment_name, | 23 | 'Environment' => @notice.environment_name, |
24 | 'Error-Id' => @notice.err_id | 24 | 'Error-Id' => @notice.err_id |
25 | 25 | ||
26 | - mail :to => @app.notification_recipients, | ||
27 | - :subject => "#{count}[#{@app.name}][#{@notice.environment_name}] #{@notice.message.truncate(50)}" | 26 | + mail to: @app.notification_recipients, |
27 | + subject: "#{count}[#{@app.name}][#{@notice.environment_name}] #{@notice.message.truncate(50)}" | ||
28 | end | 28 | end |
29 | 29 | ||
30 | def deploy_notification(deploy) | 30 | def deploy_notification(deploy) |
@@ -36,8 +36,8 @@ class Mailer < ActionMailer::Base | @@ -36,8 +36,8 @@ class Mailer < ActionMailer::Base | ||
36 | 'Deploy-Revision' => @deploy.revision, | 36 | 'Deploy-Revision' => @deploy.revision, |
37 | 'Deploy-User' => @deploy.username | 37 | 'Deploy-User' => @deploy.username |
38 | 38 | ||
39 | - mail :to => @app.notification_recipients, | ||
40 | - :subject => "[#{@app.name}] Deployed to #{@deploy.environment} by #{@deploy.username}" | 39 | + mail to: @app.notification_recipients, |
40 | + subject: "[#{@app.name}] Deployed to #{@deploy.environment} by #{@deploy.username}" | ||
41 | end | 41 | end |
42 | 42 | ||
43 | def comment_notification(comment) | 43 | def comment_notification(comment) |
@@ -54,8 +54,8 @@ class Mailer < ActionMailer::Base | @@ -54,8 +54,8 @@ class Mailer < ActionMailer::Base | ||
54 | 'Problem-Id' => @problem.id, | 54 | 'Problem-Id' => @problem.id, |
55 | 'Comment-Author' => @user.name | 55 | 'Comment-Author' => @user.name |
56 | 56 | ||
57 | - mail :to => recipients, | ||
58 | - :subject => "#{@user.name} commented on [#{@app.name}][#{@notice.environment_name}] #{@notice.message.truncate(50)}" | 57 | + mail to: recipients, |
58 | + subject: "#{@user.name} commented on [#{@app.name}][#{@notice.environment_name}] #{@notice.message.truncate(50)}" | ||
59 | end | 59 | end |
60 | 60 | ||
61 | private def errbit_headers(header) | 61 | private def errbit_headers(header) |
app/models/app.rb
@@ -3,51 +3,54 @@ class App | @@ -3,51 +3,54 @@ class App | ||
3 | include Mongoid::Document | 3 | include Mongoid::Document |
4 | include Mongoid::Timestamps | 4 | include Mongoid::Timestamps |
5 | 5 | ||
6 | - field :name, :type => String | 6 | + field :name, type: String |
7 | field :api_key | 7 | field :api_key |
8 | field :github_repo | 8 | field :github_repo |
9 | field :bitbucket_repo | 9 | field :bitbucket_repo |
10 | field :asset_host | 10 | field :asset_host |
11 | field :repository_branch | 11 | field :repository_branch |
12 | field :current_app_version | 12 | field :current_app_version |
13 | - field :resolve_errs_on_deploy, :type => Boolean, :default => false | ||
14 | - field :notify_all_users, :type => Boolean, :default => false | ||
15 | - field :notify_on_errs, :type => Boolean, :default => true | ||
16 | - field :notify_on_deploys, :type => Boolean, :default => false | ||
17 | - field :email_at_notices, :type => Array, :default => Errbit::Config.email_at_notices | 13 | + field :resolve_errs_on_deploy, type: Boolean, default: false |
14 | + field :notify_all_users, type: Boolean, default: false | ||
15 | + field :notify_on_errs, type: Boolean, default: true | ||
16 | + field :notify_on_deploys, type: Boolean, default: false | ||
17 | + field :email_at_notices, type: Array, default: Errbit::Config.email_at_notices | ||
18 | 18 | ||
19 | # Some legacy apps may have string as key instead of BSON::ObjectID | 19 | # Some legacy apps may have string as key instead of BSON::ObjectID |
20 | # identity :type => String | 20 | # identity :type => String |
21 | field :_id, | 21 | field :_id, |
22 | - type: String, | 22 | + type: String, |
23 | pre_processed: true, | 23 | pre_processed: true, |
24 | - default: -> { BSON::ObjectId.new.to_s } | 24 | + default: -> { BSON::ObjectId.new.to_s } |
25 | 25 | ||
26 | embeds_many :watchers | 26 | embeds_many :watchers |
27 | embeds_many :deploys | 27 | embeds_many :deploys |
28 | - embeds_one :issue_tracker, :class_name => 'IssueTracker' | 28 | + embeds_one :issue_tracker, class_name: 'IssueTracker' |
29 | embeds_one :notification_service | 29 | embeds_one :notification_service |
30 | embeds_one :notice_fingerprinter, autobuild: true | 30 | embeds_one :notice_fingerprinter, autobuild: true |
31 | 31 | ||
32 | - has_many :problems, :inverse_of => :app, :dependent => :destroy | 32 | + has_many :problems, inverse_of: :app, dependent: :destroy |
33 | 33 | ||
34 | - before_validation :generate_api_key, :on => :create | 34 | + before_validation :generate_api_key, on: :create |
35 | before_save :normalize_github_repo | 35 | before_save :normalize_github_repo |
36 | after_update :store_cached_attributes_on_problems | 36 | after_update :store_cached_attributes_on_problems |
37 | 37 | ||
38 | validates_presence_of :name, :api_key | 38 | validates_presence_of :name, :api_key |
39 | - validates_uniqueness_of :name, :allow_blank => true | ||
40 | - validates_uniqueness_of :api_key, :allow_blank => true | 39 | + validates_uniqueness_of :name, allow_blank: true |
40 | + validates_uniqueness_of :api_key, allow_blank: true | ||
41 | validates_associated :watchers | 41 | validates_associated :watchers |
42 | validates_associated :notice_fingerprinter | 42 | validates_associated :notice_fingerprinter |
43 | validate :check_issue_tracker | 43 | validate :check_issue_tracker |
44 | 44 | ||
45 | - accepts_nested_attributes_for :watchers, :allow_destroy => true, | ||
46 | - :reject_if => proc { |attrs| attrs[:user_id].blank? && attrs[:email].blank? } | ||
47 | - accepts_nested_attributes_for :issue_tracker, :allow_destroy => true, | ||
48 | - :reject_if => proc { |attrs| !ErrbitPlugin::Registry.issue_trackers.keys.map(&:to_s).include?(attrs[:type_tracker].to_s) } | ||
49 | - accepts_nested_attributes_for :notification_service, :allow_destroy => true, | ||
50 | - :reject_if => proc { |attrs| !NotificationService.subclasses.map(&:to_s).include?(attrs[:type].to_s) } | 45 | + accepts_nested_attributes_for :watchers, |
46 | + allow_destroy: true, | ||
47 | + reject_if: proc { |attrs| attrs[:user_id].blank? && attrs[:email].blank? } | ||
48 | + accepts_nested_attributes_for :issue_tracker, | ||
49 | + allow_destroy: true, | ||
50 | + reject_if: proc { |attrs| !ErrbitPlugin::Registry.issue_trackers.keys.map(&:to_s).include?(attrs[:type_tracker].to_s) } | ||
51 | + accepts_nested_attributes_for :notification_service, | ||
52 | + allow_destroy: true, | ||
53 | + reject_if: proc { |attrs| !NotificationService.subclasses.map(&:to_s).include?(attrs[:type].to_s) } | ||
51 | accepts_nested_attributes_for :notice_fingerprinter | 54 | accepts_nested_attributes_for :notice_fingerprinter |
52 | 55 | ||
53 | scope :watched_by, ->(user) do | 56 | scope :watched_by, ->(user) do |
@@ -71,7 +74,7 @@ class App | @@ -71,7 +74,7 @@ class App | ||
71 | problem = problems.create!( | 74 | problem = problems.create!( |
72 | error_class: attrs[:error_class], | 75 | error_class: attrs[:error_class], |
73 | environment: attrs[:environment], | 76 | environment: attrs[:environment], |
74 | - app_name: name | 77 | + app_name: name |
75 | ) | 78 | ) |
76 | problem.errs.create!(attrs.slice(:fingerprint, :problem_id)) | 79 | problem.errs.create!(attrs.slice(:fingerprint, :problem_id)) |
77 | end | 80 | end |
@@ -82,7 +85,7 @@ class App | @@ -82,7 +85,7 @@ class App | ||
82 | end | 85 | end |
83 | 86 | ||
84 | def self.find_by_api_key!(key) | 87 | def self.find_by_api_key!(key) |
85 | - find_by(:api_key => key) | 88 | + find_by(api_key: key) |
86 | end | 89 | end |
87 | 90 | ||
88 | def last_deploy_at | 91 | def last_deploy_at |
@@ -151,7 +154,7 @@ class App | @@ -151,7 +154,7 @@ class App | ||
151 | 154 | ||
152 | # Copy app attributes from another app. | 155 | # Copy app attributes from another app. |
153 | def copy_attributes_from(app_id) | 156 | def copy_attributes_from(app_id) |
154 | - if (copy_app = App.where(:_id => app_id).first) | 157 | + if (copy_app = App.where(_id: app_id).first) |
155 | # Copy fields | 158 | # Copy fields |
156 | (copy_app.fields.keys - %w(_id name created_at updated_at)).each do |k| | 159 | (copy_app.fields.keys - %w(_id name created_at updated_at)).each do |k| |
157 | send("#{k}=", copy_app.send(k)) | 160 | send("#{k}=", copy_app.send(k)) |
@@ -191,7 +194,7 @@ class App | @@ -191,7 +194,7 @@ class App | ||
191 | protected | 194 | protected |
192 | 195 | ||
193 | def store_cached_attributes_on_problems | 196 | def store_cached_attributes_on_problems |
194 | - Problem.where(:app_id => id).update_all( | 197 | + Problem.where(app_id: id).update_all( |
195 | app_name: name | 198 | app_name: name |
196 | ) | 199 | ) |
197 | end | 200 | end |
app/models/backtrace.rb
@@ -8,7 +8,7 @@ class Backtrace | @@ -8,7 +8,7 @@ class Backtrace | ||
8 | field :fingerprint | 8 | field :fingerprint |
9 | field :lines | 9 | field :lines |
10 | 10 | ||
11 | - index :fingerprint => 1 | 11 | + index fingerprint: 1 |
12 | 12 | ||
13 | def self.find_or_create(lines) | 13 | def self.find_or_create(lines) |
14 | fingerprint = generate_fingerprint(lines) | 14 | fingerprint = generate_fingerprint(lines) |
app/models/comment.rb
@@ -5,14 +5,14 @@ class Comment | @@ -5,14 +5,14 @@ class Comment | ||
5 | after_create :increase_counter_cache | 5 | after_create :increase_counter_cache |
6 | before_destroy :decrease_counter_cache | 6 | before_destroy :decrease_counter_cache |
7 | 7 | ||
8 | - after_create :deliver_email, :if => :emailable? | 8 | + after_create :deliver_email, if: :emailable? |
9 | 9 | ||
10 | - field :body, :type => String | ||
11 | - index(:user_id => 1) | 10 | + field :body, type: String |
11 | + index(user_id: 1) | ||
12 | 12 | ||
13 | - belongs_to :err, :class_name => "Problem" | 13 | + belongs_to :err, class_name: "Problem" |
14 | belongs_to :user | 14 | belongs_to :user |
15 | - delegate :app, :to => :err | 15 | + delegate :app, to: :err |
16 | 16 | ||
17 | validates_presence_of :body | 17 | validates_presence_of :body |
18 | 18 |
app/models/deploy.rb
@@ -8,11 +8,11 @@ class Deploy | @@ -8,11 +8,11 @@ class Deploy | ||
8 | field :revision | 8 | field :revision |
9 | field :message | 9 | field :message |
10 | 10 | ||
11 | - index(:created_at => -1) | 11 | + index(created_at: -1) |
12 | 12 | ||
13 | - embedded_in :app, :inverse_of => :deploys | 13 | + embedded_in :app, inverse_of: :deploys |
14 | 14 | ||
15 | - after_create :resolve_app_errs, :if => :should_resolve_app_errs? | 15 | + after_create :resolve_app_errs, if: :should_resolve_app_errs? |
16 | after_create :store_cached_attributes_on_problems | 16 | after_create :store_cached_attributes_on_problems |
17 | after_create :deliver_email | 17 | after_create :deliver_email |
18 | 18 | ||
@@ -33,7 +33,7 @@ protected | @@ -33,7 +33,7 @@ protected | ||
33 | end | 33 | end |
34 | 34 | ||
35 | def store_cached_attributes_on_problems | 35 | def store_cached_attributes_on_problems |
36 | - Problem.where(:app_id => app.id).update_all( | 36 | + Problem.where(app_id: app.id).update_all( |
37 | last_deploy_at: created_at | 37 | last_deploy_at: created_at |
38 | ) | 38 | ) |
39 | end | 39 | end |
app/models/err.rb
@@ -12,9 +12,9 @@ class Err | @@ -12,9 +12,9 @@ class Err | ||
12 | index fingerprint: 1 | 12 | index fingerprint: 1 |
13 | 13 | ||
14 | belongs_to :problem | 14 | belongs_to :problem |
15 | - has_many :notices, :inverse_of => :err, :dependent => :destroy | 15 | + has_many :notices, inverse_of: :err, dependent: :destroy |
16 | 16 | ||
17 | validates_presence_of :problem_id, :fingerprint | 17 | validates_presence_of :problem_id, :fingerprint |
18 | 18 | ||
19 | - delegate :app, :resolved?, :to => :problem | 19 | + delegate :app, :resolved?, to: :problem |
20 | end | 20 | end |
app/models/error_report.rb
@@ -61,15 +61,15 @@ class ErrorReport | @@ -61,15 +61,15 @@ class ErrorReport | ||
61 | 61 | ||
62 | def make_notice | 62 | def make_notice |
63 | @notice = Notice.new( | 63 | @notice = Notice.new( |
64 | - app: app, | ||
65 | - message: message, | ||
66 | - error_class: error_class, | ||
67 | - backtrace: backtrace, | ||
68 | - request: request, | 64 | + app: app, |
65 | + message: message, | ||
66 | + error_class: error_class, | ||
67 | + backtrace: backtrace, | ||
68 | + request: request, | ||
69 | server_environment: server_environment, | 69 | server_environment: server_environment, |
70 | - notifier: notifier, | ||
71 | - user_attributes: user_attributes, | ||
72 | - framework: framework | 70 | + notifier: notifier, |
71 | + user_attributes: user_attributes, | ||
72 | + framework: framework | ||
73 | ) | 73 | ) |
74 | end | 74 | end |
75 | 75 |
app/models/issue_tracker.rb
@@ -2,10 +2,10 @@ class IssueTracker | @@ -2,10 +2,10 @@ class IssueTracker | ||
2 | include Mongoid::Document | 2 | include Mongoid::Document |
3 | include Mongoid::Timestamps | 3 | include Mongoid::Timestamps |
4 | 4 | ||
5 | - embedded_in :app, :inverse_of => :issue_tracker | 5 | + embedded_in :app, inverse_of: :issue_tracker |
6 | 6 | ||
7 | - field :type_tracker, :type => String | ||
8 | - field :options, :type => Hash, :default => {} | 7 | + field :type_tracker, type: String |
8 | + field :options, type: Hash, default: {} | ||
9 | 9 | ||
10 | validate :validate_tracker | 10 | validate :validate_tracker |
11 | 11 | ||
@@ -15,7 +15,7 @@ class IssueTracker | @@ -15,7 +15,7 @@ class IssueTracker | ||
15 | klass = ErrbitPlugin::Registry.issue_trackers[type_tracker] || ErrbitPlugin::NoneIssueTracker | 15 | klass = ErrbitPlugin::Registry.issue_trackers[type_tracker] || ErrbitPlugin::NoneIssueTracker |
16 | # TODO: we need to find out a better way to pass those config to the issue tracker | 16 | # TODO: we need to find out a better way to pass those config to the issue tracker |
17 | klass.new(options.merge( | 17 | klass.new(options.merge( |
18 | - github_repo: app.try(:github_repo), | 18 | + github_repo: app.try(:github_repo), |
19 | bitbucket_repo: app.try(:bitbucket_repo) | 19 | bitbucket_repo: app.try(:bitbucket_repo) |
20 | )) | 20 | )) |
21 | end | 21 | end |
@@ -32,7 +32,7 @@ class IssueTracker | @@ -32,7 +32,7 @@ class IssueTracker | ||
32 | end | 32 | end |
33 | end | 33 | end |
34 | 34 | ||
35 | - delegate :configured?, :to => :tracker | ||
36 | - delegate :create_issue, :to => :tracker | ||
37 | - delegate :url, :to => :tracker | 35 | + delegate :configured?, to: :tracker |
36 | + delegate :create_issue, to: :tracker | ||
37 | + delegate :url, to: :tracker | ||
38 | end | 38 | end |
app/models/notice.rb
@@ -5,21 +5,21 @@ class Notice | @@ -5,21 +5,21 @@ class Notice | ||
5 | include Mongoid::Timestamps | 5 | include Mongoid::Timestamps |
6 | 6 | ||
7 | field :message | 7 | field :message |
8 | - field :server_environment, :type => Hash | ||
9 | - field :request, :type => Hash | ||
10 | - field :notifier, :type => Hash | ||
11 | - field :user_attributes, :type => Hash | 8 | + field :server_environment, type: Hash |
9 | + field :request, type: Hash | ||
10 | + field :notifier, type: Hash | ||
11 | + field :user_attributes, type: Hash | ||
12 | field :framework | 12 | field :framework |
13 | field :error_class | 13 | field :error_class |
14 | - delegate :lines, :to => :backtrace, :prefix => true | ||
15 | - delegate :problem, :to => :err | 14 | + delegate :lines, to: :backtrace, prefix: true |
15 | + delegate :problem, to: :err | ||
16 | 16 | ||
17 | belongs_to :app | 17 | belongs_to :app |
18 | belongs_to :err | 18 | belongs_to :err |
19 | - belongs_to :backtrace, :index => true | 19 | + belongs_to :backtrace, index: true |
20 | 20 | ||
21 | - index(:created_at => 1) | ||
22 | - index(:err_id => 1, :created_at => 1, :_id => 1) | 21 | + index(created_at: 1) |
22 | + index(err_id: 1, created_at: 1, _id: 1) | ||
23 | 23 | ||
24 | before_save :sanitize | 24 | before_save :sanitize |
25 | before_destroy :problem_recache | 25 | before_destroy :problem_recache |
app/models/notification_service.rb
@@ -5,22 +5,22 @@ class NotificationService | @@ -5,22 +5,22 @@ class NotificationService | ||
5 | default_url_options[:host] = ActionMailer::Base.default_url_options[:host] | 5 | default_url_options[:host] = ActionMailer::Base.default_url_options[:host] |
6 | default_url_options[:port] = ActionMailer::Base.default_url_options[:port] | 6 | default_url_options[:port] = ActionMailer::Base.default_url_options[:port] |
7 | 7 | ||
8 | - field :room_id, :type => String | ||
9 | - field :user_id, :type => String | ||
10 | - field :service_url, :type => String | ||
11 | - field :service, :type => String | ||
12 | - field :api_token, :type => String | ||
13 | - field :subdomain, :type => String | ||
14 | - field :sender_name, :type => String | ||
15 | - field :notify_at_notices, :type => Array, :default => Errbit::Config.notify_at_notices | ||
16 | - embedded_in :app, :inverse_of => :notification_service | 8 | + field :room_id, type: String |
9 | + field :user_id, type: String | ||
10 | + field :service_url, type: String | ||
11 | + field :service, type: String | ||
12 | + field :api_token, type: String | ||
13 | + field :subdomain, type: String | ||
14 | + field :sender_name, type: String | ||
15 | + field :notify_at_notices, type: Array, default: Errbit::Config.notify_at_notices | ||
16 | + embedded_in :app, inverse_of: :notification_service | ||
17 | 17 | ||
18 | validate :check_params | 18 | validate :check_params |
19 | 19 | ||
20 | if Errbit::Config.per_app_notify_at_notices | 20 | if Errbit::Config.per_app_notify_at_notices |
21 | FIELDS = [[:notify_at_notices, | 21 | FIELDS = [[:notify_at_notices, |
22 | - { :placeholder => 'comma separated numbers or simply 0 for every notice', | ||
23 | - :label => 'notify on errors (0 for all errors)' | 22 | + { placeholder: 'comma separated numbers or simply 0 for every notice', |
23 | + label: 'notify on errors (0 for all errors)' | ||
24 | } | 24 | } |
25 | ]] | 25 | ]] |
26 | else | 26 | else |
app/models/notification_services/campfire_service.rb
@@ -3,16 +3,16 @@ if defined? Campy | @@ -3,16 +3,16 @@ if defined? Campy | ||
3 | LABEL = "campfire" | 3 | LABEL = "campfire" |
4 | FIELDS += [ | 4 | FIELDS += [ |
5 | [:subdomain, { | 5 | [:subdomain, { |
6 | - :label => "Subdomain", | ||
7 | - :placeholder => "subdomain from http://{{subdomain}}.campfirenow.com" | 6 | + label: "Subdomain", |
7 | + placeholder: "subdomain from http://{{subdomain}}.campfirenow.com" | ||
8 | }], | 8 | }], |
9 | [:api_token, { | 9 | [:api_token, { |
10 | - :label => "API Token", | ||
11 | - :placeholder => "123456789abcdef123456789abcdef" | 10 | + label: "API Token", |
11 | + placeholder: "123456789abcdef123456789abcdef" | ||
12 | }], | 12 | }], |
13 | [:room_id, { | 13 | [:room_id, { |
14 | - :label => "Room ID", | ||
15 | - :placeholder => "123456" | 14 | + label: "Room ID", |
15 | + placeholder: "123456" | ||
16 | }] | 16 | }] |
17 | ] | 17 | ] |
18 | 18 | ||
@@ -28,7 +28,7 @@ if defined? Campy | @@ -28,7 +28,7 @@ if defined? Campy | ||
28 | 28 | ||
29 | def create_notification(problem) | 29 | def create_notification(problem) |
30 | # build the campfire client | 30 | # build the campfire client |
31 | - campy = Campy::Room.new(:account => subdomain, :token => api_token, :room_id => room_id) | 31 | + campy = Campy::Room.new(account: subdomain, token: api_token, room_id: room_id) |
32 | # post the issue to the campfire room | 32 | # post the issue to the campfire room |
33 | campy.speak "[errbit] #{problem.app.name} #{notification_description problem} - #{Errbit::Config.protocol}://#{Errbit::Config.host}/apps/#{problem.app.id}/problems/#{problem.id}" | 33 | campy.speak "[errbit] #{problem.app.name} #{notification_description problem} - #{Errbit::Config.protocol}://#{Errbit::Config.host}/apps/#{problem.app.id}/problems/#{problem.id}" |
34 | end | 34 | end |
app/models/notification_services/flowdock_service.rb
@@ -4,8 +4,8 @@ if defined? Flowdock | @@ -4,8 +4,8 @@ if defined? Flowdock | ||
4 | FIELDS += [ | 4 | FIELDS += [ |
5 | [ | 5 | [ |
6 | :api_token, { | 6 | :api_token, { |
7 | - :label => 'Flow API Token', | ||
8 | - :placeholder => '123456789abcdef123456789abcdefgh' | 7 | + label: 'Flow API Token', |
8 | + placeholder: '123456789abcdef123456789abcdefgh' | ||
9 | } | 9 | } |
10 | ] | 10 | ] |
11 | ] | 11 | ] |
@@ -21,10 +21,10 @@ if defined? Flowdock | @@ -21,10 +21,10 @@ if defined? Flowdock | ||
21 | end | 21 | end |
22 | 22 | ||
23 | def create_notification(problem) | 23 | def create_notification(problem) |
24 | - flow = Flowdock::Flow.new(:api_token => api_token, :source => "Errbit", :from => { :name => "Errbit", :address => ENV['ERRBIT_EMAIL_FROM'] || 'support@flowdock.com' }) | 24 | + flow = Flowdock::Flow.new(api_token: api_token, source: "Errbit", from: { name: "Errbit", address: ENV['ERRBIT_EMAIL_FROM'] || 'support@flowdock.com' }) |
25 | subject = "[#{problem.environment}] #{problem.message.to_s.truncate(100)}" | 25 | subject = "[#{problem.environment}] #{problem.message.to_s.truncate(100)}" |
26 | url = app_problem_url problem.app, problem | 26 | url = app_problem_url problem.app, problem |
27 | - flow.push_to_team_inbox(:subject => subject, :content => content(problem, url), :project => project_name(problem), :link => url) | 27 | + flow.push_to_team_inbox(subject: subject, content: content(problem, url), project: project_name(problem), link: url) |
28 | end | 28 | end |
29 | 29 | ||
30 | private | 30 | private |
app/models/notification_services/gtalk_service.rb
@@ -2,28 +2,28 @@ class NotificationServices::GtalkService < NotificationService | @@ -2,28 +2,28 @@ class NotificationServices::GtalkService < NotificationService | ||
2 | LABEL = "gtalk" | 2 | LABEL = "gtalk" |
3 | FIELDS += [ | 3 | FIELDS += [ |
4 | [:subdomain, { | 4 | [:subdomain, { |
5 | - :placeholder => "username@example.com", | ||
6 | - :label => "Username" | 5 | + placeholder: "username@example.com", |
6 | + label: "Username" | ||
7 | }], | 7 | }], |
8 | [:api_token, { | 8 | [:api_token, { |
9 | - :placeholder => "password", | ||
10 | - :label => "Password" | 9 | + placeholder: "password", |
10 | + label: "Password" | ||
11 | }], | 11 | }], |
12 | [:user_id, { | 12 | [:user_id, { |
13 | - :placeholder => "touser@example.com, anotheruser@example.com", | ||
14 | - :label => "Send To User(s)" | 13 | + placeholder: "touser@example.com, anotheruser@example.com", |
14 | + label: "Send To User(s)" | ||
15 | }, :room_id], | 15 | }, :room_id], |
16 | [:room_id, { | 16 | [:room_id, { |
17 | - :placeholder => "toroom@conference.example.com", | ||
18 | - :label => "Send To Room (one only)" | 17 | + placeholder: "toroom@conference.example.com", |
18 | + label: "Send To Room (one only)" | ||
19 | }, :user_id], | 19 | }, :user_id], |
20 | [:service, { | 20 | [:service, { |
21 | - :placeholder => "talk.google.com", | ||
22 | - :label => "Jabber Service" | 21 | + placeholder: "talk.google.com", |
22 | + label: "Jabber Service" | ||
23 | }], | 23 | }], |
24 | [:service_url, { | 24 | [:service_url, { |
25 | - :placeholder => "http://www.google.com/talk/", | ||
26 | - :label => "Link To Jabber Service" | 25 | + placeholder: "http://www.google.com/talk/", |
26 | + label: "Link To Jabber Service" | ||
27 | }] | 27 | }] |
28 | ] | 28 | ] |
29 | 29 |
app/models/notification_services/hipchat_service.rb
@@ -3,20 +3,20 @@ if defined? HipChat | @@ -3,20 +3,20 @@ if defined? HipChat | ||
3 | LABEL = 'hipchat' | 3 | LABEL = 'hipchat' |
4 | FIELDS += [ | 4 | FIELDS += [ |
5 | [:service, { | 5 | [:service, { |
6 | - :placeholder => "'v1' (admin API token) or 'v2' (account API token)", | ||
7 | - :label => "HipChat API version" | 6 | + placeholder: "'v1' (admin API token) or 'v2' (account API token)", |
7 | + label: "HipChat API version" | ||
8 | }], | 8 | }], |
9 | [:service_url, { | 9 | [:service_url, { |
10 | - :placeholder => "Optional, leave empty for HipChat.com", | ||
11 | - :label => "Custom HipChat Server URL" | 10 | + placeholder: "Optional, leave empty for HipChat.com", |
11 | + label: "Custom HipChat Server URL" | ||
12 | }], | 12 | }], |
13 | [:api_token, { | 13 | [:api_token, { |
14 | - :placeholder => "API token", | ||
15 | - :label => "API token" | 14 | + placeholder: "API token", |
15 | + label: "API token" | ||
16 | }], | 16 | }], |
17 | [:room_id, { | 17 | [:room_id, { |
18 | - :placeholder => "Room name", | ||
19 | - :label => "Room name" | 18 | + placeholder: "Room name", |
19 | + label: "Room name" | ||
20 | }] | 20 | }] |
21 | ] | 21 | ] |
22 | MANDATORY_FIELDS = [:service, :api_token, :room_id] | 22 | MANDATORY_FIELDS = [:service, :api_token, :room_id] |
@@ -45,11 +45,11 @@ if defined? HipChat | @@ -45,11 +45,11 @@ if defined? HipChat | ||
45 | Times occurred: #{problem.notices_count} | 45 | Times occurred: #{problem.notices_count} |
46 | MSG | 46 | MSG |
47 | 47 | ||
48 | - options = { :api_version => self[:service] } | 48 | + options = { api_version: self[:service] } |
49 | options[:server_url] = self[:service_url] if service_url.present? | 49 | options[:server_url] = self[:service_url] if service_url.present? |
50 | 50 | ||
51 | client = HipChat::Client.new(api_token, options) | 51 | client = HipChat::Client.new(api_token, options) |
52 | - client[room_id].send('Errbit', message, :color => 'red', :notify => true) | 52 | + client[room_id].send('Errbit', message, color: 'red', notify: true) |
53 | end | 53 | end |
54 | end | 54 | end |
55 | end | 55 | end |
app/models/notification_services/hoiio_service.rb
@@ -2,16 +2,16 @@ class NotificationServices::HoiioService < NotificationService | @@ -2,16 +2,16 @@ class NotificationServices::HoiioService < NotificationService | ||
2 | LABEL = "hoiio" | 2 | LABEL = "hoiio" |
3 | FIELDS += [ | 3 | FIELDS += [ |
4 | [:api_token, { | 4 | [:api_token, { |
5 | - :placeholder => "App ID", | ||
6 | - :label => "App ID" | 5 | + placeholder: "App ID", |
6 | + label: "App ID" | ||
7 | }], | 7 | }], |
8 | [:subdomain, { | 8 | [:subdomain, { |
9 | - :placeholder => "Access Token", | ||
10 | - :label => "Access Token" | 9 | + placeholder: "Access Token", |
10 | + label: "Access Token" | ||
11 | }], | 11 | }], |
12 | [:room_id, { | 12 | [:room_id, { |
13 | - :placeholder => "+6511111111, +6511111111", | ||
14 | - :label => "Recipient's phone numbers seperated by comma. Phone numbers should start with a \"+\" and country code." | 13 | + placeholder: "+6511111111, +6511111111", |
14 | + label: "Recipient's phone numbers seperated by comma. Phone numbers should start with a \"+\" and country code." | ||
15 | }] | 15 | }] |
16 | ] | 16 | ] |
17 | 17 | ||
@@ -35,7 +35,7 @@ class NotificationServices::HoiioService < NotificationService | @@ -35,7 +35,7 @@ class NotificationServices::HoiioService < NotificationService | ||
35 | 35 | ||
36 | # send sms | 36 | # send sms |
37 | room_id.split(',').each do |number| | 37 | room_id.split(',').each do |number| |
38 | - sms.send :dest => number, :msg => "#{Errbit::Config.protocol}://#{Errbit::Config.host}/apps/#{problem.app.id} #{notification_description problem}" | 38 | + sms.send dest: number, msg: "#{Errbit::Config.protocol}://#{Errbit::Config.host}/apps/#{problem.app.id} #{notification_description problem}" |
39 | end | 39 | end |
40 | end | 40 | end |
41 | end | 41 | end |
app/models/notification_services/hubot_service.rb
@@ -2,12 +2,12 @@ class NotificationServices::HubotService < NotificationService | @@ -2,12 +2,12 @@ class NotificationServices::HubotService < NotificationService | ||
2 | LABEL = "hubot" | 2 | LABEL = "hubot" |
3 | FIELDS += [ | 3 | FIELDS += [ |
4 | [:api_token, { | 4 | [:api_token, { |
5 | - :placeholder => 'http://hubot.example.org:8080/hubot/say', | ||
6 | - :label => 'Hubot URL' | 5 | + placeholder: 'http://hubot.example.org:8080/hubot/say', |
6 | + label: 'Hubot URL' | ||
7 | }], | 7 | }], |
8 | [:room_id, { | 8 | [:room_id, { |
9 | - :placeholder => '#dev', | ||
10 | - :label => 'Room where Hubot should notify' | 9 | + placeholder: '#dev', |
10 | + label: 'Room where Hubot should notify' | ||
11 | }] | 11 | }] |
12 | ] | 12 | ] |
13 | 13 | ||
@@ -26,6 +26,6 @@ class NotificationServices::HubotService < NotificationService | @@ -26,6 +26,6 @@ class NotificationServices::HubotService < NotificationService | ||
26 | end | 26 | end |
27 | 27 | ||
28 | def create_notification(problem) | 28 | def create_notification(problem) |
29 | - HTTParty.post(url, :body => { :message => message_for_hubot(problem), :room => room_id }) | 29 | + HTTParty.post(url, body: { message: message_for_hubot(problem), room: room_id }) |
30 | end | 30 | end |
31 | end | 31 | end |
app/models/notification_services/pushover_service.rb
@@ -2,12 +2,12 @@ class NotificationServices::PushoverService < NotificationService | @@ -2,12 +2,12 @@ class NotificationServices::PushoverService < NotificationService | ||
2 | LABEL = "pushover" | 2 | LABEL = "pushover" |
3 | FIELDS += [ | 3 | FIELDS += [ |
4 | [:api_token, { | 4 | [:api_token, { |
5 | - :placeholder => "User Key", | ||
6 | - :label => "User Key" | 5 | + placeholder: "User Key", |
6 | + label: "User Key" | ||
7 | }], | 7 | }], |
8 | [:subdomain, { | 8 | [:subdomain, { |
9 | - :placeholder => "Application API Token", | ||
10 | - :label => "Application API Token" | 9 | + placeholder: "Application API Token", |
10 | + label: "Application API Token" | ||
11 | }] | 11 | }] |
12 | ] | 12 | ] |
13 | 13 | ||
@@ -26,6 +26,6 @@ class NotificationServices::PushoverService < NotificationService | @@ -26,6 +26,6 @@ class NotificationServices::PushoverService < NotificationService | ||
26 | notification = Rushover::Client.new(subdomain) | 26 | notification = Rushover::Client.new(subdomain) |
27 | 27 | ||
28 | # send push notification to pushover | 28 | # send push notification to pushover |
29 | - notification.notify(api_token, "#{notification_description problem}", :priority => 1, :title => "Errbit Notification", :url => "#{Errbit::Config.protocol}://#{Errbit::Config.host}/apps/#{problem.app.id}", :url_title => "Link to error") | 29 | + notification.notify(api_token, "#{notification_description problem}", priority: 1, title: "Errbit Notification", url: "#{Errbit::Config.protocol}://#{Errbit::Config.host}/apps/#{problem.app.id}", url_title: "Link to error") |
30 | end | 30 | end |
31 | end | 31 | end |
app/models/notification_services/slack_service.rb
@@ -2,8 +2,8 @@ class NotificationServices::SlackService < NotificationService | @@ -2,8 +2,8 @@ class NotificationServices::SlackService < NotificationService | ||
2 | LABEL = "slack" | 2 | LABEL = "slack" |
3 | FIELDS += [ | 3 | FIELDS += [ |
4 | [:service_url, { | 4 | [:service_url, { |
5 | - :placeholder => 'Slack Hook URL (https://hooks.slack.com/services/XXXXXXXXX/XXXXXXXXX/XXXXXXXXX)', | ||
6 | - :label => 'Hook URL' | 5 | + placeholder: 'Slack Hook URL (https://hooks.slack.com/services/XXXXXXXXX/XXXXXXXXX/XXXXXXXXX)', |
6 | + label: 'Hook URL' | ||
7 | }] | 7 | }] |
8 | ] | 8 | ] |
9 | 9 | ||
@@ -19,41 +19,41 @@ class NotificationServices::SlackService < NotificationService | @@ -19,41 +19,41 @@ class NotificationServices::SlackService < NotificationService | ||
19 | 19 | ||
20 | def post_payload(problem) | 20 | def post_payload(problem) |
21 | { | 21 | { |
22 | - :attachments => [ | 22 | + attachments: [ |
23 | { | 23 | { |
24 | - :fallback => message_for_slack(problem), | ||
25 | - :pretext => "<#{problem_url(problem)}|Errbit - #{problem.app.name}: #{problem.error_class}>", | ||
26 | - :color => "#D00000", | ||
27 | - :fields => [ | 24 | + fallback: message_for_slack(problem), |
25 | + pretext: "<#{problem_url(problem)}|Errbit - #{problem.app.name}: #{problem.error_class}>", | ||
26 | + color: "#D00000", | ||
27 | + fields: [ | ||
28 | { | 28 | { |
29 | - :title => "Environment", | ||
30 | - :value => problem.environment, | ||
31 | - :short => false | 29 | + title: "Environment", |
30 | + value: problem.environment, | ||
31 | + short: false | ||
32 | }, | 32 | }, |
33 | { | 33 | { |
34 | - :title => "Location", | ||
35 | - :value => problem.where, | ||
36 | - :short => false | 34 | + title: "Location", |
35 | + value: problem.where, | ||
36 | + short: false | ||
37 | }, | 37 | }, |
38 | { | 38 | { |
39 | - :title => "Message", | ||
40 | - :value => problem.message.to_s, | ||
41 | - :short => false | 39 | + title: "Message", |
40 | + value: problem.message.to_s, | ||
41 | + short: false | ||
42 | }, | 42 | }, |
43 | { | 43 | { |
44 | - :title => "First Noticed", | ||
45 | - :value => problem.first_notice_at, | ||
46 | - :short => false | 44 | + title: "First Noticed", |
45 | + value: problem.first_notice_at, | ||
46 | + short: false | ||
47 | }, | 47 | }, |
48 | { | 48 | { |
49 | - :title => "Last Noticed", | ||
50 | - :value => problem.last_notice_at, | ||
51 | - :short => false | 49 | + title: "Last Noticed", |
50 | + value: problem.last_notice_at, | ||
51 | + short: false | ||
52 | }, | 52 | }, |
53 | { | 53 | { |
54 | - :title => "Times Occurred", | ||
55 | - :value => problem.notices_count, | ||
56 | - :short => false | 54 | + title: "Times Occurred", |
55 | + value: problem.notices_count, | ||
56 | + short: false | ||
57 | } | 57 | } |
58 | ] | 58 | ] |
59 | } | 59 | } |
@@ -62,7 +62,7 @@ class NotificationServices::SlackService < NotificationService | @@ -62,7 +62,7 @@ class NotificationServices::SlackService < NotificationService | ||
62 | end | 62 | end |
63 | 63 | ||
64 | def create_notification(problem) | 64 | def create_notification(problem) |
65 | - HTTParty.post(service_url, :body => post_payload(problem), :headers => { 'Content-Type' => 'application/json' }) | 65 | + HTTParty.post(service_url, body: post_payload(problem), headers: { 'Content-Type' => 'application/json' }) |
66 | end | 66 | end |
67 | 67 | ||
68 | def configured? | 68 | def configured? |
app/models/notification_services/webhook_service.rb
@@ -2,8 +2,8 @@ class NotificationServices::WebhookService < NotificationService | @@ -2,8 +2,8 @@ class NotificationServices::WebhookService < NotificationService | ||
2 | LABEL = "webhook" | 2 | LABEL = "webhook" |
3 | FIELDS = [ | 3 | FIELDS = [ |
4 | [:api_token, { | 4 | [:api_token, { |
5 | - :placeholder => 'URL to receive a POST request when an error occurs', | ||
6 | - :label => 'URL' | 5 | + placeholder: 'URL to receive a POST request when an error occurs', |
6 | + label: 'URL' | ||
7 | }] | 7 | }] |
8 | ] | 8 | ] |
9 | 9 | ||
@@ -14,10 +14,10 @@ class NotificationServices::WebhookService < NotificationService | @@ -14,10 +14,10 @@ class NotificationServices::WebhookService < NotificationService | ||
14 | end | 14 | end |
15 | 15 | ||
16 | def message_for_webhook(problem) | 16 | def message_for_webhook(problem) |
17 | - { :problem => { :url => problem_url(problem) }.merge(problem.as_json).to_json } | 17 | + { problem: { url: problem_url(problem) }.merge(problem.as_json).to_json } |
18 | end | 18 | end |
19 | 19 | ||
20 | def create_notification(problem) | 20 | def create_notification(problem) |
21 | - HTTParty.post(api_token, :body => message_for_webhook(problem)) | 21 | + HTTParty.post(api_token, body: message_for_webhook(problem)) |
22 | end | 22 | end |
23 | end | 23 | end |
app/models/problem.rb
@@ -7,59 +7,59 @@ class Problem | @@ -7,59 +7,59 @@ class Problem | ||
7 | include Mongoid::Timestamps | 7 | include Mongoid::Timestamps |
8 | 8 | ||
9 | CACHED_NOTICE_ATTRIBUTES = { | 9 | CACHED_NOTICE_ATTRIBUTES = { |
10 | - messages: :message, | ||
11 | - hosts: :host, | 10 | + messages: :message, |
11 | + hosts: :host, | ||
12 | user_agents: :user_agent_string | 12 | user_agents: :user_agent_string |
13 | }.freeze | 13 | }.freeze |
14 | 14 | ||
15 | - field :last_notice_at, :type => ActiveSupport::TimeWithZone, :default => proc { Time.zone.now } | ||
16 | - field :first_notice_at, :type => ActiveSupport::TimeWithZone, :default => proc { Time.zone.now } | ||
17 | - field :last_deploy_at, :type => Time | ||
18 | - field :resolved, :type => Boolean, :default => false | ||
19 | - field :resolved_at, :type => Time | ||
20 | - field :issue_link, :type => String | ||
21 | - field :issue_type, :type => String | 15 | + field :last_notice_at, type: ActiveSupport::TimeWithZone, default: proc { Time.zone.now } |
16 | + field :first_notice_at, type: ActiveSupport::TimeWithZone, default: proc { Time.zone.now } | ||
17 | + field :last_deploy_at, type: Time | ||
18 | + field :resolved, type: Boolean, default: false | ||
19 | + field :resolved_at, type: Time | ||
20 | + field :issue_link, type: String | ||
21 | + field :issue_type, type: String | ||
22 | 22 | ||
23 | # Cached fields | 23 | # Cached fields |
24 | - field :app_name, :type => String | ||
25 | - field :notices_count, :type => Integer, :default => 0 | 24 | + field :app_name, type: String |
25 | + field :notices_count, type: Integer, default: 0 | ||
26 | field :message | 26 | field :message |
27 | field :environment | 27 | field :environment |
28 | field :error_class | 28 | field :error_class |
29 | field :where | 29 | field :where |
30 | - field :user_agents, :type => Hash, :default => {} | ||
31 | - field :messages, :type => Hash, :default => {} | ||
32 | - field :hosts, :type => Hash, :default => {} | ||
33 | - field :comments_count, :type => Integer, :default => 0 | ||
34 | - | ||
35 | - index :app_id => 1 | ||
36 | - index :app_name => 1 | ||
37 | - index :message => 1 | ||
38 | - index :last_notice_at => 1 | ||
39 | - index :first_notice_at => 1 | ||
40 | - index :last_deploy_at => 1 | ||
41 | - index :resolved_at => 1 | ||
42 | - index :notices_count => 1 | 30 | + field :user_agents, type: Hash, default: {} |
31 | + field :messages, type: Hash, default: {} | ||
32 | + field :hosts, type: Hash, default: {} | ||
33 | + field :comments_count, type: Integer, default: 0 | ||
34 | + | ||
35 | + index app_id: 1 | ||
36 | + index app_name: 1 | ||
37 | + index message: 1 | ||
38 | + index last_notice_at: 1 | ||
39 | + index first_notice_at: 1 | ||
40 | + index last_deploy_at: 1 | ||
41 | + index resolved_at: 1 | ||
42 | + index notices_count: 1 | ||
43 | 43 | ||
44 | index({ | 44 | index({ |
45 | error_class: "text", | 45 | error_class: "text", |
46 | - where: "text", | ||
47 | - message: "text", | ||
48 | - app_name: "text", | 46 | + where: "text", |
47 | + message: "text", | ||
48 | + app_name: "text", | ||
49 | environment: "text" | 49 | environment: "text" |
50 | }, default_language: "english") | 50 | }, default_language: "english") |
51 | 51 | ||
52 | belongs_to :app | 52 | belongs_to :app |
53 | - has_many :errs, :inverse_of => :problem, :dependent => :destroy | ||
54 | - has_many :comments, :inverse_of => :err, :dependent => :destroy | 53 | + has_many :errs, inverse_of: :problem, dependent: :destroy |
54 | + has_many :comments, inverse_of: :err, dependent: :destroy | ||
55 | 55 | ||
56 | validates_presence_of :environment | 56 | validates_presence_of :environment |
57 | 57 | ||
58 | before_create :cache_app_attributes | 58 | before_create :cache_app_attributes |
59 | before_save :truncate_message | 59 | before_save :truncate_message |
60 | 60 | ||
61 | - scope :resolved, -> { where(:resolved => true) } | ||
62 | - scope :unresolved, -> { where(:resolved => false) } | 61 | + scope :resolved, -> { where(resolved: true) } |
62 | + scope :unresolved, -> { where(resolved: false) } | ||
63 | scope :ordered, -> { order_by(:last_notice_at.desc) } | 63 | scope :ordered, -> { order_by(:last_notice_at.desc) } |
64 | scope :for_apps, ->(apps) { where(:app_id.in => apps.all.map(&:id)) } | 64 | scope :for_apps, ->(apps) { where(:app_id.in => apps.all.map(&:id)) } |
65 | 65 | ||
@@ -69,12 +69,12 @@ class Problem | @@ -69,12 +69,12 @@ class Problem | ||
69 | if fetch_all | 69 | if fetch_all |
70 | all | 70 | all |
71 | else | 71 | else |
72 | - where(:resolved => false) | 72 | + where(resolved: false) |
73 | end | 73 | end |
74 | end | 74 | end |
75 | 75 | ||
76 | def self.in_env(env) | 76 | def self.in_env(env) |
77 | - env.present? ? where(:environment => env) : scoped | 77 | + env.present? ? where(environment: env) : scoped |
78 | end | 78 | end |
79 | 79 | ||
80 | def self.cache_notice(id, notice) | 80 | def self.cache_notice(id, notice) |
@@ -164,8 +164,8 @@ class Problem | @@ -164,8 +164,8 @@ class Problem | ||
164 | Rails.application.routes.url_helpers.app_problem_url( | 164 | Rails.application.routes.url_helpers.app_problem_url( |
165 | app, | 165 | app, |
166 | self, | 166 | self, |
167 | - :host => Errbit::Config.host, | ||
168 | - :port => Errbit::Config.port | 167 | + host: Errbit::Config.host, |
168 | + port: Errbit::Config.port | ||
169 | ) | 169 | ) |
170 | end | 170 | end |
171 | 171 | ||
@@ -174,11 +174,11 @@ class Problem | @@ -174,11 +174,11 @@ class Problem | ||
174 | end | 174 | end |
175 | 175 | ||
176 | def resolve! | 176 | def resolve! |
177 | - self.update_attributes!(:resolved => true, :resolved_at => Time.zone.now) | 177 | + self.update_attributes!(resolved: true, resolved_at: Time.zone.now) |
178 | end | 178 | end |
179 | 179 | ||
180 | def unresolve! | 180 | def unresolve! |
181 | - self.update_attributes!(:resolved => false, :resolved_at => nil) | 181 | + self.update_attributes!(resolved: false, resolved_at: nil) |
182 | end | 182 | end |
183 | 183 | ||
184 | def unresolved? | 184 | def unresolved? |
@@ -194,7 +194,7 @@ class Problem | @@ -194,7 +194,7 @@ class Problem | ||
194 | end | 194 | end |
195 | 195 | ||
196 | def unmerge! | 196 | def unmerge! |
197 | - attrs = { :error_class => error_class, :environment => environment } | 197 | + attrs = { error_class: error_class, environment: environment } |
198 | problem_errs = errs.to_a | 198 | problem_errs = errs.to_a |
199 | 199 | ||
200 | # associate and return all the problems | 200 | # associate and return all the problems |
app/models/user.rb
@@ -9,37 +9,37 @@ class User | @@ -9,37 +9,37 @@ class User | ||
9 | field :github_login | 9 | field :github_login |
10 | field :github_oauth_token | 10 | field :github_oauth_token |
11 | field :name | 11 | field :name |
12 | - field :admin, :type => Boolean, :default => false | ||
13 | - field :per_page, :type => Fixnum, :default => PER_PAGE | ||
14 | - field :time_zone, :default => "UTC" | 12 | + field :admin, type: Boolean, default: false |
13 | + field :per_page, type: Fixnum, default: PER_PAGE | ||
14 | + field :time_zone, default: "UTC" | ||
15 | 15 | ||
16 | ## Devise field | 16 | ## Devise field |
17 | ### Database Authenticatable | 17 | ### Database Authenticatable |
18 | - field :encrypted_password, :type => String | 18 | + field :encrypted_password, type: String |
19 | 19 | ||
20 | ### Recoverable | 20 | ### Recoverable |
21 | - field :reset_password_token, :type => String | ||
22 | - field :reset_password_sent_at, :type => Time | 21 | + field :reset_password_token, type: String |
22 | + field :reset_password_sent_at, type: Time | ||
23 | 23 | ||
24 | ### Rememberable | 24 | ### Rememberable |
25 | - field :remember_created_at, :type => Time | 25 | + field :remember_created_at, type: Time |
26 | 26 | ||
27 | ### Trackable | 27 | ### Trackable |
28 | - field :sign_in_count, :type => Integer | ||
29 | - field :current_sign_in_at, :type => Time | ||
30 | - field :last_sign_in_at, :type => Time | ||
31 | - field :current_sign_in_ip, :type => String | ||
32 | - field :last_sign_in_ip, :type => String | 28 | + field :sign_in_count, type: Integer |
29 | + field :current_sign_in_at, type: Time | ||
30 | + field :last_sign_in_at, type: Time | ||
31 | + field :current_sign_in_ip, type: String | ||
32 | + field :last_sign_in_ip, type: String | ||
33 | 33 | ||
34 | ### Token_authenticatable | 34 | ### Token_authenticatable |
35 | - field :authentication_token, :type => String | 35 | + field :authentication_token, type: String |
36 | 36 | ||
37 | - index :authentication_token => 1 | 37 | + index authentication_token: 1 |
38 | 38 | ||
39 | before_save :ensure_authentication_token | 39 | before_save :ensure_authentication_token |
40 | 40 | ||
41 | validates_presence_of :name | 41 | validates_presence_of :name |
42 | - validates_uniqueness_of :github_login, :allow_nil => true | 42 | + validates_uniqueness_of :github_login, allow_nil: true |
43 | 43 | ||
44 | if Errbit::Config.user_has_username | 44 | if Errbit::Config.user_has_username |
45 | field :username | 45 | field :username |
app/models/watcher.rb
config/application.rb
@@ -39,7 +39,7 @@ module Errbit | @@ -39,7 +39,7 @@ module Errbit | ||
39 | config.generators do |g| | 39 | config.generators do |g| |
40 | g.orm :mongoid | 40 | g.orm :mongoid |
41 | g.template_engine :haml | 41 | g.template_engine :haml |
42 | - g.test_framework :rspec, :fixture => false | 42 | + g.test_framework :rspec, fixture: false |
43 | g.fixture_replacement :fabrication | 43 | g.fixture_replacement :fabrication |
44 | end | 44 | end |
45 | 45 |
config/initializers/action_mailer.rb
@@ -2,12 +2,12 @@ | @@ -2,12 +2,12 @@ | ||
2 | if Errbit::Config.email_delivery_method == :smtp | 2 | if Errbit::Config.email_delivery_method == :smtp |
3 | ActionMailer::Base.delivery_method = :smtp | 3 | ActionMailer::Base.delivery_method = :smtp |
4 | ActionMailer::Base.smtp_settings = { | 4 | ActionMailer::Base.smtp_settings = { |
5 | - :address => Errbit::Config.smtp_address, | ||
6 | - :port => Errbit::Config.smtp_port, | ||
7 | - :authentication => Errbit::Config.smtp_authentication, | ||
8 | - :user_name => Errbit::Config.smtp_user_name, | ||
9 | - :password => Errbit::Config.smtp_password, | ||
10 | - :domain => Errbit::Config.smtp_domain | 5 | + address: Errbit::Config.smtp_address, |
6 | + port: Errbit::Config.smtp_port, | ||
7 | + authentication: Errbit::Config.smtp_authentication, | ||
8 | + user_name: Errbit::Config.smtp_user_name, | ||
9 | + password: Errbit::Config.smtp_password, | ||
10 | + domain: Errbit::Config.smtp_domain | ||
11 | } | 11 | } |
12 | end | 12 | end |
13 | 13 | ||
@@ -23,8 +23,8 @@ end | @@ -23,8 +23,8 @@ end | ||
23 | # Set config specific values | 23 | # Set config specific values |
24 | (ActionMailer::Base.default_url_options ||= {}).tap do |default| | 24 | (ActionMailer::Base.default_url_options ||= {}).tap do |default| |
25 | options_from_config = { | 25 | options_from_config = { |
26 | - host: Errbit::Config.host, | ||
27 | - port: Errbit::Config.port, | 26 | + host: Errbit::Config.host, |
27 | + port: Errbit::Config.port, | ||
28 | protocol: Errbit::Config.protocol | 28 | protocol: Errbit::Config.protocol |
29 | }.select { |_k, v| v } | 29 | }.select { |_k, v| v } |
30 | 30 |
config/initializers/devise.rb
@@ -237,12 +237,12 @@ Devise.setup do |config| | @@ -237,12 +237,12 @@ Devise.setup do |config| | ||
237 | 237 | ||
238 | if Errbit::Config.github_authentication || Rails.env.test? | 238 | if Errbit::Config.github_authentication || Rails.env.test? |
239 | github_options = { | 239 | github_options = { |
240 | - :scope => Errbit::Config.github_access_scope.join(','), | ||
241 | - :skip_info => true, | ||
242 | - :client_options => { | ||
243 | - :site => Errbit::Config.github_api_url, | ||
244 | - :authorize_url => "#{Errbit::Config.github_url}/login/oauth/authorize", | ||
245 | - :token_url => "#{Errbit::Config.github_url}/login/oauth/access_token" | 240 | + scope: Errbit::Config.github_access_scope.join(','), |
241 | + skip_info: true, | ||
242 | + client_options: { | ||
243 | + site: Errbit::Config.github_api_url, | ||
244 | + authorize_url: "#{Errbit::Config.github_url}/login/oauth/authorize", | ||
245 | + token_url: "#{Errbit::Config.github_url}/login/oauth/access_token" | ||
246 | } | 246 | } |
247 | } | 247 | } |
248 | 248 |
config/initializers/ssl_enforcer.rb
1 | # Enforce SSL connections, if configured | 1 | # Enforce SSL connections, if configured |
2 | if Errbit::Config.enforce_ssl | 2 | if Errbit::Config.enforce_ssl |
3 | require 'rack/ssl-enforcer' | 3 | require 'rack/ssl-enforcer' |
4 | - ActionMailer::Base.default_url_options.merge!(:protocol => 'https://') | 4 | + ActionMailer::Base.default_url_options.merge!(protocol: 'https://') |
5 | Rails.application.configure do | 5 | Rails.application.configure do |
6 | - config.middleware.use Rack::SslEnforcer, :except => %r{^/deploys} | 6 | + config.middleware.use Rack::SslEnforcer, except: %r{^/deploys} |
7 | end | 7 | end |
8 | end | 8 | end |
config/routes.rb
1 | Rails.application.routes.draw do | 1 | Rails.application.routes.draw do |
2 | - devise_for :users, :controllers => { :omniauth_callbacks => "users/omniauth_callbacks" } | 2 | + devise_for :users, controllers: { omniauth_callbacks: "users/omniauth_callbacks" } |
3 | 3 | ||
4 | # Hoptoad Notifier Routes | 4 | # Hoptoad Notifier Routes |
5 | match '/notifier_api/v2/notices' => 'notices#create', via: [:get, :post] | 5 | match '/notifier_api/v2/notices' => 'notices#create', via: [:get, :post] |
6 | get '/locate/:id' => 'notices#locate', :as => :locate | 6 | get '/locate/:id' => 'notices#locate', :as => :locate |
7 | post '/deploys.txt' => 'deploys#create' | 7 | post '/deploys.txt' => 'deploys#create' |
8 | 8 | ||
9 | - resources :notices, :only => [:show] | ||
10 | - resources :deploys, :only => [:show] | 9 | + resources :notices, only: [:show] |
10 | + resources :deploys, only: [:show] | ||
11 | resources :users do | 11 | resources :users do |
12 | member do | 12 | member do |
13 | delete :unlink_github | 13 | delete :unlink_github |
14 | end | 14 | end |
15 | end | 15 | end |
16 | 16 | ||
17 | - resources :site_config, :only => [:index] do | 17 | + resources :site_config, only: [:index] do |
18 | collection do | 18 | collection do |
19 | put :update | 19 | put :update |
20 | end | 20 | end |
21 | end | 21 | end |
22 | 22 | ||
23 | - resources :problems, :only => [:index] do | 23 | + resources :problems, only: [:index] do |
24 | collection do | 24 | collection do |
25 | post :destroy_several | 25 | post :destroy_several |
26 | post :resolve_several | 26 | post :resolve_several |
@@ -34,7 +34,7 @@ Rails.application.routes.draw do | @@ -34,7 +34,7 @@ Rails.application.routes.draw do | ||
34 | resources :apps do | 34 | resources :apps do |
35 | resources :problems do | 35 | resources :problems do |
36 | resources :notices | 36 | resources :notices |
37 | - resources :comments, :only => [:create, :destroy] | 37 | + resources :comments, only: [:create, :destroy] |
38 | 38 | ||
39 | collection do | 39 | collection do |
40 | post :destroy_all | 40 | post :destroy_all |
@@ -47,8 +47,8 @@ Rails.application.routes.draw do | @@ -47,8 +47,8 @@ Rails.application.routes.draw do | ||
47 | delete :unlink_issue | 47 | delete :unlink_issue |
48 | end | 48 | end |
49 | end | 49 | end |
50 | - resources :deploys, :only => [:index] | ||
51 | - resources :watchers, :only => [:destroy, :update] | 50 | + resources :deploys, only: [:index] |
51 | + resources :watchers, only: [:destroy, :update] | ||
52 | member do | 52 | member do |
53 | post :regenerate_api_key | 53 | post :regenerate_api_key |
54 | end | 54 | end |
@@ -56,9 +56,9 @@ Rails.application.routes.draw do | @@ -56,9 +56,9 @@ Rails.application.routes.draw do | ||
56 | 56 | ||
57 | namespace :api do | 57 | namespace :api do |
58 | namespace :v1 do | 58 | namespace :v1 do |
59 | - resources :problems, :only => [:index, :show], :defaults => { :format => 'json' } | ||
60 | - resources :notices, :only => [:index], :defaults => { :format => 'json' } | ||
61 | - resources :stats, :only => [], :defaults => { :format => 'json' } do | 59 | + resources :problems, only: [:index, :show], defaults: { format: 'json' } |
60 | + resources :notices, only: [:index], defaults: { format: 'json' } | ||
61 | + resources :stats, only: [], defaults: { format: 'json' } do | ||
62 | collection do | 62 | collection do |
63 | get :app | 63 | get :app |
64 | end | 64 | end |
@@ -69,5 +69,5 @@ Rails.application.routes.draw do | @@ -69,5 +69,5 @@ Rails.application.routes.draw do | ||
69 | match '/api/v3/projects/:project_id/create-notice' => 'api/v3/notices#create', via: [:post] | 69 | match '/api/v3/projects/:project_id/create-notice' => 'api/v3/notices#create', via: [:post] |
70 | match '/api/v3/projects/:project_id/notices' => 'api/v3/notices#create', via: [:post] | 70 | match '/api/v3/projects/:project_id/notices' => 'api/v3/notices#create', via: [:post] |
71 | 71 | ||
72 | - root :to => 'apps#index' | 72 | + root to: 'apps#index' |
73 | end | 73 | end |
db/migrate/201510290041_extract_issue_tracker.rb
@@ -35,7 +35,7 @@ class ExtractIssueTracker < Mongoid::Migration | @@ -35,7 +35,7 @@ class ExtractIssueTracker < Mongoid::Migration | ||
35 | } | 35 | } |
36 | 36 | ||
37 | App.where({ _id: app.id }).update({ | 37 | App.where({ _id: app.id }).update({ |
38 | - "$set" => { :issue_tracker => tracker } | 38 | + "$set" => { issue_tracker: tracker } |
39 | }) | 39 | }) |
40 | end | 40 | end |
41 | end | 41 | end |
db/seeds.rb
@@ -15,7 +15,7 @@ puts "-- password: #{admin_pass}" | @@ -15,7 +15,7 @@ puts "-- password: #{admin_pass}" | ||
15 | puts "" | 15 | puts "" |
16 | puts "Be sure to note down these credentials now!" | 16 | puts "Be sure to note down these credentials now!" |
17 | 17 | ||
18 | -user = User.find_or_initialize_by(:email => admin_email) | 18 | +user = User.find_or_initialize_by(email: admin_email) |
19 | 19 | ||
20 | user.name = 'Errbit Admin' | 20 | user.name = 'Errbit Admin' |
21 | user.password = admin_pass | 21 | user.password = admin_pass |
lib/airbrake_api/v3/notice_parser.rb
@@ -11,14 +11,14 @@ module AirbrakeApi | @@ -11,14 +11,14 @@ module AirbrakeApi | ||
11 | 11 | ||
12 | def report | 12 | def report |
13 | attributes = { | 13 | attributes = { |
14 | - error_class: error['type'], | ||
15 | - message: error['message'], | ||
16 | - backtrace: backtrace, | ||
17 | - request: request, | 14 | + error_class: error['type'], |
15 | + message: error['message'], | ||
16 | + backtrace: backtrace, | ||
17 | + request: request, | ||
18 | server_environment: server_environment, | 18 | server_environment: server_environment, |
19 | - api_key: params['key'].present? ? params['key'] : params['project_id'], | ||
20 | - notifier: params['notifier'], | ||
21 | - user_attributes: user_attributes | 19 | + api_key: params['key'].present? ? params['key'] : params['project_id'], |
20 | + notifier: params['notifier'], | ||
21 | + user_attributes: user_attributes | ||
22 | } | 22 | } |
23 | 23 | ||
24 | ErrorReport.new(attributes) | 24 | ErrorReport.new(attributes) |
@@ -35,7 +35,7 @@ module AirbrakeApi | @@ -35,7 +35,7 @@ module AirbrakeApi | ||
35 | (error['backtrace'] || []).map do |backtrace_line| | 35 | (error['backtrace'] || []).map do |backtrace_line| |
36 | { | 36 | { |
37 | method: backtrace_line['function'], | 37 | method: backtrace_line['function'], |
38 | - file: backtrace_line['file'], | 38 | + file: backtrace_line['file'], |
39 | number: backtrace_line['line'], | 39 | number: backtrace_line['line'], |
40 | column: backtrace_line['column'] | 40 | column: backtrace_line['column'] |
41 | } | 41 | } |
lib/hoptoad/v2.rb
@@ -53,18 +53,18 @@ module Hoptoad | @@ -53,18 +53,18 @@ module Hoptoad | ||
53 | 53 | ||
54 | def self.for_errbit_api(notice) | 54 | def self.for_errbit_api(notice) |
55 | { | 55 | { |
56 | - :error_class => notice['error']['class'] || notice['error']['key'], | ||
57 | - :message => notice['error']['message'], | ||
58 | - :backtrace => notice['error']['backtrace']['line'], | 56 | + error_class: notice['error']['class'] || notice['error']['key'], |
57 | + message: notice['error']['message'], | ||
58 | + backtrace: notice['error']['backtrace']['line'], | ||
59 | 59 | ||
60 | - :request => notice['request'], | ||
61 | - :server_environment => notice['server-environment'], | 60 | + request: notice['request'], |
61 | + server_environment: notice['server-environment'], | ||
62 | 62 | ||
63 | - :api_key => notice['api-key'], | ||
64 | - :notifier => notice['notifier'], | 63 | + api_key: notice['api-key'], |
64 | + notifier: notice['notifier'], | ||
65 | # 'current-user' from airbrake, 'user-attributes' from airbrake_user_attributes gem | 65 | # 'current-user' from airbrake, 'user-attributes' from airbrake_user_attributes gem |
66 | - :user_attributes => notice['current-user'] || notice['user-attributes'] || {}, | ||
67 | - :framework => notice['framework'] | 66 | + user_attributes: notice['current-user'] || notice['user-attributes'] || {}, |
67 | + framework: notice['framework'] | ||
68 | } | 68 | } |
69 | end | 69 | end |
70 | end | 70 | end |
lib/overrides/hoptoad_notifier/hoptoad_notifier.rb
@@ -7,7 +7,7 @@ HoptoadNotifier.module_eval do | @@ -7,7 +7,7 @@ HoptoadNotifier.module_eval do | ||
7 | private def send_notice(notice) | 7 | private def send_notice(notice) |
8 | # Log the error internally if we are not in a development environment. | 8 | # Log the error internally if we are not in a development environment. |
9 | if configuration.public? | 9 | if configuration.public? |
10 | - app = App.find_or_initialize_by(:name => "Self.Errbit") | 10 | + app = App.find_or_initialize_by(name: "Self.Errbit") |
11 | app.github_repo = "errbit/errbit" | 11 | app.github_repo = "errbit/errbit" |
12 | app.save! | 12 | app.save! |
13 | notice.send("api_key=", app.api_key) | 13 | notice.send("api_key=", app.api_key) |
lib/tasks/errbit/database.rake
1 | namespace :errbit do | 1 | namespace :errbit do |
2 | desc "Updates cached attributes on Problem" | 2 | desc "Updates cached attributes on Problem" |
3 | - task :problem_recache => :environment do | 3 | + task problem_recache: :environment do |
4 | ProblemRecacher.run | 4 | ProblemRecacher.run |
5 | end | 5 | end |
6 | 6 | ||
7 | desc "Delete resolved errors from the database. (Useful for limited heroku databases)" | 7 | desc "Delete resolved errors from the database. (Useful for limited heroku databases)" |
8 | - task :clear_resolved => :environment do | 8 | + task clear_resolved: :environment do |
9 | require 'resolved_problem_clearer' | 9 | require 'resolved_problem_clearer' |
10 | puts "=== Cleared #{ResolvedProblemClearer.new.execute} resolved errors from the database." | 10 | puts "=== Cleared #{ResolvedProblemClearer.new.execute} resolved errors from the database." |
11 | end | 11 | end |
12 | 12 | ||
13 | desc "Regenerate fingerprints" | 13 | desc "Regenerate fingerprints" |
14 | - task :notice_refingerprint => :environment do | 14 | + task notice_refingerprint: :environment do |
15 | NoticeRefingerprinter.run | 15 | NoticeRefingerprinter.run |
16 | ProblemRecacher.run | 16 | ProblemRecacher.run |
17 | end | 17 | end |
lib/tasks/errbit/demo.rake
1 | namespace :errbit do | 1 | namespace :errbit do |
2 | desc "Add a demo app & errors to your database (for testing)" | 2 | desc "Add a demo app & errors to your database (for testing)" |
3 | - task :demo => :environment do | 3 | + task demo: :environment do |
4 | require 'fabrication' | 4 | require 'fabrication' |
5 | 5 | ||
6 | - app = Fabricate(:app, :name => "Demo App #{Time.zone.now.strftime('%N')}") | 6 | + app = Fabricate(:app, name: "Demo App #{Time.zone.now.strftime('%N')}") |
7 | 7 | ||
8 | # Report a number of errors for the application | 8 | # Report a number of errors for the application |
9 | app.problems.delete_all | 9 | app.problems.delete_all |
10 | 10 | ||
11 | errors = [{ | 11 | errors = [{ |
12 | - :error_class => "ArgumentError", | ||
13 | - :message => "wrong number of arguments (3 for 0)" | 12 | + error_class: "ArgumentError", |
13 | + message: "wrong number of arguments (3 for 0)" | ||
14 | }, { | 14 | }, { |
15 | - :error_class => "RuntimeError", | ||
16 | - :message => "Could not find Red October" | 15 | + error_class: "RuntimeError", |
16 | + message: "Could not find Red October" | ||
17 | }, { | 17 | }, { |
18 | - :error_class => "TypeError", | ||
19 | - :message => "can't convert Symbol into Integer" | 18 | + error_class: "TypeError", |
19 | + message: "can't convert Symbol into Integer" | ||
20 | }, { | 20 | }, { |
21 | - :error_class => "ActiveRecord::RecordNotFound", | ||
22 | - :message => "could not find a record with the id 5" | 21 | + error_class: "ActiveRecord::RecordNotFound", |
22 | + message: "could not find a record with the id 5" | ||
23 | }, { | 23 | }, { |
24 | - :error_class => "NameError", | ||
25 | - :message => "uninitialized constant Tag" | 24 | + error_class: "NameError", |
25 | + message: "uninitialized constant Tag" | ||
26 | }, { | 26 | }, { |
27 | - :error_class => "SyntaxError", | ||
28 | - :message => "unexpected tSTRING_BEG, expecting keyword_do or '{' or '('" | 27 | + error_class: "SyntaxError", |
28 | + message: "unexpected tSTRING_BEG, expecting keyword_do or '{' or '('" | ||
29 | }] | 29 | }] |
30 | 30 | ||
31 | RANDOM_METHODS = ActiveSupport.methods.shuffle[1..8] | 31 | RANDOM_METHODS = ActiveSupport.methods.shuffle[1..8] |
@@ -44,28 +44,28 @@ namespace :errbit do | @@ -44,28 +44,28 @@ namespace :errbit do | ||
44 | errors.each do |error_template| | 44 | errors.each do |error_template| |
45 | rand(34).times do | 45 | rand(34).times do |
46 | ErrorReport.new(error_template.reverse_merge({ | 46 | ErrorReport.new(error_template.reverse_merge({ |
47 | - :api_key => app.api_key, | ||
48 | - :error_class => "StandardError", | ||
49 | - :message => "Oops. Something went wrong!", | ||
50 | - :backtrace => random_backtrace, | ||
51 | - :request => { | 47 | + api_key: app.api_key, |
48 | + error_class: "StandardError", | ||
49 | + message: "Oops. Something went wrong!", | ||
50 | + backtrace: random_backtrace, | ||
51 | + request: { | ||
52 | 'component' => 'main', | 52 | 'component' => 'main', |
53 | 'action' => 'error', | 53 | 'action' => 'error', |
54 | 'url' => "http://example.com/post/#{[111, 222, 333].sample}" | 54 | 'url' => "http://example.com/post/#{[111, 222, 333].sample}" |
55 | }, | 55 | }, |
56 | - :server_environment => { 'environment-name' => Rails.env.to_s }, | ||
57 | - :notifier => { :name => "seeds.rb" }, | ||
58 | - :app_user => { | ||
59 | - :id => "1234", | ||
60 | - :username => "jsmith", | ||
61 | - :name => "John Smith", | ||
62 | - :url => "http://www.example.com/users/jsmith" | 56 | + server_environment: { 'environment-name' => Rails.env.to_s }, |
57 | + notifier: { name: "seeds.rb" }, | ||
58 | + app_user: { | ||
59 | + id: "1234", | ||
60 | + username: "jsmith", | ||
61 | + name: "John Smith", | ||
62 | + url: "http://www.example.com/users/jsmith" | ||
63 | } | 63 | } |
64 | })).generate_notice! | 64 | })).generate_notice! |
65 | end | 65 | end |
66 | end | 66 | end |
67 | 67 | ||
68 | - Fabricate(:notice, :err => Fabricate(:err, :problem => Fabricate(:problem, :app => app))) | 68 | + Fabricate(:notice, err: Fabricate(:err, problem: Fabricate(:problem, app: app))) |
69 | puts "=== Created demo app: '#{app.name}', with example errors." | 69 | puts "=== Created demo app: '#{app.name}', with example errors." |
70 | end | 70 | end |
71 | end | 71 | end |
lib/tasks/heroku/cron.rake
spec/acceptance/acceptance_helper.rb
@@ -22,7 +22,7 @@ end | @@ -22,7 +22,7 @@ end | ||
22 | 22 | ||
23 | def log_in(user) | 23 | def log_in(user) |
24 | visit '/' | 24 | visit '/' |
25 | - fill_in :user_email, :with => user.email | ||
26 | - fill_in :user_password, :with => 'password' | 25 | + fill_in :user_email, with: user.email |
26 | + fill_in :user_password, with: 'password' | ||
27 | click_on I18n.t('devise.sessions.new.sign_in') | 27 | click_on I18n.t('devise.sessions.new.sign_in') |
28 | end | 28 | end |
spec/acceptance/app_regenerate_api_key_spec.rb
@@ -4,7 +4,7 @@ feature "Regeneration api_Key" do | @@ -4,7 +4,7 @@ feature "Regeneration api_Key" do | ||
4 | let(:app) { Fabricate(:app) } | 4 | let(:app) { Fabricate(:app) } |
5 | let(:admin) { Fabricate(:admin) } | 5 | let(:admin) { Fabricate(:admin) } |
6 | let(:user) { | 6 | let(:user) { |
7 | - Fabricate(:user_watcher, :app => app).user | 7 | + Fabricate(:user_watcher, app: app).user |
8 | } | 8 | } |
9 | 9 | ||
10 | before do | 10 | before do |
@@ -37,7 +37,7 @@ end | @@ -37,7 +37,7 @@ end | ||
37 | feature "Create an application" do | 37 | feature "Create an application" do |
38 | let(:admin) { Fabricate(:admin) } | 38 | let(:admin) { Fabricate(:admin) } |
39 | let(:user) { | 39 | let(:user) { |
40 | - Fabricate(:user_watcher, :app => app).user | 40 | + Fabricate(:user_watcher, app: app).user |
41 | } | 41 | } |
42 | 42 | ||
43 | before do | 43 | before do |
@@ -48,37 +48,37 @@ feature "Create an application" do | @@ -48,37 +48,37 @@ feature "Create an application" do | ||
48 | visit '/' | 48 | visit '/' |
49 | log_in admin | 49 | log_in admin |
50 | click_on I18n.t('apps.index.new_app') | 50 | click_on I18n.t('apps.index.new_app') |
51 | - fill_in 'app_name', :with => 'My new app' | 51 | + fill_in 'app_name', with: 'My new app' |
52 | click_on I18n.t('apps.new.add_app') | 52 | click_on I18n.t('apps.new.add_app') |
53 | page.has_content?(I18n.t('controllers.apps.flash.create.success')) | 53 | page.has_content?(I18n.t('controllers.apps.flash.create.success')) |
54 | - expect(App.where(:name => 'My new app').count).to eq 1 | ||
55 | - expect(App.where(:name => 'My new app 2').count).to eq 0 | 54 | + expect(App.where(name: 'My new app').count).to eq 1 |
55 | + expect(App.where(name: 'My new app 2').count).to eq 0 | ||
56 | 56 | ||
57 | click_on I18n.t('shared.navigation.apps') | 57 | click_on I18n.t('shared.navigation.apps') |
58 | click_on 'My new app' | 58 | click_on 'My new app' |
59 | click_link I18n.t('apps.show.edit') | 59 | click_link I18n.t('apps.show.edit') |
60 | - fill_in 'app_name', :with => 'My new app 2' | 60 | + fill_in 'app_name', with: 'My new app 2' |
61 | click_on I18n.t('apps.edit.update') | 61 | click_on I18n.t('apps.edit.update') |
62 | page.has_content?(I18n.t('controllers.apps.flash.update.success')) | 62 | page.has_content?(I18n.t('controllers.apps.flash.update.success')) |
63 | - expect(App.where(:name => 'My new app').count).to eq 0 | ||
64 | - expect(App.where(:name => 'My new app 2').count).to eq 1 | 63 | + expect(App.where(name: 'My new app').count).to eq 0 |
64 | + expect(App.where(name: 'My new app 2').count).to eq 1 | ||
65 | end | 65 | end |
66 | 66 | ||
67 | - scenario "create an apps with issue tracker and edit it", :js => true do | 67 | + scenario "create an apps with issue tracker and edit it", js: true do |
68 | visit '/' | 68 | visit '/' |
69 | log_in admin | 69 | log_in admin |
70 | click_on I18n.t('apps.index.new_app') | 70 | click_on I18n.t('apps.index.new_app') |
71 | - fill_in 'app_name', :with => 'My new app' | 71 | + fill_in 'app_name', with: 'My new app' |
72 | find('.label_radio.github').click | 72 | find('.label_radio.github').click |
73 | 73 | ||
74 | fill_in 'app_github_repo', with: 'foo/bar' | 74 | fill_in 'app_github_repo', with: 'foo/bar' |
75 | within ".github.tracker_params" do | 75 | within ".github.tracker_params" do |
76 | - fill_in 'app_issue_tracker_attributes_options_username', :with => 'token' | ||
77 | - fill_in 'app_issue_tracker_attributes_options_password', :with => 'pass' | 76 | + fill_in 'app_issue_tracker_attributes_options_username', with: 'token' |
77 | + fill_in 'app_issue_tracker_attributes_options_password', with: 'pass' | ||
78 | end | 78 | end |
79 | click_on I18n.t('apps.new.add_app') | 79 | click_on I18n.t('apps.new.add_app') |
80 | expect(page.has_content?(I18n.t('controllers.apps.flash.create.success'))).to eql true | 80 | expect(page.has_content?(I18n.t('controllers.apps.flash.create.success'))).to eql true |
81 | - app = App.where(:name => 'My new app').first | 81 | + app = App.where(name: 'My new app').first |
82 | expect(app.issue_tracker.type_tracker).to eql 'github' | 82 | expect(app.issue_tracker.type_tracker).to eql 'github' |
83 | expect(app.issue_tracker.options['username']).to eql 'token' | 83 | expect(app.issue_tracker.options['username']).to eql 'token' |
84 | expect(app.issue_tracker.options['password']).to eql 'pass' | 84 | expect(app.issue_tracker.options['password']).to eql 'pass' |
@@ -89,7 +89,7 @@ feature "Create an application" do | @@ -89,7 +89,7 @@ feature "Create an application" do | ||
89 | find('.issue_tracker .label_radio.none').click | 89 | find('.issue_tracker .label_radio.none').click |
90 | click_on I18n.t('apps.edit.update') | 90 | click_on I18n.t('apps.edit.update') |
91 | expect(page.has_content?(I18n.t('controllers.apps.flash.update.success'))).to eql true | 91 | expect(page.has_content?(I18n.t('controllers.apps.flash.update.success'))).to eql true |
92 | - app = App.where(:name => 'My new app').first | 92 | + app = App.where(name: 'My new app').first |
93 | expect(app.issue_tracker.tracker).to be_a ErrbitPlugin::NoneIssueTracker | 93 | expect(app.issue_tracker.tracker).to be_a ErrbitPlugin::NoneIssueTracker |
94 | end | 94 | end |
95 | end | 95 | end |
spec/acceptance/sign_in_with_github_spec.rb
@@ -3,7 +3,7 @@ require 'acceptance/acceptance_helper' | @@ -3,7 +3,7 @@ require 'acceptance/acceptance_helper' | ||
3 | feature 'Sign in with GitHub' do | 3 | feature 'Sign in with GitHub' do |
4 | background do | 4 | background do |
5 | allow(Errbit::Config).to receive(:github_authentication).and_return(true) | 5 | allow(Errbit::Config).to receive(:github_authentication).and_return(true) |
6 | - Fabricate(:user, :github_login => 'nashby') | 6 | + Fabricate(:user, github_login: 'nashby') |
7 | end | 7 | end |
8 | 8 | ||
9 | scenario 'log in via GitHub with recognized user' do | 9 | scenario 'log in via GitHub with recognized user' do |
@@ -11,7 +11,7 @@ feature 'Sign in with GitHub' do | @@ -11,7 +11,7 @@ feature 'Sign in with GitHub' do | ||
11 | 11 | ||
12 | visit '/' | 12 | visit '/' |
13 | click_link 'Sign in with GitHub' | 13 | click_link 'Sign in with GitHub' |
14 | - expect(page).to have_content I18n.t("devise.omniauth_callbacks.success", :kind => 'GitHub') | 14 | + expect(page).to have_content I18n.t("devise.omniauth_callbacks.success", kind: 'GitHub') |
15 | end | 15 | end |
16 | 16 | ||
17 | scenario 'reject unrecognized user if authenticating via GitHub' do | 17 | scenario 'reject unrecognized user if authenticating via GitHub' do |
spec/controllers/api/v1/notices_controller_spec.rb
@@ -6,30 +6,30 @@ describe Api::V1::NoticesController, type: 'controller' do | @@ -6,30 +6,30 @@ describe Api::V1::NoticesController, type: 'controller' do | ||
6 | 6 | ||
7 | describe "GET /api/v1/notices" do | 7 | describe "GET /api/v1/notices" do |
8 | before do | 8 | before do |
9 | - Fabricate(:notice, :created_at => Time.zone.parse('2012-08-01')) | ||
10 | - Fabricate(:notice, :created_at => Time.zone.parse('2012-08-01')) | ||
11 | - Fabricate(:notice, :created_at => Time.zone.parse('2012-08-21')) | ||
12 | - Fabricate(:notice, :created_at => Time.zone.parse('2012-08-30')) | 9 | + Fabricate(:notice, created_at: Time.zone.parse('2012-08-01')) |
10 | + Fabricate(:notice, created_at: Time.zone.parse('2012-08-01')) | ||
11 | + Fabricate(:notice, created_at: Time.zone.parse('2012-08-21')) | ||
12 | + Fabricate(:notice, created_at: Time.zone.parse('2012-08-30')) | ||
13 | end | 13 | end |
14 | 14 | ||
15 | it "should return JSON if JSON is requested" do | 15 | it "should return JSON if JSON is requested" do |
16 | - get :index, :auth_token => @user.authentication_token, :format => "json" | 16 | + get :index, auth_token: @user.authentication_token, format: "json" |
17 | expect { JSON.load(response.body) }.not_to raise_error #JSON::ParserError) | 17 | expect { JSON.load(response.body) }.not_to raise_error #JSON::ParserError) |
18 | end | 18 | end |
19 | 19 | ||
20 | it "should return XML if XML is requested" do | 20 | it "should return XML if XML is requested" do |
21 | - get :index, :auth_token => @user.authentication_token, :format => "xml" | 21 | + get :index, auth_token: @user.authentication_token, format: "xml" |
22 | expect(Nokogiri::XML(response.body).errors).to be_empty | 22 | expect(Nokogiri::XML(response.body).errors).to be_empty |
23 | end | 23 | end |
24 | 24 | ||
25 | it "should return JSON by default" do | 25 | it "should return JSON by default" do |
26 | - get :index, :auth_token => @user.authentication_token | 26 | + get :index, auth_token: @user.authentication_token |
27 | expect { JSON.load(response.body) }.not_to raise_error #JSON::ParserError) | 27 | expect { JSON.load(response.body) }.not_to raise_error #JSON::ParserError) |
28 | end | 28 | end |
29 | 29 | ||
30 | describe "given a date range" do | 30 | describe "given a date range" do |
31 | it "should return only the notices created during the date range" do | 31 | it "should return only the notices created during the date range" do |
32 | - get :index, { :auth_token => @user.authentication_token, :start_date => "2012-08-01", :end_date => "2012-08-27" } | 32 | + get :index, { auth_token: @user.authentication_token, start_date: "2012-08-01", end_date: "2012-08-27" } |
33 | expect(response).to be_success | 33 | expect(response).to be_success |
34 | notices = JSON.load response.body | 34 | notices = JSON.load response.body |
35 | expect(notices.length).to eq 3 | 35 | expect(notices.length).to eq 3 |
@@ -37,7 +37,7 @@ describe Api::V1::NoticesController, type: 'controller' do | @@ -37,7 +37,7 @@ describe Api::V1::NoticesController, type: 'controller' do | ||
37 | end | 37 | end |
38 | 38 | ||
39 | it "should return all notices" do | 39 | it "should return all notices" do |
40 | - get :index, { :auth_token => @user.authentication_token } | 40 | + get :index, { auth_token: @user.authentication_token } |
41 | expect(response).to be_success | 41 | expect(response).to be_success |
42 | notices = JSON.load response.body | 42 | notices = JSON.load response.body |
43 | expect(notices.length).to eq 4 | 43 | expect(notices.length).to eq 4 |
spec/controllers/api/v1/problems_controller_spec.rb
@@ -7,34 +7,34 @@ describe Api::V1::ProblemsController, type: 'controller' do | @@ -7,34 +7,34 @@ describe Api::V1::ProblemsController, type: 'controller' do | ||
7 | describe "GET /api/v1/problems/:id" do | 7 | describe "GET /api/v1/problems/:id" do |
8 | before do | 8 | before do |
9 | notice = Fabricate(:notice) | 9 | notice = Fabricate(:notice) |
10 | - err = Fabricate(:err, :notices => [notice]) | ||
11 | - @problem = Fabricate(:problem, :errs => [err]) | 10 | + err = Fabricate(:err, notices: [notice]) |
11 | + @problem = Fabricate(:problem, errs: [err]) | ||
12 | end | 12 | end |
13 | 13 | ||
14 | it "should return JSON if JSON is requested" do | 14 | it "should return JSON if JSON is requested" do |
15 | - get :show, :auth_token => @user.authentication_token, :format => "json", :id => Problem.first.id | 15 | + get :show, auth_token: @user.authentication_token, format: "json", id: Problem.first.id |
16 | expect { JSON.load(response.body) }.not_to raise_error #JSON::ParserError | 16 | expect { JSON.load(response.body) }.not_to raise_error #JSON::ParserError |
17 | end | 17 | end |
18 | 18 | ||
19 | it "should return XML if XML is requested" do | 19 | it "should return XML if XML is requested" do |
20 | - get :index, :auth_token => @user.authentication_token, :format => "xml", :id => @problem.id | 20 | + get :index, auth_token: @user.authentication_token, format: "xml", id: @problem.id |
21 | expect(Nokogiri::XML(response.body).errors).to be_empty | 21 | expect(Nokogiri::XML(response.body).errors).to be_empty |
22 | end | 22 | end |
23 | 23 | ||
24 | it "should return JSON by default" do | 24 | it "should return JSON by default" do |
25 | - get :show, :auth_token => @user.authentication_token, :id => @problem.id | 25 | + get :show, auth_token: @user.authentication_token, id: @problem.id |
26 | expect { JSON.load(response.body) }.not_to raise_error #JSON::ParserError) | 26 | expect { JSON.load(response.body) }.not_to raise_error #JSON::ParserError) |
27 | end | 27 | end |
28 | 28 | ||
29 | it "should return the correct problem" do | 29 | it "should return the correct problem" do |
30 | - get :show, :auth_token => @user.authentication_token, :format => "json", :id => @problem.id | 30 | + get :show, auth_token: @user.authentication_token, format: "json", id: @problem.id |
31 | 31 | ||
32 | returned_problem = JSON.parse(response.body) | 32 | returned_problem = JSON.parse(response.body) |
33 | expect(returned_problem["_id"]).to eq(@problem.id.to_s) | 33 | expect(returned_problem["_id"]).to eq(@problem.id.to_s) |
34 | end | 34 | end |
35 | 35 | ||
36 | it "should return only the correct fields" do | 36 | it "should return only the correct fields" do |
37 | - get :show, :auth_token => @user.authentication_token, :format => "json", :id => @problem.id | 37 | + get :show, auth_token: @user.authentication_token, format: "json", id: @problem.id |
38 | returned_problem = JSON.parse(response.body) | 38 | returned_problem = JSON.parse(response.body) |
39 | 39 | ||
40 | expect(returned_problem.keys).to match_array(%w( | 40 | expect(returned_problem.keys).to match_array(%w( |
@@ -52,37 +52,37 @@ describe Api::V1::ProblemsController, type: 'controller' do | @@ -52,37 +52,37 @@ describe Api::V1::ProblemsController, type: 'controller' do | ||
52 | end | 52 | end |
53 | 53 | ||
54 | it "returns a 404 if the problem cannot be found" do | 54 | it "returns a 404 if the problem cannot be found" do |
55 | - get :show, :auth_token => @user.authentication_token, :format => "json", :id => 'IdontExist' | 55 | + get :show, auth_token: @user.authentication_token, format: "json", id: 'IdontExist' |
56 | expect(response.status).to eq(404) | 56 | expect(response.status).to eq(404) |
57 | end | 57 | end |
58 | end | 58 | end |
59 | 59 | ||
60 | describe "GET /api/v1/problems" do | 60 | describe "GET /api/v1/problems" do |
61 | before do | 61 | before do |
62 | - Fabricate(:problem, :first_notice_at => Date.new(2012, 8, 01), :resolved_at => Date.new(2012, 8, 02)) | ||
63 | - Fabricate(:problem, :first_notice_at => Date.new(2012, 8, 01), :resolved_at => Date.new(2012, 8, 21)) | ||
64 | - Fabricate(:problem, :first_notice_at => Date.new(2012, 8, 21)) | ||
65 | - Fabricate(:problem, :first_notice_at => Date.new(2012, 8, 30)) | 62 | + Fabricate(:problem, first_notice_at: Date.new(2012, 8, 01), resolved_at: Date.new(2012, 8, 02)) |
63 | + Fabricate(:problem, first_notice_at: Date.new(2012, 8, 01), resolved_at: Date.new(2012, 8, 21)) | ||
64 | + Fabricate(:problem, first_notice_at: Date.new(2012, 8, 21)) | ||
65 | + Fabricate(:problem, first_notice_at: Date.new(2012, 8, 30)) | ||
66 | end | 66 | end |
67 | 67 | ||
68 | it "should return JSON if JSON is requested" do | 68 | it "should return JSON if JSON is requested" do |
69 | - get :index, :auth_token => @user.authentication_token, :format => "json" | 69 | + get :index, auth_token: @user.authentication_token, format: "json" |
70 | expect { JSON.load(response.body) }.not_to raise_error #JSON::ParserError) | 70 | expect { JSON.load(response.body) }.not_to raise_error #JSON::ParserError) |
71 | end | 71 | end |
72 | 72 | ||
73 | it "should return XML if XML is requested" do | 73 | it "should return XML if XML is requested" do |
74 | - get :index, :auth_token => @user.authentication_token, :format => "xml" | 74 | + get :index, auth_token: @user.authentication_token, format: "xml" |
75 | expect(Nokogiri::XML(response.body).errors).to be_empty | 75 | expect(Nokogiri::XML(response.body).errors).to be_empty |
76 | end | 76 | end |
77 | 77 | ||
78 | it "should return JSON by default" do | 78 | it "should return JSON by default" do |
79 | - get :index, :auth_token => @user.authentication_token | 79 | + get :index, auth_token: @user.authentication_token |
80 | expect { JSON.load(response.body) }.not_to raise_error #JSON::ParserError) | 80 | expect { JSON.load(response.body) }.not_to raise_error #JSON::ParserError) |
81 | end | 81 | end |
82 | 82 | ||
83 | describe "given a date range" do | 83 | describe "given a date range" do |
84 | it "should return only the problems open during the date range" do | 84 | it "should return only the problems open during the date range" do |
85 | - get :index, { :auth_token => @user.authentication_token, :start_date => "2012-08-20", :end_date => "2012-08-27" } | 85 | + get :index, { auth_token: @user.authentication_token, start_date: "2012-08-20", end_date: "2012-08-27" } |
86 | expect(response).to be_success | 86 | expect(response).to be_success |
87 | problems = JSON.load response.body | 87 | problems = JSON.load response.body |
88 | expect(problems.length).to eq 2 | 88 | expect(problems.length).to eq 2 |
@@ -90,7 +90,7 @@ describe Api::V1::ProblemsController, type: 'controller' do | @@ -90,7 +90,7 @@ describe Api::V1::ProblemsController, type: 'controller' do | ||
90 | end | 90 | end |
91 | 91 | ||
92 | it "should return all problems" do | 92 | it "should return all problems" do |
93 | - get :index, { :auth_token => @user.authentication_token } | 93 | + get :index, { auth_token: @user.authentication_token } |
94 | expect(response).to be_success | 94 | expect(response).to be_success |
95 | problems = JSON.load response.body | 95 | problems = JSON.load response.body |
96 | expect(problems.length).to eq 4 | 96 | expect(problems.length).to eq 4 |
spec/controllers/apps_controller_spec.rb
1 | describe AppsController, type: 'controller' do | 1 | describe AppsController, type: 'controller' do |
2 | it_requires_authentication | 2 | it_requires_authentication |
3 | - it_requires_admin_privileges :for => { :new => :get, :edit => :get, :create => :post, :update => :put, :destroy => :delete } | 3 | + it_requires_admin_privileges for: { new: :get, edit: :get, create: :post, update: :put, destroy: :delete } |
4 | 4 | ||
5 | let(:admin) { Fabricate(:admin) } | 5 | let(:admin) { Fabricate(:admin) } |
6 | let(:user) { Fabricate(:user) } | 6 | let(:user) { Fabricate(:user) } |
7 | - let(:watcher) { Fabricate(:user_watcher, :app => app, :user => user) } | 7 | + let(:watcher) { Fabricate(:user_watcher, app: app, user: user) } |
8 | let(:unwatched_app) { Fabricate(:app) } | 8 | let(:unwatched_app) { Fabricate(:app) } |
9 | let(:app) { unwatched_app } | 9 | let(:app) { unwatched_app } |
10 | let(:watched_app1) do | 10 | let(:watched_app1) do |
11 | a = Fabricate(:app) | 11 | a = Fabricate(:app) |
12 | - Fabricate(:user_watcher, :user => user, :app => a) | 12 | + Fabricate(:user_watcher, user: user, app: a) |
13 | a | 13 | a |
14 | end | 14 | end |
15 | let(:watched_app2) do | 15 | let(:watched_app2) do |
16 | a = Fabricate(:app) | 16 | a = Fabricate(:app) |
17 | - Fabricate(:user_watcher, :user => user, :app => a) | 17 | + Fabricate(:user_watcher, user: user, app: a) |
18 | a | 18 | a |
19 | end | 19 | end |
20 | let(:err) do | 20 | let(:err) do |
21 | - Fabricate(:err, :problem => problem) | 21 | + Fabricate(:err, problem: problem) |
22 | end | 22 | end |
23 | let(:notice) do | 23 | let(:notice) do |
24 | - Fabricate(:notice, :err => err) | 24 | + Fabricate(:notice, err: err) |
25 | end | 25 | end |
26 | let(:problem) do | 26 | let(:problem) do |
27 | - Fabricate(:problem, :app => app) | 27 | + Fabricate(:problem, app: app) |
28 | end | 28 | end |
29 | - let(:problem_resolved) { Fabricate(:problem_resolved, :app => app) } | 29 | + let(:problem_resolved) { Fabricate(:problem_resolved, app: app) } |
30 | 30 | ||
31 | describe "GET /apps" do | 31 | describe "GET /apps" do |
32 | context 'when logged in as an admin' do | 32 | context 'when logged in as an admin' do |
@@ -55,43 +55,43 @@ describe AppsController, type: 'controller' do | @@ -55,43 +55,43 @@ describe AppsController, type: 'controller' do | ||
55 | end | 55 | end |
56 | 56 | ||
57 | it 'finds the app' do | 57 | it 'finds the app' do |
58 | - get :show, :id => app.id | 58 | + get :show, id: app.id |
59 | expect(controller.app).to eq app | 59 | expect(controller.app).to eq app |
60 | end | 60 | end |
61 | 61 | ||
62 | it "should not raise errors for app with err without notices" do | 62 | it "should not raise errors for app with err without notices" do |
63 | err | 63 | err |
64 | - expect { get :show, :id => app.id }.to_not raise_error | 64 | + expect { get :show, id: app.id }.to_not raise_error |
65 | end | 65 | end |
66 | 66 | ||
67 | it "should list atom feed successfully" do | 67 | it "should list atom feed successfully" do |
68 | - get :show, :id => app.id, :format => "atom" | 68 | + get :show, id: app.id, format: "atom" |
69 | expect(response).to be_success | 69 | expect(response).to be_success |
70 | end | 70 | end |
71 | 71 | ||
72 | it "should list available watchers by name" do | 72 | it "should list available watchers by name" do |
73 | - Fabricate(:user, :name => "Carol") | ||
74 | - Fabricate(:user, :name => "Alice") | ||
75 | - Fabricate(:user, :name => "Betty") | 73 | + Fabricate(:user, name: "Carol") |
74 | + Fabricate(:user, name: "Alice") | ||
75 | + Fabricate(:user, name: "Betty") | ||
76 | 76 | ||
77 | - get :show, :id => app.id | 77 | + get :show, id: app.id |
78 | 78 | ||
79 | expect(controller.users.to_a).to eq(User.all.to_a.sort_by(&:name)) | 79 | expect(controller.users.to_a).to eq(User.all.to_a.sort_by(&:name)) |
80 | end | 80 | end |
81 | 81 | ||
82 | context "pagination" do | 82 | context "pagination" do |
83 | before(:each) do | 83 | before(:each) do |
84 | - 35.times { Fabricate(:err, :problem => Fabricate(:problem, :app => app)) } | 84 | + 35.times { Fabricate(:err, problem: Fabricate(:problem, app: app)) } |
85 | end | 85 | end |
86 | 86 | ||
87 | it "should have default per_page value for user" do | 87 | it "should have default per_page value for user" do |
88 | - get :show, :id => app.id | 88 | + get :show, id: app.id |
89 | expect(controller.problems.to_a.size).to eq User::PER_PAGE | 89 | expect(controller.problems.to_a.size).to eq User::PER_PAGE |
90 | end | 90 | end |
91 | 91 | ||
92 | it "should be able to override default per_page value" do | 92 | it "should be able to override default per_page value" do |
93 | admin.update_attribute :per_page, 10 | 93 | admin.update_attribute :per_page, 10 |
94 | - get :show, :id => app.id | 94 | + get :show, id: app.id |
95 | expect(controller.problems.to_a.size).to eq 10 | 95 | expect(controller.problems.to_a.size).to eq 10 |
96 | end | 96 | end |
97 | end | 97 | end |
@@ -103,14 +103,14 @@ describe AppsController, type: 'controller' do | @@ -103,14 +103,14 @@ describe AppsController, type: 'controller' do | ||
103 | 103 | ||
104 | context 'and no params' do | 104 | context 'and no params' do |
105 | it 'shows only unresolved problems' do | 105 | it 'shows only unresolved problems' do |
106 | - get :show, :id => app.id | 106 | + get :show, id: app.id |
107 | expect(controller.problems.size).to eq 1 | 107 | expect(controller.problems.size).to eq 1 |
108 | end | 108 | end |
109 | end | 109 | end |
110 | 110 | ||
111 | context 'and all_problems=true params' do | 111 | context 'and all_problems=true params' do |
112 | it 'shows all errors' do | 112 | it 'shows all errors' do |
113 | - get :show, :id => app.id, :all_errs => true | 113 | + get :show, id: app.id, all_errs: true |
114 | expect(controller.problems.size).to eq 2 | 114 | expect(controller.problems.size).to eq 2 |
115 | end | 115 | end |
116 | end | 116 | end |
@@ -120,41 +120,41 @@ describe AppsController, type: 'controller' do | @@ -120,41 +120,41 @@ describe AppsController, type: 'controller' do | ||
120 | before(:each) do | 120 | before(:each) do |
121 | environments = %w(production test development staging) | 121 | environments = %w(production test development staging) |
122 | 20.times do |i| | 122 | 20.times do |i| |
123 | - Fabricate(:problem, :app => app, :environment => environments[i % environments.length]) | 123 | + Fabricate(:problem, app: app, environment: environments[i % environments.length]) |
124 | end | 124 | end |
125 | end | 125 | end |
126 | 126 | ||
127 | context 'no params' do | 127 | context 'no params' do |
128 | it 'shows errs for all environments' do | 128 | it 'shows errs for all environments' do |
129 | - get :show, :id => app.id | 129 | + get :show, id: app.id |
130 | expect(controller.problems.size).to eq 20 | 130 | expect(controller.problems.size).to eq 20 |
131 | end | 131 | end |
132 | end | 132 | end |
133 | 133 | ||
134 | context 'environment production' do | 134 | context 'environment production' do |
135 | it 'shows errs for just production' do | 135 | it 'shows errs for just production' do |
136 | - get :show, :id => app.id, :environment => 'production' | 136 | + get :show, id: app.id, environment: 'production' |
137 | expect(controller.problems.size).to eq 5 | 137 | expect(controller.problems.size).to eq 5 |
138 | end | 138 | end |
139 | end | 139 | end |
140 | 140 | ||
141 | context 'environment staging' do | 141 | context 'environment staging' do |
142 | it 'shows errs for just staging' do | 142 | it 'shows errs for just staging' do |
143 | - get :show, :id => app.id, :environment => 'staging' | 143 | + get :show, id: app.id, environment: 'staging' |
144 | expect(controller.problems.size).to eq 5 | 144 | expect(controller.problems.size).to eq 5 |
145 | end | 145 | end |
146 | end | 146 | end |
147 | 147 | ||
148 | context 'environment development' do | 148 | context 'environment development' do |
149 | it 'shows errs for just development' do | 149 | it 'shows errs for just development' do |
150 | - get :show, :id => app.id, :environment => 'development' | 150 | + get :show, id: app.id, environment: 'development' |
151 | expect(controller.problems.size).to eq 5 | 151 | expect(controller.problems.size).to eq 5 |
152 | end | 152 | end |
153 | end | 153 | end |
154 | 154 | ||
155 | context 'environment test' do | 155 | context 'environment test' do |
156 | it 'shows errs for just test' do | 156 | it 'shows errs for just test' do |
157 | - get :show, :id => app.id, :environment => 'test' | 157 | + get :show, id: app.id, environment: 'test' |
158 | expect(controller.problems.size).to eq 5 | 158 | expect(controller.problems.size).to eq 5 |
159 | end | 159 | end |
160 | end | 160 | end |
@@ -166,7 +166,7 @@ describe AppsController, type: 'controller' do | @@ -166,7 +166,7 @@ describe AppsController, type: 'controller' do | ||
166 | sign_in Fabricate(:user) | 166 | sign_in Fabricate(:user) |
167 | app = Fabricate(:app) | 167 | app = Fabricate(:app) |
168 | 168 | ||
169 | - get :show, :id => app.id | 169 | + get :show, id: app.id |
170 | expect(controller.app).to eq app | 170 | expect(controller.app).to eq app |
171 | end | 171 | end |
172 | end | 172 | end |
@@ -186,9 +186,9 @@ describe AppsController, type: 'controller' do | @@ -186,9 +186,9 @@ describe AppsController, type: 'controller' do | ||
186 | end | 186 | end |
187 | 187 | ||
188 | it "should copy attributes from an existing app" do | 188 | it "should copy attributes from an existing app" do |
189 | - @app = Fabricate(:app, :name => "do not copy", | ||
190 | - :github_repo => "test/example") | ||
191 | - get :new, :copy_attributes_from => @app.id | 189 | + @app = Fabricate(:app, name: "do not copy", |
190 | + github_repo: "test/example") | ||
191 | + get :new, copy_attributes_from: @app.id | ||
192 | expect(controller.app).to be_a(App) | 192 | expect(controller.app).to be_a(App) |
193 | expect(controller.app).to be_new_record | 193 | expect(controller.app).to be_new_record |
194 | expect(controller.app.name).to be_blank | 194 | expect(controller.app.name).to be_blank |
@@ -199,7 +199,7 @@ describe AppsController, type: 'controller' do | @@ -199,7 +199,7 @@ describe AppsController, type: 'controller' do | ||
199 | describe "GET /apps/:id/edit" do | 199 | describe "GET /apps/:id/edit" do |
200 | it 'finds the correct app' do | 200 | it 'finds the correct app' do |
201 | app = Fabricate(:app) | 201 | app = Fabricate(:app) |
202 | - get :edit, :id => app.id | 202 | + get :edit, id: app.id |
203 | expect(controller.app).to eq app | 203 | expect(controller.app).to eq app |
204 | end | 204 | end |
205 | end | 205 | end |
@@ -216,12 +216,12 @@ describe AppsController, type: 'controller' do | @@ -216,12 +216,12 @@ describe AppsController, type: 'controller' do | ||
216 | end | 216 | end |
217 | 217 | ||
218 | it "should redirect to the app page" do | 218 | it "should redirect to the app page" do |
219 | - post :create, :app => {} | 219 | + post :create, app: {} |
220 | expect(response).to redirect_to(app_path(@app)) | 220 | expect(response).to redirect_to(app_path(@app)) |
221 | end | 221 | end |
222 | 222 | ||
223 | it "should display a message" do | 223 | it "should display a message" do |
224 | - post :create, :app => {} | 224 | + post :create, app: {} |
225 | expect(request.flash[:success]).to match(/success/) | 225 | expect(request.flash[:success]).to match(/success/) |
226 | end | 226 | end |
227 | end | 227 | end |
@@ -234,12 +234,12 @@ describe AppsController, type: 'controller' do | @@ -234,12 +234,12 @@ describe AppsController, type: 'controller' do | ||
234 | 234 | ||
235 | context "when the update is successful" do | 235 | context "when the update is successful" do |
236 | it "should redirect to the app page" do | 236 | it "should redirect to the app page" do |
237 | - put :update, :id => @app.id, :app => {} | 237 | + put :update, id: @app.id, app: {} |
238 | expect(response).to redirect_to(app_path(@app)) | 238 | expect(response).to redirect_to(app_path(@app)) |
239 | end | 239 | end |
240 | 240 | ||
241 | it "should display a message" do | 241 | it "should display a message" do |
242 | - put :update, :id => @app.id, :app => {} | 242 | + put :update, id: @app.id, app: {} |
243 | expect(request.flash[:success]).to match(/success/) | 243 | expect(request.flash[:success]).to match(/success/) |
244 | end | 244 | end |
245 | end | 245 | end |
@@ -247,14 +247,14 @@ describe AppsController, type: 'controller' do | @@ -247,14 +247,14 @@ describe AppsController, type: 'controller' do | ||
247 | context "changing name" do | 247 | context "changing name" do |
248 | it "should redirect to app page" do | 248 | it "should redirect to app page" do |
249 | id = @app.id | 249 | id = @app.id |
250 | - put :update, :id => id, :app => { :name => "new name" } | 250 | + put :update, id: id, app: { name: "new name" } |
251 | expect(response).to redirect_to(app_path(id)) | 251 | expect(response).to redirect_to(app_path(id)) |
252 | end | 252 | end |
253 | end | 253 | end |
254 | 254 | ||
255 | context "when the update is unsuccessful" do | 255 | context "when the update is unsuccessful" do |
256 | it "should render the edit page" do | 256 | it "should render the edit page" do |
257 | - put :update, :id => @app.id, :app => { :name => '' } | 257 | + put :update, id: @app.id, app: { name: '' } |
258 | expect(response).to render_template(:edit) | 258 | expect(response).to render_template(:edit) |
259 | end | 259 | end |
260 | end | 260 | end |
@@ -265,30 +265,30 @@ describe AppsController, type: 'controller' do | @@ -265,30 +265,30 @@ describe AppsController, type: 'controller' do | ||
265 | end | 265 | end |
266 | 266 | ||
267 | it "should parse legal csv values" do | 267 | it "should parse legal csv values" do |
268 | - put :update, :id => @app.id, :app => { :email_at_notices => '1, 4, 7,8, 10' } | 268 | + put :update, id: @app.id, app: { email_at_notices: '1, 4, 7,8, 10' } |
269 | @app.reload | 269 | @app.reload |
270 | expect(@app.email_at_notices).to eq [1, 4, 7, 8, 10] | 270 | expect(@app.email_at_notices).to eq [1, 4, 7, 8, 10] |
271 | end | 271 | end |
272 | context "failed parsing of CSV" do | 272 | context "failed parsing of CSV" do |
273 | it "should set the default value" do | 273 | it "should set the default value" do |
274 | - @app = Fabricate(:app, :email_at_notices => [1, 2, 3, 4]) | ||
275 | - put :update, :id => @app.id, :app => { :email_at_notices => 'asdf, -1,0,foobar,gd00,0,abc' } | 274 | + @app = Fabricate(:app, email_at_notices: [1, 2, 3, 4]) |
275 | + put :update, id: @app.id, app: { email_at_notices: 'asdf, -1,0,foobar,gd00,0,abc' } | ||
276 | @app.reload | 276 | @app.reload |
277 | expect(@app.email_at_notices).to eq Errbit::Config.email_at_notices | 277 | expect(@app.email_at_notices).to eq Errbit::Config.email_at_notices |
278 | end | 278 | end |
279 | 279 | ||
280 | it "should display a message" do | 280 | it "should display a message" do |
281 | - put :update, :id => @app.id, :app => { :email_at_notices => 'qwertyuiop' } | 281 | + put :update, id: @app.id, app: { email_at_notices: 'qwertyuiop' } |
282 | expect(request.flash[:error]).to match(/Couldn't parse/) | 282 | expect(request.flash[:error]).to match(/Couldn't parse/) |
283 | end | 283 | end |
284 | end | 284 | end |
285 | end | 285 | end |
286 | 286 | ||
287 | - context "setting up issue tracker", :cur => true do | 287 | + context "setting up issue tracker", cur: true do |
288 | context "unknown tracker type" do | 288 | context "unknown tracker type" do |
289 | before(:each) do | 289 | before(:each) do |
290 | - put :update, :id => @app.id, :app => { :issue_tracker_attributes => { | ||
291 | - :type_tracker => 'unknown', :options => { :project_id => '1234', :api_token => '123123', :account => 'myapp' } | 290 | + put :update, id: @app.id, app: { issue_tracker_attributes: { |
291 | + type_tracker: 'unknown', options: { project_id: '1234', api_token: '123123', account: 'myapp' } | ||
292 | } } | 292 | } } |
293 | @app.reload | 293 | @app.reload |
294 | end | 294 | end |
@@ -306,24 +306,24 @@ describe AppsController, type: 'controller' do | @@ -306,24 +306,24 @@ describe AppsController, type: 'controller' do | ||
306 | end | 306 | end |
307 | 307 | ||
308 | it "should find the app" do | 308 | it "should find the app" do |
309 | - delete :destroy, :id => @app.id | 309 | + delete :destroy, id: @app.id |
310 | expect(controller.app).to eq @app | 310 | expect(controller.app).to eq @app |
311 | end | 311 | end |
312 | 312 | ||
313 | it "should destroy the app" do | 313 | it "should destroy the app" do |
314 | - delete :destroy, :id => @app.id | 314 | + delete :destroy, id: @app.id |
315 | expect { | 315 | expect { |
316 | @app.reload | 316 | @app.reload |
317 | }.to raise_error(Mongoid::Errors::DocumentNotFound) | 317 | }.to raise_error(Mongoid::Errors::DocumentNotFound) |
318 | end | 318 | end |
319 | 319 | ||
320 | it "should display a message" do | 320 | it "should display a message" do |
321 | - delete :destroy, :id => @app.id | 321 | + delete :destroy, id: @app.id |
322 | expect(request.flash[:success]).to match(/success/) | 322 | expect(request.flash[:success]).to match(/success/) |
323 | end | 323 | end |
324 | 324 | ||
325 | it "should redirect to the apps page" do | 325 | it "should redirect to the apps page" do |
326 | - delete :destroy, :id => @app.id | 326 | + delete :destroy, id: @app.id |
327 | expect(response).to redirect_to(apps_path) | 327 | expect(response).to redirect_to(apps_path) |
328 | end | 328 | end |
329 | end | 329 | end |
@@ -336,7 +336,7 @@ describe AppsController, type: 'controller' do | @@ -336,7 +336,7 @@ describe AppsController, type: 'controller' do | ||
336 | end | 336 | end |
337 | 337 | ||
338 | it 'redirect to root with flash error' do | 338 | it 'redirect to root with flash error' do |
339 | - post :regenerate_api_key, :id => 'foo' | 339 | + post :regenerate_api_key, id: 'foo' |
340 | expect(request).to redirect_to root_path | 340 | expect(request).to redirect_to root_path |
341 | end | 341 | end |
342 | end | 342 | end |
@@ -348,7 +348,7 @@ describe AppsController, type: 'controller' do | @@ -348,7 +348,7 @@ describe AppsController, type: 'controller' do | ||
348 | 348 | ||
349 | it 'redirect_to app view' do | 349 | it 'redirect_to app view' do |
350 | expect do | 350 | expect do |
351 | - post :regenerate_api_key, :id => app.id | 351 | + post :regenerate_api_key, id: app.id |
352 | expect(request).to redirect_to edit_app_path(app) | 352 | expect(request).to redirect_to edit_app_path(app) |
353 | end.to change { app.reload.api_key } | 353 | end.to change { app.reload.api_key } |
354 | end | 354 | end |
spec/controllers/comments_controller_spec.rb
1 | describe CommentsController, type: 'controller' do | 1 | describe CommentsController, type: 'controller' do |
2 | let(:app) { Fabricate(:app) } | 2 | let(:app) { Fabricate(:app) } |
3 | - let(:err) { Fabricate(:err, :problem => Fabricate(:problem, :app => app, :environment => "production")) } | 3 | + let(:err) { Fabricate(:err, problem: Fabricate(:problem, app: app, environment: "production")) } |
4 | 4 | ||
5 | describe "POST /apps/:app_id/errs/:id/comments/create" do | 5 | describe "POST /apps/:app_id/errs/:id/comments/create" do |
6 | render_views | 6 | render_views |
@@ -14,8 +14,8 @@ describe CommentsController, type: 'controller' do | @@ -14,8 +14,8 @@ describe CommentsController, type: 'controller' do | ||
14 | let(:user) { Fabricate(:user) } | 14 | let(:user) { Fabricate(:user) } |
15 | 15 | ||
16 | before(:each) do | 16 | before(:each) do |
17 | - post :create, :app_id => problem.app.id, :problem_id => problem.id, | ||
18 | - :comment => { :body => "One test comment", :user_id => user.id } | 17 | + post :create, app_id: problem.app.id, problem_id: problem.id, |
18 | + comment: { body: "One test comment", user_id: user.id } | ||
19 | problem.reload | 19 | problem.reload |
20 | end | 20 | end |
21 | 21 | ||
@@ -41,7 +41,7 @@ describe CommentsController, type: 'controller' do | @@ -41,7 +41,7 @@ describe CommentsController, type: 'controller' do | ||
41 | let(:comment) { problem.reload.comments.first } | 41 | let(:comment) { problem.reload.comments.first } |
42 | 42 | ||
43 | before(:each) do | 43 | before(:each) do |
44 | - delete :destroy, :app_id => problem.app.id, :problem_id => problem.id, :id => comment.id.to_s | 44 | + delete :destroy, app_id: problem.app.id, problem_id: problem.id, id: comment.id.to_s |
45 | problem.reload | 45 | problem.reload |
46 | end | 46 | end |
47 | 47 |
spec/controllers/deploys_controller_spec.rb
@@ -10,30 +10,30 @@ describe DeploysController, type: 'controller' do | @@ -10,30 +10,30 @@ describe DeploysController, type: 'controller' do | ||
10 | 'scm_revision' => '19d77837eef37902cf5df7e4445c85f392a8d0d5', | 10 | 'scm_revision' => '19d77837eef37902cf5df7e4445c85f392a8d0d5', |
11 | 'message' => 'johns first deploy' | 11 | 'message' => 'johns first deploy' |
12 | } | 12 | } |
13 | - @app = Fabricate(:app_with_watcher, :notify_on_deploys => true, :api_key => 'APIKEY') | 13 | + @app = Fabricate(:app_with_watcher, notify_on_deploys: true, api_key: 'APIKEY') |
14 | end | 14 | end |
15 | 15 | ||
16 | it 'finds the app via the api key' do | 16 | it 'finds the app via the api key' do |
17 | expect(App).to receive(:find_by_api_key!).with('APIKEY').and_return(@app) | 17 | expect(App).to receive(:find_by_api_key!).with('APIKEY').and_return(@app) |
18 | - post :create, :deploy => @params, :api_key => 'APIKEY' | 18 | + post :create, deploy: @params, api_key: 'APIKEY' |
19 | end | 19 | end |
20 | 20 | ||
21 | it 'creates a deploy' do | 21 | it 'creates a deploy' do |
22 | expect(App).to receive(:find_by_api_key!).and_return(@app) | 22 | expect(App).to receive(:find_by_api_key!).and_return(@app) |
23 | expect(@app.deploys).to receive(:create!). | 23 | expect(@app.deploys).to receive(:create!). |
24 | with({ | 24 | with({ |
25 | - :username => 'john.doe', | ||
26 | - :environment => 'production', | ||
27 | - :repository => 'git@github.com/errbit/errbit.git', | ||
28 | - :revision => '19d77837eef37902cf5df7e4445c85f392a8d0d5', | ||
29 | - :message => 'johns first deploy' | 25 | + username: 'john.doe', |
26 | + environment: 'production', | ||
27 | + repository: 'git@github.com/errbit/errbit.git', | ||
28 | + revision: '19d77837eef37902cf5df7e4445c85f392a8d0d5', | ||
29 | + message: 'johns first deploy' | ||
30 | 30 | ||
31 | }).and_return(Fabricate(:deploy)) | 31 | }).and_return(Fabricate(:deploy)) |
32 | - post :create, :deploy => @params, :api_key => 'APIKEY' | 32 | + post :create, deploy: @params, api_key: 'APIKEY' |
33 | end | 33 | end |
34 | 34 | ||
35 | it 'sends an email notification when configured to do so' do | 35 | it 'sends an email notification when configured to do so' do |
36 | - post :create, :deploy => @params, :api_key => 'APIKEY' | 36 | + post :create, deploy: @params, api_key: 'APIKEY' |
37 | email = ActionMailer::Base.deliveries.last | 37 | email = ActionMailer::Base.deliveries.last |
38 | expect(email.to).to include(@app.watchers.first.email) | 38 | expect(email.to).to include(@app.watchers.first.email) |
39 | expect(email.subject).to eq "[#{@app.name}] Deployed to production by john.doe" | 39 | expect(email.subject).to eq "[#{@app.name}] Deployed to production by john.doe" |
@@ -44,7 +44,7 @@ describe DeploysController, type: 'controller' do | @@ -44,7 +44,7 @@ describe DeploysController, type: 'controller' do | ||
44 | before(:each) do | 44 | before(:each) do |
45 | @deploy = Fabricate :deploy | 45 | @deploy = Fabricate :deploy |
46 | sign_in Fabricate(:admin) | 46 | sign_in Fabricate(:admin) |
47 | - get :index, :app_id => @deploy.app.id | 47 | + get :index, app_id: @deploy.app.id |
48 | end | 48 | end |
49 | 49 | ||
50 | it "should render successfully" do | 50 | it "should render successfully" do |
spec/controllers/devise_sessions_controller_spec.rb
@@ -10,12 +10,12 @@ describe Devise::SessionsController, type: 'controller' do | @@ -10,12 +10,12 @@ describe Devise::SessionsController, type: 'controller' do | ||
10 | let(:user) { Fabricate(:user) } | 10 | let(:user) { Fabricate(:user) } |
11 | 11 | ||
12 | it 'redirects to app index page if there are no apps for the user' do | 12 | it 'redirects to app index page if there are no apps for the user' do |
13 | - post :create, { :user => { 'email' => user.email, 'password' => user.password } } | 13 | + post :create, { user: { 'email' => user.email, 'password' => user.password } } |
14 | expect(response).to redirect_to(root_path) | 14 | expect(response).to redirect_to(root_path) |
15 | end | 15 | end |
16 | 16 | ||
17 | it 'displays a friendly error when credentials are invalid' do | 17 | it 'displays a friendly error when credentials are invalid' do |
18 | - post :create, { :user => { 'email' => 'whatever', 'password' => 'somethinginvalid' } } | 18 | + post :create, { user: { 'email' => 'whatever', 'password' => 'somethinginvalid' } } |
19 | expect(request.flash["alert"]).to eq(I18n.t 'devise.failure.user.email_invalid') | 19 | expect(request.flash["alert"]).to eq(I18n.t 'devise.failure.user.email_invalid') |
20 | end | 20 | end |
21 | end | 21 | end |
spec/controllers/notices_controller_spec.rb
1 | describe NoticesController, type: 'controller' do | 1 | describe NoticesController, type: 'controller' do |
2 | - it_requires_authentication :for => { :locate => :get } | 2 | + it_requires_authentication for: { locate: :get } |
3 | 3 | ||
4 | let(:notice) { Fabricate(:notice) } | 4 | let(:notice) { Fabricate(:notice) } |
5 | let(:xml) { Rails.root.join('spec', 'fixtures', 'hoptoad_test_notice.xml').read } | 5 | let(:xml) { Rails.root.join('spec', 'fixtures', 'hoptoad_test_notice.xml').read } |
6 | let(:app) { Fabricate(:app) } | 6 | let(:app) { Fabricate(:app) } |
7 | - let(:error_report) { double(:valid? => true, :generate_notice! => true, :notice => notice, :should_keep? => true) } | 7 | + let(:error_report) { double(valid?: true, generate_notice!: true, notice: notice, should_keep?: true) } |
8 | 8 | ||
9 | context 'notices API' do | 9 | context 'notices API' do |
10 | context "with bogus xml" do | 10 | context "with bogus xml" do |
11 | it "returns an error" do | 11 | it "returns an error" do |
12 | expect(request).to receive(:raw_post).and_return('<r><b>notxml</r>') | 12 | expect(request).to receive(:raw_post).and_return('<r><b>notxml</r>') |
13 | - post :create, :format => :xml | 13 | + post :create, format: :xml |
14 | expect(response.status).to eq(422) | 14 | expect(response.status).to eq(422) |
15 | expect(response.body).to eq('The provided XML was not well-formed') | 15 | expect(response.body).to eq('The provided XML was not well-formed') |
16 | end | 16 | end |
@@ -24,7 +24,7 @@ describe NoticesController, type: 'controller' do | @@ -24,7 +24,7 @@ describe NoticesController, type: 'controller' do | ||
24 | context "with xml pass in raw_port" do | 24 | context "with xml pass in raw_port" do |
25 | before do | 25 | before do |
26 | expect(request).to receive(:raw_post).and_return(xml) | 26 | expect(request).to receive(:raw_post).and_return(xml) |
27 | - post :create, :format => :xml | 27 | + post :create, format: :xml |
28 | end | 28 | end |
29 | 29 | ||
30 | it "generates a notice from raw xml [POST]" do | 30 | it "generates a notice from raw xml [POST]" do |
@@ -37,7 +37,7 @@ describe NoticesController, type: 'controller' do | @@ -37,7 +37,7 @@ describe NoticesController, type: 'controller' do | ||
37 | end | 37 | end |
38 | 38 | ||
39 | it "generates a notice from xml in a data param [POST]" do | 39 | it "generates a notice from xml in a data param [POST]" do |
40 | - post :create, :data => xml, :format => :xml | 40 | + post :create, data: xml, format: :xml |
41 | expect(response).to be_success | 41 | expect(response).to be_success |
42 | # Same RegExp from Airbrake::Sender#send_to_airbrake (https://github.com/airbrake/airbrake/blob/master/lib/airbrake/sender.rb#L53) | 42 | # Same RegExp from Airbrake::Sender#send_to_airbrake (https://github.com/airbrake/airbrake/blob/master/lib/airbrake/sender.rb#L53) |
43 | # Inspired by https://github.com/airbrake/airbrake/blob/master/test/sender_test.rb | 43 | # Inspired by https://github.com/airbrake/airbrake/blob/master/test/sender_test.rb |
@@ -46,15 +46,15 @@ describe NoticesController, type: 'controller' do | @@ -46,15 +46,15 @@ describe NoticesController, type: 'controller' do | ||
46 | end | 46 | end |
47 | 47 | ||
48 | it "generates a notice from xml [GET]" do | 48 | it "generates a notice from xml [GET]" do |
49 | - get :create, :data => xml, :format => :xml | 49 | + get :create, data: xml, format: :xml |
50 | expect(response).to be_success | 50 | expect(response).to be_success |
51 | expect(response.body).to match(%r{<id[^>]*>#{notice.id}</id>}) | 51 | expect(response.body).to match(%r{<id[^>]*>#{notice.id}</id>}) |
52 | expect(response.body).to match(%r{<url[^>]*>(.+)#{locate_path(notice.id)}</url>}) | 52 | expect(response.body).to match(%r{<url[^>]*>(.+)#{locate_path(notice.id)}</url>}) |
53 | end | 53 | end |
54 | context "with an invalid API_KEY" do | 54 | context "with an invalid API_KEY" do |
55 | - let(:error_report) { double(:valid? => false) } | 55 | + let(:error_report) { double(valid?: false) } |
56 | it 'return 422' do | 56 | it 'return 422' do |
57 | - post :create, :format => :xml, :data => xml | 57 | + post :create, format: :xml, data: xml |
58 | expect(response.status).to eq 422 | 58 | expect(response.status).to eq 422 |
59 | end | 59 | end |
60 | end | 60 | end |
@@ -62,7 +62,7 @@ describe NoticesController, type: 'controller' do | @@ -62,7 +62,7 @@ describe NoticesController, type: 'controller' do | ||
62 | 62 | ||
63 | context "without params needed" do | 63 | context "without params needed" do |
64 | it 'return 400' do | 64 | it 'return 400' do |
65 | - post :create, :format => :xml | 65 | + post :create, format: :xml |
66 | expect(response.status).to eq 400 | 66 | expect(response.status).to eq 400 |
67 | expect(response.body).to eq 'Need a data params in GET or raw post data' | 67 | expect(response.body).to eq 'Need a data params in GET or raw post data' |
68 | end | 68 | end |
@@ -77,9 +77,9 @@ describe NoticesController, type: 'controller' do | @@ -77,9 +77,9 @@ describe NoticesController, type: 'controller' do | ||
77 | end | 77 | end |
78 | 78 | ||
79 | it "should locate notice and redirect to problem" do | 79 | it "should locate notice and redirect to problem" do |
80 | - problem = Fabricate(:problem, :app => app, :environment => "production") | ||
81 | - notice = Fabricate(:notice, :err => Fabricate(:err, :problem => problem)) | ||
82 | - get :locate, :id => notice.id | 80 | + problem = Fabricate(:problem, app: app, environment: "production") |
81 | + notice = Fabricate(:notice, err: Fabricate(:err, problem: problem)) | ||
82 | + get :locate, id: notice.id | ||
83 | expect(response).to redirect_to(app_problem_path(problem.app, problem)) | 83 | expect(response).to redirect_to(app_problem_path(problem.app, problem)) |
84 | end | 84 | end |
85 | end | 85 | end |
spec/controllers/problems_controller_spec.rb
1 | describe ProblemsController, type: 'controller' do | 1 | describe ProblemsController, type: 'controller' do |
2 | - it_requires_authentication :for => { | ||
3 | - :index => :get, :show => :get, :resolve => :put, :search => :get | 2 | + it_requires_authentication for: { |
3 | + index: :get, show: :get, resolve: :put, search: :get | ||
4 | }, | 4 | }, |
5 | - :params => { :app_id => 'dummyid', :id => 'dummyid' } | 5 | + params: { app_id: 'dummyid', id: 'dummyid' } |
6 | 6 | ||
7 | let(:app) { Fabricate(:app) } | 7 | let(:app) { Fabricate(:app) } |
8 | - let(:err) { Fabricate(:err, :problem => problem) } | 8 | + let(:err) { Fabricate(:err, problem: problem) } |
9 | let(:user) { Fabricate(:user) } | 9 | let(:user) { Fabricate(:user) } |
10 | - let(:problem) { Fabricate(:problem, :app => app, :environment => "production") } | 10 | + let(:problem) { Fabricate(:problem, app: app, environment: "production") } |
11 | 11 | ||
12 | describe "GET /problems" do | 12 | describe "GET /problems" do |
13 | before(:each) do | 13 | before(:each) do |
14 | sign_in user | 14 | sign_in user |
15 | - @problem = Fabricate(:notice, :err => Fabricate(:err, :problem => Fabricate(:problem, :app => app, :environment => "production"))).problem | 15 | + @problem = Fabricate(:notice, err: Fabricate(:err, problem: Fabricate(:problem, app: app, environment: "production"))).problem |
16 | end | 16 | end |
17 | 17 | ||
18 | context "pagination" do | 18 | context "pagination" do |
@@ -36,7 +36,7 @@ describe ProblemsController, type: 'controller' do | @@ -36,7 +36,7 @@ describe ProblemsController, type: 'controller' do | ||
36 | before(:each) do | 36 | before(:each) do |
37 | environments = %w(production test development staging) | 37 | environments = %w(production test development staging) |
38 | 20.times do |i| | 38 | 20.times do |i| |
39 | - Fabricate(:problem, :environment => environments[i % environments.length]) | 39 | + Fabricate(:problem, environment: environments[i % environments.length]) |
40 | end | 40 | end |
41 | end | 41 | end |
42 | 42 | ||
@@ -49,28 +49,28 @@ describe ProblemsController, type: 'controller' do | @@ -49,28 +49,28 @@ describe ProblemsController, type: 'controller' do | ||
49 | 49 | ||
50 | context 'environment production' do | 50 | context 'environment production' do |
51 | it 'shows problems for just production' do | 51 | it 'shows problems for just production' do |
52 | - get :index, :environment => 'production' | 52 | + get :index, environment: 'production' |
53 | expect(controller.problems.size).to eq 6 | 53 | expect(controller.problems.size).to eq 6 |
54 | end | 54 | end |
55 | end | 55 | end |
56 | 56 | ||
57 | context 'environment staging' do | 57 | context 'environment staging' do |
58 | it 'shows problems for just staging' do | 58 | it 'shows problems for just staging' do |
59 | - get :index, :environment => 'staging' | 59 | + get :index, environment: 'staging' |
60 | expect(controller.problems.size).to eq 5 | 60 | expect(controller.problems.size).to eq 5 |
61 | end | 61 | end |
62 | end | 62 | end |
63 | 63 | ||
64 | context 'environment development' do | 64 | context 'environment development' do |
65 | it 'shows problems for just development' do | 65 | it 'shows problems for just development' do |
66 | - get :index, :environment => 'development' | 66 | + get :index, environment: 'development' |
67 | expect(controller.problems.size).to eq 5 | 67 | expect(controller.problems.size).to eq 5 |
68 | end | 68 | end |
69 | end | 69 | end |
70 | 70 | ||
71 | context 'environment test' do | 71 | context 'environment test' do |
72 | it 'shows problems for just test' do | 72 | it 'shows problems for just test' do |
73 | - get :index, :environment => 'test' | 73 | + get :index, environment: 'test' |
74 | expect(controller.problems.size).to eq 5 | 74 | expect(controller.problems.size).to eq 5 |
75 | end | 75 | end |
76 | end | 76 | end |
@@ -82,11 +82,11 @@ describe ProblemsController, type: 'controller' do | @@ -82,11 +82,11 @@ describe ProblemsController, type: 'controller' do | ||
82 | sign_in Fabricate(:user) | 82 | sign_in Fabricate(:user) |
83 | problems = Kaminari.paginate_array((1..30).to_a) | 83 | problems = Kaminari.paginate_array((1..30).to_a) |
84 | 3.times { problems << Fabricate(:err).problem } | 84 | 3.times { problems << Fabricate(:err).problem } |
85 | - 3.times { problems << Fabricate(:err, :problem => Fabricate(:problem, :resolved => true)).problem } | 85 | + 3.times { problems << Fabricate(:err, problem: Fabricate(:problem, resolved: true)).problem } |
86 | expect(Problem).to receive(:ordered_by).and_return( | 86 | expect(Problem).to receive(:ordered_by).and_return( |
87 | - double('proxy', :page => double('other_proxy', :per => problems)) | 87 | + double('proxy', page: double('other_proxy', per: problems)) |
88 | ) | 88 | ) |
89 | - get :index, :all_errs => true | 89 | + get :index, all_errs: true |
90 | expect(controller.problems).to eq problems | 90 | expect(controller.problems).to eq problems |
91 | end | 91 | end |
92 | end | 92 | end |
@@ -95,8 +95,8 @@ describe ProblemsController, type: 'controller' do | @@ -95,8 +95,8 @@ describe ProblemsController, type: 'controller' do | ||
95 | before do | 95 | before do |
96 | sign_in user | 96 | sign_in user |
97 | @app = Fabricate(:app) | 97 | @app = Fabricate(:app) |
98 | - @problem1 = Fabricate(:problem, :app => @app, message: "Most important") | ||
99 | - @problem2 = Fabricate(:problem, :app => @app, message: "Very very important") | 98 | + @problem1 = Fabricate(:problem, app: @app, message: "Most important") |
99 | + @problem2 = Fabricate(:problem, app: @app, message: "Very very important") | ||
100 | end | 100 | end |
101 | 101 | ||
102 | it "renders successfully" do | 102 | it "renders successfully" do |
@@ -110,7 +110,7 @@ describe ProblemsController, type: 'controller' do | @@ -110,7 +110,7 @@ describe ProblemsController, type: 'controller' do | ||
110 | end | 110 | end |
111 | 111 | ||
112 | it "searches problems for given string" do | 112 | it "searches problems for given string" do |
113 | - get :search, :search => "\"Most important\"" | 113 | + get :search, search: "\"Most important\"" |
114 | expect(controller.problems).to include(@problem1) | 114 | expect(controller.problems).to include(@problem1) |
115 | expect(controller.problems).to_not include(@problem2) | 115 | expect(controller.problems).to_not include(@problem2) |
116 | end | 116 | end |
@@ -122,35 +122,35 @@ describe ProblemsController, type: 'controller' do | @@ -122,35 +122,35 @@ describe ProblemsController, type: 'controller' do | ||
122 | end | 122 | end |
123 | 123 | ||
124 | it "finds the app" do | 124 | it "finds the app" do |
125 | - get :show, :app_id => app.id, :id => err.problem.id | 125 | + get :show, app_id: app.id, id: err.problem.id |
126 | expect(controller.app).to eq app | 126 | expect(controller.app).to eq app |
127 | end | 127 | end |
128 | 128 | ||
129 | it "finds the problem" do | 129 | it "finds the problem" do |
130 | - get :show, :app_id => app.id, :id => err.problem.id | 130 | + get :show, app_id: app.id, id: err.problem.id |
131 | expect(controller.problem).to eq err.problem | 131 | expect(controller.problem).to eq err.problem |
132 | end | 132 | end |
133 | 133 | ||
134 | it "successfully render page" do | 134 | it "successfully render page" do |
135 | - get :show, :app_id => app.id, :id => err.problem.id | 135 | + get :show, app_id: app.id, id: err.problem.id |
136 | expect(response).to be_success | 136 | expect(response).to be_success |
137 | end | 137 | end |
138 | 138 | ||
139 | context 'pagination' do | 139 | context 'pagination' do |
140 | let!(:notices) do | 140 | let!(:notices) do |
141 | 3.times.reduce([]) do |coll, i| | 141 | 3.times.reduce([]) do |coll, i| |
142 | - coll << Fabricate(:notice, :err => err, :created_at => (i.seconds.from_now)) | 142 | + coll << Fabricate(:notice, err: err, created_at: (i.seconds.from_now)) |
143 | end | 143 | end |
144 | end | 144 | end |
145 | 145 | ||
146 | it "paginates the notices 1 at a time, starting with the most recent" do | 146 | it "paginates the notices 1 at a time, starting with the most recent" do |
147 | - get :show, :app_id => app.id, :id => err.problem.id | 147 | + get :show, app_id: app.id, id: err.problem.id |
148 | expect(assigns(:notices).entries.count).to eq 1 | 148 | expect(assigns(:notices).entries.count).to eq 1 |
149 | expect(assigns(:notices)).to include(notices.last) | 149 | expect(assigns(:notices)).to include(notices.last) |
150 | end | 150 | end |
151 | 151 | ||
152 | it "paginates the notices 1 at a time, based on then notice param" do | 152 | it "paginates the notices 1 at a time, based on then notice param" do |
153 | - get :show, :app_id => app.id, :id => err.problem.id, :notice => 3 | 153 | + get :show, app_id: app.id, id: err.problem.id, notice: 3 |
154 | expect(assigns(:notices).entries.count).to eq 1 | 154 | expect(assigns(:notices).entries.count).to eq 1 |
155 | expect(assigns(:notices)).to include(notices.first) | 155 | expect(assigns(:notices)).to include(notices.first) |
156 | end | 156 | end |
@@ -165,29 +165,29 @@ describe ProblemsController, type: 'controller' do | @@ -165,29 +165,29 @@ describe ProblemsController, type: 'controller' do | ||
165 | end | 165 | end |
166 | 166 | ||
167 | it 'finds the app and the problem' do | 167 | it 'finds the app and the problem' do |
168 | - put :resolve, :app_id => @err.app.id, :id => @err.problem.id | 168 | + put :resolve, app_id: @err.app.id, id: @err.problem.id |
169 | expect(controller.app).to eq @err.app | 169 | expect(controller.app).to eq @err.app |
170 | expect(controller.problem).to eq @err.problem | 170 | expect(controller.problem).to eq @err.problem |
171 | end | 171 | end |
172 | 172 | ||
173 | it "should resolve the issue" do | 173 | it "should resolve the issue" do |
174 | - put :resolve, :app_id => @err.app.id, :id => @err.problem.id | 174 | + put :resolve, app_id: @err.app.id, id: @err.problem.id |
175 | expect(@err.problem.reload.resolved).to be(true) | 175 | expect(@err.problem.reload.resolved).to be(true) |
176 | end | 176 | end |
177 | 177 | ||
178 | it "should display a message" do | 178 | it "should display a message" do |
179 | - put :resolve, :app_id => @err.app.id, :id => @err.problem.id | 179 | + put :resolve, app_id: @err.app.id, id: @err.problem.id |
180 | expect(request.flash[:success]).to match(/Great news/) | 180 | expect(request.flash[:success]).to match(/Great news/) |
181 | end | 181 | end |
182 | 182 | ||
183 | it "should redirect to the app page" do | 183 | it "should redirect to the app page" do |
184 | - put :resolve, :app_id => @err.app.id, :id => @err.problem.id | 184 | + put :resolve, app_id: @err.app.id, id: @err.problem.id |
185 | expect(response).to redirect_to(app_path(@err.app)) | 185 | expect(response).to redirect_to(app_path(@err.app)) |
186 | end | 186 | end |
187 | 187 | ||
188 | it "should redirect back to problems page" do | 188 | it "should redirect back to problems page" do |
189 | request.env["HTTP_REFERER"] = problems_path | 189 | request.env["HTTP_REFERER"] = problems_path |
190 | - put :resolve, :app_id => @err.app.id, :id => @err.problem.id | 190 | + put :resolve, app_id: @err.app.id, id: @err.problem.id |
191 | expect(response).to redirect_to(problems_path) | 191 | expect(response).to redirect_to(problems_path) |
192 | end | 192 | end |
193 | end | 193 | end |
@@ -245,7 +245,7 @@ describe ProblemsController, type: 'controller' do | @@ -245,7 +245,7 @@ describe ProblemsController, type: 'controller' do | ||
245 | 245 | ||
246 | it "should render whatever the issue tracker says" do | 246 | it "should render whatever the issue tracker says" do |
247 | allow_any_instance_of(Issue).to receive(:render_body_args).and_return( | 247 | allow_any_instance_of(Issue).to receive(:render_body_args).and_return( |
248 | - [{ :inline => 'one <%= problem.id %> two' }]) | 248 | + [{ inline: 'one <%= problem.id %> two' }]) |
249 | post :create_issue, app_id: problem.app.id, id: problem.id, format: 'html' | 249 | post :create_issue, app_id: problem.app.id, id: problem.id, format: 'html' |
250 | line = issue_tracker.tracker.output.shift | 250 | line = issue_tracker.tracker.output.shift |
251 | expect(line[1]).to eq("one #{problem.id} two") | 251 | expect(line[1]).to eq("one #{problem.id} two") |
@@ -268,10 +268,10 @@ describe ProblemsController, type: 'controller' do | @@ -268,10 +268,10 @@ describe ProblemsController, type: 'controller' do | ||
268 | end | 268 | end |
269 | 269 | ||
270 | context "problem with issue" do | 270 | context "problem with issue" do |
271 | - let(:err) { Fabricate(:err, :problem => Fabricate(:problem, :issue_link => "http://some.host")) } | 271 | + let(:err) { Fabricate(:err, problem: Fabricate(:problem, issue_link: "http://some.host")) } |
272 | 272 | ||
273 | before(:each) do | 273 | before(:each) do |
274 | - delete :unlink_issue, :app_id => err.app.id, :id => err.problem.id | 274 | + delete :unlink_issue, app_id: err.app.id, id: err.problem.id |
275 | err.problem.reload | 275 | err.problem.reload |
276 | end | 276 | end |
277 | 277 | ||
@@ -288,7 +288,7 @@ describe ProblemsController, type: 'controller' do | @@ -288,7 +288,7 @@ describe ProblemsController, type: 'controller' do | ||
288 | let(:err) { Fabricate :err } | 288 | let(:err) { Fabricate :err } |
289 | 289 | ||
290 | before(:each) do | 290 | before(:each) do |
291 | - delete :unlink_issue, :app_id => err.app.id, :id => err.problem.id | 291 | + delete :unlink_issue, app_id: err.app.id, id: err.problem.id |
292 | err.problem.reload | 292 | err.problem.reload |
293 | end | 293 | end |
294 | 294 | ||
@@ -301,25 +301,25 @@ describe ProblemsController, type: 'controller' do | @@ -301,25 +301,25 @@ describe ProblemsController, type: 'controller' do | ||
301 | describe "Bulk Actions" do | 301 | describe "Bulk Actions" do |
302 | before(:each) do | 302 | before(:each) do |
303 | sign_in user | 303 | sign_in user |
304 | - @problem1 = Fabricate(:err, :problem => Fabricate(:problem, :resolved => true)).problem | ||
305 | - @problem2 = Fabricate(:err, :problem => Fabricate(:problem, :resolved => false)).problem | 304 | + @problem1 = Fabricate(:err, problem: Fabricate(:problem, resolved: true)).problem |
305 | + @problem2 = Fabricate(:err, problem: Fabricate(:problem, resolved: false)).problem | ||
306 | end | 306 | end |
307 | 307 | ||
308 | context "POST /problems/merge_several" do | 308 | context "POST /problems/merge_several" do |
309 | it "should require at least two problems" do | 309 | it "should require at least two problems" do |
310 | - post :merge_several, :problems => [@problem1.id.to_s] | 310 | + post :merge_several, problems: [@problem1.id.to_s] |
311 | expect(request.flash[:notice]).to eql I18n.t('controllers.problems.flash.need_two_errors_merge') | 311 | expect(request.flash[:notice]).to eql I18n.t('controllers.problems.flash.need_two_errors_merge') |
312 | end | 312 | end |
313 | 313 | ||
314 | it "should merge the problems" do | 314 | it "should merge the problems" do |
315 | - expect(ProblemMerge).to receive(:new).and_return(double(:merge => true)) | ||
316 | - post :merge_several, :problems => [@problem1.id.to_s, @problem2.id.to_s] | 315 | + expect(ProblemMerge).to receive(:new).and_return(double(merge: true)) |
316 | + post :merge_several, problems: [@problem1.id.to_s, @problem2.id.to_s] | ||
317 | end | 317 | end |
318 | end | 318 | end |
319 | 319 | ||
320 | context "POST /problems/unmerge_several" do | 320 | context "POST /problems/unmerge_several" do |
321 | it "should require at least one problem" do | 321 | it "should require at least one problem" do |
322 | - post :unmerge_several, :problems => [] | 322 | + post :unmerge_several, problems: [] |
323 | expect(request.flash[:notice]).to eql I18n.t('controllers.problems.flash.no_select_problem') | 323 | expect(request.flash[:notice]).to eql I18n.t('controllers.problems.flash.no_select_problem') |
324 | end | 324 | end |
325 | 325 | ||
@@ -327,7 +327,7 @@ describe ProblemsController, type: 'controller' do | @@ -327,7 +327,7 @@ describe ProblemsController, type: 'controller' do | ||
327 | merged_problem = Problem.merge!(@problem1, @problem2) | 327 | merged_problem = Problem.merge!(@problem1, @problem2) |
328 | expect(merged_problem.errs.length).to eq 2 | 328 | expect(merged_problem.errs.length).to eq 2 |
329 | expect { | 329 | expect { |
330 | - post :unmerge_several, :problems => [merged_problem.id.to_s] | 330 | + post :unmerge_several, problems: [merged_problem.id.to_s] |
331 | expect(merged_problem.reload.errs.length).to eq 1 | 331 | expect(merged_problem.reload.errs.length).to eq 1 |
332 | }.to change(Problem, :count).by(1) | 332 | }.to change(Problem, :count).by(1) |
333 | end | 333 | end |
@@ -335,22 +335,22 @@ describe ProblemsController, type: 'controller' do | @@ -335,22 +335,22 @@ describe ProblemsController, type: 'controller' do | ||
335 | 335 | ||
336 | context "POST /problems/resolve_several" do | 336 | context "POST /problems/resolve_several" do |
337 | it "should require at least one problem" do | 337 | it "should require at least one problem" do |
338 | - post :resolve_several, :problems => [] | 338 | + post :resolve_several, problems: [] |
339 | expect(request.flash[:notice]).to eql I18n.t('controllers.problems.flash.no_select_problem') | 339 | expect(request.flash[:notice]).to eql I18n.t('controllers.problems.flash.no_select_problem') |
340 | end | 340 | end |
341 | 341 | ||
342 | it "should resolve the issue" do | 342 | it "should resolve the issue" do |
343 | - post :resolve_several, :problems => [@problem2.id.to_s] | 343 | + post :resolve_several, problems: [@problem2.id.to_s] |
344 | expect(@problem2.reload.resolved?).to eq true | 344 | expect(@problem2.reload.resolved?).to eq true |
345 | end | 345 | end |
346 | 346 | ||
347 | it "should display a message about 1 err" do | 347 | it "should display a message about 1 err" do |
348 | - post :resolve_several, :problems => [@problem2.id.to_s] | 348 | + post :resolve_several, problems: [@problem2.id.to_s] |
349 | expect(flash[:success]).to match(/1 error has been resolved/) | 349 | expect(flash[:success]).to match(/1 error has been resolved/) |
350 | end | 350 | end |
351 | 351 | ||
352 | it "should display a message about 2 errs" do | 352 | it "should display a message about 2 errs" do |
353 | - post :resolve_several, :problems => [@problem1.id.to_s, @problem2.id.to_s] | 353 | + post :resolve_several, problems: [@problem1.id.to_s, @problem2.id.to_s] |
354 | expect(flash[:success]).to match(/2 errors have been resolved/) | 354 | expect(flash[:success]).to match(/2 errors have been resolved/) |
355 | expect(controller.selected_problems).to eq [@problem1, @problem2] | 355 | expect(controller.selected_problems).to eq [@problem1, @problem2] |
356 | end | 356 | end |
@@ -358,12 +358,12 @@ describe ProblemsController, type: 'controller' do | @@ -358,12 +358,12 @@ describe ProblemsController, type: 'controller' do | ||
358 | 358 | ||
359 | context "POST /problems/unresolve_several" do | 359 | context "POST /problems/unresolve_several" do |
360 | it "should require at least one problem" do | 360 | it "should require at least one problem" do |
361 | - post :unresolve_several, :problems => [] | 361 | + post :unresolve_several, problems: [] |
362 | expect(request.flash[:notice]).to eql I18n.t('controllers.problems.flash.no_select_problem') | 362 | expect(request.flash[:notice]).to eql I18n.t('controllers.problems.flash.no_select_problem') |
363 | end | 363 | end |
364 | 364 | ||
365 | it "should unresolve the issue" do | 365 | it "should unresolve the issue" do |
366 | - post :unresolve_several, :problems => [@problem1.id.to_s] | 366 | + post :unresolve_several, problems: [@problem1.id.to_s] |
367 | expect(@problem1.reload.resolved?).to eq false | 367 | expect(@problem1.reload.resolved?).to eq false |
368 | end | 368 | end |
369 | end | 369 | end |
@@ -371,7 +371,7 @@ describe ProblemsController, type: 'controller' do | @@ -371,7 +371,7 @@ describe ProblemsController, type: 'controller' do | ||
371 | context "POST /problems/destroy_several" do | 371 | context "POST /problems/destroy_several" do |
372 | it "should delete the problems" do | 372 | it "should delete the problems" do |
373 | expect { | 373 | expect { |
374 | - post :destroy_several, :problems => [@problem1.id.to_s] | 374 | + post :destroy_several, problems: [@problem1.id.to_s] |
375 | }.to change(Problem, :count).by(-1) | 375 | }.to change(Problem, :count).by(-1) |
376 | end | 376 | end |
377 | end | 377 | end |
@@ -380,25 +380,25 @@ describe ProblemsController, type: 'controller' do | @@ -380,25 +380,25 @@ describe ProblemsController, type: 'controller' do | ||
380 | before do | 380 | before do |
381 | sign_in user | 381 | sign_in user |
382 | @app = Fabricate(:app) | 382 | @app = Fabricate(:app) |
383 | - @problem1 = Fabricate(:problem, :app => @app) | ||
384 | - @problem2 = Fabricate(:problem, :app => @app) | 383 | + @problem1 = Fabricate(:problem, app: @app) |
384 | + @problem2 = Fabricate(:problem, app: @app) | ||
385 | end | 385 | end |
386 | 386 | ||
387 | it "destroys all problems" do | 387 | it "destroys all problems" do |
388 | expect { | 388 | expect { |
389 | - post :destroy_all, :app_id => @app.id | 389 | + post :destroy_all, app_id: @app.id |
390 | }.to change(Problem, :count).by(-2) | 390 | }.to change(Problem, :count).by(-2) |
391 | expect(controller.app).to eq @app | 391 | expect(controller.app).to eq @app |
392 | end | 392 | end |
393 | 393 | ||
394 | it "should display a message" do | 394 | it "should display a message" do |
395 | - put :destroy_all, :app_id => @app.id | 395 | + put :destroy_all, app_id: @app.id |
396 | expect(request.flash[:success]).to match(/been deleted/) | 396 | expect(request.flash[:success]).to match(/been deleted/) |
397 | end | 397 | end |
398 | 398 | ||
399 | it "should redirect back to the app page" do | 399 | it "should redirect back to the app page" do |
400 | request.env["HTTP_REFERER"] = edit_app_path(@app) | 400 | request.env["HTTP_REFERER"] = edit_app_path(@app) |
401 | - put :destroy_all, :app_id => @app.id | 401 | + put :destroy_all, app_id: @app.id |
402 | expect(response).to redirect_to(edit_app_path(@app)) | 402 | expect(response).to redirect_to(edit_app_path(@app)) |
403 | end | 403 | end |
404 | end | 404 | end |
spec/controllers/site_config_controller_spec.rb
1 | describe SiteConfigController, type: 'controller' do | 1 | describe SiteConfigController, type: 'controller' do |
2 | it_requires_admin_privileges for: { | 2 | it_requires_admin_privileges for: { |
3 | - index: :get, | 3 | + index: :get, |
4 | update: :put | 4 | update: :put |
5 | } | 5 | } |
6 | 6 | ||
@@ -18,7 +18,7 @@ describe SiteConfigController, type: 'controller' do | @@ -18,7 +18,7 @@ describe SiteConfigController, type: 'controller' do | ||
18 | it 'updates' do | 18 | it 'updates' do |
19 | put :update, site_config: { | 19 | put :update, site_config: { |
20 | notice_fingerprinter_attributes: { | 20 | notice_fingerprinter_attributes: { |
21 | - backtrace_lines: 3, | 21 | + backtrace_lines: 3, |
22 | environment_name: false | 22 | environment_name: false |
23 | } | 23 | } |
24 | } | 24 | } |
spec/controllers/users/omniauth_callbacks_controller_spec.rb
@@ -4,9 +4,9 @@ describe Users::OmniauthCallbacksController, type: 'controller' do | @@ -4,9 +4,9 @@ describe Users::OmniauthCallbacksController, type: 'controller' do | ||
4 | request.env["devise.mapping"] = Devise.mappings[:user] | 4 | request.env["devise.mapping"] = Devise.mappings[:user] |
5 | env = { | 5 | env = { |
6 | "omniauth.auth" => Hashie::Mash.new( | 6 | "omniauth.auth" => Hashie::Mash.new( |
7 | - :provider => 'github', | ||
8 | - :extra => { :raw_info => { :login => login } }, | ||
9 | - :credentials => { :token => token } | 7 | + provider: 'github', |
8 | + extra: { raw_info: { login: login } }, | ||
9 | + credentials: { token: token } | ||
10 | ) | 10 | ) |
11 | } | 11 | } |
12 | allow(@controller).to receive(:env).and_return(env) | 12 | allow(@controller).to receive(:env).and_return(env) |
@@ -18,7 +18,7 @@ describe Users::OmniauthCallbacksController, type: 'controller' do | @@ -18,7 +18,7 @@ describe Users::OmniauthCallbacksController, type: 'controller' do | ||
18 | end | 18 | end |
19 | 19 | ||
20 | it "should show an error if another user already has that github login" do | 20 | it "should show an error if another user already has that github login" do |
21 | - Fabricate(:user, :github_login => "existing_user") | 21 | + Fabricate(:user, github_login: "existing_user") |
22 | stub_env_for_github_omniauth("existing_user") | 22 | stub_env_for_github_omniauth("existing_user") |
23 | get :github | 23 | get :github |
24 | 24 |
spec/controllers/users_controller_spec.rb
1 | describe UsersController, type: 'controller' do | 1 | describe UsersController, type: 'controller' do |
2 | it_requires_authentication | 2 | it_requires_authentication |
3 | - it_requires_admin_privileges :for => { | ||
4 | - :index => :get, | ||
5 | - :show => :get, | ||
6 | - :new => :get, | ||
7 | - :create => :post, | ||
8 | - :destroy => :delete | 3 | + it_requires_admin_privileges for: { |
4 | + index: :get, | ||
5 | + show: :get, | ||
6 | + new: :get, | ||
7 | + create: :post, | ||
8 | + destroy: :delete | ||
9 | } | 9 | } |
10 | 10 | ||
11 | let(:admin) { Fabricate(:admin) } | 11 | let(:admin) { Fabricate(:admin) } |
@@ -23,14 +23,14 @@ describe UsersController, type: 'controller' do | @@ -23,14 +23,14 @@ describe UsersController, type: 'controller' do | ||
23 | 23 | ||
24 | context "GET /users/:other_id/edit" do | 24 | context "GET /users/:other_id/edit" do |
25 | it "redirects to the home page" do | 25 | it "redirects to the home page" do |
26 | - get :edit, :id => other_user.id | 26 | + get :edit, id: other_user.id |
27 | expect(response).to redirect_to(root_path) | 27 | expect(response).to redirect_to(root_path) |
28 | end | 28 | end |
29 | end | 29 | end |
30 | 30 | ||
31 | context "GET /users/:my_id/edit" do | 31 | context "GET /users/:my_id/edit" do |
32 | it 'finds the user' do | 32 | it 'finds the user' do |
33 | - get :edit, :id => user.id | 33 | + get :edit, id: user.id |
34 | expect(controller.user).to eq(user) | 34 | expect(controller.user).to eq(user) |
35 | expect(response).to render_template 'edit' | 35 | expect(response).to render_template 'edit' |
36 | end | 36 | end |
@@ -38,7 +38,7 @@ describe UsersController, type: 'controller' do | @@ -38,7 +38,7 @@ describe UsersController, type: 'controller' do | ||
38 | 38 | ||
39 | context "PUT /users/:other_id" do | 39 | context "PUT /users/:other_id" do |
40 | it "redirects to the home page" do | 40 | it "redirects to the home page" do |
41 | - put :update, :id => other_user.id | 41 | + put :update, id: other_user.id |
42 | expect(response).to redirect_to(root_path) | 42 | expect(response).to redirect_to(root_path) |
43 | end | 43 | end |
44 | end | 44 | end |
@@ -46,47 +46,47 @@ describe UsersController, type: 'controller' do | @@ -46,47 +46,47 @@ describe UsersController, type: 'controller' do | ||
46 | context "PUT /users/:my_id/id" do | 46 | context "PUT /users/:my_id/id" do |
47 | context "when the update is successful" do | 47 | context "when the update is successful" do |
48 | it "sets a message to display" do | 48 | it "sets a message to display" do |
49 | - put :update, :id => user.to_param, :user => { :name => 'Kermit' } | 49 | + put :update, id: user.to_param, user: { name: 'Kermit' } |
50 | expect(request.flash[:success]).to include('updated') | 50 | expect(request.flash[:success]).to include('updated') |
51 | end | 51 | end |
52 | 52 | ||
53 | it "redirects to the user's page" do | 53 | it "redirects to the user's page" do |
54 | - put :update, :id => user.to_param, :user => { :name => 'Kermit' } | 54 | + put :update, id: user.to_param, user: { name: 'Kermit' } |
55 | expect(response).to redirect_to(user_path(user)) | 55 | expect(response).to redirect_to(user_path(user)) |
56 | end | 56 | end |
57 | 57 | ||
58 | it "should not be able to become an admin" do | 58 | it "should not be able to become an admin" do |
59 | expect { | 59 | expect { |
60 | - put :update, :id => user.to_param, :user => { :admin => true } | 60 | + put :update, id: user.to_param, user: { admin: true } |
61 | }.to_not change { | 61 | }.to_not change { |
62 | user.reload.admin | 62 | user.reload.admin |
63 | }.from(false) | 63 | }.from(false) |
64 | end | 64 | end |
65 | 65 | ||
66 | it "should be able to set per_page option" do | 66 | it "should be able to set per_page option" do |
67 | - put :update, :id => user.to_param, :user => { :per_page => 555 } | 67 | + put :update, id: user.to_param, user: { per_page: 555 } |
68 | expect(user.reload.per_page).to eq 555 | 68 | expect(user.reload.per_page).to eq 555 |
69 | end | 69 | end |
70 | 70 | ||
71 | it "should be able to set time_zone option" do | 71 | it "should be able to set time_zone option" do |
72 | - put :update, :id => user.to_param, :user => { :time_zone => "Warsaw" } | 72 | + put :update, id: user.to_param, user: { time_zone: "Warsaw" } |
73 | expect(user.reload.time_zone).to eq "Warsaw" | 73 | expect(user.reload.time_zone).to eq "Warsaw" |
74 | end | 74 | end |
75 | 75 | ||
76 | it "should be able to not set github_login option" do | 76 | it "should be able to not set github_login option" do |
77 | - put :update, :id => user.to_param, :user => { :github_login => " " } | 77 | + put :update, id: user.to_param, user: { github_login: " " } |
78 | expect(user.reload.github_login).to eq nil | 78 | expect(user.reload.github_login).to eq nil |
79 | end | 79 | end |
80 | 80 | ||
81 | it "should be able to set github_login option" do | 81 | it "should be able to set github_login option" do |
82 | - put :update, :id => user.to_param, :user => { :github_login => "awesome_name" } | 82 | + put :update, id: user.to_param, user: { github_login: "awesome_name" } |
83 | expect(user.reload.github_login).to eq "awesome_name" | 83 | expect(user.reload.github_login).to eq "awesome_name" |
84 | end | 84 | end |
85 | end | 85 | end |
86 | 86 | ||
87 | context "when the update is unsuccessful" do | 87 | context "when the update is unsuccessful" do |
88 | it "renders the edit page" do | 88 | it "renders the edit page" do |
89 | - put :update, :id => user.to_param, :user => { :name => nil } | 89 | + put :update, id: user.to_param, user: { name: nil } |
90 | expect(response).to render_template(:edit) | 90 | expect(response).to render_template(:edit) |
91 | end | 91 | end |
92 | end | 92 | end |
@@ -109,7 +109,7 @@ describe UsersController, type: 'controller' do | @@ -109,7 +109,7 @@ describe UsersController, type: 'controller' do | ||
109 | 109 | ||
110 | context "GET /users/:id" do | 110 | context "GET /users/:id" do |
111 | it 'finds the user' do | 111 | it 'finds the user' do |
112 | - get :show, :id => user.id | 112 | + get :show, id: user.id |
113 | expect(controller.user).to eq user | 113 | expect(controller.user).to eq user |
114 | end | 114 | end |
115 | end | 115 | end |
@@ -124,14 +124,14 @@ describe UsersController, type: 'controller' do | @@ -124,14 +124,14 @@ describe UsersController, type: 'controller' do | ||
124 | 124 | ||
125 | context "GET /users/:id/edit" do | 125 | context "GET /users/:id/edit" do |
126 | it 'finds the user' do | 126 | it 'finds the user' do |
127 | - get :edit, :id => user.id | 127 | + get :edit, id: user.id |
128 | expect(controller.user).to eq user | 128 | expect(controller.user).to eq user |
129 | end | 129 | end |
130 | end | 130 | end |
131 | 131 | ||
132 | context "POST /users" do | 132 | context "POST /users" do |
133 | context "when the create is successful" do | 133 | context "when the create is successful" do |
134 | - let(:attrs) { { :user => Fabricate.to_params(:user) } } | 134 | + let(:attrs) { { user: Fabricate.to_params(:user) } } |
135 | 135 | ||
136 | it "sets a message to display" do | 136 | it "sets a message to display" do |
137 | post :create, attrs | 137 | post :create, attrs |
@@ -166,7 +166,7 @@ describe UsersController, type: 'controller' do | @@ -166,7 +166,7 @@ describe UsersController, type: 'controller' do | ||
166 | end | 166 | end |
167 | 167 | ||
168 | it "renders the new page" do | 168 | it "renders the new page" do |
169 | - post :create, :user => { :username => 'foo' } | 169 | + post :create, user: { username: 'foo' } |
170 | expect(response).to render_template(:new) | 170 | expect(response).to render_template(:new) |
171 | end | 171 | end |
172 | end | 172 | end |
@@ -175,20 +175,20 @@ describe UsersController, type: 'controller' do | @@ -175,20 +175,20 @@ describe UsersController, type: 'controller' do | ||
175 | context "PUT /users/:id" do | 175 | context "PUT /users/:id" do |
176 | context "when the update is successful" do | 176 | context "when the update is successful" do |
177 | before { | 177 | before { |
178 | - put :update, :id => user.to_param, :user => user_params | 178 | + put :update, id: user.to_param, user: user_params |
179 | } | 179 | } |
180 | 180 | ||
181 | context "with normal params" do | 181 | context "with normal params" do |
182 | - let(:user_params) { { :name => 'Kermit' } } | 182 | + let(:user_params) { { name: 'Kermit' } } |
183 | it "sets a message to display" do | 183 | it "sets a message to display" do |
184 | - expect(request.flash[:success]).to eq I18n.t('controllers.users.flash.update.success', :name => user.reload.name) | 184 | + expect(request.flash[:success]).to eq I18n.t('controllers.users.flash.update.success', name: user.reload.name) |
185 | expect(response).to redirect_to(user_path(user)) | 185 | expect(response).to redirect_to(user_path(user)) |
186 | end | 186 | end |
187 | end | 187 | end |
188 | end | 188 | end |
189 | context "when the update is unsuccessful" do | 189 | context "when the update is unsuccessful" do |
190 | it "renders the edit page" do | 190 | it "renders the edit page" do |
191 | - put :update, :id => user.to_param, :user => { :name => nil } | 191 | + put :update, id: user.to_param, user: { name: nil } |
192 | expect(response).to render_template(:edit) | 192 | expect(response).to render_template(:edit) |
193 | end | 193 | end |
194 | end | 194 | end |
@@ -196,15 +196,15 @@ describe UsersController, type: 'controller' do | @@ -196,15 +196,15 @@ describe UsersController, type: 'controller' do | ||
196 | 196 | ||
197 | context "DELETE /users/:id" do | 197 | context "DELETE /users/:id" do |
198 | context "with a destroy success" do | 198 | context "with a destroy success" do |
199 | - let(:user_destroy) { double(:destroy => true) } | 199 | + let(:user_destroy) { double(destroy: true) } |
200 | 200 | ||
201 | before { | 201 | before { |
202 | expect(UserDestroy).to receive(:new).with(user).and_return(user_destroy) | 202 | expect(UserDestroy).to receive(:new).with(user).and_return(user_destroy) |
203 | - delete :destroy, :id => user.id | 203 | + delete :destroy, id: user.id |
204 | } | 204 | } |
205 | 205 | ||
206 | it 'should destroy user' do | 206 | it 'should destroy user' do |
207 | - expect(request.flash[:success]).to eq I18n.t('controllers.users.flash.destroy.success', :name => user.name) | 207 | + expect(request.flash[:success]).to eq I18n.t('controllers.users.flash.destroy.success', name: user.name) |
208 | expect(response).to redirect_to(users_path) | 208 | expect(response).to redirect_to(users_path) |
209 | end | 209 | end |
210 | end | 210 | end |
@@ -212,7 +212,7 @@ describe UsersController, type: 'controller' do | @@ -212,7 +212,7 @@ describe UsersController, type: 'controller' do | ||
212 | context "with trying destroy himself" do | 212 | context "with trying destroy himself" do |
213 | before { | 213 | before { |
214 | expect(UserDestroy).to_not receive(:new) | 214 | expect(UserDestroy).to_not receive(:new) |
215 | - delete :destroy, :id => admin.id | 215 | + delete :destroy, id: admin.id |
216 | } | 216 | } |
217 | 217 | ||
218 | it 'should not destroy user' do | 218 | it 'should not destroy user' do |
@@ -230,7 +230,7 @@ describe UsersController, type: 'controller' do | @@ -230,7 +230,7 @@ describe UsersController, type: 'controller' do | ||
230 | ActionController::Parameters.new(user_param) | 230 | ActionController::Parameters.new(user_param) |
231 | ) | 231 | ) |
232 | } | 232 | } |
233 | - let(:user_param) { { 'user' => { :name => 'foo', :admin => true } } } | 233 | + let(:user_param) { { 'user' => { name: 'foo', admin: true } } } |
234 | it 'not have admin field' do | 234 | it 'not have admin field' do |
235 | expect(controller.send(:user_params)).to eq({ 'name' => 'foo' }) | 235 | expect(controller.send(:user_params)).to eq({ 'name' => 'foo' }) |
236 | end | 236 | end |
spec/controllers/watchers_controller_spec.rb
@@ -15,7 +15,7 @@ describe WatchersController, type: 'controller' do | @@ -15,7 +15,7 @@ describe WatchersController, type: 'controller' do | ||
15 | let(:watcher) { app.watchers.first } | 15 | let(:watcher) { app.watchers.first } |
16 | 16 | ||
17 | before(:each) do | 17 | before(:each) do |
18 | - delete :destroy, :app_id => app.id, :id => watcher.user.id.to_s | 18 | + delete :destroy, app_id: app.id, id: watcher.user.id.to_s |
19 | problem.reload | 19 | problem.reload |
20 | end | 20 | end |
21 | 21 | ||
@@ -34,7 +34,7 @@ describe WatchersController, type: 'controller' do | @@ -34,7 +34,7 @@ describe WatchersController, type: 'controller' do | ||
34 | 34 | ||
35 | context "successful watcher update" do | 35 | context "successful watcher update" do |
36 | before(:each) do | 36 | before(:each) do |
37 | - put :update, :app_id => app.id, :id => user.id.to_s | 37 | + put :update, app_id: app.id, id: user.id.to_s |
38 | problem.reload | 38 | problem.reload |
39 | end | 39 | end |
40 | 40 |
spec/decorators/app_decorator_spec.rb
1 | describe AppDecorator do | 1 | describe AppDecorator do |
2 | describe "#email_at_notices" do | 2 | describe "#email_at_notices" do |
3 | it 'return the list separate by comma' do | 3 | it 'return the list separate by comma' do |
4 | - expect(AppDecorator.new(double(:email_at_notices => [2, 3])).email_at_notices).to eql '2, 3' | 4 | + expect(AppDecorator.new(double(email_at_notices: [2, 3])).email_at_notices).to eql '2, 3' |
5 | end | 5 | end |
6 | end | 6 | end |
7 | 7 | ||
8 | describe "#notify_user_display" do | 8 | describe "#notify_user_display" do |
9 | it 'return display:none if notify' do | 9 | it 'return display:none if notify' do |
10 | - expect(AppDecorator.new(double(:notify_all_users => true)).notify_user_display).to eql 'display: none;' | 10 | + expect(AppDecorator.new(double(notify_all_users: true)).notify_user_display).to eql 'display: none;' |
11 | end | 11 | end |
12 | 12 | ||
13 | it 'return blank if no notify' do | 13 | it 'return blank if no notify' do |
14 | - expect(AppDecorator.new(double(:notify_all_users => false)).notify_user_display).to eql '' | 14 | + expect(AppDecorator.new(double(notify_all_users: false)).notify_user_display).to eql '' |
15 | end | 15 | end |
16 | end | 16 | end |
17 | 17 | ||
18 | describe "#notify_err_display" do | 18 | describe "#notify_err_display" do |
19 | it 'return display:none if no notify' do | 19 | it 'return display:none if no notify' do |
20 | - expect(AppDecorator.new(double(:notify_on_errs => false)).notify_err_display).to eql 'display: none;' | 20 | + expect(AppDecorator.new(double(notify_on_errs: false)).notify_err_display).to eql 'display: none;' |
21 | end | 21 | end |
22 | 22 | ||
23 | it 'return blank if no notify' do | 23 | it 'return blank if no notify' do |
24 | - expect(AppDecorator.new(double(:notify_on_errs => true)).notify_err_display).to eql '' | 24 | + expect(AppDecorator.new(double(notify_on_errs: true)).notify_err_display).to eql '' |
25 | end | 25 | end |
26 | end | 26 | end |
27 | end | 27 | end |
spec/decorators/backtrace_decorator_spec.rb
@@ -3,22 +3,22 @@ describe BacktraceDecorator, type: :decorator do | @@ -3,22 +3,22 @@ describe BacktraceDecorator, type: :decorator do | ||
3 | described_class.new(Backtrace.new( | 3 | described_class.new(Backtrace.new( |
4 | lines: [ | 4 | lines: [ |
5 | { number: 131, | 5 | { number: 131, |
6 | - file: '[PROJECT_ROOT]app/controllers/accounts_controller.rb', | 6 | + file: '[PROJECT_ROOT]app/controllers/accounts_controller.rb', |
7 | method: :update_preferences }, | 7 | method: :update_preferences }, |
8 | { number: 61, | 8 | { number: 61, |
9 | - file: '[PROJECT_ROOT]app/controllers/application_controller.rb', | 9 | + file: '[PROJECT_ROOT]app/controllers/application_controller.rb', |
10 | method: :call }, | 10 | method: :call }, |
11 | { number: 182, | 11 | { number: 182, |
12 | - file: '[GEM_ROOT]activesupport-2.3.18/lib/active_support/callbacks.rb', | 12 | + file: '[GEM_ROOT]activesupport-2.3.18/lib/active_support/callbacks.rb', |
13 | method: :call }, | 13 | method: :call }, |
14 | { number: 384, | 14 | { number: 384, |
15 | - file: '[PROJECT_ROOT]app/models/account.rb', | 15 | + file: '[PROJECT_ROOT]app/models/account.rb', |
16 | method: :update_server_tag_scope }, | 16 | method: :update_server_tag_scope }, |
17 | { number: 182, | 17 | { number: 182, |
18 | - file: '[GEM_ROOT]activesupport-2.3.18/lib/active_support/callbacks.rb', | 18 | + file: '[GEM_ROOT]activesupport-2.3.18/lib/active_support/callbacks.rb', |
19 | method: :evaluate_method }, | 19 | method: :evaluate_method }, |
20 | { number: 23, | 20 | { number: 23, |
21 | - file: '/home/rails/library/current/vendor/bundle/ruby/2.1.0/bin/rainbows', | 21 | + file: '/home/rails/library/current/vendor/bundle/ruby/2.1.0/bin/rainbows', |
22 | method: '<main>' } | 22 | method: '<main>' } |
23 | ] | 23 | ] |
24 | )) | 24 | )) |
spec/decorators/backtrace_line_decorator_spec.rb
@@ -2,13 +2,13 @@ describe BacktraceLineDecorator, type: :decorator do | @@ -2,13 +2,13 @@ describe BacktraceLineDecorator, type: :decorator do | ||
2 | let(:backtrace_line) do | 2 | let(:backtrace_line) do |
3 | described_class.new( | 3 | described_class.new( |
4 | number: 884, | 4 | number: 884, |
5 | - file: '/path/to/file/ea315ea4.rb', | 5 | + file: '/path/to/file/ea315ea4.rb', |
6 | method: :instance_eval) | 6 | method: :instance_eval) |
7 | end | 7 | end |
8 | let(:backtrace_line_in_app) do | 8 | let(:backtrace_line_in_app) do |
9 | described_class.new( | 9 | described_class.new( |
10 | number: 884, | 10 | number: 884, |
11 | - file: '[PROJECT_ROOT]/path/to/file/ea315ea4.rb', | 11 | + file: '[PROJECT_ROOT]/path/to/file/ea315ea4.rb', |
12 | method: :instance_eval) | 12 | method: :instance_eval) |
13 | end | 13 | end |
14 | let(:app) { Fabricate(:app, github_repo: 'foo/bar') } | 14 | let(:app) { Fabricate(:app, github_repo: 'foo/bar') } |
spec/decorators/issue_tracker_decorator_spec.rb
@@ -11,8 +11,8 @@ describe IssueTrackerDecorator do | @@ -11,8 +11,8 @@ describe IssueTrackerDecorator do | ||
11 | 11 | ||
12 | def self.fields | 12 | def self.fields |
13 | { | 13 | { |
14 | - :foo => { :label => 'foo' }, | ||
15 | - :bar => { :label => 'bar' } | 14 | + foo: { label: 'foo' }, |
15 | + bar: { label: 'bar' } | ||
16 | } | 16 | } |
17 | end | 17 | end |
18 | 18 |
spec/decorators/issue_tracker_field_decorator.rb
1 | describe IssueTrackerFieldDecorator do | 1 | describe IssueTrackerFieldDecorator do |
2 | describe "#label" do | 2 | describe "#label" do |
3 | it 'return the label of field_info by default' do | 3 | it 'return the label of field_info by default' do |
4 | - expect(IssueTrackerFieldDecorator.new(:foo, { :label => 'hello' }).label).to eq 'hello' | 4 | + expect(IssueTrackerFieldDecorator.new(:foo, { label: 'hello' }).label).to eq 'hello' |
5 | end | 5 | end |
6 | 6 | ||
7 | it 'return the key of field if no label define' do | 7 | it 'return the key of field if no label define' do |
spec/decorators/issue_tracker_type_decorator_spec.rb
@@ -11,8 +11,8 @@ describe IssueTrackerDecorator do | @@ -11,8 +11,8 @@ describe IssueTrackerDecorator do | ||
11 | 11 | ||
12 | def self.fields | 12 | def self.fields |
13 | { | 13 | { |
14 | - :foo => { :label => 'foo' }, | ||
15 | - :bar => { :label => 'bar' } | 14 | + foo: { label: 'foo' }, |
15 | + bar: { label: 'bar' } | ||
16 | } | 16 | } |
17 | end | 17 | end |
18 | 18 | ||
@@ -45,7 +45,7 @@ describe IssueTrackerDecorator do | @@ -45,7 +45,7 @@ describe IssueTrackerDecorator do | ||
45 | decorator.fields do |itf| | 45 | decorator.fields do |itf| |
46 | expect(itf).to be_a(IssueTrackerFieldDecorator) | 46 | expect(itf).to be_a(IssueTrackerFieldDecorator) |
47 | expect([:foo, :bar]).to be_include(itf.object) | 47 | expect([:foo, :bar]).to be_include(itf.object) |
48 | - expect([{ :label => 'foo' }, { :label => 'bar' }]).to be_include(itf.field_info) | 48 | + expect([{ label: 'foo' }, { label: 'bar' }]).to be_include(itf.field_info) |
49 | end | 49 | end |
50 | end | 50 | end |
51 | end | 51 | end |
spec/decorators/watcher_decorator_spec.rb
@@ -2,13 +2,13 @@ describe WatcherDecorator do | @@ -2,13 +2,13 @@ describe WatcherDecorator do | ||
2 | describe "#email_choosen" do | 2 | describe "#email_choosen" do |
3 | context "with email define" do | 3 | context "with email define" do |
4 | it 'return blank' do | 4 | it 'return blank' do |
5 | - expect(WatcherDecorator.new(double(:email => 'foo')).email_choosen).to eql '' | 5 | + expect(WatcherDecorator.new(double(email: 'foo')).email_choosen).to eql '' |
6 | end | 6 | end |
7 | end | 7 | end |
8 | 8 | ||
9 | context "without email define" do | 9 | context "without email define" do |
10 | it 'return choosen' do | 10 | it 'return choosen' do |
11 | - expect(WatcherDecorator.new(double(:email => '')).email_choosen).to eql 'chosen' | 11 | + expect(WatcherDecorator.new(double(email: '')).email_choosen).to eql 'chosen' |
12 | end | 12 | end |
13 | end | 13 | end |
14 | end | 14 | end |
spec/errbit_plugin/mock_issue_tracker.rb
spec/fabricators/app_fabricator.rb
@@ -3,9 +3,9 @@ Fabricator(:app) do | @@ -3,9 +3,9 @@ Fabricator(:app) do | ||
3 | repository_branch 'master' | 3 | repository_branch 'master' |
4 | end | 4 | end |
5 | 5 | ||
6 | -Fabricator(:app_with_watcher, :from => :app) do | ||
7 | - watchers(:count => 1) { |parent, _i| | ||
8 | - Fabricate.build(:watcher, :app => parent) | 6 | +Fabricator(:app_with_watcher, from: :app) do |
7 | + watchers(count: 1) { |parent, _i| | ||
8 | + Fabricate.build(:watcher, app: parent) | ||
9 | } | 9 | } |
10 | end | 10 | end |
11 | 11 | ||
@@ -15,7 +15,7 @@ Fabricator(:watcher) do | @@ -15,7 +15,7 @@ Fabricator(:watcher) do | ||
15 | email { sequence(:email) { |n| "email#{n}@example.com" } } | 15 | email { sequence(:email) { |n| "email#{n}@example.com" } } |
16 | end | 16 | end |
17 | 17 | ||
18 | -Fabricator(:user_watcher, :from => :watcher) do | 18 | +Fabricator(:user_watcher, from: :watcher) do |
19 | user | 19 | user |
20 | watcher_type 'user' | 20 | watcher_type 'user' |
21 | end | 21 | end |
spec/fabricators/backtrace_fabricator.rb
1 | Fabricator :backtrace do | 1 | Fabricator :backtrace do |
2 | - lines(:count => 99) do | 2 | + lines(count: 99) do |
3 | { | 3 | { |
4 | number: rand(999), | 4 | number: rand(999), |
5 | - file: "/path/to/file/#{SecureRandom.hex(4)}.rb", | 5 | + file: "/path/to/file/#{SecureRandom.hex(4)}.rb", |
6 | method: ActiveSupport.methods.sample | 6 | method: ActiveSupport.methods.sample |
7 | } | 7 | } |
8 | end | 8 | end |
spec/fabricators/comment_fabricator.rb
spec/fabricators/issue_tracker_fabricator.rb
spec/fabricators/notification_service_fabricator.rb
@@ -6,20 +6,20 @@ Fabricator :notification_service do | @@ -6,20 +6,20 @@ Fabricator :notification_service do | ||
6 | notify_at_notices { sequence { |_a| [0] } } | 6 | notify_at_notices { sequence { |_a| [0] } } |
7 | end | 7 | end |
8 | 8 | ||
9 | -Fabricator :gtalk_notification_service, :from => :notification_service, :class_name => "NotificationServices::GtalkService" do | 9 | +Fabricator :gtalk_notification_service, from: :notification_service, class_name: "NotificationServices::GtalkService" do |
10 | user_id { sequence :word } | 10 | user_id { sequence :word } |
11 | service_url { sequence :word } | 11 | service_url { sequence :word } |
12 | service { sequence :word } | 12 | service { sequence :word } |
13 | end | 13 | end |
14 | 14 | ||
15 | -Fabricator :slack_notification_service, :from => :notification_service, :class_name => "NotificationServices::SlackService" do | 15 | +Fabricator :slack_notification_service, from: :notification_service, class_name: "NotificationServices::SlackService" do |
16 | service_url { sequence :word } | 16 | service_url { sequence :word } |
17 | end | 17 | end |
18 | 18 | ||
19 | -Fabricator :hipchat_notification_service, :from => :notification_service, :class_name => "NotificationServices::HipchatService" do | 19 | +Fabricator :hipchat_notification_service, from: :notification_service, class_name: "NotificationServices::HipchatService" do |
20 | service { 'v2' } | 20 | service { 'v2' } |
21 | end | 21 | end |
22 | 22 | ||
23 | %w(campfire flowdock hoiio hubot pushover webhook).each do |t| | 23 | %w(campfire flowdock hoiio hubot pushover webhook).each do |t| |
24 | - Fabricator "#{t}_notification_service".to_sym, :from => :notification_service, :class_name => "NotificationServices::#{t.camelcase}Service" | 24 | + Fabricator "#{t}_notification_service".to_sym, from: :notification_service, class_name: "NotificationServices::#{t.camelcase}Service" |
25 | end | 25 | end |
spec/fabricators/problem_fabricator.rb
@@ -5,25 +5,25 @@ Fabricator(:problem) do | @@ -5,25 +5,25 @@ Fabricator(:problem) do | ||
5 | environment 'production' | 5 | environment 'production' |
6 | end | 6 | end |
7 | 7 | ||
8 | -Fabricator(:problem_with_comments, :from => :problem) do | 8 | +Fabricator(:problem_with_comments, from: :problem) do |
9 | after_create { |parent| | 9 | after_create { |parent| |
10 | 3.times do | 10 | 3.times do |
11 | - Fabricate(:comment, :err => parent) | 11 | + Fabricate(:comment, err: parent) |
12 | end | 12 | end |
13 | } | 13 | } |
14 | end | 14 | end |
15 | 15 | ||
16 | -Fabricator(:problem_with_errs, :from => :problem) do | 16 | +Fabricator(:problem_with_errs, from: :problem) do |
17 | after_create { |parent| | 17 | after_create { |parent| |
18 | 3.times do | 18 | 3.times do |
19 | - Fabricate(:err, :problem => parent) | 19 | + Fabricate(:err, problem: parent) |
20 | end | 20 | end |
21 | } | 21 | } |
22 | end | 22 | end |
23 | 23 | ||
24 | -Fabricator(:problem_resolved, :from => :problem) do | 24 | +Fabricator(:problem_resolved, from: :problem) do |
25 | after_create do |pr| | 25 | after_create do |pr| |
26 | - Fabricate(:notice, :err => Fabricate(:err, :problem => pr)) | 26 | + Fabricate(:notice, err: Fabricate(:err, problem: pr)) |
27 | pr.resolve! | 27 | pr.resolve! |
28 | end | 28 | end |
29 | end | 29 | end |
spec/fabricators/user_fabricator.rb
spec/helpers/problems_helper_spec.rb
1 | describe ProblemsHelper do | 1 | describe ProblemsHelper do |
2 | describe '#truncated_problem_message' do | 2 | describe '#truncated_problem_message' do |
3 | it 'is html safe' do | 3 | it 'is html safe' do |
4 | - problem = double('problem', :message => '#<NoMethodError: ...>') | 4 | + problem = double('problem', message: '#<NoMethodError: ...>') |
5 | truncated = helper.truncated_problem_message(problem) | 5 | truncated = helper.truncated_problem_message(problem) |
6 | expect(truncated).to be_html_safe | 6 | expect(truncated).to be_html_safe |
7 | expect(truncated).to_not include('<', '>') | 7 | expect(truncated).to_not include('<', '>') |
8 | end | 8 | end |
9 | 9 | ||
10 | it 'does not double escape html' do | 10 | it 'does not double escape html' do |
11 | - problem = double('problem', :message => '#<NoMethodError: ...>') | 11 | + problem = double('problem', message: '#<NoMethodError: ...>') |
12 | truncated = helper.truncated_problem_message(problem) | 12 | truncated = helper.truncated_problem_message(problem) |
13 | expect(truncated).to be_html_safe | 13 | expect(truncated).to be_html_safe |
14 | expect(truncated).to_not include('&') | 14 | expect(truncated).to_not include('&') |
@@ -28,12 +28,12 @@ describe ProblemsHelper do | @@ -28,12 +28,12 @@ describe ProblemsHelper do | ||
28 | 28 | ||
29 | it "should render image_tag with correct alt and src" do | 29 | it "should render image_tag with correct alt and src" do |
30 | expected = "<img alt=\"#{email}\" class=\"gravatar\" src=\"#{base_url}?d=identicon&s=48\" />" | 30 | expected = "<img alt=\"#{email}\" class=\"gravatar\" src=\"#{base_url}?d=identicon&s=48\" />" |
31 | - expect(helper.gravatar_tag(email, :s => 48)).to eq(expected) | 31 | + expect(helper.gravatar_tag(email, s: 48)).to eq(expected) |
32 | end | 32 | end |
33 | 33 | ||
34 | it "should override :d" do | 34 | it "should override :d" do |
35 | expected = "<img alt=\"#{email}\" class=\"gravatar\" src=\"#{base_url}?d=retro&s=48\" />" | 35 | expected = "<img alt=\"#{email}\" class=\"gravatar\" src=\"#{base_url}?d=retro&s=48\" />" |
36 | - expect(helper.gravatar_tag(email, :d => 'retro', :s => 48)).to eq(expected) | 36 | + expect(helper.gravatar_tag(email, d: 'retro', s: 48)).to eq(expected) |
37 | end | 37 | end |
38 | end | 38 | end |
39 | 39 |
spec/initializers/action_mailer_spec.rb
@@ -35,12 +35,12 @@ describe 'initializers/action_mailer' do | @@ -35,12 +35,12 @@ describe 'initializers/action_mailer' do | ||
35 | load_initializer | 35 | load_initializer |
36 | 36 | ||
37 | expect(ActionMailer::Base.smtp_settings).to eq({ | 37 | expect(ActionMailer::Base.smtp_settings).to eq({ |
38 | - address: 'smtp.somedomain.com', | ||
39 | - port: 998, | 38 | + address: 'smtp.somedomain.com', |
39 | + port: 998, | ||
40 | authentication: :login, | 40 | authentication: :login, |
41 | - user_name: 'my-username', | ||
42 | - password: 'my-password', | ||
43 | - domain: 'someotherdomain.com' | 41 | + user_name: 'my-username', |
42 | + password: 'my-password', | ||
43 | + domain: 'someotherdomain.com' | ||
44 | }) | 44 | }) |
45 | end | 45 | end |
46 | end | 46 | end |
spec/initializers/devise_spec.rb
@@ -15,9 +15,9 @@ describe 'initializers/devise' do | @@ -15,9 +15,9 @@ describe 'initializers/devise' do | ||
15 | options = Devise.omniauth_configs[:github].options | 15 | options = Devise.omniauth_configs[:github].options |
16 | expect(options).to have_key(:client_options) | 16 | expect(options).to have_key(:client_options) |
17 | expect(options[:client_options]).to eq({ | 17 | expect(options[:client_options]).to eq({ |
18 | - site: 'https://api.github.com', | 18 | + site: 'https://api.github.com', |
19 | authorize_url: 'https://github.com/login/oauth/authorize', | 19 | authorize_url: 'https://github.com/login/oauth/authorize', |
20 | - token_url: 'https://github.com/login/oauth/access_token' | 20 | + token_url: 'https://github.com/login/oauth/access_token' |
21 | }) | 21 | }) |
22 | end | 22 | end |
23 | 23 | ||
@@ -29,9 +29,9 @@ describe 'initializers/devise' do | @@ -29,9 +29,9 @@ describe 'initializers/devise' do | ||
29 | options = Devise.omniauth_configs[:github].options | 29 | options = Devise.omniauth_configs[:github].options |
30 | expect(options).to have_key(:client_options) | 30 | expect(options).to have_key(:client_options) |
31 | expect(options[:client_options]).to eq({ | 31 | expect(options[:client_options]).to eq({ |
32 | - site: 'https://github.example.com/api/v3', | 32 | + site: 'https://github.example.com/api/v3', |
33 | authorize_url: 'https://github.example.com/login/oauth/authorize', | 33 | authorize_url: 'https://github.example.com/login/oauth/authorize', |
34 | - token_url: 'https://github.example.com/login/oauth/access_token' | 34 | + token_url: 'https://github.example.com/login/oauth/access_token' |
35 | }) | 35 | }) |
36 | end | 36 | end |
37 | end | 37 | end |
spec/interactors/problem_destroy_spec.rb
@@ -6,8 +6,8 @@ describe ProblemDestroy do | @@ -6,8 +6,8 @@ describe ProblemDestroy do | ||
6 | context "in unit way" do | 6 | context "in unit way" do |
7 | let(:problem) { | 7 | let(:problem) { |
8 | problem = Problem.new | 8 | problem = Problem.new |
9 | - allow(problem).to receive(:errs).and_return(double(:criteria, :only => [err_1, err_2])) | ||
10 | - allow(problem).to receive(:comments).and_return(double(:criteria, :only => [comment_1, comment_2])) | 9 | + allow(problem).to receive(:errs).and_return(double(:criteria, only: [err_1, err_2])) |
10 | + allow(problem).to receive(:comments).and_return(double(:criteria, only: [comment_1, comment_2])) | ||
11 | allow(problem).to receive(:delete) | 11 | allow(problem).to receive(:delete) |
12 | problem | 12 | problem |
13 | } | 13 | } |
@@ -30,17 +30,17 @@ describe ProblemDestroy do | @@ -30,17 +30,17 @@ describe ProblemDestroy do | ||
30 | end | 30 | end |
31 | 31 | ||
32 | it 'delete all errs associate' do | 32 | it 'delete all errs associate' do |
33 | - expect(Err).to receive(:delete_all).with(:_id => { '$in' => [err_1.id, err_2.id] }) | 33 | + expect(Err).to receive(:delete_all).with(_id: { '$in' => [err_1.id, err_2.id] }) |
34 | problem_destroy.execute | 34 | problem_destroy.execute |
35 | end | 35 | end |
36 | 36 | ||
37 | it 'delete all comments associate' do | 37 | it 'delete all comments associate' do |
38 | - expect(Comment).to receive(:delete_all).with(:_id => { '$in' => [comment_1.id, comment_2.id] }) | 38 | + expect(Comment).to receive(:delete_all).with(_id: { '$in' => [comment_1.id, comment_2.id] }) |
39 | problem_destroy.execute | 39 | problem_destroy.execute |
40 | end | 40 | end |
41 | 41 | ||
42 | it 'delete all notice of associate to this errs' do | 42 | it 'delete all notice of associate to this errs' do |
43 | - expect(Notice).to receive(:delete_all).with({ :err_id => { '$in' => [err_1.id, err_2.id] } }) | 43 | + expect(Notice).to receive(:delete_all).with({ err_id: { '$in' => [err_1.id, err_2.id] } }) |
44 | problem_destroy.execute | 44 | problem_destroy.execute |
45 | end | 45 | end |
46 | end | 46 | end |
@@ -48,26 +48,26 @@ describe ProblemDestroy do | @@ -48,26 +48,26 @@ describe ProblemDestroy do | ||
48 | 48 | ||
49 | context "in integration way" do | 49 | context "in integration way" do |
50 | let!(:problem) { Fabricate(:problem) } | 50 | let!(:problem) { Fabricate(:problem) } |
51 | - let!(:comment_1) { Fabricate(:comment, :err => problem) } | ||
52 | - let!(:comment_2) { Fabricate(:comment, :err => problem) } | ||
53 | - let!(:err_1) { Fabricate(:err, :problem => problem) } | ||
54 | - let!(:err_2) { Fabricate(:err, :problem => problem) } | ||
55 | - let!(:notice_1_1) { Fabricate(:notice, :err => err_1) } | ||
56 | - let!(:notice_1_2) { Fabricate(:notice, :err => err_1) } | ||
57 | - let!(:notice_2_1) { Fabricate(:notice, :err => err_2) } | ||
58 | - let!(:notice_2_2) { Fabricate(:notice, :err => err_2) } | 51 | + let!(:comment_1) { Fabricate(:comment, err: problem) } |
52 | + let!(:comment_2) { Fabricate(:comment, err: problem) } | ||
53 | + let!(:err_1) { Fabricate(:err, problem: problem) } | ||
54 | + let!(:err_2) { Fabricate(:err, problem: problem) } | ||
55 | + let!(:notice_1_1) { Fabricate(:notice, err: err_1) } | ||
56 | + let!(:notice_1_2) { Fabricate(:notice, err: err_1) } | ||
57 | + let!(:notice_2_1) { Fabricate(:notice, err: err_2) } | ||
58 | + let!(:notice_2_2) { Fabricate(:notice, err: err_2) } | ||
59 | 59 | ||
60 | it 'should all destroy' do | 60 | it 'should all destroy' do |
61 | problem_destroy.execute | 61 | problem_destroy.execute |
62 | - expect(Problem.where(:_id => problem.id).entries).to be_empty | ||
63 | - expect(Err.where(:_id => err_1.id).entries).to be_empty | ||
64 | - expect(Err.where(:_id => err_2.id).entries).to be_empty | ||
65 | - expect(Comment.where(:_id => comment_1.id).entries).to be_empty | ||
66 | - expect(Comment.where(:_id => comment_2.id).entries).to be_empty | ||
67 | - expect(Notice.where(:_id => notice_1_1.id).entries).to be_empty | ||
68 | - expect(Notice.where(:_id => notice_1_2.id).entries).to be_empty | ||
69 | - expect(Notice.where(:_id => notice_2_1.id).entries).to be_empty | ||
70 | - expect(Notice.where(:_id => notice_2_2.id).entries).to be_empty | 62 | + expect(Problem.where(_id: problem.id).entries).to be_empty |
63 | + expect(Err.where(_id: err_1.id).entries).to be_empty | ||
64 | + expect(Err.where(_id: err_2.id).entries).to be_empty | ||
65 | + expect(Comment.where(_id: comment_1.id).entries).to be_empty | ||
66 | + expect(Comment.where(_id: comment_2.id).entries).to be_empty | ||
67 | + expect(Notice.where(_id: notice_1_1.id).entries).to be_empty | ||
68 | + expect(Notice.where(_id: notice_1_2.id).entries).to be_empty | ||
69 | + expect(Notice.where(_id: notice_2_1.id).entries).to be_empty | ||
70 | + expect(Notice.where(_id: notice_2_2.id).entries).to be_empty | ||
71 | end | 71 | end |
72 | end | 72 | end |
73 | end | 73 | end |
spec/interactors/problem_merge_spec.rb
@@ -25,8 +25,8 @@ describe ProblemMerge do | @@ -25,8 +25,8 @@ describe ProblemMerge do | ||
25 | } | 25 | } |
26 | let(:first_errs) { problem.errs } | 26 | let(:first_errs) { problem.errs } |
27 | let(:merged_errs) { problem_1.errs } | 27 | let(:merged_errs) { problem_1.errs } |
28 | - let!(:notice) { Fabricate(:notice, :err => first_errs.first) } | ||
29 | - let!(:notice_1) { Fabricate(:notice, :err => merged_errs.first) } | 28 | + let!(:notice) { Fabricate(:notice, err: first_errs.first) } |
29 | + let!(:notice_1) { Fabricate(:notice, err: merged_errs.first) } | ||
30 | 30 | ||
31 | it 'delete one of problem' do | 31 | it 'delete one of problem' do |
32 | expect { | 32 | expect { |
@@ -52,8 +52,8 @@ describe ProblemMerge do | @@ -52,8 +52,8 @@ describe ProblemMerge do | ||
52 | end | 52 | end |
53 | 53 | ||
54 | context "with problem with comment" do | 54 | context "with problem with comment" do |
55 | - let!(:comment) { Fabricate(:comment, :err => problem) } | ||
56 | - let!(:comment_2) { Fabricate(:comment, :err => problem_1, :user => comment.user) } | 55 | + let!(:comment) { Fabricate(:comment, err: problem) } |
56 | + let!(:comment_2) { Fabricate(:comment, err: problem_1, user: comment.user) } | ||
57 | it 'merge comment' do | 57 | it 'merge comment' do |
58 | expect { | 58 | expect { |
59 | problem_merge.merge | 59 | problem_merge.merge |
spec/interactors/resolved_problem_clearer_spec.rb
@@ -20,7 +20,7 @@ describe ResolvedProblemClearer do | @@ -20,7 +20,7 @@ describe ResolvedProblemClearer do | ||
20 | end | 20 | end |
21 | it 'not repair database' do | 21 | it 'not repair database' do |
22 | allow(Mongoid.default_client).to receive(:command).and_call_original | 22 | allow(Mongoid.default_client).to receive(:command).and_call_original |
23 | - expect(Mongoid.default_client).to_not receive(:command).with({ :repairDatabase => 1 }) | 23 | + expect(Mongoid.default_client).to_not receive(:command).with({ repairDatabase: 1 }) |
24 | resolved_problem_clearer.execute | 24 | resolved_problem_clearer.execute |
25 | end | 25 | end |
26 | end | 26 | end |
@@ -28,7 +28,7 @@ describe ResolvedProblemClearer do | @@ -28,7 +28,7 @@ describe ResolvedProblemClearer do | ||
28 | context "with problem resolve" do | 28 | context "with problem resolve" do |
29 | before do | 29 | before do |
30 | allow(Mongoid.default_client).to receive(:command).and_call_original | 30 | allow(Mongoid.default_client).to receive(:command).and_call_original |
31 | - allow(Mongoid.default_client).to receive(:command).with({ :repairDatabase => 1 }) | 31 | + allow(Mongoid.default_client).to receive(:command).with({ repairDatabase: 1 }) |
32 | problems.first.resolve! | 32 | problems.first.resolve! |
33 | problems.second.resolve! | 33 | problems.second.resolve! |
34 | end | 34 | end |
@@ -39,12 +39,12 @@ describe ResolvedProblemClearer do | @@ -39,12 +39,12 @@ describe ResolvedProblemClearer do | ||
39 | }.to change { | 39 | }.to change { |
40 | Problem.count | 40 | Problem.count |
41 | }.by(-2) | 41 | }.by(-2) |
42 | - expect(Problem.where(:_id => problems.first.id).first).to be_nil | ||
43 | - expect(Problem.where(:_id => problems.second.id).first).to be_nil | 42 | + expect(Problem.where(_id: problems.first.id).first).to be_nil |
43 | + expect(Problem.where(_id: problems.second.id).first).to be_nil | ||
44 | end | 44 | end |
45 | 45 | ||
46 | it 'repair database' do | 46 | it 'repair database' do |
47 | - expect(Mongoid.default_client).to receive(:command).with({ :repairDatabase => 1 }) | 47 | + expect(Mongoid.default_client).to receive(:command).with({ repairDatabase: 1 }) |
48 | resolved_problem_clearer.execute | 48 | resolved_problem_clearer.execute |
49 | end | 49 | end |
50 | end | 50 | end |
spec/interactors/user_destroy_spec.rb
@@ -2,8 +2,8 @@ describe UserDestroy do | @@ -2,8 +2,8 @@ describe UserDestroy do | ||
2 | let(:app) { | 2 | let(:app) { |
3 | Fabricate( | 3 | Fabricate( |
4 | :app, | 4 | :app, |
5 | - :watchers => [ | ||
6 | - Fabricate.build(:user_watcher, :user => user) | 5 | + watchers: [ |
6 | + Fabricate.build(:user_watcher, user: user) | ||
7 | ]) | 7 | ]) |
8 | } | 8 | } |
9 | 9 | ||
@@ -19,7 +19,7 @@ describe UserDestroy do | @@ -19,7 +19,7 @@ describe UserDestroy do | ||
19 | expect { | 19 | expect { |
20 | UserDestroy.new(user).destroy | 20 | UserDestroy.new(user).destroy |
21 | }.to change { | 21 | }.to change { |
22 | - app.reload.watchers.where(:user_id => user.id).count | 22 | + app.reload.watchers.where(user_id: user.id).count |
23 | }.from(1).to(0) | 23 | }.from(1).to(0) |
24 | end | 24 | end |
25 | end | 25 | end |
spec/lib/configurator_spec.rb
@@ -29,7 +29,7 @@ describe Configurator do | @@ -29,7 +29,7 @@ describe Configurator do | ||
29 | 29 | ||
30 | it 'overrides can refer to other values' do | 30 | it 'overrides can refer to other values' do |
31 | result = Configurator.run({ | 31 | result = Configurator.run({ |
32 | - one: ['VARONE', ->(values) { values[:one] }], | 32 | + one: ['VARONE', ->(values) { values[:one] }], |
33 | three: ['VARTHREE'] | 33 | three: ['VARTHREE'] |
34 | }) | 34 | }) |
35 | expect(result.one).to eq('zoom') | 35 | expect(result.one).to eq('zoom') |
spec/mailers/mailer_spec.rb
@@ -41,8 +41,8 @@ describe Mailer do | @@ -41,8 +41,8 @@ describe Mailer do | ||
41 | let(:app) do | 41 | let(:app) do |
42 | a = notice.app | 42 | a = notice.app |
43 | a.update_attributes( | 43 | a.update_attributes( |
44 | - :asset_host => "http://example.com", | ||
45 | - :notify_all_users => true | 44 | + asset_host: "http://example.com", |
45 | + notify_all_users: true | ||
46 | ) | 46 | ) |
47 | a | 47 | a |
48 | end | 48 | end |
@@ -55,8 +55,8 @@ describe Mailer do | @@ -55,8 +55,8 @@ describe Mailer do | ||
55 | let(:error_report) do | 55 | let(:error_report) do |
56 | instance_double( | 56 | instance_double( |
57 | 'ErrorReport', | 57 | 'ErrorReport', |
58 | - notice: notice, | ||
59 | - app: app, | 58 | + notice: notice, |
59 | + app: app, | ||
60 | problem: problem | 60 | problem: problem |
61 | ) | 61 | ) |
62 | end | 62 | end |
@@ -85,7 +85,7 @@ describe Mailer do | @@ -85,7 +85,7 @@ describe Mailer do | ||
85 | end | 85 | end |
86 | 86 | ||
87 | context 'with a very long message' do | 87 | context 'with a very long message' do |
88 | - let(:notice) { Fabricate(:notice, :message => 6.times.collect { |_a| "0123456789" }.join('')) } | 88 | + let(:notice) { Fabricate(:notice, message: 6.times.collect { |_a| "0123456789" }.join('')) } |
89 | it "should truncate the long message" do | 89 | it "should truncate the long message" do |
90 | expect(email.subject).to match(/ \d{47}\.{3}$/) | 90 | expect(email.subject).to match(/ \d{47}\.{3}$/) |
91 | end | 91 | end |
@@ -97,13 +97,13 @@ describe Mailer do | @@ -97,13 +97,13 @@ describe Mailer do | ||
97 | include EmailSpec::Matchers | 97 | include EmailSpec::Matchers |
98 | 98 | ||
99 | let!(:notice) { Fabricate(:notice) } | 99 | let!(:notice) { Fabricate(:notice) } |
100 | - let!(:comment) { Fabricate(:comment, :err => notice.problem) } | ||
101 | - let!(:watcher) { Fabricate(:watcher, :app => comment.app) } | 100 | + let!(:comment) { Fabricate(:comment, err: notice.problem) } |
101 | + let!(:watcher) { Fabricate(:watcher, app: comment.app) } | ||
102 | let(:recipients) { ['recipient@example.com', 'another@example.com'] } | 102 | let(:recipients) { ['recipient@example.com', 'another@example.com'] } |
103 | 103 | ||
104 | before do | 104 | before do |
105 | expect(comment).to receive(:notification_recipients).and_return(recipients) | 105 | expect(comment).to receive(:notification_recipients).and_return(recipients) |
106 | - Fabricate(:notice, :err => notice.err) | 106 | + Fabricate(:notice, err: notice.err) |
107 | @email = Mailer.comment_notification(comment).deliver_now | 107 | @email = Mailer.comment_notification(comment).deliver_now |
108 | end | 108 | end |
109 | 109 |
spec/models/app_spec.rb
@@ -9,21 +9,21 @@ describe App, type: 'model' do | @@ -9,21 +9,21 @@ describe App, type: 'model' do | ||
9 | 9 | ||
10 | context 'validations' do | 10 | context 'validations' do |
11 | it 'requires a name' do | 11 | it 'requires a name' do |
12 | - app = Fabricate.build(:app, :name => nil) | 12 | + app = Fabricate.build(:app, name: nil) |
13 | expect(app).to_not be_valid | 13 | expect(app).to_not be_valid |
14 | expect(app.errors[:name]).to include("can't be blank") | 14 | expect(app.errors[:name]).to include("can't be blank") |
15 | end | 15 | end |
16 | 16 | ||
17 | it 'requires unique names' do | 17 | it 'requires unique names' do |
18 | - Fabricate(:app, :name => 'Errbit') | ||
19 | - app = Fabricate.build(:app, :name => 'Errbit') | 18 | + Fabricate(:app, name: 'Errbit') |
19 | + app = Fabricate.build(:app, name: 'Errbit') | ||
20 | expect(app).to_not be_valid | 20 | expect(app).to_not be_valid |
21 | expect(app.errors[:name]).to include('is already taken') | 21 | expect(app.errors[:name]).to include('is already taken') |
22 | end | 22 | end |
23 | 23 | ||
24 | it 'requires unique api_keys' do | 24 | it 'requires unique api_keys' do |
25 | - Fabricate(:app, :api_key => 'APIKEY') | ||
26 | - app = Fabricate.build(:app, :api_key => 'APIKEY') | 25 | + Fabricate(:app, api_key: 'APIKEY') |
26 | + app = Fabricate.build(:app, api_key: 'APIKEY') | ||
27 | expect(app).to_not be_valid | 27 | expect(app).to_not be_valid |
28 | expect(app.errors[:api_key]).to include('is already taken') | 28 | expect(app.errors[:api_key]).to include('is already taken') |
29 | end | 29 | end |
@@ -31,24 +31,24 @@ describe App, type: 'model' do | @@ -31,24 +31,24 @@ describe App, type: 'model' do | ||
31 | 31 | ||
32 | describe '<=>' do | 32 | describe '<=>' do |
33 | it 'is compared by unresolved count' do | 33 | it 'is compared by unresolved count' do |
34 | - app_0 = stub_model(App, :name => 'app', :unresolved_count => 1, :problem_count => 1) | ||
35 | - app_1 = stub_model(App, :name => 'app', :unresolved_count => 0, :problem_count => 1) | 34 | + app_0 = stub_model(App, name: 'app', unresolved_count: 1, problem_count: 1) |
35 | + app_1 = stub_model(App, name: 'app', unresolved_count: 0, problem_count: 1) | ||
36 | 36 | ||
37 | expect(app_0).to be < app_1 | 37 | expect(app_0).to be < app_1 |
38 | expect(app_1).to be > app_0 | 38 | expect(app_1).to be > app_0 |
39 | end | 39 | end |
40 | 40 | ||
41 | it 'is compared by problem count' do | 41 | it 'is compared by problem count' do |
42 | - app_0 = stub_model(App, :name => 'app', :unresolved_count => 0, :problem_count => 1) | ||
43 | - app_1 = stub_model(App, :name => 'app', :unresolved_count => 0, :problem_count => 0) | 42 | + app_0 = stub_model(App, name: 'app', unresolved_count: 0, problem_count: 1) |
43 | + app_1 = stub_model(App, name: 'app', unresolved_count: 0, problem_count: 0) | ||
44 | 44 | ||
45 | expect(app_0).to be < app_1 | 45 | expect(app_0).to be < app_1 |
46 | expect(app_1).to be > app_0 | 46 | expect(app_1).to be > app_0 |
47 | end | 47 | end |
48 | 48 | ||
49 | it 'is compared by name' do | 49 | it 'is compared by name' do |
50 | - app_0 = stub_model(App, :name => 'app_0', :unresolved_count => 0, :problem_count => 0) | ||
51 | - app_1 = stub_model(App, :name => 'app_1', :unresolved_count => 0, :problem_count => 0) | 50 | + app_0 = stub_model(App, name: 'app_0', unresolved_count: 0, problem_count: 0) |
51 | + app_1 = stub_model(App, name: 'app_1', unresolved_count: 0, problem_count: 0) | ||
52 | 52 | ||
53 | expect(app_0).to be < app_1 | 53 | expect(app_0).to be < app_1 |
54 | expect(app_1).to be > app_0 | 54 | expect(app_1).to be > app_0 |
@@ -69,31 +69,31 @@ describe App, type: 'model' do | @@ -69,31 +69,31 @@ describe App, type: 'model' do | ||
69 | end | 69 | end |
70 | 70 | ||
71 | it 'is fine with blank github repos' do | 71 | it 'is fine with blank github repos' do |
72 | - app = Fabricate.build(:app, :github_repo => "") | 72 | + app = Fabricate.build(:app, github_repo: "") |
73 | app.save | 73 | app.save |
74 | expect(app.github_repo).to eq "" | 74 | expect(app.github_repo).to eq "" |
75 | end | 75 | end |
76 | 76 | ||
77 | it 'doesnt touch github user/repo' do | 77 | it 'doesnt touch github user/repo' do |
78 | - app = Fabricate.build(:app, :github_repo => "errbit/errbit") | 78 | + app = Fabricate.build(:app, github_repo: "errbit/errbit") |
79 | app.save | 79 | app.save |
80 | expect(app.github_repo).to eq "errbit/errbit" | 80 | expect(app.github_repo).to eq "errbit/errbit" |
81 | end | 81 | end |
82 | 82 | ||
83 | it 'removes domain from https github repos' do | 83 | it 'removes domain from https github repos' do |
84 | - app = Fabricate.build(:app, :github_repo => "https://github.com/errbit/errbit") | 84 | + app = Fabricate.build(:app, github_repo: "https://github.com/errbit/errbit") |
85 | app.save | 85 | app.save |
86 | expect(app.github_repo).to eq "errbit/errbit" | 86 | expect(app.github_repo).to eq "errbit/errbit" |
87 | end | 87 | end |
88 | 88 | ||
89 | it 'normalizes public git repo as a github repo' do | 89 | it 'normalizes public git repo as a github repo' do |
90 | - app = Fabricate.build(:app, :github_repo => "https://github.com/errbit/errbit.git") | 90 | + app = Fabricate.build(:app, github_repo: "https://github.com/errbit/errbit.git") |
91 | app.save | 91 | app.save |
92 | expect(app.github_repo).to eq "errbit/errbit" | 92 | expect(app.github_repo).to eq "errbit/errbit" |
93 | end | 93 | end |
94 | 94 | ||
95 | it 'normalizes private git repo as a github repo' do | 95 | it 'normalizes private git repo as a github repo' do |
96 | - app = Fabricate.build(:app, :github_repo => "git@github.com:errbit/errbit.git") | 96 | + app = Fabricate.build(:app, github_repo: "git@github.com:errbit/errbit.git") |
97 | app.save | 97 | app.save |
98 | expect(app.github_repo).to eq "errbit/errbit" | 98 | expect(app.github_repo).to eq "errbit/errbit" |
99 | end | 99 | end |
@@ -101,14 +101,14 @@ describe App, type: 'model' do | @@ -101,14 +101,14 @@ describe App, type: 'model' do | ||
101 | 101 | ||
102 | context '#github_url_to_file' do | 102 | context '#github_url_to_file' do |
103 | it 'resolves to full path to file' do | 103 | it 'resolves to full path to file' do |
104 | - app = Fabricate(:app, :github_repo => "errbit/errbit") | 104 | + app = Fabricate(:app, github_repo: "errbit/errbit") |
105 | expect(app.github_url_to_file('path/to/file')).to eq "https://github.com/errbit/errbit/blob/master/path/to/file" | 105 | expect(app.github_url_to_file('path/to/file')).to eq "https://github.com/errbit/errbit/blob/master/path/to/file" |
106 | end | 106 | end |
107 | end | 107 | end |
108 | 108 | ||
109 | context '#github_repo?' do | 109 | context '#github_repo?' do |
110 | it 'is true when there is a github_repo' do | 110 | it 'is true when there is a github_repo' do |
111 | - app = Fabricate(:app, :github_repo => "errbit/errbit") | 111 | + app = Fabricate(:app, github_repo: "errbit/errbit") |
112 | expect(app.github_repo?).to be(true) | 112 | expect(app.github_repo?).to be(true) |
113 | end | 113 | end |
114 | 114 | ||
@@ -122,7 +122,7 @@ describe App, type: 'model' do | @@ -122,7 +122,7 @@ describe App, type: 'model' do | ||
122 | it "should send notices to either all users plus watchers, or the configured watchers" do | 122 | it "should send notices to either all users plus watchers, or the configured watchers" do |
123 | @app = Fabricate(:app) | 123 | @app = Fabricate(:app) |
124 | 3.times { Fabricate(:user) } | 124 | 3.times { Fabricate(:user) } |
125 | - 5.times { Fabricate(:watcher, :app => @app) } | 125 | + 5.times { Fabricate(:watcher, app: @app) } |
126 | @app.notify_all_users = true | 126 | @app.notify_all_users = true |
127 | expect(@app.notification_recipients.size).to eq 8 | 127 | expect(@app.notification_recipients.size).to eq 8 |
128 | @app.notify_all_users = false | 128 | @app.notify_all_users = false |
@@ -132,19 +132,19 @@ describe App, type: 'model' do | @@ -132,19 +132,19 @@ describe App, type: 'model' do | ||
132 | 132 | ||
133 | context "emailable?" do | 133 | context "emailable?" do |
134 | it "should be true if notify on errs and there are notification recipients" do | 134 | it "should be true if notify on errs and there are notification recipients" do |
135 | - app = Fabricate(:app, :notify_on_errs => true, :notify_all_users => false) | ||
136 | - 2.times { Fabricate(:watcher, :app => app) } | 135 | + app = Fabricate(:app, notify_on_errs: true, notify_all_users: false) |
136 | + 2.times { Fabricate(:watcher, app: app) } | ||
137 | expect(app.emailable?).to be(true) | 137 | expect(app.emailable?).to be(true) |
138 | end | 138 | end |
139 | 139 | ||
140 | it "should be false if notify on errs is disabled" do | 140 | it "should be false if notify on errs is disabled" do |
141 | - app = Fabricate(:app, :notify_on_errs => false, :notify_all_users => false) | ||
142 | - 2.times { Fabricate(:watcher, :app => app) } | 141 | + app = Fabricate(:app, notify_on_errs: false, notify_all_users: false) |
142 | + 2.times { Fabricate(:watcher, app: app) } | ||
143 | expect(app.emailable?).to be(false) | 143 | expect(app.emailable?).to be(false) |
144 | end | 144 | end |
145 | 145 | ||
146 | it "should be false if there are no notification recipients" do | 146 | it "should be false if there are no notification recipients" do |
147 | - app = Fabricate(:app, :notify_on_errs => true, :notify_all_users => false) | 147 | + app = Fabricate(:app, notify_on_errs: true, notify_all_users: false) |
148 | expect(app.watchers).to be_empty | 148 | expect(app.watchers).to be_empty |
149 | expect(app.emailable?).to be(false) | 149 | expect(app.emailable?).to be(false) |
150 | end | 150 | end |
@@ -152,9 +152,9 @@ describe App, type: 'model' do | @@ -152,9 +152,9 @@ describe App, type: 'model' do | ||
152 | 152 | ||
153 | context "copying attributes from existing app" do | 153 | context "copying attributes from existing app" do |
154 | it "should only copy the necessary fields" do | 154 | it "should only copy the necessary fields" do |
155 | - @app = Fabricate(:app, :name => "app", :github_repo => "url") | ||
156 | - @copy_app = Fabricate(:app, :name => "copy_app", :github_repo => "copy url") | ||
157 | - @copy_watcher = Fabricate(:watcher, :email => "copywatcher@example.com", :app => @copy_app) | 155 | + @app = Fabricate(:app, name: "app", github_repo: "url") |
156 | + @copy_app = Fabricate(:app, name: "copy_app", github_repo: "copy url") | ||
157 | + @copy_watcher = Fabricate(:watcher, email: "copywatcher@example.com", app: @copy_app) | ||
158 | @app.copy_attributes_from(@copy_app.id) | 158 | @app.copy_attributes_from(@copy_app.id) |
159 | expect(@app.name).to eq "app" | 159 | expect(@app.name).to eq "app" |
160 | expect(@app.github_repo).to eq "copy url" | 160 | expect(@app.github_repo).to eq "copy url" |
@@ -166,18 +166,18 @@ describe App, type: 'model' do | @@ -166,18 +166,18 @@ describe App, type: 'model' do | ||
166 | let(:app) { Fabricate(:app) } | 166 | let(:app) { Fabricate(:app) } |
167 | let(:conditions) { | 167 | let(:conditions) { |
168 | { | 168 | { |
169 | - :error_class => 'Whoops', | ||
170 | - :environment => 'production', | ||
171 | - :fingerprint => 'some-finger-print' | 169 | + error_class: 'Whoops', |
170 | + environment: 'production', | ||
171 | + fingerprint: 'some-finger-print' | ||
172 | } | 172 | } |
173 | } | 173 | } |
174 | 174 | ||
175 | it 'returns the correct err if one already exists' do | 175 | it 'returns the correct err if one already exists' do |
176 | existing = Fabricate(:err, { | 176 | existing = Fabricate(:err, { |
177 | - :problem => Fabricate(:problem, :app => app), | ||
178 | - :fingerprint => conditions[:fingerprint] | 177 | + problem: Fabricate(:problem, app: app), |
178 | + fingerprint: conditions[:fingerprint] | ||
179 | }) | 179 | }) |
180 | - expect(Err.where(:fingerprint => conditions[:fingerprint]).first).to eq existing | 180 | + expect(Err.where(fingerprint: conditions[:fingerprint]).first).to eq existing |
181 | expect(app.find_or_create_err!(conditions)).to eq existing | 181 | expect(app.find_or_create_err!(conditions)).to eq existing |
182 | end | 182 | end |
183 | 183 | ||
@@ -195,8 +195,8 @@ describe App, type: 'model' do | @@ -195,8 +195,8 @@ describe App, type: 'model' do | ||
195 | context "without error_class" do | 195 | context "without error_class" do |
196 | let(:conditions) { | 196 | let(:conditions) { |
197 | { | 197 | { |
198 | - :environment => 'production', | ||
199 | - :fingerprint => 'some-finger-print' | 198 | + environment: 'production', |
199 | + fingerprint: 'some-finger-print' | ||
200 | } | 200 | } |
201 | } | 201 | } |
202 | it 'save the err' do | 202 | it 'save the err' do |
spec/models/comment_observer_spec.rb
@@ -8,7 +8,7 @@ describe "Callback on Comment", type: 'model' do | @@ -8,7 +8,7 @@ describe "Callback on Comment", type: 'model' do | ||
8 | it 'should send an email notification' do | 8 | it 'should send an email notification' do |
9 | expect(Mailer).to receive(:comment_notification). | 9 | expect(Mailer).to receive(:comment_notification). |
10 | with(comment). | 10 | with(comment). |
11 | - and_return(double('email', :deliver_now => true)) | 11 | + and_return(double('email', deliver_now: true)) |
12 | comment.save | 12 | comment.save |
13 | end | 13 | end |
14 | end | 14 | end |
spec/models/comment_spec.rb
1 | describe Comment, type: 'model' do | 1 | describe Comment, type: 'model' do |
2 | context 'validations' do | 2 | context 'validations' do |
3 | it 'should require a body' do | 3 | it 'should require a body' do |
4 | - comment = Fabricate.build(:comment, :body => nil) | 4 | + comment = Fabricate.build(:comment, body: nil) |
5 | expect(comment).to_not be_valid | 5 | expect(comment).to_not be_valid |
6 | expect(comment.errors[:body]).to include("can't be blank") | 6 | expect(comment.errors[:body]).to include("can't be blank") |
7 | end | 7 | end |
@@ -9,13 +9,13 @@ describe Comment, type: 'model' do | @@ -9,13 +9,13 @@ describe Comment, type: 'model' do | ||
9 | 9 | ||
10 | context 'notification_recipients' do | 10 | context 'notification_recipients' do |
11 | let(:app) { Fabricate(:app) } | 11 | let(:app) { Fabricate(:app) } |
12 | - let!(:watcher) { Fabricate(:watcher, :app => app) } | ||
13 | - let(:err) { Fabricate(:problem, :app => app) } | ||
14 | - let(:comment_user) { Fabricate(:user, :email => 'author@example.com') } | ||
15 | - let(:comment) { Fabricate.build(:comment, :err => err, :user => comment_user) } | 12 | + let!(:watcher) { Fabricate(:watcher, app: app) } |
13 | + let(:err) { Fabricate(:problem, app: app) } | ||
14 | + let(:comment_user) { Fabricate(:user, email: 'author@example.com') } | ||
15 | + let(:comment) { Fabricate.build(:comment, err: err, user: comment_user) } | ||
16 | 16 | ||
17 | before do | 17 | before do |
18 | - Fabricate(:user_watcher, :app => app, :user => comment_user) | 18 | + Fabricate(:user_watcher, app: app, user: comment_user) |
19 | end | 19 | end |
20 | 20 | ||
21 | it 'includes app notification_recipients except user email' do | 21 | it 'includes app notification_recipients except user email' do |
@@ -24,14 +24,14 @@ describe Comment, type: 'model' do | @@ -24,14 +24,14 @@ describe Comment, type: 'model' do | ||
24 | end | 24 | end |
25 | 25 | ||
26 | context 'emailable?' do | 26 | context 'emailable?' do |
27 | - let(:app) { Fabricate(:app, :notify_on_errs => true) } | ||
28 | - let!(:watcher) { Fabricate(:watcher, :app => app) } | ||
29 | - let(:err) { Fabricate(:problem, :app => app) } | ||
30 | - let(:comment_user) { Fabricate(:user, :email => 'author@example.com') } | ||
31 | - let(:comment) { Fabricate.build(:comment, :err => err, :user => comment_user) } | 27 | + let(:app) { Fabricate(:app, notify_on_errs: true) } |
28 | + let!(:watcher) { Fabricate(:watcher, app: app) } | ||
29 | + let(:err) { Fabricate(:problem, app: app) } | ||
30 | + let(:comment_user) { Fabricate(:user, email: 'author@example.com') } | ||
31 | + let(:comment) { Fabricate.build(:comment, err: err, user: comment_user) } | ||
32 | 32 | ||
33 | before do | 33 | before do |
34 | - Fabricate(:user_watcher, :app => app, :user => comment_user) | 34 | + Fabricate(:user_watcher, app: app, user: comment_user) |
35 | end | 35 | end |
36 | 36 | ||
37 | it 'should be true if app is emailable? and there are notification recipients' do | 37 | it 'should be true if app is emailable? and there are notification recipients' do |
spec/models/deploy_observer_spec.rb
@@ -3,15 +3,15 @@ describe "Callback on Deploy", type: 'model' do | @@ -3,15 +3,15 @@ describe "Callback on Deploy", type: 'model' do | ||
3 | context 'and the app should notify on deploys' do | 3 | context 'and the app should notify on deploys' do |
4 | it 'should send an email notification' do | 4 | it 'should send an email notification' do |
5 | expect(Mailer).to receive(:deploy_notification). | 5 | expect(Mailer).to receive(:deploy_notification). |
6 | - and_return(double('email', :deliver_now => true)) | ||
7 | - Fabricate(:deploy, :app => Fabricate(:app_with_watcher, :notify_on_deploys => true)) | 6 | + and_return(double('email', deliver_now: true)) |
7 | + Fabricate(:deploy, app: Fabricate(:app_with_watcher, notify_on_deploys: true)) | ||
8 | end | 8 | end |
9 | end | 9 | end |
10 | 10 | ||
11 | context 'and the app is not set to notify on deploys' do | 11 | context 'and the app is not set to notify on deploys' do |
12 | it 'should not send an email notification' do | 12 | it 'should not send an email notification' do |
13 | expect(Mailer).to_not receive(:deploy_notification) | 13 | expect(Mailer).to_not receive(:deploy_notification) |
14 | - Fabricate(:deploy, :app => Fabricate(:app_with_watcher, :notify_on_deploys => false)) | 14 | + Fabricate(:deploy, app: Fabricate(:app_with_watcher, notify_on_deploys: false)) |
15 | end | 15 | end |
16 | end | 16 | end |
17 | end | 17 | end |
spec/models/deploy_spec.rb
1 | describe Deploy, type: 'model' do | 1 | describe Deploy, type: 'model' do |
2 | context 'validations' do | 2 | context 'validations' do |
3 | it 'requires a username' do | 3 | it 'requires a username' do |
4 | - deploy = Fabricate.build(:deploy, :username => nil) | 4 | + deploy = Fabricate.build(:deploy, username: nil) |
5 | expect(deploy).to_not be_valid | 5 | expect(deploy).to_not be_valid |
6 | expect(deploy.errors[:username]).to include("can't be blank") | 6 | expect(deploy.errors[:username]).to include("can't be blank") |
7 | end | 7 | end |
8 | 8 | ||
9 | it 'requires an environment' do | 9 | it 'requires an environment' do |
10 | - deploy = Fabricate.build(:deploy, :environment => nil) | 10 | + deploy = Fabricate.build(:deploy, environment: nil) |
11 | expect(deploy).to_not be_valid | 11 | expect(deploy).to_not be_valid |
12 | expect(deploy.errors[:environment]).to include("can't be blank") | 12 | expect(deploy.errors[:environment]).to include("can't be blank") |
13 | end | 13 | end |
@@ -16,19 +16,19 @@ describe Deploy, type: 'model' do | @@ -16,19 +16,19 @@ describe Deploy, type: 'model' do | ||
16 | context 'being created' do | 16 | context 'being created' do |
17 | context 'when the app has resolve_errs_on_deploy set to false' do | 17 | context 'when the app has resolve_errs_on_deploy set to false' do |
18 | it 'should not resolve the apps errs' do | 18 | it 'should not resolve the apps errs' do |
19 | - app = Fabricate(:app, :resolve_errs_on_deploy => false) | ||
20 | - @problems = 3.times.map { Fabricate(:err, :problem => Fabricate(:problem, :resolved => false, :app => app)) } | ||
21 | - Fabricate(:deploy, :app => app) | 19 | + app = Fabricate(:app, resolve_errs_on_deploy: false) |
20 | + @problems = 3.times.map { Fabricate(:err, problem: Fabricate(:problem, resolved: false, app: app)) } | ||
21 | + Fabricate(:deploy, app: app) | ||
22 | expect(app.reload.problems.none?(&:resolved?)).to eq true | 22 | expect(app.reload.problems.none?(&:resolved?)).to eq true |
23 | end | 23 | end |
24 | end | 24 | end |
25 | 25 | ||
26 | context 'when the app has resolve_errs_on_deploy set to true' do | 26 | context 'when the app has resolve_errs_on_deploy set to true' do |
27 | it 'should resolve the apps errs that were in the same environment' do | 27 | it 'should resolve the apps errs that were in the same environment' do |
28 | - app = Fabricate(:app, :resolve_errs_on_deploy => true) | ||
29 | - @prod_errs = 3.times.map { Fabricate(:problem, :resolved => false, :app => app, :environment => 'production') } | ||
30 | - @staging_errs = 3.times.map { Fabricate(:problem, :resolved => false, :app => app, :environment => 'staging') } | ||
31 | - Fabricate(:deploy, :app => app, :environment => 'production') | 28 | + app = Fabricate(:app, resolve_errs_on_deploy: true) |
29 | + @prod_errs = 3.times.map { Fabricate(:problem, resolved: false, app: app, environment: 'production') } | ||
30 | + @staging_errs = 3.times.map { Fabricate(:problem, resolved: false, app: app, environment: 'staging') } | ||
31 | + Fabricate(:deploy, app: app, environment: 'production') | ||
32 | expect(@prod_errs.all? { |problem| problem.reload.resolved? }).to eq true | 32 | expect(@prod_errs.all? { |problem| problem.reload.resolved? }).to eq true |
33 | expect(@staging_errs.all? { |problem| problem.reload.resolved? }).to eq false | 33 | expect(@staging_errs.all? { |problem| problem.reload.resolved? }).to eq false |
34 | end | 34 | end |
@@ -36,6 +36,6 @@ describe Deploy, type: 'model' do | @@ -36,6 +36,6 @@ describe Deploy, type: 'model' do | ||
36 | end | 36 | end |
37 | 37 | ||
38 | it "should produce a shortened revision with 7 characters" do | 38 | it "should produce a shortened revision with 7 characters" do |
39 | - expect(Deploy.new(:revision => "1234567890abcdef").short_revision).to eq "1234567" | 39 | + expect(Deploy.new(revision: "1234567890abcdef").short_revision).to eq "1234567" |
40 | end | 40 | end |
41 | end | 41 | end |
spec/models/err_spec.rb
1 | describe Err, type: 'model' do | 1 | describe Err, type: 'model' do |
2 | context 'validations' do | 2 | context 'validations' do |
3 | it 'requires a fingerprint' do | 3 | it 'requires a fingerprint' do |
4 | - err = Fabricate.build(:err, :fingerprint => nil) | 4 | + err = Fabricate.build(:err, fingerprint: nil) |
5 | expect(err).to_not be_valid | 5 | expect(err).to_not be_valid |
6 | expect(err.errors[:fingerprint]).to include("can't be blank") | 6 | expect(err.errors[:fingerprint]).to include("can't be blank") |
7 | end | 7 | end |
8 | 8 | ||
9 | it 'requires a problem' do | 9 | it 'requires a problem' do |
10 | - err = Fabricate.build(:err, :problem_id => nil, :problem => nil) | 10 | + err = Fabricate.build(:err, problem_id: nil, problem: nil) |
11 | expect(err).to_not be_valid | 11 | expect(err).to_not be_valid |
12 | expect(err.errors[:problem_id]).to include("can't be blank") | 12 | expect(err.errors[:problem_id]).to include("can't be blank") |
13 | end | 13 | end |
spec/models/error_report_spec.rb
@@ -26,7 +26,7 @@ describe ErrorReport do | @@ -26,7 +26,7 @@ describe ErrorReport do | ||
26 | let!(:app) { | 26 | let!(:app) { |
27 | Fabricate( | 27 | Fabricate( |
28 | :app, | 28 | :app, |
29 | - :api_key => 'APIKEY' | 29 | + api_key: 'APIKEY' |
30 | ) | 30 | ) |
31 | } | 31 | } |
32 | 32 | ||
@@ -68,9 +68,9 @@ describe ErrorReport do | @@ -68,9 +68,9 @@ describe ErrorReport do | ||
68 | context "with notice generate by Airbrake gem" do | 68 | context "with notice generate by Airbrake gem" do |
69 | let(:xml) { | 69 | let(:xml) { |
70 | Airbrake::Notice.new( | 70 | Airbrake::Notice.new( |
71 | - :exception => Exception.new, | ||
72 | - :api_key => 'APIKEY', | ||
73 | - :project_root => Rails.root | 71 | + exception: Exception.new, |
72 | + api_key: 'APIKEY', | ||
73 | + project_root: Rails.root | ||
74 | ).to_xml | 74 | ).to_xml |
75 | } | 75 | } |
76 | it 'save a notice' do | 76 | it 'save a notice' do |
@@ -159,7 +159,7 @@ describe ErrorReport do | @@ -159,7 +159,7 @@ describe ErrorReport do | ||
159 | problem = error_report.problem | 159 | problem = error_report.problem |
160 | problem.update( | 160 | problem.update( |
161 | resolved_at: Time.zone.now, | 161 | resolved_at: Time.zone.now, |
162 | - resolved: true | 162 | + resolved: true |
163 | ) | 163 | ) |
164 | 164 | ||
165 | error_report = ErrorReport.new(xml) | 165 | error_report = ErrorReport.new(xml) |
@@ -223,7 +223,7 @@ describe ErrorReport do | @@ -223,7 +223,7 @@ describe ErrorReport do | ||
223 | context "with notification service configured" do | 223 | context "with notification service configured" do |
224 | before do | 224 | before do |
225 | app.notify_on_errs = true | 225 | app.notify_on_errs = true |
226 | - app.watchers.build(:email => 'foo@example.com') | 226 | + app.watchers.build(email: 'foo@example.com') |
227 | app.save | 227 | app.save |
228 | end | 228 | end |
229 | 229 | ||
@@ -271,7 +271,7 @@ describe ErrorReport do | @@ -271,7 +271,7 @@ describe ErrorReport do | ||
271 | end | 271 | end |
272 | context "with not valid api_key" do | 272 | context "with not valid api_key" do |
273 | before do | 273 | before do |
274 | - App.where(:api_key => app.api_key).delete_all | 274 | + App.where(api_key: app.api_key).delete_all |
275 | end | 275 | end |
276 | it "return false" do | 276 | it "return false" do |
277 | expect(error_report.valid?).to be false | 277 | expect(error_report.valid?).to be false |
spec/models/notice_observer_spec.rb
@@ -2,27 +2,27 @@ describe "Callback on Notice", type: 'model' do | @@ -2,27 +2,27 @@ describe "Callback on Notice", type: 'model' do | ||
2 | let(:notice_attrs_for) do | 2 | let(:notice_attrs_for) do |
3 | lambda do |api_key| | 3 | lambda do |api_key| |
4 | { | 4 | { |
5 | - error_class: "HoptoadTestingException", | ||
6 | - message: "some message", | ||
7 | - backtrace: [ | 5 | + error_class: "HoptoadTestingException", |
6 | + message: "some message", | ||
7 | + backtrace: [ | ||
8 | { | 8 | { |
9 | "number" => "425", | 9 | "number" => "425", |
10 | "file" => "[GEM_ROOT]/callbacks.rb", | 10 | "file" => "[GEM_ROOT]/callbacks.rb", |
11 | "method" => "__callbacks" | 11 | "method" => "__callbacks" |
12 | } | 12 | } |
13 | ], | 13 | ], |
14 | - request: { "component" => "application" }, | 14 | + request: { "component" => "application" }, |
15 | server_environment: { | 15 | server_environment: { |
16 | "project-root" => "/path/to/sample/project", | 16 | "project-root" => "/path/to/sample/project", |
17 | "environment-name" => "development" | 17 | "environment-name" => "development" |
18 | }, | 18 | }, |
19 | - api_key: api_key, | ||
20 | - notifier: { | 19 | + api_key: api_key, |
20 | + notifier: { | ||
21 | "name" => "Hoptoad Notifier", | 21 | "name" => "Hoptoad Notifier", |
22 | "version" => "2.3.2", | 22 | "version" => "2.3.2", |
23 | "url" => "http://hoptoadapp.com" | 23 | "url" => "http://hoptoadapp.com" |
24 | }, | 24 | }, |
25 | - framework: "Rails: 3.2.11" | 25 | + framework: "Rails: 3.2.11" |
26 | } | 26 | } |
27 | end | 27 | end |
28 | end | 28 | end |
@@ -49,7 +49,7 @@ describe "Callback on Notice", type: 'model' do | @@ -49,7 +49,7 @@ describe "Callback on Notice", type: 'model' do | ||
49 | @problem.update_attributes notices_count: threshold - 1 | 49 | @problem.update_attributes notices_count: threshold - 1 |
50 | 50 | ||
51 | expect(Mailer).to receive(:err_notification). | 51 | expect(Mailer).to receive(:err_notification). |
52 | - and_return(double('email', :deliver_now => true)) | 52 | + and_return(double('email', deliver_now: true)) |
53 | 53 | ||
54 | error_report = ErrorReport.new(notice_attrs) | 54 | error_report = ErrorReport.new(notice_attrs) |
55 | error_report.generate_notice! | 55 | error_report.generate_notice! |
@@ -77,7 +77,7 @@ describe "Callback on Notice", type: 'model' do | @@ -77,7 +77,7 @@ describe "Callback on Notice", type: 'model' do | ||
77 | let(:app) do | 77 | let(:app) do |
78 | Fabricate( | 78 | Fabricate( |
79 | :app_with_watcher, | 79 | :app_with_watcher, |
80 | - notify_on_errs: true, | 80 | + notify_on_errs: true, |
81 | email_at_notices: [1, 100] | 81 | email_at_notices: [1, 100] |
82 | ) | 82 | ) |
83 | end | 83 | end |
@@ -95,7 +95,7 @@ describe "Callback on Notice", type: 'model' do | @@ -95,7 +95,7 @@ describe "Callback on Notice", type: 'model' do | ||
95 | err.problem.resolve! | 95 | err.problem.resolve! |
96 | 96 | ||
97 | expect(Mailer).to receive(:err_notification). | 97 | expect(Mailer).to receive(:err_notification). |
98 | - and_return(double('email', :deliver_now => true)) | 98 | + and_return(double('email', deliver_now: true)) |
99 | 99 | ||
100 | ErrorReport.new(notice_attrs).generate_notice! | 100 | ErrorReport.new(notice_attrs).generate_notice! |
101 | end | 101 | end |
@@ -106,7 +106,7 @@ describe "Callback on Notice", type: 'model' do | @@ -106,7 +106,7 @@ describe "Callback on Notice", type: 'model' do | ||
106 | let(:app) do | 106 | let(:app) do |
107 | Fabricate( | 107 | Fabricate( |
108 | :app_with_watcher, | 108 | :app_with_watcher, |
109 | - notify_on_errs: true, | 109 | + notify_on_errs: true, |
110 | notification_service: notification_service | 110 | notification_service: notification_service |
111 | ) | 111 | ) |
112 | end | 112 | end |
@@ -121,7 +121,7 @@ describe "Callback on Notice", type: 'model' do | @@ -121,7 +121,7 @@ describe "Callback on Notice", type: 'model' do | ||
121 | expect(error_report.app.notification_service). | 121 | expect(error_report.app.notification_service). |
122 | to receive(:create_notification).and_raise(ArgumentError) | 122 | to receive(:create_notification).and_raise(ArgumentError) |
123 | expect(Mailer). | 123 | expect(Mailer). |
124 | - to receive(:err_notification).and_return(double(:deliver_now => true)) | 124 | + to receive(:err_notification).and_return(double(deliver_now: true)) |
125 | 125 | ||
126 | error_report.generate_notice! | 126 | error_report.generate_notice! |
127 | end | 127 | end |
spec/models/notice_spec.rb
1 | describe Notice, type: 'model' do | 1 | describe Notice, type: 'model' do |
2 | context 'validations' do | 2 | context 'validations' do |
3 | it 'requires a backtrace' do | 3 | it 'requires a backtrace' do |
4 | - notice = Fabricate.build(:notice, :backtrace => nil) | 4 | + notice = Fabricate.build(:notice, backtrace: nil) |
5 | expect(notice).to_not be_valid | 5 | expect(notice).to_not be_valid |
6 | expect(notice.errors[:backtrace_id]).to include("can't be blank") | 6 | expect(notice.errors[:backtrace_id]).to include("can't be blank") |
7 | end | 7 | end |
8 | 8 | ||
9 | it 'requires the server_environment' do | 9 | it 'requires the server_environment' do |
10 | - notice = Fabricate.build(:notice, :server_environment => nil) | 10 | + notice = Fabricate.build(:notice, server_environment: nil) |
11 | expect(notice).to_not be_valid | 11 | expect(notice).to_not be_valid |
12 | expect(notice.errors[:server_environment]).to include("can't be blank") | 12 | expect(notice.errors[:server_environment]).to include("can't be blank") |
13 | end | 13 | end |
14 | 14 | ||
15 | it 'requires the notifier' do | 15 | it 'requires the notifier' do |
16 | - notice = Fabricate.build(:notice, :notifier => nil) | 16 | + notice = Fabricate.build(:notice, notifier: nil) |
17 | expect(notice).to_not be_valid | 17 | expect(notice).to_not be_valid |
18 | expect(notice.errors[:notifier]).to include("can't be blank") | 18 | expect(notice.errors[:notifier]).to include("can't be blank") |
19 | end | 19 | end |
@@ -57,7 +57,7 @@ describe Notice, type: 'model' do | @@ -57,7 +57,7 @@ describe Notice, type: 'model' do | ||
57 | 57 | ||
58 | describe "user agent" do | 58 | describe "user agent" do |
59 | it "should be parsed and human-readable" do | 59 | it "should be parsed and human-readable" do |
60 | - notice = Fabricate.build(:notice, :request => { 'cgi-data' => { | 60 | + notice = Fabricate.build(:notice, request: { 'cgi-data' => { |
61 | 'HTTP_USER_AGENT' => 'Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_7; en-US) AppleWebKit/534.16 (KHTML, like Gecko) Chrome/10.0.648.204 Safari/534.16' | 61 | 'HTTP_USER_AGENT' => 'Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_7; en-US) AppleWebKit/534.16 (KHTML, like Gecko) Chrome/10.0.648.204 Safari/534.16' |
62 | } }) | 62 | } }) |
63 | expect(notice.user_agent.browser).to eq 'Chrome' | 63 | expect(notice.user_agent.browser).to eq 'Chrome' |
@@ -72,7 +72,7 @@ describe Notice, type: 'model' do | @@ -72,7 +72,7 @@ describe Notice, type: 'model' do | ||
72 | 72 | ||
73 | describe "user agent string" do | 73 | describe "user agent string" do |
74 | it "should be parsed and human-readable" do | 74 | it "should be parsed and human-readable" do |
75 | - notice = Fabricate.build(:notice, :request => { 'cgi-data' => { 'HTTP_USER_AGENT' => 'Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_7; en-US) AppleWebKit/534.16 (KHTML, like Gecko) Chrome/10.0.648.204 Safari/534.16' } }) | 75 | + notice = Fabricate.build(:notice, request: { 'cgi-data' => { 'HTTP_USER_AGENT' => 'Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_7; en-US) AppleWebKit/534.16 (KHTML, like Gecko) Chrome/10.0.648.204 Safari/534.16' } }) |
76 | expect(notice.user_agent_string).to eq 'Chrome 10.0.648.204 (OS X 10.6.7)' | 76 | expect(notice.user_agent_string).to eq 'Chrome 10.0.648.204 (OS X 10.6.7)' |
77 | end | 77 | end |
78 | 78 | ||
@@ -84,22 +84,22 @@ describe Notice, type: 'model' do | @@ -84,22 +84,22 @@ describe Notice, type: 'model' do | ||
84 | 84 | ||
85 | describe "host" do | 85 | describe "host" do |
86 | it "returns host if url is valid" do | 86 | it "returns host if url is valid" do |
87 | - notice = Fabricate.build(:notice, :request => { 'url' => "http://example.com/resource/12" }) | 87 | + notice = Fabricate.build(:notice, request: { 'url' => "http://example.com/resource/12" }) |
88 | expect(notice.host).to eq 'example.com' | 88 | expect(notice.host).to eq 'example.com' |
89 | end | 89 | end |
90 | 90 | ||
91 | it "returns 'N/A' when url is not valid" do | 91 | it "returns 'N/A' when url is not valid" do |
92 | - notice = Fabricate.build(:notice, :request => { 'url' => "file:///path/to/some/resource/12" }) | 92 | + notice = Fabricate.build(:notice, request: { 'url' => "file:///path/to/some/resource/12" }) |
93 | expect(notice.host).to eq 'N/A' | 93 | expect(notice.host).to eq 'N/A' |
94 | end | 94 | end |
95 | 95 | ||
96 | it "returns 'N/A' when url is not valid" do | 96 | it "returns 'N/A' when url is not valid" do |
97 | - notice = Fabricate.build(:notice, :request => { 'url' => "some string" }) | 97 | + notice = Fabricate.build(:notice, request: { 'url' => "some string" }) |
98 | expect(notice.host).to eq 'N/A' | 98 | expect(notice.host).to eq 'N/A' |
99 | end | 99 | end |
100 | 100 | ||
101 | it "returns 'N/A' when url is empty" do | 101 | it "returns 'N/A' when url is empty" do |
102 | - notice = Fabricate.build(:notice, :request => {}) | 102 | + notice = Fabricate.build(:notice, request: {}) |
103 | expect(notice.host).to eq 'N/A' | 103 | expect(notice.host).to eq 'N/A' |
104 | end | 104 | end |
105 | end | 105 | end |
spec/models/notification_service/campfire_service_spec.rb
@@ -2,7 +2,7 @@ describe NotificationServices::CampfireService, type: 'model' do | @@ -2,7 +2,7 @@ describe NotificationServices::CampfireService, type: 'model' do | ||
2 | it "it should send a notification to campfire" do | 2 | it "it should send a notification to campfire" do |
3 | # setup | 3 | # setup |
4 | notice = Fabricate :notice | 4 | notice = Fabricate :notice |
5 | - notification_service = Fabricate :campfire_notification_service, :app => notice.app | 5 | + notification_service = Fabricate :campfire_notification_service, app: notice.app |
6 | problem = notice.problem | 6 | problem = notice.problem |
7 | 7 | ||
8 | #campy stubbing | 8 | #campy stubbing |
spec/models/notification_service/flowdock_service_spec.rb
1 | describe NotificationServices::FlowdockService, type: 'model' do | 1 | describe NotificationServices::FlowdockService, type: 'model' do |
2 | let(:service) { Fabricate.build(:flowdock_notification_service) } | 2 | let(:service) { Fabricate.build(:flowdock_notification_service) } |
3 | - let(:app) { Fabricate(:app, :name => 'App #3') } | ||
4 | - let(:problem) { Fabricate(:problem, :app => app, :message => '<3') } | 3 | + let(:app) { Fabricate(:app, name: 'App #3') } |
4 | + let(:problem) { Fabricate(:problem, app: app, message: '<3') } | ||
5 | 5 | ||
6 | it 'sends message in appropriate format' do | 6 | it 'sends message in appropriate format' do |
7 | allow_any_instance_of(Flowdock::Flow).to receive(:push_to_team_inbox) do |*args| | 7 | allow_any_instance_of(Flowdock::Flow).to receive(:push_to_team_inbox) do |*args| |
spec/models/notification_service/gtalk_service_spec.rb
@@ -3,7 +3,7 @@ describe NotificationServices::GtalkService, type: 'model' do | @@ -3,7 +3,7 @@ describe NotificationServices::GtalkService, type: 'model' do | ||
3 | # setup | 3 | # setup |
4 | notice = Fabricate :notice | 4 | notice = Fabricate :notice |
5 | notice.problem | 5 | notice.problem |
6 | - notification_service = Fabricate :gtalk_notification_service, :app => notice.app | 6 | + notification_service = Fabricate :gtalk_notification_service, app: notice.app |
7 | problem = notice.problem | 7 | problem = notice.problem |
8 | 8 | ||
9 | #gtalk stubbing | 9 | #gtalk stubbing |
@@ -35,7 +35,7 @@ describe NotificationServices::GtalkService, type: 'model' do | @@ -35,7 +35,7 @@ describe NotificationServices::GtalkService, type: 'model' do | ||
35 | before(:each) do | 35 | before(:each) do |
36 | # setup | 36 | # setup |
37 | @notice = Fabricate :notice | 37 | @notice = Fabricate :notice |
38 | - @notification_service = Fabricate :gtalk_notification_service, :app => @notice.app | 38 | + @notification_service = Fabricate :gtalk_notification_service, app: @notice.app |
39 | @problem = @notice.problem | 39 | @problem = @notice.problem |
40 | @error_msg = """#{@problem.app.name} | 40 | @error_msg = """#{@problem.app.name} |
41 | #{Errbit::Config.protocol}://#{Errbit::Config.host}/apps/#{@problem.app.id} | 41 | #{Errbit::Config.protocol}://#{Errbit::Config.host}/apps/#{@problem.app.id} |
@@ -94,7 +94,7 @@ describe NotificationServices::GtalkService, type: 'model' do | @@ -94,7 +94,7 @@ describe NotificationServices::GtalkService, type: 'model' do | ||
94 | # setup | 94 | # setup |
95 | notice = Fabricate :notice | 95 | notice = Fabricate :notice |
96 | notice.problem | 96 | notice.problem |
97 | - notification_service = Fabricate :gtalk_notification_service, :app => notice.app | 97 | + notification_service = Fabricate :gtalk_notification_service, app: notice.app |
98 | problem = notice.problem | 98 | problem = notice.problem |
99 | 99 | ||
100 | #gtalk stubbing | 100 | #gtalk stubbing |
spec/models/notification_service/hoiio_service_spec.rb
@@ -2,7 +2,7 @@ describe NotificationServices::HoiioService, type: 'model' do | @@ -2,7 +2,7 @@ describe NotificationServices::HoiioService, type: 'model' do | ||
2 | it "it should send a notification to hoiio" do | 2 | it "it should send a notification to hoiio" do |
3 | # setup | 3 | # setup |
4 | notice = Fabricate :notice | 4 | notice = Fabricate :notice |
5 | - notification_service = Fabricate :hoiio_notification_service, :app => notice.app | 5 | + notification_service = Fabricate :hoiio_notification_service, app: notice.app |
6 | problem = notice.problem | 6 | problem = notice.problem |
7 | 7 | ||
8 | # hoi stubbing | 8 | # hoi stubbing |
spec/models/notification_service/hubot_service_spec.rb
@@ -2,11 +2,11 @@ describe NotificationServices::HubotService, type: 'model' do | @@ -2,11 +2,11 @@ describe NotificationServices::HubotService, type: 'model' do | ||
2 | it "it should send a notification to Hubot" do | 2 | it "it should send a notification to Hubot" do |
3 | # setup | 3 | # setup |
4 | notice = Fabricate :notice | 4 | notice = Fabricate :notice |
5 | - notification_service = Fabricate :hubot_notification_service, :app => notice.app | 5 | + notification_service = Fabricate :hubot_notification_service, app: notice.app |
6 | problem = notice.problem | 6 | problem = notice.problem |
7 | 7 | ||
8 | # faraday stubbing | 8 | # faraday stubbing |
9 | - expect(HTTParty).to receive(:post).with(notification_service.api_token, :body => { :message => an_instance_of(String), :room => notification_service.room_id }).and_return(true) | 9 | + expect(HTTParty).to receive(:post).with(notification_service.api_token, body: { message: an_instance_of(String), room: notification_service.room_id }).and_return(true) |
10 | 10 | ||
11 | notification_service.create_notification(problem) | 11 | notification_service.create_notification(problem) |
12 | end | 12 | end |
spec/models/notification_service/notification_service_spec.rb
1 | describe NotificationServices, type: 'model' do | 1 | describe NotificationServices, type: 'model' do |
2 | let(:notice) { Fabricate :notice } | 2 | let(:notice) { Fabricate :notice } |
3 | - let(:notification_service) { Fabricate :notification_service, :app => notice.app } | 3 | + let(:notification_service) { Fabricate :notification_service, app: notice.app } |
4 | let(:problem) { notice.problem } | 4 | let(:problem) { notice.problem } |
5 | 5 | ||
6 | it "it should use http by default in #problem_url" do | 6 | it "it should use http by default in #problem_url" do |
spec/models/notification_service/pushover_service_spec.rb
@@ -2,7 +2,7 @@ describe NotificationServices::PushoverService, type: 'model' do | @@ -2,7 +2,7 @@ describe NotificationServices::PushoverService, type: 'model' do | ||
2 | it "it should send a notification to Pushover" do | 2 | it "it should send a notification to Pushover" do |
3 | # setup | 3 | # setup |
4 | notice = Fabricate :notice | 4 | notice = Fabricate :notice |
5 | - notification_service = Fabricate :pushover_notification_service, :app => notice.app | 5 | + notification_service = Fabricate :pushover_notification_service, app: notice.app |
6 | problem = notice.problem | 6 | problem = notice.problem |
7 | 7 | ||
8 | # hoi stubbing | 8 | # hoi stubbing |
spec/models/notification_service/slack_service_spec.rb
@@ -2,52 +2,52 @@ describe NotificationServices::SlackService, type: 'model' do | @@ -2,52 +2,52 @@ describe NotificationServices::SlackService, type: 'model' do | ||
2 | it "it should send a notification to Slack with hook url" do | 2 | it "it should send a notification to Slack with hook url" do |
3 | # setup | 3 | # setup |
4 | notice = Fabricate :notice | 4 | notice = Fabricate :notice |
5 | - notification_service = Fabricate :slack_notification_service, :app => notice.app, :service_url => "https://hooks.slack.com/services/XXXXXXXXX/XXXXXXXXX/XXXXXXXXX" | 5 | + notification_service = Fabricate :slack_notification_service, app: notice.app, service_url: "https://hooks.slack.com/services/XXXXXXXXX/XXXXXXXXX/XXXXXXXXX" |
6 | problem = notice.problem | 6 | problem = notice.problem |
7 | 7 | ||
8 | # faraday stubbing | 8 | # faraday stubbing |
9 | payload = { | 9 | payload = { |
10 | - :attachments => [ | 10 | + attachments: [ |
11 | { | 11 | { |
12 | - :fallback => notification_service.message_for_slack(problem), | ||
13 | - :pretext => "<#{notification_service.problem_url(problem)}|Errbit - #{problem.app.name}: #{problem.error_class}>", | ||
14 | - :color => "#D00000", | ||
15 | - :fields => [ | 12 | + fallback: notification_service.message_for_slack(problem), |
13 | + pretext: "<#{notification_service.problem_url(problem)}|Errbit - #{problem.app.name}: #{problem.error_class}>", | ||
14 | + color: "#D00000", | ||
15 | + fields: [ | ||
16 | { | 16 | { |
17 | - :title => "Environment", | ||
18 | - :value => problem.environment, | ||
19 | - :short => false | 17 | + title: "Environment", |
18 | + value: problem.environment, | ||
19 | + short: false | ||
20 | }, | 20 | }, |
21 | { | 21 | { |
22 | - :title => "Location", | ||
23 | - :value => problem.where, | ||
24 | - :short => false | 22 | + title: "Location", |
23 | + value: problem.where, | ||
24 | + short: false | ||
25 | }, | 25 | }, |
26 | { | 26 | { |
27 | - :title => "Message", | ||
28 | - :value => problem.message.to_s, | ||
29 | - :short => false | 27 | + title: "Message", |
28 | + value: problem.message.to_s, | ||
29 | + short: false | ||
30 | }, | 30 | }, |
31 | { | 31 | { |
32 | - :title => "First Noticed", | ||
33 | - :value => problem.first_notice_at, | ||
34 | - :short => false | 32 | + title: "First Noticed", |
33 | + value: problem.first_notice_at, | ||
34 | + short: false | ||
35 | }, | 35 | }, |
36 | { | 36 | { |
37 | - :title => "Last Noticed", | ||
38 | - :value => problem.last_notice_at, | ||
39 | - :short => false | 37 | + title: "Last Noticed", |
38 | + value: problem.last_notice_at, | ||
39 | + short: false | ||
40 | }, | 40 | }, |
41 | { | 41 | { |
42 | - :title => "Times Occurred", | ||
43 | - :value => problem.notices_count, | ||
44 | - :short => false | 42 | + title: "Times Occurred", |
43 | + value: problem.notices_count, | ||
44 | + short: false | ||
45 | } | 45 | } |
46 | ] | 46 | ] |
47 | } | 47 | } |
48 | ] | 48 | ] |
49 | }.to_json | 49 | }.to_json |
50 | - expect(HTTParty).to receive(:post).with(notification_service.service_url, :body => payload, :headers => { "Content-Type" => "application/json" }).and_return(true) | 50 | + expect(HTTParty).to receive(:post).with(notification_service.service_url, body: payload, headers: { "Content-Type" => "application/json" }).and_return(true) |
51 | 51 | ||
52 | notification_service.create_notification(problem) | 52 | notification_service.create_notification(problem) |
53 | end | 53 | end |
spec/models/notification_service/webhook_service_spec.rb
1 | describe NotificationServices::WebhookService, type: 'model' do | 1 | describe NotificationServices::WebhookService, type: 'model' do |
2 | it "it should send a notification to a user-specified URL" do | 2 | it "it should send a notification to a user-specified URL" do |
3 | notice = Fabricate :notice | 3 | notice = Fabricate :notice |
4 | - notification_service = Fabricate :webhook_notification_service, :app => notice.app | 4 | + notification_service = Fabricate :webhook_notification_service, app: notice.app |
5 | problem = notice.problem | 5 | problem = notice.problem |
6 | 6 | ||
7 | payload = notification_service.message_for_webhook(problem) | 7 | payload = notification_service.message_for_webhook(problem) |
8 | - expect(HTTParty).to receive(:post).with(notification_service.api_token, :body => payload).and_return(true) | 8 | + expect(HTTParty).to receive(:post).with(notification_service.api_token, body: payload).and_return(true) |
9 | 9 | ||
10 | notification_service.create_notification(problem) | 10 | notification_service.create_notification(problem) |
11 | end | 11 | end |
spec/models/problem_spec.rb
1 | describe Problem, type: 'model' do | 1 | describe Problem, type: 'model' do |
2 | context 'validations' do | 2 | context 'validations' do |
3 | it 'requires an environment' do | 3 | it 'requires an environment' do |
4 | - err = Fabricate.build(:problem, :environment => nil) | 4 | + err = Fabricate.build(:problem, environment: nil) |
5 | expect(err).to_not be_valid | 5 | expect(err).to_not be_valid |
6 | expect(err.errors[:environment]).to include("can't be blank") | 6 | expect(err.errors[:environment]).to include("can't be blank") |
7 | end | 7 | end |
@@ -39,10 +39,10 @@ describe Problem, type: 'model' do | @@ -39,10 +39,10 @@ describe Problem, type: 'model' do | ||
39 | problem = err.problem | 39 | problem = err.problem |
40 | expect(problem).to_not be_nil | 40 | expect(problem).to_not be_nil |
41 | 41 | ||
42 | - notice1 = Fabricate(:notice, :err => err) | 42 | + notice1 = Fabricate(:notice, err: err) |
43 | expect(problem.last_notice_at).to eq notice1.reload.created_at | 43 | expect(problem.last_notice_at).to eq notice1.reload.created_at |
44 | 44 | ||
45 | - notice2 = Fabricate(:notice, :err => err) | 45 | + notice2 = Fabricate(:notice, err: err) |
46 | expect(problem.last_notice_at).to eq notice2.reload.created_at | 46 | expect(problem.last_notice_at).to eq notice2.reload.created_at |
47 | end | 47 | end |
48 | end | 48 | end |
@@ -53,10 +53,10 @@ describe Problem, type: 'model' do | @@ -53,10 +53,10 @@ describe Problem, type: 'model' do | ||
53 | problem = err.problem | 53 | problem = err.problem |
54 | expect(problem).to_not be_nil | 54 | expect(problem).to_not be_nil |
55 | 55 | ||
56 | - notice1 = Fabricate(:notice, :err => err) | 56 | + notice1 = Fabricate(:notice, err: err) |
57 | expect(problem.first_notice_at.to_i).to be_within(1).of(notice1.created_at.to_i) | 57 | expect(problem.first_notice_at.to_i).to be_within(1).of(notice1.created_at.to_i) |
58 | 58 | ||
59 | - Fabricate(:notice, :err => err) | 59 | + Fabricate(:notice, err: err) |
60 | expect(problem.first_notice_at.to_i).to be_within(1).of(notice1.created_at.to_i) | 60 | expect(problem.first_notice_at.to_i).to be_within(1).of(notice1.created_at.to_i) |
61 | end | 61 | end |
62 | end | 62 | end |
@@ -66,7 +66,7 @@ describe Problem, type: 'model' do | @@ -66,7 +66,7 @@ describe Problem, type: 'model' do | ||
66 | err = Fabricate(:err) | 66 | err = Fabricate(:err) |
67 | problem = err.problem | 67 | problem = err.problem |
68 | expect { | 68 | expect { |
69 | - Fabricate(:notice, :err => err, :message => 'ERR 1') | 69 | + Fabricate(:notice, err: err, message: 'ERR 1') |
70 | }.to change(problem, :message).from(nil).to('ERR 1') | 70 | }.to change(problem, :message).from(nil).to('ERR 1') |
71 | end | 71 | end |
72 | end | 72 | end |
@@ -74,9 +74,9 @@ describe Problem, type: 'model' do | @@ -74,9 +74,9 @@ describe Problem, type: 'model' do | ||
74 | context 'being created' do | 74 | context 'being created' do |
75 | context 'when the app has err notifications set to false' do | 75 | context 'when the app has err notifications set to false' do |
76 | it 'should not send an email notification' do | 76 | it 'should not send an email notification' do |
77 | - app = Fabricate(:app_with_watcher, :notify_on_errs => false) | 77 | + app = Fabricate(:app_with_watcher, notify_on_errs: false) |
78 | expect(Mailer).to_not receive(:err_notification) | 78 | expect(Mailer).to_not receive(:err_notification) |
79 | - Fabricate(:problem, :app => app) | 79 | + Fabricate(:problem, app: app) |
80 | end | 80 | end |
81 | end | 81 | end |
82 | end | 82 | end |
@@ -114,7 +114,7 @@ describe Problem, type: 'model' do | @@ -114,7 +114,7 @@ describe Problem, type: 'model' do | ||
114 | end | 114 | end |
115 | 115 | ||
116 | it "should not reset notice count" do | 116 | it "should not reset notice count" do |
117 | - problem = Fabricate(:problem, :notices_count => 1) | 117 | + problem = Fabricate(:problem, notices_count: 1) |
118 | original_notices_count = problem.notices_count | 118 | original_notices_count = problem.notices_count |
119 | expect(original_notices_count).to be > 0 | 119 | expect(original_notices_count).to be > 0 |
120 | 120 | ||
@@ -157,8 +157,8 @@ describe Problem, type: 'model' do | @@ -157,8 +157,8 @@ describe Problem, type: 'model' do | ||
157 | context "Scopes" do | 157 | context "Scopes" do |
158 | context "resolved" do | 158 | context "resolved" do |
159 | it 'only finds resolved Problems' do | 159 | it 'only finds resolved Problems' do |
160 | - resolved = Fabricate(:problem, :resolved => true) | ||
161 | - unresolved = Fabricate(:problem, :resolved => false) | 160 | + resolved = Fabricate(:problem, resolved: true) |
161 | + unresolved = Fabricate(:problem, resolved: false) | ||
162 | expect(Problem.resolved.all).to include(resolved) | 162 | expect(Problem.resolved.all).to include(resolved) |
163 | expect(Problem.resolved.all).to_not include(unresolved) | 163 | expect(Problem.resolved.all).to_not include(unresolved) |
164 | end | 164 | end |
@@ -166,8 +166,8 @@ describe Problem, type: 'model' do | @@ -166,8 +166,8 @@ describe Problem, type: 'model' do | ||
166 | 166 | ||
167 | context "unresolved" do | 167 | context "unresolved" do |
168 | it 'only finds unresolved Problems' do | 168 | it 'only finds unresolved Problems' do |
169 | - resolved = Fabricate(:problem, :resolved => true) | ||
170 | - unresolved = Fabricate(:problem, :resolved => false) | 169 | + resolved = Fabricate(:problem, resolved: true) |
170 | + unresolved = Fabricate(:problem, resolved: false) | ||
171 | expect(Problem.unresolved.all).to_not include(resolved) | 171 | expect(Problem.unresolved.all).to_not include(resolved) |
172 | expect(Problem.unresolved.all).to include(unresolved) | 172 | expect(Problem.unresolved.all).to include(unresolved) |
173 | end | 173 | end |
@@ -175,15 +175,15 @@ describe Problem, type: 'model' do | @@ -175,15 +175,15 @@ describe Problem, type: 'model' do | ||
175 | 175 | ||
176 | context "searching" do | 176 | context "searching" do |
177 | it 'finds the correct record' do | 177 | it 'finds the correct record' do |
178 | - find = Fabricate(:problem, :resolved => false, :error_class => 'theErrorclass::other', | ||
179 | - :message => "other", :where => 'errorclass', :environment => 'development', :app_name => 'other') | ||
180 | - dont_find = Fabricate(:problem, :resolved => false, :error_class => "Batman", | ||
181 | - :message => 'todo', :where => 'classerror', :environment => 'development', :app_name => 'other') | 178 | + find = Fabricate(:problem, resolved: false, error_class: 'theErrorclass::other', |
179 | + message: "other", where: 'errorclass', environment: 'development', app_name: 'other') | ||
180 | + dont_find = Fabricate(:problem, resolved: false, error_class: "Batman", | ||
181 | + message: 'todo', where: 'classerror', environment: 'development', app_name: 'other') | ||
182 | expect(Problem.search("theErrorClass").unresolved).to include(find) | 182 | expect(Problem.search("theErrorClass").unresolved).to include(find) |
183 | expect(Problem.search("theErrorClass").unresolved).to_not include(dont_find) | 183 | expect(Problem.search("theErrorClass").unresolved).to_not include(dont_find) |
184 | end | 184 | end |
185 | it 'find on where message' do | 185 | it 'find on where message' do |
186 | - problem = Fabricate(:problem, :where => 'cyril') | 186 | + problem = Fabricate(:problem, where: 'cyril') |
187 | expect(Problem.search('cyril').entries).to eq [problem] | 187 | expect(Problem.search('cyril').entries).to eq [problem] |
188 | end | 188 | end |
189 | end | 189 | end |
@@ -192,8 +192,8 @@ describe Problem, type: 'model' do | @@ -192,8 +192,8 @@ describe Problem, type: 'model' do | ||
192 | context "notice counter cache" do | 192 | context "notice counter cache" do |
193 | before do | 193 | before do |
194 | @app = Fabricate(:app) | 194 | @app = Fabricate(:app) |
195 | - @problem = Fabricate(:problem, :app => @app) | ||
196 | - @err = Fabricate(:err, :problem => @problem) | 195 | + @problem = Fabricate(:problem, app: @app) |
196 | + @err = Fabricate(:err, problem: @problem) | ||
197 | end | 197 | end |
198 | 198 | ||
199 | it "#notices_count returns 0 by default" do | 199 | it "#notices_count returns 0 by default" do |
@@ -202,12 +202,12 @@ describe Problem, type: 'model' do | @@ -202,12 +202,12 @@ describe Problem, type: 'model' do | ||
202 | 202 | ||
203 | it "adding a notice increases #notices_count by 1" do | 203 | it "adding a notice increases #notices_count by 1" do |
204 | expect { | 204 | expect { |
205 | - Fabricate(:notice, :err => @err, :message => 'ERR 1') | 205 | + Fabricate(:notice, err: @err, message: 'ERR 1') |
206 | }.to change(@problem.reload, :notices_count).from(0).to(1) | 206 | }.to change(@problem.reload, :notices_count).from(0).to(1) |
207 | end | 207 | end |
208 | 208 | ||
209 | it "removing a notice decreases #notices_count by 1" do | 209 | it "removing a notice decreases #notices_count by 1" do |
210 | - Fabricate(:notice, :err => @err, :message => 'ERR 1') | 210 | + Fabricate(:notice, err: @err, message: 'ERR 1') |
211 | expect { | 211 | expect { |
212 | @err.notices.first.destroy | 212 | @err.notices.first.destroy |
213 | @problem.reload | 213 | @problem.reload |
@@ -217,7 +217,7 @@ describe Problem, type: 'model' do | @@ -217,7 +217,7 @@ describe Problem, type: 'model' do | ||
217 | 217 | ||
218 | context "#app_name" do | 218 | context "#app_name" do |
219 | let!(:app) { Fabricate(:app) } | 219 | let!(:app) { Fabricate(:app) } |
220 | - let!(:problem) { Fabricate(:problem, :app => app) } | 220 | + let!(:problem) { Fabricate(:problem, app: app) } |
221 | 221 | ||
222 | before { app.reload } | 222 | before { app.reload } |
223 | 223 | ||
@@ -227,7 +227,7 @@ describe Problem, type: 'model' do | @@ -227,7 +227,7 @@ describe Problem, type: 'model' do | ||
227 | 227 | ||
228 | it "is updated when an app is updated" do | 228 | it "is updated when an app is updated" do |
229 | expect { | 229 | expect { |
230 | - app.update_attributes!(:name => "Bar App") | 230 | + app.update_attributes!(name: "Bar App") |
231 | problem.reload | 231 | problem.reload |
232 | }.to change(problem, :app_name).to("Bar App") | 232 | }.to change(problem, :app_name).to("Bar App") |
233 | end | 233 | end |
@@ -237,19 +237,19 @@ describe Problem, type: 'model' do | @@ -237,19 +237,19 @@ describe Problem, type: 'model' do | ||
237 | before do | 237 | before do |
238 | @app = Fabricate(:app) | 238 | @app = Fabricate(:app) |
239 | @last_deploy = 10.days.ago | 239 | @last_deploy = 10.days.ago |
240 | - Fabricate(:deploy, :app => @app, :created_at => @last_deploy, :environment => "production") | 240 | + Fabricate(:deploy, app: @app, created_at: @last_deploy, environment: "production") |
241 | end | 241 | end |
242 | 242 | ||
243 | it "is set when a problem is created" do | 243 | it "is set when a problem is created" do |
244 | - problem = Fabricate(:problem, :app => @app, :environment => "production") | 244 | + problem = Fabricate(:problem, app: @app, environment: "production") |
245 | assert_equal @last_deploy, problem.last_deploy_at | 245 | assert_equal @last_deploy, problem.last_deploy_at |
246 | end | 246 | end |
247 | 247 | ||
248 | it "is updated when a deploy is created" do | 248 | it "is updated when a deploy is created" do |
249 | - problem = Fabricate(:problem, :app => @app, :environment => "production") | 249 | + problem = Fabricate(:problem, app: @app, environment: "production") |
250 | next_deploy = 5.minutes.ago | 250 | next_deploy = 5.minutes.ago |
251 | expect { | 251 | expect { |
252 | - @deploy = Fabricate(:deploy, :app => @app, :created_at => next_deploy) | 252 | + @deploy = Fabricate(:deploy, app: @app, created_at: next_deploy) |
253 | problem.reload | 253 | problem.reload |
254 | }.to change { problem.last_deploy_at.iso8601 }. | 254 | }.to change { problem.last_deploy_at.iso8601 }. |
255 | from(@last_deploy.iso8601). | 255 | from(@last_deploy.iso8601). |
@@ -260,8 +260,8 @@ describe Problem, type: 'model' do | @@ -260,8 +260,8 @@ describe Problem, type: 'model' do | ||
260 | context "notice messages cache" do | 260 | context "notice messages cache" do |
261 | before do | 261 | before do |
262 | @app = Fabricate(:app) | 262 | @app = Fabricate(:app) |
263 | - @problem = Fabricate(:problem, :app => @app) | ||
264 | - @err = Fabricate(:err, :problem => @problem) | 263 | + @problem = Fabricate(:problem, app: @app) |
264 | + @err = Fabricate(:err, problem: @problem) | ||
265 | end | 265 | end |
266 | 266 | ||
267 | it "#messages should be empty by default" do | 267 | it "#messages should be empty by default" do |
@@ -269,7 +269,7 @@ describe Problem, type: 'model' do | @@ -269,7 +269,7 @@ describe Problem, type: 'model' do | ||
269 | end | 269 | end |
270 | 270 | ||
271 | it "removing a notice removes string from #messages" do | 271 | it "removing a notice removes string from #messages" do |
272 | - Fabricate(:notice, :err => @err, :message => 'ERR 1') | 272 | + Fabricate(:notice, err: @err, message: 'ERR 1') |
273 | expect { | 273 | expect { |
274 | @err.notices.first.destroy | 274 | @err.notices.first.destroy |
275 | @problem.reload | 275 | @problem.reload |
@@ -277,7 +277,7 @@ describe Problem, type: 'model' do | @@ -277,7 +277,7 @@ describe Problem, type: 'model' do | ||
277 | end | 277 | end |
278 | 278 | ||
279 | it "removing a notice from the problem with broken counter should not raise an error" do | 279 | it "removing a notice from the problem with broken counter should not raise an error" do |
280 | - Fabricate(:notice, :err => @err, :message => 'ERR 1') | 280 | + Fabricate(:notice, err: @err, message: 'ERR 1') |
281 | @problem.messages = {} | 281 | @problem.messages = {} |
282 | @problem.save! | 282 | @problem.save! |
283 | expect { @err.notices.first.destroy }.not_to raise_error | 283 | expect { @err.notices.first.destroy }.not_to raise_error |
@@ -287,8 +287,8 @@ describe Problem, type: 'model' do | @@ -287,8 +287,8 @@ describe Problem, type: 'model' do | ||
287 | context "notice hosts cache" do | 287 | context "notice hosts cache" do |
288 | before do | 288 | before do |
289 | @app = Fabricate(:app) | 289 | @app = Fabricate(:app) |
290 | - @problem = Fabricate(:problem, :app => @app) | ||
291 | - @err = Fabricate(:err, :problem => @problem) | 290 | + @problem = Fabricate(:problem, app: @app) |
291 | + @err = Fabricate(:err, problem: @problem) | ||
292 | end | 292 | end |
293 | 293 | ||
294 | it "#hosts should be empty by default" do | 294 | it "#hosts should be empty by default" do |
@@ -296,7 +296,7 @@ describe Problem, type: 'model' do | @@ -296,7 +296,7 @@ describe Problem, type: 'model' do | ||
296 | end | 296 | end |
297 | 297 | ||
298 | it "removing a notice removes string from #hosts" do | 298 | it "removing a notice removes string from #hosts" do |
299 | - Fabricate(:notice, :err => @err, :request => { 'url' => "http://example.com/resource/12" }) | 299 | + Fabricate(:notice, err: @err, request: { 'url' => "http://example.com/resource/12" }) |
300 | expect { | 300 | expect { |
301 | @err.notices.first.destroy | 301 | @err.notices.first.destroy |
302 | @problem.reload | 302 | @problem.reload |
@@ -307,8 +307,8 @@ describe Problem, type: 'model' do | @@ -307,8 +307,8 @@ describe Problem, type: 'model' do | ||
307 | context "notice user_agents cache" do | 307 | context "notice user_agents cache" do |
308 | before do | 308 | before do |
309 | @app = Fabricate(:app) | 309 | @app = Fabricate(:app) |
310 | - @problem = Fabricate(:problem, :app => @app) | ||
311 | - @err = Fabricate(:err, :problem => @problem) | 310 | + @problem = Fabricate(:problem, app: @app) |
311 | + @err = Fabricate(:err, problem: @problem) | ||
312 | end | 312 | end |
313 | 313 | ||
314 | it "#user_agents should be empty by default" do | 314 | it "#user_agents should be empty by default" do |
@@ -316,7 +316,7 @@ describe Problem, type: 'model' do | @@ -316,7 +316,7 @@ describe Problem, type: 'model' do | ||
316 | end | 316 | end |
317 | 317 | ||
318 | it "removing a notice removes string from #user_agents" do | 318 | it "removing a notice removes string from #user_agents" do |
319 | - Fabricate(:notice, :err => @err, :request => { 'cgi-data' => { 'HTTP_USER_AGENT' => 'Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_7; en-US) AppleWebKit/534.16 (KHTML, like Gecko) Chrome/10.0.648.204 Safari/534.16' } }) | 319 | + Fabricate(:notice, err: @err, request: { 'cgi-data' => { 'HTTP_USER_AGENT' => 'Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_7; en-US) AppleWebKit/534.16 (KHTML, like Gecko) Chrome/10.0.648.204 Safari/534.16' } }) |
320 | expect { | 320 | expect { |
321 | @err.notices.first.destroy | 321 | @err.notices.first.destroy |
322 | @problem.reload | 322 | @problem.reload |
@@ -329,7 +329,7 @@ describe Problem, type: 'model' do | @@ -329,7 +329,7 @@ describe Problem, type: 'model' do | ||
329 | context "comment counter cache" do | 329 | context "comment counter cache" do |
330 | before do | 330 | before do |
331 | @app = Fabricate(:app) | 331 | @app = Fabricate(:app) |
332 | - @problem = Fabricate(:problem, :app => @app) | 332 | + @problem = Fabricate(:problem, app: @app) |
333 | end | 333 | end |
334 | 334 | ||
335 | it "#comments_count returns 0 by default" do | 335 | it "#comments_count returns 0 by default" do |
@@ -338,12 +338,12 @@ describe Problem, type: 'model' do | @@ -338,12 +338,12 @@ describe Problem, type: 'model' do | ||
338 | 338 | ||
339 | it "adding a comment increases #comments_count by 1" do | 339 | it "adding a comment increases #comments_count by 1" do |
340 | expect { | 340 | expect { |
341 | - Fabricate(:comment, :err => @problem) | 341 | + Fabricate(:comment, err: @problem) |
342 | }.to change(@problem, :comments_count).from(0).to(1) | 342 | }.to change(@problem, :comments_count).from(0).to(1) |
343 | end | 343 | end |
344 | 344 | ||
345 | it "removing a comment decreases #comments_count by 1" do | 345 | it "removing a comment decreases #comments_count by 1" do |
346 | - Fabricate(:comment, :err => @problem) | 346 | + Fabricate(:comment, err: @problem) |
347 | expect { | 347 | expect { |
348 | @problem.reload.comments.first.destroy | 348 | @problem.reload.comments.first.destroy |
349 | @problem.reload | 349 | @problem.reload |
@@ -354,11 +354,11 @@ describe Problem, type: 'model' do | @@ -354,11 +354,11 @@ describe Problem, type: 'model' do | ||
354 | describe "#issue_type" do | 354 | describe "#issue_type" do |
355 | context "without issue_type fill in Problem" do | 355 | context "without issue_type fill in Problem" do |
356 | let(:problem) do | 356 | let(:problem) do |
357 | - Problem.new(:app => app) | 357 | + Problem.new(app: app) |
358 | end | 358 | end |
359 | 359 | ||
360 | let(:app) do | 360 | let(:app) do |
361 | - App.new(:issue_tracker => issue_tracker) | 361 | + App.new(issue_tracker: issue_tracker) |
362 | end | 362 | end |
363 | 363 | ||
364 | context "without issue_tracker associate to app" do | 364 | context "without issue_tracker associate to app" do |
@@ -384,7 +384,7 @@ describe Problem, type: 'model' do | @@ -384,7 +384,7 @@ describe Problem, type: 'model' do | ||
384 | 384 | ||
385 | context "with issue_tracker not valid associate to app" do | 385 | context "with issue_tracker not valid associate to app" do |
386 | let(:issue_tracker) do | 386 | let(:issue_tracker) do |
387 | - IssueTracker.new(:type_tracker => 'fake') | 387 | + IssueTracker.new(type_tracker: 'fake') |
388 | end | 388 | end |
389 | 389 | ||
390 | it 'return nil' do | 390 | it 'return nil' do |
@@ -395,7 +395,7 @@ describe Problem, type: 'model' do | @@ -395,7 +395,7 @@ describe Problem, type: 'model' do | ||
395 | 395 | ||
396 | context "with issue_type fill in Problem" do | 396 | context "with issue_type fill in Problem" do |
397 | it 'return the value associate' do | 397 | it 'return the value associate' do |
398 | - expect(Problem.new(:issue_type => 'foo').issue_type).to eql 'foo' | 398 | + expect(Problem.new(issue_type: 'foo').issue_type).to eql 'foo' |
399 | end | 399 | end |
400 | end | 400 | end |
401 | end | 401 | end |
@@ -403,7 +403,7 @@ describe Problem, type: 'model' do | @@ -403,7 +403,7 @@ describe Problem, type: 'model' do | ||
403 | describe '#recache' do | 403 | describe '#recache' do |
404 | let(:problem) { Fabricate(:problem_with_errs) } | 404 | let(:problem) { Fabricate(:problem_with_errs) } |
405 | let(:first_errs) { problem.errs } | 405 | let(:first_errs) { problem.errs } |
406 | - let!(:notice) { Fabricate(:notice, :err => first_errs.first) } | 406 | + let!(:notice) { Fabricate(:notice, err: first_errs.first) } |
407 | 407 | ||
408 | before do | 408 | before do |
409 | problem.update_attribute(:notices_count, 0) | 409 | problem.update_attribute(:notices_count, 0) |
@@ -419,7 +419,7 @@ describe Problem, type: 'model' do | @@ -419,7 +419,7 @@ describe Problem, type: 'model' do | ||
419 | 419 | ||
420 | context "with only one notice" do | 420 | context "with only one notice" do |
421 | before do | 421 | before do |
422 | - problem.update_attributes!(:messages => {}) | 422 | + problem.update_attributes!(messages: {}) |
423 | problem.recache | 423 | problem.recache |
424 | end | 424 | end |
425 | 425 | ||
@@ -456,10 +456,10 @@ describe Problem, type: 'model' do | @@ -456,10 +456,10 @@ describe Problem, type: 'model' do | ||
456 | end | 456 | end |
457 | 457 | ||
458 | context "with several notices" do | 458 | context "with several notices" do |
459 | - let!(:notice_2) { Fabricate(:notice, :err => first_errs.first) } | ||
460 | - let!(:notice_3) { Fabricate(:notice, :err => first_errs.first) } | 459 | + let!(:notice_2) { Fabricate(:notice, err: first_errs.first) } |
460 | + let!(:notice_3) { Fabricate(:notice, err: first_errs.first) } | ||
461 | before do | 461 | before do |
462 | - problem.update_attributes!(:messages => {}) | 462 | + problem.update_attributes!(messages: {}) |
463 | problem.recache | 463 | problem.recache |
464 | end | 464 | end |
465 | 465 |
spec/models/user_spec.rb
1 | describe User do | 1 | describe User do |
2 | context 'validations' do | 2 | context 'validations' do |
3 | it 'require that a name is present' do | 3 | it 'require that a name is present' do |
4 | - user = Fabricate.build(:user, :name => nil) | 4 | + user = Fabricate.build(:user, name: nil) |
5 | expect(user).to_not be_valid | 5 | expect(user).to_not be_valid |
6 | expect(user.errors[:name]).to include("can't be blank") | 6 | expect(user.errors[:name]).to include("can't be blank") |
7 | end | 7 | end |
8 | 8 | ||
9 | it 'requires password without github login' do | 9 | it 'requires password without github login' do |
10 | - user = Fabricate.build(:user, :password => nil) | 10 | + user = Fabricate.build(:user, password: nil) |
11 | expect(user).to_not be_valid | 11 | expect(user).to_not be_valid |
12 | expect(user.errors[:password]).to include("can't be blank") | 12 | expect(user.errors[:password]).to include("can't be blank") |
13 | end | 13 | end |
14 | 14 | ||
15 | it "doesn't require password with github login" do | 15 | it "doesn't require password with github login" do |
16 | - user = Fabricate.build(:user, :password => nil, :github_login => 'nashby') | 16 | + user = Fabricate.build(:user, password: nil, github_login: 'nashby') |
17 | expect(user).to be_valid | 17 | expect(user).to be_valid |
18 | end | 18 | end |
19 | 19 | ||
20 | it 'requires uniq github login' do | 20 | it 'requires uniq github login' do |
21 | - user1 = Fabricate(:user, :github_login => 'nashby') | 21 | + user1 = Fabricate(:user, github_login: 'nashby') |
22 | expect(user1).to be_valid | 22 | expect(user1).to be_valid |
23 | 23 | ||
24 | - user2 = Fabricate.build(:user, :github_login => 'nashby') | 24 | + user2 = Fabricate.build(:user, github_login: 'nashby') |
25 | user2.save | 25 | user2.save |
26 | expect(user2).to_not be_valid | 26 | expect(user2).to_not be_valid |
27 | expect(user2.errors[:github_login]).to include("is already taken") | 27 | expect(user2.errors[:github_login]).to include("is already taken") |
28 | end | 28 | end |
29 | 29 | ||
30 | it 'allows blank / null github_login' do | 30 | it 'allows blank / null github_login' do |
31 | - user1 = Fabricate(:user, :github_login => ' ') | 31 | + user1 = Fabricate(:user, github_login: ' ') |
32 | expect(user1).to be_valid | 32 | expect(user1).to be_valid |
33 | 33 | ||
34 | - user2 = Fabricate.build(:user, :github_login => ' ') | 34 | + user2 = Fabricate.build(:user, github_login: ' ') |
35 | user2.save | 35 | user2.save |
36 | expect(user2).to be_valid | 36 | expect(user2).to be_valid |
37 | end | 37 | end |
@@ -43,7 +43,7 @@ describe User do | @@ -43,7 +43,7 @@ describe User do | ||
43 | allow($stdout).to receive(:puts).and_return(true) | 43 | allow($stdout).to receive(:puts).and_return(true) |
44 | require Rails.root.join('db/seeds.rb') | 44 | require Rails.root.join('db/seeds.rb') |
45 | }.to change { | 45 | }.to change { |
46 | - User.where(:admin => true).count | 46 | + User.where(admin: true).count |
47 | }.from(0).to(1) | 47 | }.from(0).to(1) |
48 | end | 48 | end |
49 | end | 49 | end |
spec/models/watcher_spec.rb
1 | describe Watcher, type: 'model' do | 1 | describe Watcher, type: 'model' do |
2 | context 'validations' do | 2 | context 'validations' do |
3 | it 'requires an email address or an associated user' do | 3 | it 'requires an email address or an associated user' do |
4 | - watcher = Fabricate.build(:watcher, :email => nil, :user => nil) | 4 | + watcher = Fabricate.build(:watcher, email: nil, user: nil) |
5 | expect(watcher).to_not be_valid | 5 | expect(watcher).to_not be_valid |
6 | expect(watcher.errors[:base]).to include("You must specify either a user or an email address") | 6 | expect(watcher.errors[:base]).to include("You must specify either a user or an email address") |
7 | 7 | ||
@@ -19,13 +19,13 @@ describe Watcher, type: 'model' do | @@ -19,13 +19,13 @@ describe Watcher, type: 'model' do | ||
19 | 19 | ||
20 | context 'address' do | 20 | context 'address' do |
21 | it "returns the user's email address if there is a user" do | 21 | it "returns the user's email address if there is a user" do |
22 | - user = Fabricate(:user, :email => 'foo@bar.com') | ||
23 | - watcher = Fabricate(:user_watcher, :user => user) | 22 | + user = Fabricate(:user, email: 'foo@bar.com') |
23 | + watcher = Fabricate(:user_watcher, user: user) | ||
24 | expect(watcher.address).to eq 'foo@bar.com' | 24 | expect(watcher.address).to eq 'foo@bar.com' |
25 | end | 25 | end |
26 | 26 | ||
27 | it "returns the email if there is no user" do | 27 | it "returns the email if there is no user" do |
28 | - watcher = Fabricate(:watcher, :email => 'widgets@acme.com') | 28 | + watcher = Fabricate(:watcher, email: 'widgets@acme.com') |
29 | expect(watcher.address).to eq 'widgets@acme.com' | 29 | expect(watcher.address).to eq 'widgets@acme.com' |
30 | end | 30 | end |
31 | end | 31 | end |
spec/requests/notices_controller_spec.rb
1 | describe "Notices management", type: 'request' do | 1 | describe "Notices management", type: 'request' do |
2 | - let(:errbit_app) { Fabricate(:app, :api_key => 'APIKEY') } | 2 | + let(:errbit_app) { Fabricate(:app, api_key: 'APIKEY') } |
3 | 3 | ||
4 | describe "create a new notice" do | 4 | describe "create a new notice" do |
5 | context "with valide notice" do | 5 | context "with valide notice" do |
6 | let(:xml) { Rails.root.join('spec', 'fixtures', 'hoptoad_test_notice.xml').read } | 6 | let(:xml) { Rails.root.join('spec', 'fixtures', 'hoptoad_test_notice.xml').read } |
7 | it 'save a new notice' do | 7 | it 'save a new notice' do |
8 | expect { | 8 | expect { |
9 | - post '/notifier_api/v2/notices', :data => xml | 9 | + post '/notifier_api/v2/notices', data: xml |
10 | expect(response).to be_success | 10 | expect(response).to be_success |
11 | }.to change { | 11 | }.to change { |
12 | errbit_app.problems.count | 12 | errbit_app.problems.count |
@@ -18,7 +18,7 @@ describe "Notices management", type: 'request' do | @@ -18,7 +18,7 @@ describe "Notices management", type: 'request' do | ||
18 | let(:xml) { Rails.root.join('spec', 'fixtures', 'hoptoad_test_notice_without_line_of_backtrace.xml').read } | 18 | let(:xml) { Rails.root.join('spec', 'fixtures', 'hoptoad_test_notice_without_line_of_backtrace.xml').read } |
19 | it 'save a new notice' do | 19 | it 'save a new notice' do |
20 | expect { | 20 | expect { |
21 | - post '/notifier_api/v2/notices', :data => xml | 21 | + post '/notifier_api/v2/notices', data: xml |
22 | expect(response).to be_success | 22 | expect(response).to be_success |
23 | }.to change { | 23 | }.to change { |
24 | errbit_app.problems.count | 24 | errbit_app.problems.count |
@@ -31,7 +31,7 @@ describe "Notices management", type: 'request' do | @@ -31,7 +31,7 @@ describe "Notices management", type: 'request' do | ||
31 | let(:xml) { Rails.root.join('spec', 'fixtures', 'hoptoad_test_notice.xml').read } | 31 | let(:xml) { Rails.root.join('spec', 'fixtures', 'hoptoad_test_notice.xml').read } |
32 | it 'not save a new notice and return 422' do | 32 | it 'not save a new notice and return 422' do |
33 | expect { | 33 | expect { |
34 | - post '/notifier_api/v2/notices', :data => xml | 34 | + post '/notifier_api/v2/notices', data: xml |
35 | expect(response.status).to eq 422 | 35 | expect(response.status).to eq 422 |
36 | expect(response.body).to eq "Your API key is unknown" | 36 | expect(response.body).to eq "Your API key is unknown" |
37 | }.to_not change(errbit_app.problems, :count) | 37 | }.to_not change(errbit_app.problems, :count) |
@@ -42,7 +42,7 @@ describe "Notices management", type: 'request' do | @@ -42,7 +42,7 @@ describe "Notices management", type: 'request' do | ||
42 | let(:xml) { Rails.root.join('spec', 'fixtures', 'hoptoad_test_notice.xml').read } | 42 | let(:xml) { Rails.root.join('spec', 'fixtures', 'hoptoad_test_notice.xml').read } |
43 | it 'save a new notice' do | 43 | it 'save a new notice' do |
44 | expect { | 44 | expect { |
45 | - get '/notifier_api/v2/notices', :data => xml | 45 | + get '/notifier_api/v2/notices', data: xml |
46 | expect(response).to be_success | 46 | expect(response).to be_success |
47 | }.to change { | 47 | }.to change { |
48 | errbit_app.problems.count | 48 | errbit_app.problems.count |
spec/spec_helper.rb
@@ -36,9 +36,9 @@ Mongoid::Tasks::Database.create_indexes | @@ -36,9 +36,9 @@ Mongoid::Tasks::Database.create_indexes | ||
36 | ActionMailer::Base.delivery_method = :test | 36 | ActionMailer::Base.delivery_method = :test |
37 | 37 | ||
38 | RSpec.configure do |config| | 38 | RSpec.configure do |config| |
39 | - config.include Devise::TestHelpers, :type => :controller | ||
40 | - config.include Mongoid::Matchers, :type => :model | ||
41 | - config.alias_example_to :fit, :focused => true | 39 | + config.include Devise::TestHelpers, type: :controller |
40 | + config.include Mongoid::Matchers, type: :model | ||
41 | + config.alias_example_to :fit, focused: true | ||
42 | 42 | ||
43 | config.before(:each) do | 43 | config.before(:each) do |
44 | Mongoid::Config.truncate! | 44 | Mongoid::Config.truncate! |
spec/support/macros.rb
1 | def it_requires_authentication(options = {}) | 1 | def it_requires_authentication(options = {}) |
2 | default_options = { | 2 | default_options = { |
3 | - :for => { | ||
4 | - :index => :get, | ||
5 | - :show => :get, | ||
6 | - :new => :get, | ||
7 | - :create => :post, | ||
8 | - :edit => :get, | ||
9 | - :update => :put, | ||
10 | - :destroy => :delete | 3 | + for: { |
4 | + index: :get, | ||
5 | + show: :get, | ||
6 | + new: :get, | ||
7 | + create: :post, | ||
8 | + edit: :get, | ||
9 | + update: :put, | ||
10 | + destroy: :delete | ||
11 | }, | 11 | }, |
12 | - :params => { :id => '4c6c760494df2a18cc000015' } | 12 | + params: { id: '4c6c760494df2a18cc000015' } |
13 | } | 13 | } |
14 | options.reverse_merge!(default_options) | 14 | options.reverse_merge!(default_options) |
15 | 15 | ||
@@ -29,16 +29,16 @@ end | @@ -29,16 +29,16 @@ end | ||
29 | 29 | ||
30 | def it_requires_admin_privileges(options = {}) | 30 | def it_requires_admin_privileges(options = {}) |
31 | default_options = { | 31 | default_options = { |
32 | - :for => { | ||
33 | - :index => :get, | ||
34 | - :show => :get, | ||
35 | - :new => :get, | ||
36 | - :create => :post, | ||
37 | - :edit => :get, | ||
38 | - :update => :put, | ||
39 | - :destroy => :delete | 32 | + for: { |
33 | + index: :get, | ||
34 | + show: :get, | ||
35 | + new: :get, | ||
36 | + create: :post, | ||
37 | + edit: :get, | ||
38 | + update: :put, | ||
39 | + destroy: :delete | ||
40 | }, | 40 | }, |
41 | - :params => { :id => 'dummyid' } | 41 | + params: { id: 'dummyid' } |
42 | } | 42 | } |
43 | options.reverse_merge!(default_options) | 43 | options.reverse_merge!(default_options) |
44 | 44 |
spec/views/apps/index.html.haml_spec.rb
1 | describe "apps/index.html.haml", type: 'view' do | 1 | describe "apps/index.html.haml", type: 'view' do |
2 | before do | 2 | before do |
3 | - app = stub_model(App, :deploys => [stub_model(Deploy, :created_at => Time.zone.now, :revision => "123456789abcdef")]) | 3 | + app = stub_model(App, deploys: [stub_model(Deploy, created_at: Time.zone.now, revision: "123456789abcdef")]) |
4 | allow(view).to receive(:apps).and_return([app]) | 4 | allow(view).to receive(:apps).and_return([app]) |
5 | allow(controller).to receive(:current_user).and_return(stub_model(User)) | 5 | allow(controller).to receive(:current_user).and_return(stub_model(User)) |
6 | end | 6 | end |
spec/views/apps/new.html.haml_spec.rb
@@ -16,7 +16,7 @@ describe "apps/new.html.haml", type: 'view' do | @@ -16,7 +16,7 @@ describe "apps/new.html.haml", type: 'view' do | ||
16 | it "should confirm the 'cancel' link" do | 16 | it "should confirm the 'cancel' link" do |
17 | render | 17 | render |
18 | 18 | ||
19 | - expect(action_bar).to have_selector('a.button', :text => 'cancel') | 19 | + expect(action_bar).to have_selector('a.button', text: 'cancel') |
20 | end | 20 | end |
21 | end | 21 | end |
22 | 22 |
spec/views/apps/show.atom.builder_spec.rb
1 | describe "apps/show.atom.builder", type: 'view' do | 1 | describe "apps/show.atom.builder", type: 'view' do |
2 | let(:app) { stub_model(App) } | 2 | let(:app) { stub_model(App) } |
3 | - let(:problems) { [stub_model(Problem, :message => 'foo', :app => app)] } | 3 | + let(:problems) { [stub_model(Problem, message: 'foo', app: app)] } |
4 | 4 | ||
5 | before do | 5 | before do |
6 | allow(view).to receive(:app).and_return(app) | 6 | allow(view).to receive(:app).and_return(app) |
spec/views/apps/show.html.haml_spec.rb
@@ -17,7 +17,7 @@ describe "apps/show.html.haml", type: 'view' do | @@ -17,7 +17,7 @@ describe "apps/show.html.haml", type: 'view' do | ||
17 | it "should confirm the 'cancel' link" do | 17 | it "should confirm the 'cancel' link" do |
18 | render | 18 | render |
19 | 19 | ||
20 | - expect(action_bar).to have_selector('a.button', :text => 'all errors') | 20 | + expect(action_bar).to have_selector('a.button', text: 'all errors') |
21 | end | 21 | end |
22 | end | 22 | end |
23 | 23 |
spec/views/issue_trackers/issue.md.erb_spec.rb
1 | describe "issue_trackers/issue.md.erb", type: 'view' do | 1 | describe "issue_trackers/issue.md.erb", type: 'view' do |
2 | let(:problem) { | 2 | let(:problem) { |
3 | problem = Fabricate(:problem) | 3 | problem = Fabricate(:problem) |
4 | - Fabricate(:notice, :err => Fabricate(:err, :problem => problem)) | 4 | + Fabricate(:notice, err: Fabricate(:err, problem: problem)) |
5 | problem | 5 | problem |
6 | } | 6 | } |
7 | 7 |
spec/views/issue_trackers/issue.txt.erb_spec.rb
1 | describe "issue_trackers/issue.txt.erb", type: 'view' do | 1 | describe "issue_trackers/issue.txt.erb", type: 'view' do |
2 | let(:problem) { | 2 | let(:problem) { |
3 | problem = Fabricate(:problem) | 3 | problem = Fabricate(:problem) |
4 | - Fabricate(:notice, :err => Fabricate(:err, :problem => problem)) | 4 | + Fabricate(:notice, err: Fabricate(:err, problem: problem)) |
5 | problem | 5 | problem |
6 | } | 6 | } |
7 | 7 |
spec/views/notices/_summary.html.haml_spec.rb
1 | describe "notices/_summary.html.haml", type: 'view' do | 1 | describe "notices/_summary.html.haml", type: 'view' do |
2 | - let(:notice) { Fabricate(:notice, :framework => 'Rails 3.2.11') } | 2 | + let(:notice) { Fabricate(:notice, framework: 'Rails 3.2.11') } |
3 | 3 | ||
4 | it "renders application framework" do | 4 | it "renders application framework" do |
5 | - render "notices/summary", :notice => notice, :problem => notice.problem | 5 | + render "notices/summary", notice: notice, problem: notice.problem |
6 | 6 | ||
7 | expect(rendered).to have_content('Rails 3.2.11') | 7 | expect(rendered).to have_content('Rails 3.2.11') |
8 | end | 8 | end |
spec/views/notices/_user_attributes.html.haml_spec.rb
@@ -2,13 +2,13 @@ describe "notices/_user_attributes.html.haml", type: 'view' do | @@ -2,13 +2,13 @@ describe "notices/_user_attributes.html.haml", type: 'view' do | ||
2 | describe 'autolink' do | 2 | describe 'autolink' do |
3 | let(:notice) do | 3 | let(:notice) do |
4 | user_attributes = { 'foo' => { 'bar' => 'http://example.com' } } | 4 | user_attributes = { 'foo' => { 'bar' => 'http://example.com' } } |
5 | - Fabricate(:notice, :user_attributes => user_attributes) | 5 | + Fabricate(:notice, user_attributes: user_attributes) |
6 | end | 6 | end |
7 | 7 | ||
8 | it "renders table with user attributes" do | 8 | it "renders table with user attributes" do |
9 | assign :app, notice.err.app | 9 | assign :app, notice.err.app |
10 | 10 | ||
11 | - render "notices/user_attributes", :user => notice.user_attributes | 11 | + render "notices/user_attributes", user: notice.user_attributes |
12 | expect(rendered).to have_link('http://example.com') | 12 | expect(rendered).to have_link('http://example.com') |
13 | end | 13 | end |
14 | end | 14 | end |
spec/views/problems/index.atom.builder_spec.rb
1 | describe "problems/index.atom.builder", type: 'view' do | 1 | describe "problems/index.atom.builder", type: 'view' do |
2 | it 'display problem message' do | 2 | it 'display problem message' do |
3 | - app = App.new(:new_record => false) | 3 | + app = App.new(new_record: false) |
4 | allow(view).to receive(:problems).and_return([Problem.new( | 4 | allow(view).to receive(:problems).and_return([Problem.new( |
5 | - :message => 'foo', | ||
6 | - :new_record => false, :app => app), Problem.new(:new_record => false, :app => app)]) | 5 | + message: 'foo', |
6 | + new_record: false, app: app), Problem.new(new_record: false, app: app)]) | ||
7 | render | 7 | render |
8 | expect(rendered).to match('foo') | 8 | expect(rendered).to match('foo') |
9 | end | 9 | end |
spec/views/problems/index.html.haml_spec.rb
1 | describe "problems/index.html.haml", type: 'view' do | 1 | describe "problems/index.html.haml", type: 'view' do |
2 | let(:problem_1) { Fabricate(:problem) } | 2 | let(:problem_1) { Fabricate(:problem) } |
3 | - let(:problem_2) { Fabricate(:problem, :app => problem_1.app) } | 3 | + let(:problem_2) { Fabricate(:problem, app: problem_1.app) } |
4 | 4 | ||
5 | before do | 5 | before do |
6 | allow(view).to receive(:selected_problems).and_return([]) | 6 | allow(view).to receive(:selected_problems).and_return([]) |
spec/views/problems/show.html.haml_spec.rb
@@ -53,9 +53,9 @@ describe "problems/show.html.haml", type: 'view' do | @@ -53,9 +53,9 @@ describe "problems/show.html.haml", type: 'view' do | ||
53 | def with_issue_tracker(tracker, _problem) | 53 | def with_issue_tracker(tracker, _problem) |
54 | allow(ErrbitPlugin::Registry).to receive(:issue_trackers).and_return(trackers) | 54 | allow(ErrbitPlugin::Registry).to receive(:issue_trackers).and_return(trackers) |
55 | app.issue_tracker = IssueTrackerDecorator.new( | 55 | app.issue_tracker = IssueTrackerDecorator.new( |
56 | - IssueTracker.new :type_tracker => tracker, :options => { | ||
57 | - :api_token => "token token token", | ||
58 | - :project_id => "1234" | 56 | + IssueTracker.new type_tracker: tracker, options: { |
57 | + api_token: "token token token", | ||
58 | + project_id: "1234" | ||
59 | }) | 59 | }) |
60 | end | 60 | end |
61 | 61 | ||
@@ -85,7 +85,7 @@ describe "problems/show.html.haml", type: 'view' do | @@ -85,7 +85,7 @@ describe "problems/show.html.haml", type: 'view' do | ||
85 | url = 'http://localhost:3000/problems' | 85 | url = 'http://localhost:3000/problems' |
86 | controller.request.env['HTTP_REFERER'] = url | 86 | controller.request.env['HTTP_REFERER'] = url |
87 | render | 87 | render |
88 | - expect(action_bar).to have_selector("span a.up[href='#{url}']", :text => 'up') | 88 | + expect(action_bar).to have_selector("span a.up[href='#{url}']", text: 'up') |
89 | end | 89 | end |
90 | 90 | ||
91 | it "should link 'up' to app_problems_path if HTTP_REFERER isn't set'" do | 91 | it "should link 'up' to app_problems_path if HTTP_REFERER isn't set'" do |
@@ -96,11 +96,11 @@ describe "problems/show.html.haml", type: 'view' do | @@ -96,11 +96,11 @@ describe "problems/show.html.haml", type: 'view' do | ||
96 | allow(view).to receive(:app).and_return(problem.app) | 96 | allow(view).to receive(:app).and_return(problem.app) |
97 | render | 97 | render |
98 | 98 | ||
99 | - expect(action_bar).to have_selector("span a.up[href='#{app_problems_path(problem.app)}']", :text => 'up') | 99 | + expect(action_bar).to have_selector("span a.up[href='#{app_problems_path(problem.app)}']", text: 'up') |
100 | end | 100 | end |
101 | 101 | ||
102 | context 'create issue links' do | 102 | context 'create issue links' do |
103 | - let(:app) { Fabricate(:app, :github_repo => "test_user/test_repo") } | 103 | + let(:app) { Fabricate(:app, github_repo: "test_user/test_repo") } |
104 | 104 | ||
105 | it 'should allow creating issue for github if application has a github tracker' do | 105 | it 'should allow creating issue for github if application has a github tracker' do |
106 | problem = Fabricate(:problem_with_comments, app: app) | 106 | problem = Fabricate(:problem_with_comments, app: app) |
@@ -113,8 +113,8 @@ describe "problems/show.html.haml", type: 'view' do | @@ -113,8 +113,8 @@ describe "problems/show.html.haml", type: 'view' do | ||
113 | end | 113 | end |
114 | 114 | ||
115 | context "without issue tracker associate on app" do | 115 | context "without issue tracker associate on app" do |
116 | - let(:problem) { Problem.new(:new_record => false, :app => app) } | ||
117 | - let(:app) { App.new(:new_record => false) } | 116 | + let(:problem) { Problem.new(new_record: false, app: app) } |
117 | + let(:app) { App.new(new_record: false) } | ||
118 | 118 | ||
119 | it 'not see link to create issue' do | 119 | it 'not see link to create issue' do |
120 | render | 120 | render |
@@ -128,12 +128,12 @@ describe "problems/show.html.haml", type: 'view' do | @@ -128,12 +128,12 @@ describe "problems/show.html.haml", type: 'view' do | ||
128 | end | 128 | end |
129 | 129 | ||
130 | context "with app having github_repo" do | 130 | context "with app having github_repo" do |
131 | - let(:app) { App.new(:new_record => false, :github_repo => 'foo/bar') } | ||
132 | - let(:problem) { Problem.new(:new_record => false, :app => app) } | 131 | + let(:app) { App.new(new_record: false, github_repo: 'foo/bar') } |
132 | + let(:problem) { Problem.new(new_record: false, app: app) } | ||
133 | 133 | ||
134 | before do | 134 | before do |
135 | problem.issue_link = nil | 135 | problem.issue_link = nil |
136 | - user = Fabricate(:user, :github_login => 'test_user', :github_oauth_token => 'abcdef') | 136 | + user = Fabricate(:user, github_login: 'test_user', github_oauth_token: 'abcdef') |
137 | 137 | ||
138 | allow(controller).to receive(:current_user).and_return(user) | 138 | allow(controller).to receive(:current_user).and_return(user) |
139 | end | 139 | end |
spec/views/problems/show.ics.haml_spec.rb
@@ -6,6 +6,6 @@ describe "problems/show.html.ics", type: 'view' do | @@ -6,6 +6,6 @@ describe "problems/show.html.ics", type: 'view' do | ||
6 | end | 6 | end |
7 | 7 | ||
8 | it 'works' do | 8 | it 'works' do |
9 | - render :template => 'problems/show', :formats => [:ics], :handlers => [:haml] | 9 | + render template: 'problems/show', formats: [:ics], handlers: [:haml] |
10 | end | 10 | end |
11 | end | 11 | end |
spec/views/users/edit.html.haml_spec.rb
1 | describe 'users/edit.html.haml', type: 'view' do | 1 | describe 'users/edit.html.haml', type: 'view' do |
2 | - let(:user) { stub_model(User, :name => 'shingara') } | 2 | + let(:user) { stub_model(User, name: 'shingara') } |
3 | before { | 3 | before { |
4 | allow(view).to receive(:current_user).and_return(user) | 4 | allow(view).to receive(:current_user).and_return(user) |
5 | allow(view).to receive(:user).and_return(user) | 5 | allow(view).to receive(:user).and_return(user) |
spec/views/users/index.html.haml_spec.rb
@@ -3,7 +3,7 @@ describe 'users/index.html.haml', type: 'view' do | @@ -3,7 +3,7 @@ describe 'users/index.html.haml', type: 'view' do | ||
3 | before { | 3 | before { |
4 | allow(view).to receive(:current_user).and_return(user) | 4 | allow(view).to receive(:current_user).and_return(user) |
5 | allow(view).to receive(:users).and_return( | 5 | allow(view).to receive(:users).and_return( |
6 | - Kaminari.paginate_array([user], :total_count => 1).page(1) | 6 | + Kaminari.paginate_array([user], total_count: 1).page(1) |
7 | ) | 7 | ) |
8 | } | 8 | } |
9 | it 'should see users option' do | 9 | it 'should see users option' do |
spec/views/users/show.html.haml_spec.rb
1 | describe 'users/show.html.haml', type: 'view' do | 1 | describe 'users/show.html.haml', type: 'view' do |
2 | let(:user) do | 2 | let(:user) do |
3 | - stub_model(User, :created_at => Time.zone.now, :email => "test@example.com") | 3 | + stub_model(User, created_at: Time.zone.now, email: "test@example.com") |
4 | end | 4 | end |
5 | 5 | ||
6 | before do | 6 | before do |