Commit 9e861299b99bc00e63ee0719790d6946f8e896d5
Exists in
master
and in
1 other branch
Merge pull request #998 from rud/chore/fix-more-style
Rubocop: whittling down the TODO list
Showing
72 changed files
with
476 additions
and
531 deletions
Show diff stats
.rubocop.yml
@@ -23,6 +23,9 @@ Style/IndentationConsistency: | @@ -23,6 +23,9 @@ Style/IndentationConsistency: | ||
23 | # modifiers. | 23 | # modifiers. |
24 | EnforcedStyle: rails | 24 | EnforcedStyle: rails |
25 | 25 | ||
26 | +Style/GuardClause: | ||
27 | + MinBodyLength: 4 | ||
28 | + | ||
26 | Style/AccessModifierIndentation: | 29 | Style/AccessModifierIndentation: |
27 | EnforcedStyle: outdent | 30 | EnforcedStyle: outdent |
28 | 31 | ||
@@ -33,6 +36,9 @@ Style/DotPosition: | @@ -33,6 +36,9 @@ Style/DotPosition: | ||
33 | # Support code copy/paste into console | 36 | # Support code copy/paste into console |
34 | EnforcedStyle: trailing | 37 | EnforcedStyle: trailing |
35 | 38 | ||
39 | +Style/MultilineOperationIndentation: | ||
40 | + EnforcedStyle: indented | ||
41 | + | ||
36 | Style/IndentHash: | 42 | Style/IndentHash: |
37 | EnforcedStyle: consistent | 43 | EnforcedStyle: consistent |
38 | 44 | ||
@@ -46,3 +52,7 @@ Style/SpaceAroundOperators: | @@ -46,3 +52,7 @@ Style/SpaceAroundOperators: | ||
46 | - '=>' | 52 | - '=>' |
47 | - '||=' | 53 | - '||=' |
48 | - 'then' | 54 | - 'then' |
55 | + | ||
56 | +Style/FileName: | ||
57 | + Exclude: | ||
58 | + - 'config/initializers/cve-*.rb' |
.rubocop_todo.yml
@@ -41,24 +41,6 @@ Rails/Output: | @@ -41,24 +41,6 @@ Rails/Output: | ||
41 | - 'app/interactors/problem_recacher.rb' | 41 | - 'app/interactors/problem_recacher.rb' |
42 | - 'db/seeds.rb' | 42 | - 'db/seeds.rb' |
43 | 43 | ||
44 | -# Offense count: 12 | ||
45 | -# Configuration parameters: Include. | ||
46 | -Rails/Validation: | ||
47 | - Exclude: | ||
48 | - - 'app/models/app.rb' | ||
49 | - - 'app/models/comment.rb' | ||
50 | - - 'app/models/deploy.rb' | ||
51 | - - 'app/models/err.rb' | ||
52 | - - 'app/models/notice.rb' | ||
53 | - - 'app/models/problem.rb' | ||
54 | - - 'app/models/user.rb' | ||
55 | - | ||
56 | -# Offense count: 105 | ||
57 | -# Cop supports --auto-correct. | ||
58 | -# Configuration parameters: EnforcedStyle, SupportedStyles, ProceduralMethods, FunctionalMethods, IgnoredMethods. | ||
59 | -Style/BlockDelimiters: | ||
60 | - Enabled: false | ||
61 | - | ||
62 | # Offense count: 15 | 44 | # Offense count: 15 |
63 | # Configuration parameters: EnforcedStyle, SupportedStyles. | 45 | # Configuration parameters: EnforcedStyle, SupportedStyles. |
64 | Style/ClassAndModuleChildren: | 46 | Style/ClassAndModuleChildren: |
@@ -93,94 +75,6 @@ Style/EachWithObject: | @@ -93,94 +75,6 @@ Style/EachWithObject: | ||
93 | - 'app/models/notice_fingerprinter.rb' | 75 | - 'app/models/notice_fingerprinter.rb' |
94 | - 'lib/recurse.rb' | 76 | - 'lib/recurse.rb' |
95 | 77 | ||
96 | -# Offense count: 2 | ||
97 | -# Configuration parameters: Exclude. | ||
98 | -Style/FileName: | ||
99 | - Exclude: | ||
100 | - - 'config/initializers/cve-2013-0156.rb' | ||
101 | - - 'script/rspec-queue-mongoid.rb' | ||
102 | - | ||
103 | -# Offense count: 4 | ||
104 | -# Cop supports --auto-correct. | ||
105 | -# Configuration parameters: EnforcedStyle, SupportedStyles. | ||
106 | -Style/FirstParameterIndentation: | ||
107 | - Exclude: | ||
108 | - - 'app/models/issue_tracker.rb' | ||
109 | - - 'spec/decorators/backtrace_decorator_spec.rb' | ||
110 | - - 'spec/decorators/issue_tracker_type_decorator_spec.rb' | ||
111 | - | ||
112 | -# Offense count: 8 | ||
113 | -# Configuration parameters: EnforcedStyle, SupportedStyles. | ||
114 | -Style/FormatString: | ||
115 | - Exclude: | ||
116 | - - 'app/decorators/backtrace_line_decorator.rb' | ||
117 | - - 'app/helpers/problems_helper.rb' | ||
118 | - - 'spec/views/apps/edit.html.haml_spec.rb' | ||
119 | - - 'spec/views/problems/show.html.haml_spec.rb' | ||
120 | - - 'spec/views/users/show.html.haml_spec.rb' | ||
121 | - | ||
122 | -# Offense count: 27 | ||
123 | -# Configuration parameters: MinBodyLength. | ||
124 | -Style/GuardClause: | ||
125 | - Enabled: false | ||
126 | - | ||
127 | -# Offense count: 6 | ||
128 | -# Cop supports --auto-correct. | ||
129 | -# Configuration parameters: MaxLineLength. | ||
130 | -Style/IfUnlessModifier: | ||
131 | - Exclude: | ||
132 | - - 'app/controllers/api/v1/stats_controller.rb' | ||
133 | - - 'app/controllers/application_controller.rb' | ||
134 | - - 'app/controllers/problems_controller.rb' | ||
135 | - - 'app/models/notice.rb' | ||
136 | - - 'app/models/user.rb' | ||
137 | - | ||
138 | -# Offense count: 17 | ||
139 | -# Cop supports --auto-correct. | ||
140 | -Style/LeadingCommentSpace: | ||
141 | - Exclude: | ||
142 | - - 'app/models/notification_services/gtalk_service.rb' | ||
143 | - - 'spec/controllers/api/v1/notices_controller_spec.rb' | ||
144 | - - 'spec/controllers/api/v1/problems_controller_spec.rb' | ||
145 | - - 'spec/models/fabricators_spec.rb' | ||
146 | - - 'spec/models/notification_service/campfire_service_spec.rb' | ||
147 | - - 'spec/models/notification_service/gtalk_service_spec.rb' | ||
148 | - - 'spec/models/notification_service/hoiio_service_spec.rb' | ||
149 | - - 'spec/models/notification_service/pushover_service_spec.rb' | ||
150 | - | ||
151 | -# Offense count: 10 | ||
152 | -# Cop supports --auto-correct. | ||
153 | -# Configuration parameters: EnforcedStyle, SupportedStyles. | ||
154 | -Style/MultilineOperationIndentation: | ||
155 | - Enabled: false | ||
156 | - | ||
157 | -# Offense count: 5 | ||
158 | -# Cop supports --auto-correct. | ||
159 | -# Configuration parameters: PreferredDelimiters. | ||
160 | -Style/PercentLiteralDelimiters: | ||
161 | - Exclude: | ||
162 | - - 'app/controllers/api/v1/notices_controller.rb' | ||
163 | - - 'app/controllers/api/v1/problems_controller.rb' | ||
164 | - - 'app/controllers/problems_searcher.rb' | ||
165 | - - 'spec/models/notice_spec.rb' | ||
166 | - | ||
167 | -# Offense count: 1 | ||
168 | -# Configuration parameters: Methods. | ||
169 | -Style/SingleLineBlockParams: | ||
170 | - Exclude: | ||
171 | - - 'lib/hoptoad/v2.rb' | ||
172 | - | ||
173 | -# Offense count: 11 | ||
174 | -# Cop supports --auto-correct. | ||
175 | -Style/SingleSpaceBeforeFirstArg: | ||
176 | - Exclude: | ||
177 | - - 'app/models/comment.rb' | ||
178 | - - 'config/application.rb' | ||
179 | - - 'spec/fabricators/app_fabricator.rb' | ||
180 | - - 'spec/fabricators/comment_fabricator.rb' | ||
181 | - - 'spec/fabricators/notice_fabricator.rb' | ||
182 | - - 'spec/fabricators/user_fabricator.rb' | ||
183 | - | ||
184 | # Offense count: 873 | 78 | # Offense count: 873 |
185 | # Cop supports --auto-correct. | 79 | # Cop supports --auto-correct. |
186 | # Configuration parameters: EnforcedStyle, SupportedStyles. | 80 | # Configuration parameters: EnforcedStyle, SupportedStyles. |
app/controllers/api/v1/notices_controller.rb
@@ -3,7 +3,7 @@ class Api::V1::NoticesController < ApplicationController | @@ -3,7 +3,7 @@ class Api::V1::NoticesController < ApplicationController | ||
3 | 3 | ||
4 | def index | 4 | def index |
5 | query = {} | 5 | query = {} |
6 | - fields = %w{created_at message error_class} | 6 | + fields = %w(created_at message error_class) |
7 | 7 | ||
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 |
app/controllers/api/v1/problems_controller.rb
1 | class Api::V1::ProblemsController < ApplicationController | 1 | class Api::V1::ProblemsController < ApplicationController |
2 | respond_to :json, :xml | 2 | respond_to :json, :xml |
3 | - FIELDS = %w{_id app_id app_name environment message where first_notice_at last_notice_at resolved resolved_at notices_count} | 3 | + FIELDS = %w(_id app_id app_name environment message where first_notice_at last_notice_at resolved resolved_at notices_count) |
4 | 4 | ||
5 | def show | 5 | def show |
6 | result = benchmark("[api/v1/problems_controller/show] query time") do | 6 | result = benchmark("[api/v1/problems_controller/show] query time") do |
app/controllers/api/v1/stats_controller.rb
@@ -25,9 +25,7 @@ class Api::V1::StatsController < ApplicationController | @@ -25,9 +25,7 @@ class Api::V1::StatsController < ApplicationController | ||
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) | ||
29 | - return true | ||
30 | - end | 28 | + return true if (@app = App.where(api_key: params[:api_key]).first) |
31 | end | 29 | end |
32 | 30 | ||
33 | authenticate_user! | 31 | authenticate_user! |
app/controllers/application_controller.rb
@@ -23,10 +23,10 @@ protected | @@ -23,10 +23,10 @@ protected | ||
23 | # Check if the current_user is admin or not and redirect to root url if not | 23 | # Check if the current_user is admin or not and redirect to root url if not |
24 | # | 24 | # |
25 | def require_admin! | 25 | def require_admin! |
26 | - unless user_signed_in? && current_user.admin? | ||
27 | - flash[:error] = "Sorry, you don't have permission to do that" | ||
28 | - redirect_to_root | ||
29 | - end | 26 | + return if user_signed_in? && current_user.admin? |
27 | + | ||
28 | + flash[:error] = "Sorry, you don't have permission to do that" | ||
29 | + redirect_to_root | ||
30 | end | 30 | end |
31 | 31 | ||
32 | def redirect_to_root | 32 | def redirect_to_root |
@@ -41,8 +41,6 @@ protected | @@ -41,8 +41,6 @@ protected | ||
41 | user_token = params[User.token_authentication_key].presence | 41 | user_token = params[User.token_authentication_key].presence |
42 | user = user_token && User.find_by(authentication_token: user_token) | 42 | user = user_token && User.find_by(authentication_token: user_token) |
43 | 43 | ||
44 | - if user | ||
45 | - sign_in user, store: false | ||
46 | - end | 44 | + sign_in user, store: false if user |
47 | end | 45 | end |
48 | end | 46 | end |
app/controllers/apps_controller.rb
@@ -8,9 +8,9 @@ class AppsController < ApplicationController | @@ -8,9 +8,9 @@ class AppsController < ApplicationController | ||
8 | 8 | ||
9 | expose(:app_scope) { App } | 9 | expose(:app_scope) { App } |
10 | 10 | ||
11 | - expose(:apps) { | 11 | + expose(:apps) do |
12 | app_scope.all.sort.map { |app| AppDecorator.new(app) } | 12 | app_scope.all.sort.map { |app| AppDecorator.new(app) } |
13 | - } | 13 | + end |
14 | 14 | ||
15 | expose(:app, ancestor: :app_scope, attributes: :app_params) | 15 | expose(:app, ancestor: :app_scope, attributes: :app_params) |
16 | 16 | ||
@@ -18,11 +18,11 @@ class AppsController < ApplicationController | @@ -18,11 +18,11 @@ class AppsController < ApplicationController | ||
18 | AppDecorator.new(app) | 18 | AppDecorator.new(app) |
19 | end | 19 | end |
20 | 20 | ||
21 | - expose(:all_errs) { | 21 | + expose(:all_errs) do |
22 | params[:all_errs].present? | 22 | params[:all_errs].present? |
23 | - } | 23 | + end |
24 | 24 | ||
25 | - expose(:problems) { | 25 | + expose(:problems) do |
26 | if request.format == :atom | 26 | if request.format == :atom |
27 | app.problems.unresolved.ordered | 27 | app.problems.unresolved.ordered |
28 | else | 28 | else |
@@ -32,15 +32,15 @@ class AppsController < ApplicationController | @@ -32,15 +32,15 @@ class AppsController < ApplicationController | ||
32 | params[:environment] | 32 | params[:environment] |
33 | ).ordered_by(params_sort, params_order).page(params[:page]).per(current_user.per_page) | 33 | ).ordered_by(params_sort, params_order).page(params[:page]).per(current_user.per_page) |
34 | end | 34 | end |
35 | - } | 35 | + end |
36 | 36 | ||
37 | - expose(:deploys) { | 37 | + expose(:deploys) do |
38 | app.deploys.order_by(:created_at.desc).limit(5) | 38 | app.deploys.order_by(:created_at.desc).limit(5) |
39 | - } | 39 | + end |
40 | 40 | ||
41 | - expose(:users) { | 41 | + expose(:users) do |
42 | User.all.sort_by { |u| u.name.downcase } | 42 | User.all.sort_by { |u| u.name.downcase } |
43 | - } | 43 | + end |
44 | 44 | ||
45 | def index; end | 45 | def index; end |
46 | 46 | ||
@@ -93,13 +93,16 @@ class AppsController < ApplicationController | @@ -93,13 +93,16 @@ class AppsController < ApplicationController | ||
93 | protected | 93 | protected |
94 | 94 | ||
95 | def initialize_subclassed_notification_service | 95 | def initialize_subclassed_notification_service |
96 | + notification_type = params[:app]. | ||
97 | + fetch(:notification_service_attributes, {}). | ||
98 | + fetch(:type, nil) | ||
99 | + return if notification_type.blank? | ||
100 | + | ||
96 | # set the app's notification service | 101 | # set the app's notification service |
97 | - if params[:app][:notification_service_attributes] && (notification_type = params[:app][:notification_service_attributes][:type]) | ||
98 | - available_notification_classes = [NotificationService] + NotificationService.subclasses | ||
99 | - notification_class = available_notification_classes.detect { |c| c.name == notification_type } | ||
100 | - if notification_class.present? | ||
101 | - app.notification_service = notification_class.new(params[:app][:notification_service_attributes]) | ||
102 | - end | 102 | + available_notification_classes = [NotificationService] + NotificationService.subclasses |
103 | + notification_class = available_notification_classes.detect { |c| c.name == notification_type } | ||
104 | + if notification_class.present? | ||
105 | + app.notification_service = notification_class.new(params[:app][:notification_service_attributes]) | ||
103 | end | 106 | end |
104 | end | 107 | end |
105 | 108 | ||
@@ -112,32 +115,38 @@ protected | @@ -112,32 +115,38 @@ protected | ||
112 | 115 | ||
113 | # email_at_notices is edited as a string, and stored as an array. | 116 | # email_at_notices is edited as a string, and stored as an array. |
114 | def parse_email_at_notices_or_set_default | 117 | def parse_email_at_notices_or_set_default |
115 | - if params[:app] && (val = params[:app][:email_at_notices]) | ||
116 | - # Sanitize negative values, split on comma, | ||
117 | - # strip, parse as integer, remove all '0's. | ||
118 | - # If empty, set as default and show an error message. | ||
119 | - email_at_notices = val.gsub(/-\d+/, "").split(",").map { |v| v.strip.to_i }.reject { |v| v == 0 } | ||
120 | - if email_at_notices.any? | ||
121 | - params[:app][:email_at_notices] = email_at_notices | ||
122 | - else | ||
123 | - default_array = params[:app][:email_at_notices] = Errbit::Config.email_at_notices | ||
124 | - flash[:error] = "Couldn't parse your notification frequency. Value was reset to default (#{default_array.join(', ')})." | ||
125 | - end | 118 | + return if params[:app].blank? |
119 | + | ||
120 | + val = params[:app][:email_at_notices] | ||
121 | + return if val.blank? | ||
122 | + | ||
123 | + # Sanitize negative values, split on comma, | ||
124 | + # strip, parse as integer, remove all '0's. | ||
125 | + # If empty, set as default and show an error message. | ||
126 | + email_at_notices = val.gsub(/-\d+/, "").split(",").map { |v| v.strip.to_i }.reject { |v| v == 0 } | ||
127 | + if email_at_notices.any? | ||
128 | + params[:app][:email_at_notices] = email_at_notices | ||
129 | + else | ||
130 | + default_array = params[:app][:email_at_notices] = Errbit::Config.email_at_notices | ||
131 | + flash[:error] = "Couldn't parse your notification frequency. Value was reset to default (#{default_array.join(', ')})." | ||
126 | end | 132 | end |
127 | end | 133 | end |
128 | 134 | ||
129 | def parse_notice_at_notices_or_set_default | 135 | def parse_notice_at_notices_or_set_default |
130 | - if params[:app][:notification_service_attributes] && (val = params[:app][:notification_service_attributes][:notify_at_notices]) | ||
131 | - # Sanitize negative values, split on comma, | ||
132 | - # strip, parse as integer, remove all '0's. | ||
133 | - # If empty, set as default and show an error message. | ||
134 | - notify_at_notices = val.gsub(/-\d+/, "").split(",").map { |v| v.strip.to_i } | ||
135 | - if notify_at_notices.any? | ||
136 | - params[:app][:notification_service_attributes][:notify_at_notices] = notify_at_notices | ||
137 | - else | ||
138 | - default_array = params[:app][:notification_service_attributes][:notify_at_notices] = Errbit::Config.notify_at_notices | ||
139 | - flash[:error] = "Couldn't parse your notification frequency. Value was reset to default (#{default_array.join(', ')})." | ||
140 | - end | 136 | + return if params[:app][:notification_service_attributes].blank? |
137 | + | ||
138 | + val = params[:app][:notification_service_attributes][:notify_at_notices] | ||
139 | + return if val.blank? | ||
140 | + | ||
141 | + # Sanitize negative values, split on comma, | ||
142 | + # strip, parse as integer, remove all '0's. | ||
143 | + # If empty, set as default and show an error message. | ||
144 | + notify_at_notices = val.gsub(/-\d+/, "").split(",").map { |v| v.strip.to_i } | ||
145 | + if notify_at_notices.any? | ||
146 | + params[:app][:notification_service_attributes][:notify_at_notices] = notify_at_notices | ||
147 | + else | ||
148 | + default_array = params[:app][:notification_service_attributes][:notify_at_notices] = Errbit::Config.notify_at_notices | ||
149 | + flash[:error] = "Couldn't parse your notification frequency. Value was reset to default (#{default_array.join(', ')})." | ||
141 | end | 150 | end |
142 | end | 151 | end |
143 | 152 |
app/controllers/deploys_controller.rb
@@ -19,15 +19,15 @@ class DeploysController < ApplicationController | @@ -19,15 +19,15 @@ class DeploysController < ApplicationController | ||
19 | private | 19 | private |
20 | 20 | ||
21 | def default_deploy | 21 | def default_deploy |
22 | - if params[:deploy] | ||
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] | ||
29 | - } | ||
30 | - end | 22 | + return if params[:deploy].blank? |
23 | + | ||
24 | + { | ||
25 | + username: params[:deploy][:local_username], | ||
26 | + environment: params[:deploy][:rails_env], | ||
27 | + repository: params[:deploy][:scm_repository], | ||
28 | + revision: params[:deploy][:scm_revision], | ||
29 | + message: params[:deploy][:message] | ||
30 | + } | ||
31 | end | 31 | end |
32 | 32 | ||
33 | # handle Heroku's HTTP post deployhook format | 33 | # handle Heroku's HTTP post deployhook format |
app/controllers/problems_controller.rb
@@ -11,27 +11,27 @@ class ProblemsController < ApplicationController | @@ -11,27 +11,27 @@ class ProblemsController < ApplicationController | ||
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) do |
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 | + end |
17 | 17 | ||
18 | - expose(:app) { | 18 | + expose(:app) do |
19 | AppDecorator.new app_scope.find(params[:app_id]) | 19 | AppDecorator.new app_scope.find(params[:app_id]) |
20 | - } | 20 | + end |
21 | 21 | ||
22 | - expose(:problem) { | 22 | + expose(:problem) do |
23 | ProblemDecorator.new app.problems.find(params[:id]) | 23 | ProblemDecorator.new app.problems.find(params[:id]) |
24 | - } | 24 | + end |
25 | 25 | ||
26 | - expose(:all_errs) { | 26 | + expose(:all_errs) do |
27 | params[:all_errs] | 27 | params[:all_errs] |
28 | - } | 28 | + end |
29 | 29 | ||
30 | - expose(:params_environement) { | 30 | + expose(:params_environement) do |
31 | params[:environment] | 31 | params[:environment] |
32 | - } | 32 | + end |
33 | 33 | ||
34 | - expose(:problems) { | 34 | + expose(:problems) do |
35 | pro = Problem. | 35 | pro = Problem. |
36 | for_apps(app_scope). | 36 | for_apps(app_scope). |
37 | in_env(params_environement). | 37 | in_env(params_environement). |
@@ -43,7 +43,7 @@ class ProblemsController < ApplicationController | @@ -43,7 +43,7 @@ class ProblemsController < ApplicationController | ||
43 | else | 43 | else |
44 | pro | 44 | pro |
45 | end | 45 | end |
46 | - } | 46 | + end |
47 | 47 | ||
48 | def index; end | 48 | def index; end |
49 | 49 | ||
@@ -58,9 +58,7 @@ class ProblemsController < ApplicationController | @@ -58,9 +58,7 @@ class ProblemsController < ApplicationController | ||
58 | issue = Issue.new(problem: problem, user: current_user) | 58 | issue = Issue.new(problem: problem, user: current_user) |
59 | issue.body = render_to_string(*issue.render_body_args) | 59 | issue.body = render_to_string(*issue.render_body_args) |
60 | 60 | ||
61 | - unless issue.save | ||
62 | - flash[:error] = issue.errors.full_messages.join(', ') | ||
63 | - end | 61 | + flash[:error] = issue.errors.full_messages.join(', ') unless issue.save |
64 | 62 | ||
65 | redirect_to app_problem_path(app, problem) | 63 | redirect_to app_problem_path(app, problem) |
66 | end | 64 | end |
@@ -138,9 +136,9 @@ class ProblemsController < ApplicationController | @@ -138,9 +136,9 @@ class ProblemsController < ApplicationController | ||
138 | # Redirect :back if no errors selected | 136 | # Redirect :back if no errors selected |
139 | # | 137 | # |
140 | protected def need_selected_problem | 138 | protected def need_selected_problem |
141 | - if err_ids.empty? | ||
142 | - flash[:notice] = I18n.t('controllers.problems.flash.no_select_problem') | ||
143 | - redirect_to :back | ||
144 | - end | 139 | + return if err_ids.any? |
140 | + | ||
141 | + flash[:notice] = I18n.t('controllers.problems.flash.no_select_problem') | ||
142 | + redirect_to :back | ||
145 | end | 143 | end |
146 | end | 144 | end |
app/controllers/problems_searcher.rb
@@ -5,28 +5,28 @@ module ProblemsSearcher | @@ -5,28 +5,28 @@ module ProblemsSearcher | ||
5 | extend ActiveSupport::Concern | 5 | extend ActiveSupport::Concern |
6 | 6 | ||
7 | included do | 7 | included do |
8 | - expose(:params_sort) { | ||
9 | - if %w{app message last_notice_at last_deploy_at count}.member?(params[:sort]) | 8 | + expose(:params_sort) do |
9 | + if %w(app message last_notice_at last_deploy_at count).member?(params[:sort]) | ||
10 | params[:sort] | 10 | params[:sort] |
11 | else | 11 | else |
12 | "last_notice_at" | 12 | "last_notice_at" |
13 | end | 13 | end |
14 | - } | 14 | + end |
15 | 15 | ||
16 | - expose(:params_order) { | ||
17 | - if %w{asc desc}.member?(params[:order]) | 16 | + expose(:params_order) do |
17 | + if %w(asc desc).member?(params[:order]) | ||
18 | params[:order] | 18 | params[:order] |
19 | else | 19 | else |
20 | 'desc' | 20 | 'desc' |
21 | end | 21 | end |
22 | - } | 22 | + end |
23 | 23 | ||
24 | - expose(:selected_problems) { | 24 | + expose(:selected_problems) do |
25 | Array(Problem.find(err_ids)) | 25 | Array(Problem.find(err_ids)) |
26 | - } | 26 | + end |
27 | 27 | ||
28 | - expose(:err_ids) { | 28 | + expose(:err_ids) do |
29 | (params[:problems] || []).compact | 29 | (params[:problems] || []).compact |
30 | - } | 30 | + end |
31 | end | 31 | end |
32 | end | 32 | end |
app/controllers/users_controller.rb
@@ -5,9 +5,9 @@ class UsersController < ApplicationController | @@ -5,9 +5,9 @@ class UsersController < ApplicationController | ||
5 | before_action :require_user_edit_priviledges, only: [: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) do |
9 | User.all.page(params[:page]).per(current_user.per_page) | 9 | User.all.page(params[:page]).per(current_user.per_page) |
10 | - } | 10 | + end |
11 | 11 | ||
12 | def index; end | 12 | def index; end |
13 | def new; end | 13 | def new; end |
app/decorators/backtrace_line_decorator.rb
@@ -57,7 +57,7 @@ private | @@ -57,7 +57,7 @@ private | ||
57 | link_to_hosted_javascript(app, text) | 57 | link_to_hosted_javascript(app, text) |
58 | else | 58 | else |
59 | link_to_repo_source_file(app, text) || | 59 | link_to_repo_source_file(app, text) || |
60 | - link_to_issue_tracker_file(app, text) | 60 | + link_to_issue_tracker_file(app, text) |
61 | end | 61 | end |
62 | end | 62 | end |
63 | 63 | ||
@@ -66,20 +66,19 @@ private | @@ -66,20 +66,19 @@ private | ||
66 | end | 66 | end |
67 | 67 | ||
68 | def link_to_hosted_javascript(app, text) | 68 | def link_to_hosted_javascript(app, text) |
69 | - if app.asset_host? | ||
70 | - h.link_to(text, "#{app.asset_host}/#{file_relative}", target: '_blank') | ||
71 | - end | 69 | + return unless app.asset_host? |
70 | + h.link_to(text, "#{app.asset_host}/#{file_relative}", target: '_blank') | ||
72 | end | 71 | end |
73 | 72 | ||
74 | def link_to_github(app, text = nil) | 73 | def link_to_github(app, text = nil) |
75 | return unless app.github_repo? | 74 | return unless app.github_repo? |
76 | - href = "%s#L%s" % [app.github_url_to_file(decorated_path + file_name), number] | 75 | + href = format("%s#L%s", app.github_url_to_file(decorated_path + file_name), number) |
77 | h.link_to(text || file_name, href, target: '_blank') | 76 | h.link_to(text || file_name, href, target: '_blank') |
78 | end | 77 | end |
79 | 78 | ||
80 | def link_to_bitbucket(app, text = nil) | 79 | def link_to_bitbucket(app, text = nil) |
81 | return unless app.bitbucket_repo? | 80 | return unless app.bitbucket_repo? |
82 | - href = "%s#%s-%s" % [app.bitbucket_url_to_file(decorated_path + file_name), file_name, number] | 81 | + href = format("%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') | 82 | h.link_to(text || file_name, href, target: '_blank') |
84 | end | 83 | end |
85 | 84 |
app/helpers/application_helper.rb
@@ -20,7 +20,7 @@ module ApplicationHelper | @@ -20,7 +20,7 @@ module ApplicationHelper | ||
20 | end | 20 | end |
21 | 21 | ||
22 | def generate_ical(deploys) | 22 | def generate_ical(deploys) |
23 | - RiCal.Calendar { |cal| | 23 | + RiCal.Calendar do |cal| |
24 | deploys.each_with_index do |deploy, idx| | 24 | deploys.each_with_index do |deploy, idx| |
25 | cal.event do |event| | 25 | cal.event do |event| |
26 | event.summary = "#{idx + 1} #{deploy.repository}" | 26 | event.summary = "#{idx + 1} #{deploy.repository}" |
@@ -31,7 +31,7 @@ module ApplicationHelper | @@ -31,7 +31,7 @@ module ApplicationHelper | ||
31 | event.organizer = deploy.username.to_s | 31 | event.organizer = deploy.username.to_s |
32 | end | 32 | end |
33 | end | 33 | end |
34 | - }.to_s | 34 | + end.to_s |
35 | end | 35 | end |
36 | 36 | ||
37 | def user_agent_graph(problem) | 37 | def user_agent_graph(problem) |
@@ -57,7 +57,7 @@ module ApplicationHelper | @@ -57,7 +57,7 @@ module ApplicationHelper | ||
57 | total = (options[:total] || total_from_tallies(tallies)) | 57 | total = (options[:total] || total_from_tallies(tallies)) |
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 |
app/helpers/apps_helper.rb
1 | module AppsHelper | 1 | 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 | ||
4 | - html = link_to('copy settings from another app', '#', | ||
5 | - class: 'button copy_config') | ||
6 | - html << select("duplicate", "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;") | ||
10 | - return html | ||
11 | - end | 3 | + return if App.count <= 1 |
4 | + | ||
5 | + html = link_to('copy settings from another app', '#', | ||
6 | + class: 'button copy_config') | ||
7 | + html << select("duplicate", "app", | ||
8 | + App.all.asc(:name).reject { |a| a == @app }. | ||
9 | + collect { |p| [p.name, p.id] }, { include_blank: "[choose app]" }, | ||
10 | + class: "choose_other_app", style: "display: none;") | ||
11 | + html | ||
12 | end | 12 | end |
13 | 13 | ||
14 | def any_github_repos? | 14 | def any_github_repos? |
app/helpers/problems_helper.rb
1 | module ProblemsHelper | 1 | module ProblemsHelper |
2 | def problem_confirm(action) | 2 | def problem_confirm(action) |
3 | - t('problems.confirm.%s' % action) unless Errbit::Config.confirm_err_actions.eql? false | 3 | + t(format('problems.confirm.%s', action)) unless Errbit::Config.confirm_err_actions.eql? false |
4 | end | 4 | end |
5 | 5 | ||
6 | def truncated_problem_message(problem) | 6 | def truncated_problem_message(problem) |
7 | - unless (msg = problem.message).blank? | ||
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 | ||
10 | - end | 7 | + msg = problem.message |
8 | + return if msg.blank? | ||
9 | + | ||
10 | + # Truncate & insert invisible chars so that firefox can emulate | ||
11 | + # 'word-wrap: break-word' CSS rule | ||
12 | + truncate(msg, length: 300, escape: false). | ||
13 | + scan(/.{1,5}/).map { |s| h(s) }. | ||
14 | + join("​").html_safe | ||
11 | end | 15 | end |
12 | 16 | ||
13 | def gravatar_tag(email, options = {}) | 17 | def gravatar_tag(email, options = {}) |
app/interactors/problem_destroy.rb
@@ -20,9 +20,9 @@ class ProblemDestroy | @@ -20,9 +20,9 @@ class ProblemDestroy | ||
20 | # the number of problem destroy | 20 | # the number of problem destroy |
21 | # | 21 | # |
22 | def self.execute(problems) | 22 | def self.execute(problems) |
23 | - Array(problems).each { |problem| | 23 | + Array(problems).each do |problem| |
24 | ProblemDestroy.new(problem).execute | 24 | ProblemDestroy.new(problem).execute |
25 | - }.count | 25 | + end.count |
26 | end | 26 | end |
27 | 27 | ||
28 | private | 28 | private |
app/interactors/resolved_problem_clearer.rb
@@ -5,14 +5,14 @@ class ResolvedProblemClearer | @@ -5,14 +5,14 @@ class ResolvedProblemClearer | ||
5 | # Clear all problem already resolved | 5 | # Clear all problem already resolved |
6 | # | 6 | # |
7 | def execute | 7 | def execute |
8 | - nb_problem_resolved.tap { |nb| | 8 | + nb_problem_resolved.tap do |nb| |
9 | if nb > 0 | 9 | if nb > 0 |
10 | criteria.each do |problem| | 10 | criteria.each do |problem| |
11 | ProblemDestroy.new(problem).execute | 11 | ProblemDestroy.new(problem).execute |
12 | end | 12 | end |
13 | repair_database | 13 | repair_database |
14 | end | 14 | end |
15 | - } | 15 | + end |
16 | end | 16 | end |
17 | 17 | ||
18 | private | 18 | private |
app/models/app.rb
@@ -35,9 +35,7 @@ class App | @@ -35,9 +35,7 @@ class App | ||
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 | ||
39 | - validates_uniqueness_of :name, allow_blank: true | ||
40 | - validates_uniqueness_of :api_key, allow_blank: true | 38 | + validates :name, :api_key, presence: true, uniqueness: { allow_blank: true } |
41 | validates_associated :watchers | 39 | validates_associated :watchers |
42 | validates_associated :notice_fingerprinter | 40 | validates_associated :notice_fingerprinter |
43 | validate :check_issue_tracker | 41 | validate :check_issue_tracker |
@@ -154,16 +152,17 @@ class App | @@ -154,16 +152,17 @@ class App | ||
154 | 152 | ||
155 | # Copy app attributes from another app. | 153 | # Copy app attributes from another app. |
156 | def copy_attributes_from(app_id) | 154 | def copy_attributes_from(app_id) |
157 | - if (copy_app = App.where(_id: app_id).first) | ||
158 | - # Copy fields | ||
159 | - (copy_app.fields.keys - %w(_id name created_at updated_at)).each do |k| | ||
160 | - send("#{k}=", copy_app.send(k)) | ||
161 | - end | ||
162 | - # Clone the embedded objects that can be changed via apps/edit (ignore errs & deploys, etc.) | ||
163 | - %w(watchers issue_tracker notification_service).each do |relation| | ||
164 | - if (obj = copy_app.send(relation)) | ||
165 | - send("#{relation}=", obj.is_a?(Array) ? obj.map(&:clone) : obj.clone) | ||
166 | - end | 155 | + copy_app = App.where(_id: app_id).first |
156 | + return if copy_app.blank? | ||
157 | + | ||
158 | + # Copy fields | ||
159 | + (copy_app.fields.keys - %w(_id name created_at updated_at)).each do |k| | ||
160 | + send("#{k}=", copy_app.send(k)) | ||
161 | + end | ||
162 | + # Clone the embedded objects that can be changed via apps/edit (ignore errs & deploys, etc.) | ||
163 | + %w(watchers issue_tracker notification_service).each do |relation| | ||
164 | + if (obj = copy_app.send(relation)) | ||
165 | + send("#{relation}=", obj.is_a?(Array) ? obj.map(&:clone) : obj.clone) | ||
167 | end | 166 | end |
168 | end | 167 | end |
169 | end | 168 | end |
@@ -179,8 +178,8 @@ class App | @@ -179,8 +178,8 @@ class App | ||
179 | # Compare by number of unresolved errs, then problem counts. | 178 | # Compare by number of unresolved errs, then problem counts. |
180 | def <=>(other) | 179 | def <=>(other) |
181 | (other.unresolved_count <=> unresolved_count).nonzero? || | 180 | (other.unresolved_count <=> unresolved_count).nonzero? || |
182 | - (other.problem_count <=> problem_count).nonzero? || | ||
183 | - name <=> other.name | 181 | + (other.problem_count <=> problem_count).nonzero? || |
182 | + name <=> other.name | ||
184 | end | 183 | end |
185 | 184 | ||
186 | def email_at_notices | 185 | def email_at_notices |
@@ -204,12 +203,12 @@ protected | @@ -204,12 +203,12 @@ protected | ||
204 | end | 203 | end |
205 | 204 | ||
206 | def check_issue_tracker | 205 | def check_issue_tracker |
207 | - if issue_tracker.present? | ||
208 | - issue_tracker.valid? | ||
209 | - issue_tracker.errors.full_messages.each do |error| | ||
210 | - errors[:base] << error | ||
211 | - end if issue_tracker.errors | ||
212 | - end | 206 | + return if issue_tracker.blank? |
207 | + | ||
208 | + issue_tracker.valid? | ||
209 | + issue_tracker.errors.full_messages.each do |error| | ||
210 | + errors[:base] << error | ||
211 | + end if issue_tracker.errors | ||
213 | end | 212 | end |
214 | 213 | ||
215 | def normalize_github_repo | 214 | def normalize_github_repo |
app/models/comment.rb
@@ -12,9 +12,10 @@ class Comment | @@ -12,9 +12,10 @@ class Comment | ||
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 | ||
16 | 15 | ||
17 | - validates_presence_of :body | 16 | + delegate :app, to: :err |
17 | + | ||
18 | + validates :body, presence: true | ||
18 | 19 | ||
19 | def deliver_email | 20 | def deliver_email |
20 | Mailer.comment_notification(self).deliver_now | 21 | Mailer.comment_notification(self).deliver_now |
app/models/deploy.rb
@@ -16,7 +16,7 @@ class Deploy | @@ -16,7 +16,7 @@ class Deploy | ||
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 | ||
19 | - validates_presence_of :username, :environment | 19 | + validates :username, :environment, presence: true |
20 | 20 | ||
21 | def resolve_app_errs | 21 | def resolve_app_errs |
22 | app.problems.unresolved.in_env(environment).each(&:resolve!) | 22 | app.problems.unresolved.in_env(environment).each(&:resolve!) |
app/models/err.rb
@@ -14,7 +14,7 @@ class Err | @@ -14,7 +14,7 @@ class Err | ||
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 :problem_id, :fingerprint, presence: true |
18 | 18 | ||
19 | delegate :app, :resolved?, to: :problem | 19 | delegate :app, :resolved?, to: :problem |
20 | end | 20 | end |
app/models/issue_tracker.rb
@@ -14,10 +14,12 @@ class IssueTracker | @@ -14,10 +14,12 @@ class IssueTracker | ||
14 | begin | 14 | begin |
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( | ||
18 | - github_repo: app.try(:github_repo), | ||
19 | - bitbucket_repo: app.try(:bitbucket_repo) | ||
20 | - )) | 17 | + klass.new( |
18 | + options.merge( | ||
19 | + github_repo: app.try(:github_repo), | ||
20 | + bitbucket_repo: app.try(:bitbucket_repo) | ||
21 | + ) | ||
22 | + ) | ||
21 | end | 23 | end |
22 | end | 24 | end |
23 | 25 |
app/models/notice.rb
@@ -24,7 +24,7 @@ class Notice | @@ -24,7 +24,7 @@ class Notice | ||
24 | before_save :sanitize | 24 | before_save :sanitize |
25 | before_destroy :problem_recache | 25 | before_destroy :problem_recache |
26 | 26 | ||
27 | - validates_presence_of :backtrace_id, :server_environment, :notifier | 27 | + validates :backtrace_id, :server_environment, :notifier, presence: true |
28 | 28 | ||
29 | scope :ordered, -> { order_by(:created_at.asc) } | 29 | scope :ordered, -> { order_by(:created_at.asc) } |
30 | scope :reverse_ordered, -> { order_by(:created_at.desc) } | 30 | scope :reverse_ordered, -> { order_by(:created_at.desc) } |
@@ -107,15 +107,11 @@ class Notice | @@ -107,15 +107,11 @@ class Notice | ||
107 | # TODO: Move on decorator maybe | 107 | # TODO: Move on decorator maybe |
108 | # | 108 | # |
109 | def project_root | 109 | def project_root |
110 | - if server_environment | ||
111 | - server_environment['project-root'] || '' | ||
112 | - end | 110 | + server_environment['project-root'] || '' if server_environment |
113 | end | 111 | end |
114 | 112 | ||
115 | def app_version | 113 | def app_version |
116 | - if server_environment | ||
117 | - server_environment['app-version'] || '' | ||
118 | - end | 114 | + server_environment['app-version'] || '' if server_environment |
119 | end | 115 | end |
120 | 116 | ||
121 | # filter memory addresses out of object strings | 117 | # filter memory addresses out of object strings |
app/models/notification_services/gtalk_service.rb
@@ -45,10 +45,10 @@ class NotificationServices::GtalkService < NotificationService | @@ -45,10 +45,10 @@ class NotificationServices::GtalkService < NotificationService | ||
45 | client.connect(service) | 45 | client.connect(service) |
46 | client.auth(api_token) | 46 | client.auth(api_token) |
47 | 47 | ||
48 | - #has to look like this to be formatted properly in the client | ||
49 | - message = """#{problem.app.name} | ||
50 | -#{Errbit::Config.protocol}://#{Errbit::Config.host}/apps/#{problem.app.id} | ||
51 | -#{notification_description problem}""" | 48 | + # has to look like this to be formatted properly in the client |
49 | + message = """#{problem.app.name}\n" \ | ||
50 | + "#{Errbit::Config.protocol}://#{Errbit::Config.host}/apps/#{problem.app.id}\n" \ | ||
51 | + "#{notification_description problem}""" | ||
52 | 52 | ||
53 | # post the issue to the xmpp room(s) | 53 | # post the issue to the xmpp room(s) |
54 | send_to_users(client, message) unless user_id.blank? | 54 | send_to_users(client, message) unless user_id.blank? |
@@ -66,7 +66,7 @@ private | @@ -66,7 +66,7 @@ private | ||
66 | end | 66 | end |
67 | 67 | ||
68 | def send_to_muc(client, message) | 68 | def send_to_muc(client, message) |
69 | - #TODO: set this so that it can send to multiple rooms like users, nb multiple room joins in one send fail randomly so leave as one room for the moment | 69 | + # TODO: set this so that it can send to multiple rooms like users, nb multiple room joins in one send fail randomly so leave as one room for the moment |
70 | muc = Jabber::MUC::SimpleMUCClient.new(client) | 70 | muc = Jabber::MUC::SimpleMUCClient.new(client) |
71 | muc.join(room_id + "/errbit") | 71 | muc.join(room_id + "/errbit") |
72 | muc.send(Jabber::Message.new(room_id, message)) | 72 | muc.send(Jabber::Message.new(room_id, message)) |
app/models/problem.rb
@@ -53,7 +53,8 @@ class Problem | @@ -53,7 +53,8 @@ class Problem | ||
53 | has_many :errs, inverse_of: :problem, dependent: :destroy | 53 | has_many :errs, inverse_of: :problem, dependent: :destroy |
54 | has_many :comments, inverse_of: :err, dependent: :destroy | 54 | has_many :comments, inverse_of: :err, dependent: :destroy |
55 | 55 | ||
56 | - validates_presence_of :environment | 56 | + validates :environment, presence: true |
57 | + validates :last_notice_at, :first_notice_at, presence: true | ||
57 | 58 | ||
58 | before_create :cache_app_attributes | 59 | before_create :cache_app_attributes |
59 | before_save :truncate_message | 60 | before_save :truncate_message |
@@ -63,8 +64,6 @@ class Problem | @@ -63,8 +64,6 @@ class Problem | ||
63 | scope :ordered, -> { order_by(:last_notice_at.desc) } | 64 | scope :ordered, -> { order_by(:last_notice_at.desc) } |
64 | scope :for_apps, ->(apps) { where(:app_id.in => apps.all.map(&:id)) } | 65 | scope :for_apps, ->(apps) { where(:app_id.in => apps.all.map(&:id)) } |
65 | 66 | ||
66 | - validates_presence_of :last_notice_at, :first_notice_at | ||
67 | - | ||
68 | def self.all_else_unresolved(fetch_all) | 67 | def self.all_else_unresolved(fetch_all) |
69 | if fetch_all | 68 | if fetch_all |
70 | all | 69 | all |
app/models/user.rb
@@ -38,12 +38,12 @@ class User | @@ -38,12 +38,12 @@ class User | ||
38 | 38 | ||
39 | before_save :ensure_authentication_token | 39 | before_save :ensure_authentication_token |
40 | 40 | ||
41 | - validates_presence_of :name | ||
42 | - validates_uniqueness_of :github_login, allow_nil: true | 41 | + validates :name, presence: true |
42 | + validates :github_login, uniqueness: { 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 |
46 | - validates_presence_of :username | 46 | + validates :username, presence: true |
47 | end | 47 | end |
48 | 48 | ||
49 | def per_page | 49 | def per_page |
@@ -67,9 +67,7 @@ class User | @@ -67,9 +67,7 @@ class User | ||
67 | end | 67 | end |
68 | 68 | ||
69 | def github_login=(login) | 69 | def github_login=(login) |
70 | - if login.is_a?(String) && login.strip.empty? | ||
71 | - login = nil | ||
72 | - end | 70 | + login = nil if login.is_a?(String) && login.strip.empty? |
73 | self[:github_login] = login | 71 | self[:github_login] = login |
74 | end | 72 | end |
75 | 73 |
config/application.rb
@@ -37,9 +37,9 @@ module Errbit | @@ -37,9 +37,9 @@ module Errbit | ||
37 | 37 | ||
38 | # > rails generate - config | 38 | # > rails generate - config |
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/load.rb
@@ -29,9 +29,9 @@ Errbit::Config = Configurator.run( | @@ -29,9 +29,9 @@ Errbit::Config = Configurator.run( | ||
29 | mongo_url: %w(MONGOLAB_URI MONGOHQ_URL MONGODB_URL MONGO_URL), | 29 | mongo_url: %w(MONGOLAB_URI MONGOHQ_URL MONGODB_URL MONGO_URL), |
30 | 30 | ||
31 | # github | 31 | # github |
32 | - github_url: ['GITHUB_URL', lambda { |values| | 32 | + github_url: ['GITHUB_URL', lambda do |values| |
33 | values[:github_url].gsub(%r{/*\z}, '') | 33 | values[:github_url].gsub(%r{/*\z}, '') |
34 | - }], | 34 | + end], |
35 | github_authentication: ['GITHUB_AUTHENTICATION'], | 35 | github_authentication: ['GITHUB_AUTHENTICATION'], |
36 | github_client_id: ['GITHUB_CLIENT_ID'], | 36 | github_client_id: ['GITHUB_CLIENT_ID'], |
37 | github_secret: ['GITHUB_SECRET'], | 37 | github_secret: ['GITHUB_SECRET'], |
@@ -40,9 +40,9 @@ Errbit::Config = Configurator.run( | @@ -40,9 +40,9 @@ Errbit::Config = Configurator.run( | ||
40 | github_api_url: ['GITHUB_API_URL'], | 40 | github_api_url: ['GITHUB_API_URL'], |
41 | github_site_title: ['GITHUB_SITE_TITLE'], | 41 | github_site_title: ['GITHUB_SITE_TITLE'], |
42 | 42 | ||
43 | - email_delivery_method: ['EMAIL_DELIVERY_METHOD', lambda { |values| | 43 | + email_delivery_method: ['EMAIL_DELIVERY_METHOD', lambda do |values| |
44 | values[:email_delivery_method] && values[:email_delivery_method].to_sym | 44 | values[:email_delivery_method] && values[:email_delivery_method].to_sym |
45 | - }], | 45 | + end], |
46 | 46 | ||
47 | # smtp settings | 47 | # smtp settings |
48 | smtp_address: ['SMTP_SERVER'], | 48 | smtp_address: ['SMTP_SERVER'], |
@@ -50,10 +50,10 @@ Errbit::Config = Configurator.run( | @@ -50,10 +50,10 @@ Errbit::Config = Configurator.run( | ||
50 | smtp_authentication: ['SMTP_AUTHENTICATION'], | 50 | smtp_authentication: ['SMTP_AUTHENTICATION'], |
51 | smtp_user_name: %w(SMTP_USERNAME SENDGRID_USERNAME), | 51 | smtp_user_name: %w(SMTP_USERNAME SENDGRID_USERNAME), |
52 | smtp_password: %w(SMTP_PASSWORD SENDGRID_PASSWORD), | 52 | smtp_password: %w(SMTP_PASSWORD SENDGRID_PASSWORD), |
53 | - smtp_domain: ['SMTP_DOMAIN', 'SENDGRID_DOMAIN', lambda { |values| | 53 | + smtp_domain: ['SMTP_DOMAIN', 'SENDGRID_DOMAIN', lambda do |values| |
54 | values[:smtp_domain] || | 54 | values[:smtp_domain] || |
55 | (values[:email_from] && values[:email_from].split('@').last) || nil | 55 | (values[:email_from] && values[:email_from].split('@').last) || nil |
56 | - }], | 56 | + end], |
57 | 57 | ||
58 | # sendmail settings | 58 | # sendmail settings |
59 | sendmail_location: ['SENDMAIL_LOCATION'], | 59 | sendmail_location: ['SENDMAIL_LOCATION'], |
docs/DEVELOPER-ADVANCED.md
@@ -15,7 +15,7 @@ gem install test-queue | @@ -15,7 +15,7 @@ gem install test-queue | ||
15 | After you just need launch the script with adapting runner of mongoid. | 15 | After you just need launch the script with adapting runner of mongoid. |
16 | 16 | ||
17 | ``` | 17 | ``` |
18 | -./script/rspec-queue-mongoid.rb spec | 18 | +./script/rspec_queue_mongoid.rb spec |
19 | ``` | 19 | ``` |
20 | 20 | ||
21 | In my case, the complete test suite down to 2min after a 16min long | 21 | In my case, the complete test suite down to 2min after a 16min long |
lib/hoptoad/v2.rb
@@ -22,11 +22,15 @@ module Hoptoad | @@ -22,11 +22,15 @@ module Hoptoad | ||
22 | elsif node.key?('key') | 22 | elsif node.key?('key') |
23 | { normalize_key(node['key']) => nil } | 23 | { normalize_key(node['key']) => nil } |
24 | else | 24 | else |
25 | - node.inject({}) { |rekeyed, (key, val)| rekeyed.merge(normalize_key(key) => rekey(val)) } | 25 | + node.inject({}) do |rekeyed, (key, val)| |
26 | + rekeyed.merge(normalize_key(key) => rekey(val)) | ||
27 | + end | ||
26 | end | 28 | end |
27 | when Array | 29 | when Array |
28 | if node.first.key?('key') | 30 | if node.first.key?('key') |
29 | - node.inject({}) { |rekeyed, keypair| rekeyed.merge(rekey(keypair)) } | 31 | + node.inject({}) do |rekeyed, keypair| |
32 | + rekeyed.merge(rekey(keypair)) | ||
33 | + end | ||
30 | else | 34 | else |
31 | node.map { |n| rekey(n) } | 35 | node.map { |n| rekey(n) } |
32 | end | 36 | end |
lib/overrides/hoptoad_notifier/hoptoad_notifier.rb
@@ -6,18 +6,18 @@ HoptoadNotifier.module_eval do | @@ -6,18 +6,18 @@ HoptoadNotifier.module_eval do | ||
6 | class << self | 6 | class << self |
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? | ||
10 | - app = App.find_or_initialize_by(name: "Self.Errbit") | ||
11 | - app.github_repo = "errbit/errbit" | ||
12 | - app.save! | ||
13 | - notice.send("api_key=", app.api_key) | 9 | + return unless configuration.public? |
14 | 10 | ||
15 | - # Create notice internally. | ||
16 | - report = ErrorReport.new(notice.to_xml) | ||
17 | - report.generate_notice! | 11 | + app = App.find_or_initialize_by(name: "Self.Errbit") |
12 | + app.github_repo = "errbit/errbit" | ||
13 | + app.save! | ||
14 | + notice.send("api_key=", app.api_key) | ||
18 | 15 | ||
19 | - logger.info "Internal error was logged to 'Self.Errbit' app." | ||
20 | - end | 16 | + # Create notice internally. |
17 | + report = ErrorReport.new(notice.to_xml) | ||
18 | + report.generate_notice! | ||
19 | + | ||
20 | + logger.info "Internal error was logged to 'Self.Errbit' app." | ||
21 | end | 21 | end |
22 | end | 22 | end |
23 | end | 23 | end |
lib/tasks/errbit/demo.rake
@@ -32,12 +32,13 @@ namespace :errbit do | @@ -32,12 +32,13 @@ namespace :errbit do | ||
32 | 32 | ||
33 | def random_backtrace | 33 | def random_backtrace |
34 | backtrace = [] | 34 | backtrace = [] |
35 | - 99.times {|t| | 35 | + 99.times do |t| |
36 | backtrace << { | 36 | backtrace << { |
37 | 'number' => t.hash % 1000, | 37 | 'number' => t.hash % 1000, |
38 | 'file' => "/path/to/file.rb", | 38 | 'file' => "/path/to/file.rb", |
39 | 'method' => RANDOM_METHODS.sample.to_s | 39 | 'method' => RANDOM_METHODS.sample.to_s |
40 | - }} | 40 | + } |
41 | + end | ||
41 | backtrace | 42 | backtrace |
42 | end | 43 | end |
43 | 44 |
script/rspec-queue-mongoid.rb
@@ -1,17 +0,0 @@ | @@ -1,17 +0,0 @@ | ||
1 | -#!/usr/bin/env ruby | ||
2 | -require 'rubygems' | ||
3 | -require 'test_queue' | ||
4 | -require 'bundler' | ||
5 | -Bundler.setup(:default, :development, :test) | ||
6 | -require 'test_queue/runner/rspec' | ||
7 | - | ||
8 | -class MongoidRspecRunner < TestQueue::Runner::RSpec | ||
9 | - def after_fork(num) | ||
10 | - super | ||
11 | - Mongoid.override_database( | ||
12 | - "#{Mongoid.session(:default).options[:database]}_#{num}" | ||
13 | - ) | ||
14 | - end | ||
15 | -end | ||
16 | - | ||
17 | -MongoidRspecRunner.new.execute |
@@ -0,0 +1,18 @@ | @@ -0,0 +1,18 @@ | ||
1 | +#!/usr/bin/env ruby | ||
2 | +require 'rubygems' | ||
3 | +require 'test_queue' | ||
4 | +require 'test_queue/runner/rspec' | ||
5 | + | ||
6 | +require 'bundler' | ||
7 | +Bundler.setup(:default, :development, :test) | ||
8 | + | ||
9 | +class MongoidRspecRunner < TestQueue::Runner::RSpec | ||
10 | + def after_fork(num) | ||
11 | + super | ||
12 | + Mongoid.override_database( | ||
13 | + "#{Mongoid.client(:default).options[:database]}_#{num}" | ||
14 | + ) | ||
15 | + end | ||
16 | +end | ||
17 | + | ||
18 | +MongoidRspecRunner.new.execute |
spec/acceptance/app_regenerate_api_key_spec.rb
@@ -3,9 +3,9 @@ require 'acceptance/acceptance_helper' | @@ -3,9 +3,9 @@ require 'acceptance/acceptance_helper' | ||
3 | feature "Regeneration api_Key" do | 3 | 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) do |
7 | Fabricate(:user_watcher, app: app).user | 7 | Fabricate(:user_watcher, app: app).user |
8 | - } | 8 | + end |
9 | 9 | ||
10 | before do | 10 | before do |
11 | app && admin | 11 | app && admin |
@@ -16,9 +16,9 @@ feature "Regeneration api_Key" do | @@ -16,9 +16,9 @@ feature "Regeneration api_Key" do | ||
16 | log_in admin | 16 | log_in admin |
17 | click_link app.name | 17 | click_link app.name |
18 | click_link I18n.t('apps.show.edit') | 18 | click_link I18n.t('apps.show.edit') |
19 | - expect { | 19 | + expect do |
20 | click_link I18n.t('apps.fields.regenerate_api_key') | 20 | click_link I18n.t('apps.fields.regenerate_api_key') |
21 | - }.to change { | 21 | + end.to change { |
22 | app.reload.api_key | 22 | app.reload.api_key |
23 | } | 23 | } |
24 | click_link I18n.t('shared.navigation.apps') | 24 | click_link I18n.t('shared.navigation.apps') |
@@ -36,9 +36,9 @@ end | @@ -36,9 +36,9 @@ end | ||
36 | 36 | ||
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) do |
40 | Fabricate(:user_watcher, app: app).user | 40 | Fabricate(:user_watcher, app: app).user |
41 | - } | 41 | + end |
42 | 42 | ||
43 | before do | 43 | before do |
44 | admin | 44 | admin |
spec/controllers/api/v1/notices_controller_spec.rb
@@ -14,7 +14,7 @@ describe Api::V1::NoticesController, type: 'controller' do | @@ -14,7 +14,7 @@ describe Api::V1::NoticesController, type: 'controller' do | ||
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 |
@@ -24,7 +24,7 @@ describe Api::V1::NoticesController, type: 'controller' do | @@ -24,7 +24,7 @@ describe Api::V1::NoticesController, type: 'controller' do | ||
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 |
spec/controllers/api/v1/problems_controller_spec.rb
@@ -13,7 +13,7 @@ describe Api::V1::ProblemsController, type: 'controller' do | @@ -13,7 +13,7 @@ describe Api::V1::ProblemsController, type: 'controller' do | ||
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 |
@@ -23,7 +23,7 @@ describe Api::V1::ProblemsController, type: 'controller' do | @@ -23,7 +23,7 @@ describe Api::V1::ProblemsController, type: 'controller' do | ||
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 |
@@ -67,7 +67,7 @@ describe Api::V1::ProblemsController, type: 'controller' do | @@ -67,7 +67,7 @@ describe Api::V1::ProblemsController, type: 'controller' do | ||
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 |
@@ -77,7 +77,7 @@ describe Api::V1::ProblemsController, type: 'controller' do | @@ -77,7 +77,7 @@ describe Api::V1::ProblemsController, type: 'controller' do | ||
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 |
spec/controllers/apps_controller_spec.rb
@@ -312,9 +312,9 @@ describe AppsController, type: 'controller' do | @@ -312,9 +312,9 @@ describe AppsController, type: 'controller' do | ||
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 do |
316 | @app.reload | 316 | @app.reload |
317 | - }.to raise_error(Mongoid::Errors::DocumentNotFound) | 317 | + end.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 |
spec/controllers/problems_controller_spec.rb
@@ -326,10 +326,10 @@ describe ProblemsController, type: 'controller' do | @@ -326,10 +326,10 @@ describe ProblemsController, type: 'controller' do | ||
326 | it "should unmerge a merged problem" do | 326 | it "should unmerge a merged problem" 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 do |
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 | + end.to change(Problem, :count).by(1) |
333 | end | 333 | end |
334 | end | 334 | end |
335 | 335 | ||
@@ -370,9 +370,9 @@ describe ProblemsController, type: 'controller' do | @@ -370,9 +370,9 @@ describe ProblemsController, type: 'controller' do | ||
370 | 370 | ||
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 do |
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 | + end.to change(Problem, :count).by(-1) |
376 | end | 376 | end |
377 | end | 377 | end |
378 | 378 | ||
@@ -385,9 +385,9 @@ describe ProblemsController, type: 'controller' do | @@ -385,9 +385,9 @@ describe ProblemsController, type: 'controller' do | ||
385 | end | 385 | end |
386 | 386 | ||
387 | it "destroys all problems" do | 387 | it "destroys all problems" do |
388 | - expect { | 388 | + expect do |
389 | post :destroy_all, app_id: @app.id | 389 | post :destroy_all, app_id: @app.id |
390 | - }.to change(Problem, :count).by(-2) | 390 | + end.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 |
spec/controllers/users_controller_spec.rb
@@ -56,9 +56,9 @@ describe UsersController, type: 'controller' do | @@ -56,9 +56,9 @@ describe UsersController, type: 'controller' do | ||
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 do |
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 | + end.to_not change { |
62 | user.reload.admin | 62 | user.reload.admin |
63 | }.from(false) | 63 | }.from(false) |
64 | end | 64 | end |
@@ -157,9 +157,9 @@ describe UsersController, type: 'controller' do | @@ -157,9 +157,9 @@ describe UsersController, type: 'controller' do | ||
157 | end | 157 | end |
158 | 158 | ||
159 | context "when the create is unsuccessful" do | 159 | context "when the create is unsuccessful" do |
160 | - let(:user) { | 160 | + let(:user) do |
161 | Struct.new(:admin, :attributes).new(true, {}) | 161 | Struct.new(:admin, :attributes).new(true, {}) |
162 | - } | 162 | + end |
163 | before do | 163 | before do |
164 | expect(User).to receive(:new).and_return(user) | 164 | expect(User).to receive(:new).and_return(user) |
165 | expect(user).to receive(:save).and_return(false) | 165 | expect(user).to receive(:save).and_return(false) |
@@ -174,9 +174,9 @@ describe UsersController, type: 'controller' do | @@ -174,9 +174,9 @@ describe UsersController, type: 'controller' do | ||
174 | 174 | ||
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 do |
178 | put :update, id: user.to_param, user: user_params | 178 | put :update, id: user.to_param, user: user_params |
179 | - } | 179 | + end |
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' } } |
@@ -198,10 +198,10 @@ describe UsersController, type: 'controller' do | @@ -198,10 +198,10 @@ describe UsersController, type: 'controller' 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 do |
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 | + end |
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) |
@@ -210,10 +210,10 @@ describe UsersController, type: 'controller' do | @@ -210,10 +210,10 @@ describe UsersController, type: 'controller' do | ||
210 | end | 210 | end |
211 | 211 | ||
212 | context "with trying destroy himself" do | 212 | context "with trying destroy himself" do |
213 | - before { | 213 | + before do |
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 | + end |
217 | 217 | ||
218 | it 'should not destroy user' do | 218 | it 'should not destroy user' do |
219 | expect(response).to redirect_to(users_path) | 219 | expect(response).to redirect_to(users_path) |
@@ -224,12 +224,12 @@ describe UsersController, type: 'controller' do | @@ -224,12 +224,12 @@ describe UsersController, type: 'controller' do | ||
224 | 224 | ||
225 | describe "#user_params" do | 225 | describe "#user_params" do |
226 | context "with current user not admin" do | 226 | context "with current user not admin" do |
227 | - before { | 227 | + before do |
228 | allow(controller).to receive(:current_user).and_return(user) | 228 | allow(controller).to receive(:current_user).and_return(user) |
229 | allow(controller).to receive(:params).and_return( | 229 | allow(controller).to receive(:params).and_return( |
230 | ActionController::Parameters.new(user_param) | 230 | ActionController::Parameters.new(user_param) |
231 | ) | 231 | ) |
232 | - } | 232 | + end |
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') |
spec/decorators/backtrace_decorator_spec.rb
1 | describe BacktraceDecorator, type: :decorator do | 1 | describe BacktraceDecorator, type: :decorator do |
2 | let(:backtrace) do | 2 | let(:backtrace) do |
3 | - described_class.new(Backtrace.new( | ||
4 | - lines: [ | ||
5 | - { number: 131, | ||
6 | - file: '[PROJECT_ROOT]app/controllers/accounts_controller.rb', | ||
7 | - method: :update_preferences }, | ||
8 | - { number: 61, | ||
9 | - file: '[PROJECT_ROOT]app/controllers/application_controller.rb', | ||
10 | - method: :call }, | ||
11 | - { number: 182, | ||
12 | - file: '[GEM_ROOT]activesupport-2.3.18/lib/active_support/callbacks.rb', | ||
13 | - method: :call }, | ||
14 | - { number: 384, | ||
15 | - file: '[PROJECT_ROOT]app/models/account.rb', | ||
16 | - method: :update_server_tag_scope }, | ||
17 | - { number: 182, | ||
18 | - file: '[GEM_ROOT]activesupport-2.3.18/lib/active_support/callbacks.rb', | ||
19 | - method: :evaluate_method }, | ||
20 | - { number: 23, | ||
21 | - file: '/home/rails/library/current/vendor/bundle/ruby/2.1.0/bin/rainbows', | ||
22 | - method: '<main>' } | ||
23 | - ] | ||
24 | - )) | 3 | + described_class.new( |
4 | + Backtrace.new( | ||
5 | + lines: [ | ||
6 | + { number: 131, | ||
7 | + file: '[PROJECT_ROOT]app/controllers/accounts_controller.rb', | ||
8 | + method: :update_preferences }, | ||
9 | + { number: 61, | ||
10 | + file: '[PROJECT_ROOT]app/controllers/application_controller.rb', | ||
11 | + method: :call }, | ||
12 | + { number: 182, | ||
13 | + file: '[GEM_ROOT]activesupport-2.3.18/lib/active_support/callbacks.rb', | ||
14 | + method: :call }, | ||
15 | + { number: 384, | ||
16 | + file: '[PROJECT_ROOT]app/models/account.rb', | ||
17 | + method: :update_server_tag_scope }, | ||
18 | + { number: 182, | ||
19 | + file: '[GEM_ROOT]activesupport-2.3.18/lib/active_support/callbacks.rb', | ||
20 | + method: :evaluate_method }, | ||
21 | + { number: 23, | ||
22 | + file: '/home/rails/library/current/vendor/bundle/ruby/2.1.0/bin/rainbows', | ||
23 | + method: '<main>' } | ||
24 | + ] | ||
25 | + ) | ||
26 | + ) | ||
25 | end | 27 | end |
26 | 28 | ||
27 | describe '#grouped_lines' do | 29 | describe '#grouped_lines' do |
spec/decorators/issue_tracker_decorator_spec.rb
1 | describe IssueTrackerDecorator do | 1 | describe IssueTrackerDecorator do |
2 | let(:fake_tracker) do | 2 | let(:fake_tracker) do |
3 | - klass = Class.new(ErrbitPlugin::IssueTracker) { | 3 | + klass = Class.new(ErrbitPlugin::IssueTracker) do |
4 | def self.label | 4 | def self.label |
5 | 'fake' | 5 | 'fake' |
6 | end | 6 | end |
@@ -19,7 +19,7 @@ describe IssueTrackerDecorator do | @@ -19,7 +19,7 @@ describe IssueTrackerDecorator do | ||
19 | def configured? | 19 | def configured? |
20 | true | 20 | true |
21 | end | 21 | end |
22 | - } | 22 | + end |
23 | klass.new 'nothing special' | 23 | klass.new 'nothing special' |
24 | end | 24 | end |
25 | 25 |
spec/decorators/issue_tracker_type_decorator_spec.rb
@@ -50,15 +50,21 @@ describe IssueTrackerDecorator do | @@ -50,15 +50,21 @@ describe IssueTrackerDecorator do | ||
50 | 50 | ||
51 | describe "#params_class" do | 51 | describe "#params_class" do |
52 | it 'adds the label in class' do | 52 | it 'adds the label in class' do |
53 | - tracker = IssueTrackerDecorator.new(IssueTracker.new( | ||
54 | - type_tracker: 'none')) | 53 | + tracker = IssueTrackerDecorator.new( |
54 | + IssueTracker.new(type_tracker: 'none') | ||
55 | + ) | ||
55 | expect(decorator.params_class(tracker)).to eql 'fake' | 56 | expect(decorator.params_class(tracker)).to eql 'fake' |
56 | end | 57 | end |
57 | 58 | ||
58 | it 'adds chosen class if type is same' do | 59 | it 'adds chosen class if type is same' do |
59 | - expect(decorator.params_class( | ||
60 | - IssueTracker.new(type_tracker: 'fake').decorate | ||
61 | - )).to eql 'chosen fake' | 60 | + expect( |
61 | + decorator. | ||
62 | + params_class( | ||
63 | + IssueTracker.new( | ||
64 | + type_tracker: 'fake' | ||
65 | + ).decorate | ||
66 | + ) | ||
67 | + ).to eql 'chosen fake' | ||
62 | end | 68 | end |
63 | end | 69 | end |
64 | end | 70 | end |
spec/fabricators/app_fabricator.rb
@@ -4,9 +4,9 @@ Fabricator(:app) do | @@ -4,9 +4,9 @@ Fabricator(:app) do | ||
4 | end | 4 | end |
5 | 5 | ||
6 | Fabricator(:app_with_watcher, from: :app) do | 6 | Fabricator(:app_with_watcher, from: :app) do |
7 | - watchers(count: 1) { |parent, _i| | 7 | + watchers(count: 1) do |parent, _i| |
8 | Fabricate.build(:watcher, app: parent) | 8 | Fabricate.build(:watcher, app: parent) |
9 | - } | 9 | + end |
10 | end | 10 | end |
11 | 11 | ||
12 | Fabricator(:watcher) do | 12 | Fabricator(:watcher) do |
@@ -22,8 +22,8 @@ end | @@ -22,8 +22,8 @@ end | ||
22 | 22 | ||
23 | Fabricator(:deploy) do | 23 | Fabricator(:deploy) do |
24 | app | 24 | app |
25 | - username 'clyde.frog' | ||
26 | - repository 'git@github.com/errbit/errbit.git' | ||
27 | - environment 'production' | ||
28 | - revision { SecureRandom.hex(10) } | 25 | + username 'clyde.frog' |
26 | + repository 'git@github.com/errbit/errbit.git' | ||
27 | + environment 'production' | ||
28 | + revision { SecureRandom.hex(10) } | ||
29 | end | 29 | end |
spec/fabricators/issue_tracker_fabricator.rb
spec/fabricators/notice_fabricator.rb
1 | Fabricator :notice do | 1 | Fabricator :notice do |
2 | app | 2 | app |
3 | err | 3 | err |
4 | - error_class 'FooError' | ||
5 | - message 'Too Much Bar' | 4 | + error_class 'FooError' |
5 | + message 'Too Much Bar' | ||
6 | backtrace | 6 | backtrace |
7 | server_environment { { 'environment-name' => 'production' } } | 7 | server_environment { { 'environment-name' => 'production' } } |
8 | request { { 'component' => 'foo', 'action' => 'bar' } } | 8 | request { { 'component' => 'foo', 'action' => 'bar' } } |
spec/fabricators/problem_fabricator.rb
@@ -6,19 +6,19 @@ Fabricator(:problem) do | @@ -6,19 +6,19 @@ Fabricator(:problem) do | ||
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 do |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 | + end |
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 do |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 | + end |
22 | end | 22 | end |
23 | 23 | ||
24 | Fabricator(:problem_resolved, from: :problem) do | 24 | Fabricator(:problem_resolved, from: :problem) do |
spec/fabricators/user_fabricator.rb
1 | Fabricator :user do | 1 | Fabricator :user do |
2 | - name 'Clyde Frog' | ||
3 | - email { sequence(:user_email) { |n| "user.#{n}@example.com" } } | ||
4 | - password 'password' | 2 | + name 'Clyde Frog' |
3 | + email { sequence(:user_email) { |n| "user.#{n}@example.com" } } | ||
4 | + password 'password' | ||
5 | password_confirmation 'password' | 5 | password_confirmation 'password' |
6 | end | 6 | end |
7 | 7 |
spec/interactors/problem_destroy_spec.rb
1 | describe ProblemDestroy do | 1 | describe ProblemDestroy do |
2 | - let(:problem_destroy) { | 2 | + let(:problem_destroy) do |
3 | ProblemDestroy.new(problem) | 3 | ProblemDestroy.new(problem) |
4 | - } | 4 | + end |
5 | 5 | ||
6 | context "in unit way" do | 6 | context "in unit way" do |
7 | - let(:problem) { | 7 | + let(:problem) do |
8 | problem = Problem.new | 8 | problem = Problem.new |
9 | allow(problem).to receive(:errs).and_return(double(:criteria, only: [err_1, err_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])) | 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 | + end |
14 | let(:err_1) { Err.new } | 14 | let(:err_1) { Err.new } |
15 | let(:err_2) { Err.new } | 15 | let(:err_2) { Err.new } |
16 | 16 |
spec/interactors/problem_merge_spec.rb
@@ -4,9 +4,9 @@ describe ProblemMerge do | @@ -4,9 +4,9 @@ describe ProblemMerge do | ||
4 | 4 | ||
5 | describe "#initialize" do | 5 | describe "#initialize" do |
6 | it 'failed if less than 2 uniq problem pass in args' do | 6 | it 'failed if less than 2 uniq problem pass in args' do |
7 | - expect { | 7 | + expect do |
8 | ProblemMerge.new(problem) | 8 | ProblemMerge.new(problem) |
9 | - }.to raise_error(ArgumentError) | 9 | + end.to raise_error(ArgumentError) |
10 | end | 10 | end |
11 | 11 | ||
12 | it 'extract first problem like merged_problem' do | 12 | it 'extract first problem like merged_problem' do |
@@ -20,18 +20,18 @@ describe ProblemMerge do | @@ -20,18 +20,18 @@ describe ProblemMerge do | ||
20 | end | 20 | end |
21 | 21 | ||
22 | describe "#merge" do | 22 | describe "#merge" do |
23 | - let!(:problem_merge) { | 23 | + let!(:problem_merge) do |
24 | ProblemMerge.new(problem, problem_1) | 24 | ProblemMerge.new(problem, problem_1) |
25 | - } | 25 | + end |
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) } | 28 | let!(:notice) { Fabricate(:notice, err: first_errs.first) } |
29 | let!(:notice_1) { Fabricate(:notice, err: merged_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 do |
33 | problem_merge.merge | 33 | problem_merge.merge |
34 | - }.to change(Problem, :count).by(-1) | 34 | + end.to change(Problem, :count).by(-1) |
35 | end | 35 | end |
36 | 36 | ||
37 | it 'move all err in one problem' do | 37 | it 'move all err in one problem' do |
@@ -55,9 +55,9 @@ describe ProblemMerge do | @@ -55,9 +55,9 @@ describe ProblemMerge do | ||
55 | let!(:comment) { Fabricate(:comment, err: problem) } | 55 | let!(:comment) { Fabricate(:comment, err: problem) } |
56 | let!(:comment_2) { Fabricate(:comment, err: problem_1, user: comment.user) } | 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 do |
59 | problem_merge.merge | 59 | problem_merge.merge |
60 | - }.to change { | 60 | + end.to change { |
61 | problem.comments.size | 61 | problem.comments.size |
62 | }.from(1).to(2) | 62 | }.from(1).to(2) |
63 | expect(comment_2.reload.err).to eq problem | 63 | expect(comment_2.reload.err).to eq problem |
spec/interactors/resolved_problem_clearer_spec.rb
1 | describe ResolvedProblemClearer do | 1 | describe ResolvedProblemClearer do |
2 | - let(:resolved_problem_clearer) { | 2 | + let(:resolved_problem_clearer) do |
3 | ResolvedProblemClearer.new | 3 | ResolvedProblemClearer.new |
4 | - } | 4 | + end |
5 | describe "#execute" do | 5 | describe "#execute" do |
6 | - let!(:problems) { | 6 | + let!(:problems) do |
7 | [ | 7 | [ |
8 | Fabricate(:problem), | 8 | Fabricate(:problem), |
9 | Fabricate(:problem), | 9 | Fabricate(:problem), |
10 | Fabricate(:problem) | 10 | Fabricate(:problem) |
11 | ] | 11 | ] |
12 | - } | 12 | + end |
13 | context 'without problem resolved' do | 13 | context 'without problem resolved' do |
14 | it 'do nothing' do | 14 | it 'do nothing' do |
15 | - expect { | 15 | + expect do |
16 | expect(resolved_problem_clearer.execute).to eq 0 | 16 | expect(resolved_problem_clearer.execute).to eq 0 |
17 | - }.to_not change { | 17 | + end.to_not change { |
18 | Problem.count | 18 | Problem.count |
19 | } | 19 | } |
20 | end | 20 | end |
@@ -34,9 +34,9 @@ describe ResolvedProblemClearer do | @@ -34,9 +34,9 @@ describe ResolvedProblemClearer do | ||
34 | end | 34 | end |
35 | 35 | ||
36 | it 'delete problem resolve' do | 36 | it 'delete problem resolve' do |
37 | - expect { | 37 | + expect do |
38 | expect(resolved_problem_clearer.execute).to eq 2 | 38 | expect(resolved_problem_clearer.execute).to eq 2 |
39 | - }.to change { | 39 | + end.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 | 42 | expect(Problem.where(_id: problems.first.id).first).to be_nil |
spec/interactors/user_destroy_spec.rb
1 | describe UserDestroy do | 1 | describe UserDestroy do |
2 | - let(:app) { | 2 | + let(:app) do |
3 | Fabricate( | 3 | Fabricate( |
4 | :app, | 4 | :app, |
5 | watchers: [ | 5 | watchers: [ |
6 | Fabricate.build(:user_watcher, user: user) | 6 | Fabricate.build(:user_watcher, user: user) |
7 | ]) | 7 | ]) |
8 | - } | 8 | + end |
9 | 9 | ||
10 | describe "#destroy" do | 10 | describe "#destroy" do |
11 | let!(:user) { Fabricate(:user) } | 11 | let!(:user) { Fabricate(:user) } |
12 | it 'should delete user' do | 12 | it 'should delete user' do |
13 | - expect { | 13 | + expect do |
14 | UserDestroy.new(user).destroy | 14 | UserDestroy.new(user).destroy |
15 | - }.to change(User, :count) | 15 | + end.to change(User, :count) |
16 | end | 16 | end |
17 | 17 | ||
18 | it 'should delete watcher' do | 18 | it 'should delete watcher' do |
19 | - expect { | 19 | + expect do |
20 | UserDestroy.new(user).destroy | 20 | UserDestroy.new(user).destroy |
21 | - }.to change { | 21 | + end.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 |
spec/lib/airbrake_api/v3/notice_parser_spec.rb
@@ -2,13 +2,13 @@ describe AirbrakeApi::V3::NoticeParser do | @@ -2,13 +2,13 @@ describe AirbrakeApi::V3::NoticeParser do | ||
2 | let(:app) { Fabricate(:app) } | 2 | let(:app) { Fabricate(:app) } |
3 | 3 | ||
4 | it 'raises error when errors attribute is missing' do | 4 | it 'raises error when errors attribute is missing' do |
5 | - expect { | 5 | + expect do |
6 | AirbrakeApi::V3::NoticeParser.new({}).report | 6 | AirbrakeApi::V3::NoticeParser.new({}).report |
7 | - }.to raise_error(AirbrakeApi::ParamsError) | 7 | + end.to raise_error(AirbrakeApi::ParamsError) |
8 | 8 | ||
9 | - expect { | 9 | + expect do |
10 | AirbrakeApi::V3::NoticeParser.new('errors' => []).report | 10 | AirbrakeApi::V3::NoticeParser.new('errors' => []).report |
11 | - }.to raise_error(AirbrakeApi::ParamsError) | 11 | + end.to raise_error(AirbrakeApi::ParamsError) |
12 | end | 12 | end |
13 | 13 | ||
14 | it 'parses JSON payload and returns ErrorReport' do | 14 | it 'parses JSON payload and returns ErrorReport' do |
spec/models/app_spec.rb
@@ -164,13 +164,13 @@ describe App, type: 'model' do | @@ -164,13 +164,13 @@ describe App, type: 'model' do | ||
164 | 164 | ||
165 | context '#find_or_create_err!' do | 165 | context '#find_or_create_err!' do |
166 | let(:app) { Fabricate(:app) } | 166 | let(:app) { Fabricate(:app) } |
167 | - let(:conditions) { | 167 | + let(:conditions) do |
168 | { | 168 | { |
169 | error_class: 'Whoops', | 169 | error_class: 'Whoops', |
170 | environment: 'production', | 170 | environment: 'production', |
171 | fingerprint: 'some-finger-print' | 171 | fingerprint: 'some-finger-print' |
172 | } | 172 | } |
173 | - } | 173 | + end |
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( | 176 | existing = Fabricate( |
@@ -188,23 +188,23 @@ describe App, type: 'model' do | @@ -188,23 +188,23 @@ describe App, type: 'model' do | ||
188 | 188 | ||
189 | it 'creates a new problem if a matching one does not already exist' do | 189 | it 'creates a new problem if a matching one does not already exist' do |
190 | expect(Err.where(conditions).first).to be_nil | 190 | expect(Err.where(conditions).first).to be_nil |
191 | - expect { | 191 | + expect do |
192 | app.find_or_create_err!(conditions) | 192 | app.find_or_create_err!(conditions) |
193 | - }.to change(Problem, :count).by(1) | 193 | + end.to change(Problem, :count).by(1) |
194 | end | 194 | end |
195 | 195 | ||
196 | context "without error_class" do | 196 | context "without error_class" do |
197 | - let(:conditions) { | 197 | + let(:conditions) do |
198 | { | 198 | { |
199 | environment: 'production', | 199 | environment: 'production', |
200 | fingerprint: 'some-finger-print' | 200 | fingerprint: 'some-finger-print' |
201 | } | 201 | } |
202 | - } | 202 | + end |
203 | it 'save the err' do | 203 | it 'save the err' do |
204 | expect(Err.where(conditions).first).to be_nil | 204 | expect(Err.where(conditions).first).to be_nil |
205 | - expect { | 205 | + expect do |
206 | app.find_or_create_err!(conditions) | 206 | app.find_or_create_err!(conditions) |
207 | - }.to change(Problem, :count).by(1) | 207 | + end.to change(Problem, :count).by(1) |
208 | end | 208 | end |
209 | end | 209 | end |
210 | end | 210 | end |
@@ -215,9 +215,9 @@ describe App, type: 'model' do | @@ -215,9 +215,9 @@ describe App, type: 'model' do | ||
215 | expect(App.find_by_api_key!(app.api_key)).to eq app | 215 | expect(App.find_by_api_key!(app.api_key)).to eq app |
216 | end | 216 | end |
217 | it 'raise Mongoid::Errors::DocumentNotFound if not found' do | 217 | it 'raise Mongoid::Errors::DocumentNotFound if not found' do |
218 | - expect { | 218 | + expect do |
219 | App.find_by_api_key!('foo') | 219 | App.find_by_api_key!('foo') |
220 | - }.to raise_error(Mongoid::Errors::DocumentNotFound) | 220 | + end.to raise_error(Mongoid::Errors::DocumentNotFound) |
221 | end | 221 | end |
222 | end | 222 | end |
223 | end | 223 | end |
spec/models/error_report_spec.rb
@@ -17,18 +17,18 @@ module Airbrake | @@ -17,18 +17,18 @@ module Airbrake | ||
17 | end | 17 | end |
18 | 18 | ||
19 | describe ErrorReport do | 19 | describe ErrorReport do |
20 | - let(:xml) { | 20 | + let(:xml) do |
21 | Rails.root.join('spec', 'fixtures', 'hoptoad_test_notice.xml').read | 21 | Rails.root.join('spec', 'fixtures', 'hoptoad_test_notice.xml').read |
22 | - } | 22 | + end |
23 | 23 | ||
24 | let(:error_report) { ErrorReport.new(xml) } | 24 | let(:error_report) { ErrorReport.new(xml) } |
25 | 25 | ||
26 | - let!(:app) { | 26 | + let!(:app) do |
27 | Fabricate( | 27 | Fabricate( |
28 | :app, | 28 | :app, |
29 | api_key: 'APIKEY' | 29 | api_key: 'APIKEY' |
30 | ) | 30 | ) |
31 | - } | 31 | + end |
32 | 32 | ||
33 | describe "#app" do | 33 | describe "#app" do |
34 | it 'find the good app' do | 34 | it 'find the good app' do |
@@ -44,39 +44,39 @@ describe ErrorReport do | @@ -44,39 +44,39 @@ describe ErrorReport do | ||
44 | 44 | ||
45 | describe "#generate_notice!" do | 45 | describe "#generate_notice!" do |
46 | it "save a notice" do | 46 | it "save a notice" do |
47 | - expect { | 47 | + expect do |
48 | error_report.generate_notice! | 48 | error_report.generate_notice! |
49 | - }.to change { | 49 | + end.to change { |
50 | app.reload.problems.count | 50 | app.reload.problems.count |
51 | }.by(1) | 51 | }.by(1) |
52 | end | 52 | end |
53 | 53 | ||
54 | context "with a minimal notice" do | 54 | context "with a minimal notice" do |
55 | - let(:xml) { | 55 | + let(:xml) do |
56 | Rails.root.join('spec', 'fixtures', 'minimal_test_notice.xml').read | 56 | Rails.root.join('spec', 'fixtures', 'minimal_test_notice.xml').read |
57 | - } | 57 | + end |
58 | 58 | ||
59 | it 'save a notice' do | 59 | it 'save a notice' do |
60 | - expect { | 60 | + expect do |
61 | error_report.generate_notice! | 61 | error_report.generate_notice! |
62 | - }.to change { | 62 | + end.to change { |
63 | app.reload.problems.count | 63 | app.reload.problems.count |
64 | }.by(1) | 64 | }.by(1) |
65 | end | 65 | end |
66 | end | 66 | end |
67 | 67 | ||
68 | context "with notice generate by Airbrake gem" do | 68 | context "with notice generate by Airbrake gem" do |
69 | - let(:xml) { | 69 | + let(:xml) do |
70 | Airbrake::Notice.new( | 70 | Airbrake::Notice.new( |
71 | exception: Exception.new, | 71 | exception: Exception.new, |
72 | api_key: 'APIKEY', | 72 | api_key: 'APIKEY', |
73 | project_root: Rails.root | 73 | project_root: Rails.root |
74 | ).to_xml | 74 | ).to_xml |
75 | - } | 75 | + end |
76 | it 'save a notice' do | 76 | it 'save a notice' do |
77 | - expect { | 77 | + expect do |
78 | error_report.generate_notice! | 78 | error_report.generate_notice! |
79 | - }.to change { | 79 | + end.to change { |
80 | app.reload.problems.count | 80 | app.reload.problems.count |
81 | }.by(1) | 81 | }.by(1) |
82 | end | 82 | end |
@@ -201,10 +201,10 @@ describe ErrorReport do | @@ -201,10 +201,10 @@ describe ErrorReport do | ||
201 | end | 201 | end |
202 | 202 | ||
203 | it 'memoize the notice' do | 203 | it 'memoize the notice' do |
204 | - expect { | 204 | + expect do |
205 | error_report.generate_notice! | 205 | error_report.generate_notice! |
206 | error_report.generate_notice! | 206 | error_report.generate_notice! |
207 | - }.to change { | 207 | + end.to change { |
208 | Notice.count | 208 | Notice.count |
209 | }.by(1) | 209 | }.by(1) |
210 | end | 210 | end |
@@ -213,9 +213,9 @@ describe ErrorReport do | @@ -213,9 +213,9 @@ describe ErrorReport do | ||
213 | error_report.generate_notice! | 213 | error_report.generate_notice! |
214 | error_report.problem.resolve! | 214 | error_report.problem.resolve! |
215 | 215 | ||
216 | - expect { | 216 | + expect do |
217 | ErrorReport.new(xml).generate_notice! | 217 | ErrorReport.new(xml).generate_notice! |
218 | - }.to change { | 218 | + end.to change { |
219 | error_report.problem.reload.resolved? | 219 | error_report.problem.reload.resolved? |
220 | }.from(true).to(false) | 220 | }.from(true).to(false) |
221 | end | 221 | end |
@@ -237,26 +237,26 @@ describe ErrorReport do | @@ -237,26 +237,26 @@ describe ErrorReport do | ||
237 | end | 237 | end |
238 | 238 | ||
239 | context "with xml without request section" do | 239 | context "with xml without request section" do |
240 | - let(:xml) { | 240 | + let(:xml) do |
241 | Rails.root.join('spec', 'fixtures', 'hoptoad_test_notice_without_request_section.xml').read | 241 | Rails.root.join('spec', 'fixtures', 'hoptoad_test_notice_without_request_section.xml').read |
242 | - } | 242 | + end |
243 | it "save a notice" do | 243 | it "save a notice" do |
244 | - expect { | 244 | + expect do |
245 | error_report.generate_notice! | 245 | error_report.generate_notice! |
246 | - }.to change { | 246 | + end.to change { |
247 | app.reload.problems.count | 247 | app.reload.problems.count |
248 | }.by(1) | 248 | }.by(1) |
249 | end | 249 | end |
250 | end | 250 | end |
251 | 251 | ||
252 | context "with xml with only a single line of backtrace" do | 252 | context "with xml with only a single line of backtrace" do |
253 | - let(:xml) { | 253 | + let(:xml) do |
254 | Rails.root.join('spec', 'fixtures', 'hoptoad_test_notice_with_one_line_of_backtrace.xml').read | 254 | Rails.root.join('spec', 'fixtures', 'hoptoad_test_notice_with_one_line_of_backtrace.xml').read |
255 | - } | 255 | + end |
256 | it "save a notice" do | 256 | it "save a notice" do |
257 | - expect { | 257 | + expect do |
258 | error_report.generate_notice! | 258 | error_report.generate_notice! |
259 | - }.to change { | 259 | + end.to change { |
260 | app.reload.problems.count | 260 | app.reload.problems.count |
261 | }.by(1) | 261 | }.by(1) |
262 | end | 262 | end |
spec/models/fabricators_spec.rb
@@ -5,7 +5,7 @@ Fabrication::Config.fabricator_path.each do |folder| | @@ -5,7 +5,7 @@ Fabrication::Config.fabricator_path.each do |folder| | ||
5 | end | 5 | end |
6 | 6 | ||
7 | describe "Fabrication" do | 7 | describe "Fabrication" do |
8 | - #TODO : when 1.8.7 drop support se directly Symbol#sort | 8 | + # TODO : when 1.8.7 drop support se directly Symbol#sort |
9 | Fabrication.manager.schematics.keys.sort.each do |fabricator_name| | 9 | Fabrication.manager.schematics.keys.sort.each do |fabricator_name| |
10 | context "Fabricate(:#{fabricator_name})" do | 10 | context "Fabricate(:#{fabricator_name})" do |
11 | subject { Fabricate.build(fabricator_name) } | 11 | subject { Fabricate.build(fabricator_name) } |
spec/models/notification_service/campfire_service_spec.rb
@@ -5,12 +5,12 @@ describe NotificationServices::CampfireService, type: 'model' do | @@ -5,12 +5,12 @@ describe NotificationServices::CampfireService, type: 'model' do | ||
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 |
9 | campy = double('CampfireService') | 9 | campy = double('CampfireService') |
10 | allow(Campy::Room).to receive(:new).and_return(campy) | 10 | allow(Campy::Room).to receive(:new).and_return(campy) |
11 | allow(campy).to receive(:speak).and_return(true) | 11 | allow(campy).to receive(:speak).and_return(true) |
12 | 12 | ||
13 | - #assert | 13 | + # assert |
14 | expect(campy).to receive(:speak) | 14 | expect(campy).to receive(:speak) |
15 | 15 | ||
16 | notification_service.create_notification(problem) | 16 | notification_service.create_notification(problem) |
spec/models/notification_service/gtalk_service_spec.rb
@@ -6,7 +6,7 @@ describe NotificationServices::GtalkService, type: 'model' do | @@ -6,7 +6,7 @@ describe NotificationServices::GtalkService, type: 'model' do | ||
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 |
10 | gtalk = double('GtalkService') | 10 | gtalk = double('GtalkService') |
11 | jid = double("jid") | 11 | jid = double("jid") |
12 | message = double("message") | 12 | message = double("message") |
@@ -24,7 +24,7 @@ describe NotificationServices::GtalkService, type: 'model' do | @@ -24,7 +24,7 @@ describe NotificationServices::GtalkService, type: 'model' do | ||
24 | expect(Jabber::MUC::SimpleMUCClient).to receive(:new).and_return(gtalk) | 24 | expect(Jabber::MUC::SimpleMUCClient).to receive(:new).and_return(gtalk) |
25 | expect(gtalk).to receive(:join).with(notification_service.room_id + "/errbit") | 25 | expect(gtalk).to receive(:join).with(notification_service.room_id + "/errbit") |
26 | 26 | ||
27 | - #assert | 27 | + # assert |
28 | expect(gtalk).to receive(:send).exactly(2).times.with(message) | 28 | expect(gtalk).to receive(:send).exactly(2).times.with(message) |
29 | expect(gtalk).to receive(:close) | 29 | expect(gtalk).to receive(:close) |
30 | 30 | ||
@@ -97,7 +97,7 @@ describe NotificationServices::GtalkService, type: 'model' do | @@ -97,7 +97,7 @@ describe NotificationServices::GtalkService, type: 'model' do | ||
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 |
101 | gtalk = double('GtalkService') | 101 | gtalk = double('GtalkService') |
102 | jid = double("jid") | 102 | jid = double("jid") |
103 | message = double("message") | 103 | message = double("message") |
@@ -116,7 +116,7 @@ describe NotificationServices::GtalkService, type: 'model' do | @@ -116,7 +116,7 @@ describe NotificationServices::GtalkService, type: 'model' do | ||
116 | 116 | ||
117 | notification_service.user_id = "" | 117 | notification_service.user_id = "" |
118 | 118 | ||
119 | - #assert | 119 | + # assert |
120 | expect(gtalk).to receive(:send).with(message) | 120 | expect(gtalk).to receive(:send).with(message) |
121 | expect(gtalk).to receive(:close) | 121 | expect(gtalk).to receive(:close) |
122 | 122 |
spec/models/notification_service/hoiio_service_spec.rb
@@ -10,7 +10,7 @@ describe NotificationServices::HoiioService, type: 'model' do | @@ -10,7 +10,7 @@ describe NotificationServices::HoiioService, type: 'model' do | ||
10 | allow(Hoi::SMS).to receive(:new).and_return(sms) | 10 | allow(Hoi::SMS).to receive(:new).and_return(sms) |
11 | allow(sms).to receive(:send).and_return(true) | 11 | allow(sms).to receive(:send).and_return(true) |
12 | 12 | ||
13 | - #assert | 13 | + # assert |
14 | expect(sms).to receive(:send) | 14 | expect(sms).to receive(:send) |
15 | 15 | ||
16 | notification_service.create_notification(problem) | 16 | notification_service.create_notification(problem) |
spec/models/notification_service/pushover_service_spec.rb
@@ -10,7 +10,7 @@ describe NotificationServices::PushoverService, type: 'model' do | @@ -10,7 +10,7 @@ describe NotificationServices::PushoverService, type: 'model' do | ||
10 | allow(Rushover::Client).to receive(:new).and_return(notification) | 10 | allow(Rushover::Client).to receive(:new).and_return(notification) |
11 | allow(notification).to receive(:notify).and_return(true) | 11 | allow(notification).to receive(:notify).and_return(true) |
12 | 12 | ||
13 | - #assert | 13 | + # assert |
14 | expect(notification).to receive(:notify) | 14 | expect(notification).to receive(:notify) |
15 | 15 | ||
16 | notification_service.create_notification(problem) | 16 | notification_service.create_notification(problem) |
spec/models/problem_spec.rb
@@ -10,25 +10,25 @@ describe Problem, type: 'model' do | @@ -10,25 +10,25 @@ describe Problem, type: 'model' do | ||
10 | describe "Fabrication" do | 10 | describe "Fabrication" do |
11 | context "Fabricate(:problem)" do | 11 | context "Fabricate(:problem)" do |
12 | it 'should have no comment' do | 12 | it 'should have no comment' do |
13 | - expect { | 13 | + expect do |
14 | Fabricate(:problem) | 14 | Fabricate(:problem) |
15 | - }.to_not change(Comment, :count) | 15 | + end.to_not change(Comment, :count) |
16 | end | 16 | end |
17 | end | 17 | end |
18 | 18 | ||
19 | context "Fabricate(:problem_with_comments)" do | 19 | context "Fabricate(:problem_with_comments)" do |
20 | it 'should have 3 comments' do | 20 | it 'should have 3 comments' do |
21 | - expect { | 21 | + expect do |
22 | Fabricate(:problem_with_comments) | 22 | Fabricate(:problem_with_comments) |
23 | - }.to change(Comment, :count).by(3) | 23 | + end.to change(Comment, :count).by(3) |
24 | end | 24 | end |
25 | end | 25 | end |
26 | 26 | ||
27 | context "Fabricate(:problem_with_errs)" do | 27 | context "Fabricate(:problem_with_errs)" do |
28 | it 'should have 3 errs' do | 28 | it 'should have 3 errs' do |
29 | - expect { | 29 | + expect do |
30 | Fabricate(:problem_with_errs) | 30 | Fabricate(:problem_with_errs) |
31 | - }.to change(Err, :count).by(3) | 31 | + end.to change(Err, :count).by(3) |
32 | end | 32 | end |
33 | end | 33 | end |
34 | end | 34 | end |
@@ -65,9 +65,9 @@ describe Problem, type: 'model' do | @@ -65,9 +65,9 @@ describe Problem, type: 'model' do | ||
65 | it "adding a notice caches its message" do | 65 | it "adding a notice caches its message" do |
66 | err = Fabricate(:err) | 66 | err = Fabricate(:err) |
67 | problem = err.problem | 67 | problem = err.problem |
68 | - expect { | 68 | + expect do |
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 | + end.to change(problem, :message).from(nil).to('ERR 1') |
71 | end | 71 | end |
72 | end | 72 | end |
73 | 73 | ||
@@ -132,9 +132,9 @@ describe Problem, type: 'model' do | @@ -132,9 +132,9 @@ describe Problem, type: 'model' do | ||
132 | er.add_on_blank(:resolved) | 132 | er.add_on_blank(:resolved) |
133 | allow(problem).to receive(:errors).and_return(er) | 133 | allow(problem).to receive(:errors).and_return(er) |
134 | expect(problem).to_not be_valid | 134 | expect(problem).to_not be_valid |
135 | - expect { | 135 | + expect do |
136 | problem.resolve! | 136 | problem.resolve! |
137 | - }.to raise_error(Mongoid::Errors::Validations) | 137 | + end.to raise_error(Mongoid::Errors::Validations) |
138 | end | 138 | end |
139 | end | 139 | end |
140 | 140 | ||
@@ -201,17 +201,17 @@ describe Problem, type: 'model' do | @@ -201,17 +201,17 @@ describe Problem, type: 'model' do | ||
201 | end | 201 | end |
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 do |
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 | + end.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 do |
212 | @err.notices.first.destroy | 212 | @err.notices.first.destroy |
213 | @problem.reload | 213 | @problem.reload |
214 | - }.to change(@problem, :notices_count).from(1).to(0) | 214 | + end.to change(@problem, :notices_count).from(1).to(0) |
215 | end | 215 | end |
216 | end | 216 | end |
217 | 217 | ||
@@ -226,10 +226,10 @@ describe Problem, type: 'model' do | @@ -226,10 +226,10 @@ describe Problem, type: 'model' do | ||
226 | end | 226 | end |
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 do |
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 | + end.to change(problem, :app_name).to("Bar App") |
233 | end | 233 | end |
234 | end | 234 | end |
235 | 235 | ||
@@ -248,10 +248,10 @@ describe Problem, type: 'model' do | @@ -248,10 +248,10 @@ describe Problem, type: 'model' do | ||
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 do |
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 | + end.to change { problem.last_deploy_at.iso8601 }. |
255 | from(@last_deploy.iso8601). | 255 | from(@last_deploy.iso8601). |
256 | to(next_deploy.iso8601) | 256 | to(next_deploy.iso8601) |
257 | end | 257 | end |
@@ -270,10 +270,10 @@ describe Problem, type: 'model' do | @@ -270,10 +270,10 @@ describe Problem, type: 'model' do | ||
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 do |
274 | @err.notices.first.destroy | 274 | @err.notices.first.destroy |
275 | @problem.reload | 275 | @problem.reload |
276 | - }.to change(@problem, :messages).from(Digest::MD5.hexdigest('ERR 1') => { 'value' => 'ERR 1', 'count' => 1 }).to({}) | 276 | + end.to change(@problem, :messages).from(Digest::MD5.hexdigest('ERR 1') => { 'value' => 'ERR 1', 'count' => 1 }).to({}) |
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 |
@@ -297,10 +297,10 @@ describe Problem, type: 'model' do | @@ -297,10 +297,10 @@ describe Problem, type: 'model' do | ||
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 do |
301 | @err.notices.first.destroy | 301 | @err.notices.first.destroy |
302 | @problem.reload | 302 | @problem.reload |
303 | - }.to change(@problem, :hosts).from(Digest::MD5.hexdigest('example.com') => { 'value' => 'example.com', 'count' => 1 }).to({}) | 303 | + end.to change(@problem, :hosts).from(Digest::MD5.hexdigest('example.com') => { 'value' => 'example.com', 'count' => 1 }).to({}) |
304 | end | 304 | end |
305 | end | 305 | end |
306 | 306 | ||
@@ -325,10 +325,10 @@ describe Problem, type: 'model' do | @@ -325,10 +325,10 @@ describe Problem, type: 'model' do | ||
325 | } | 325 | } |
326 | } | 326 | } |
327 | ) | 327 | ) |
328 | - expect { | 328 | + expect do |
329 | @err.notices.first.destroy | 329 | @err.notices.first.destroy |
330 | @problem.reload | 330 | @problem.reload |
331 | - }.to change(@problem, :user_agents). | 331 | + end.to change(@problem, :user_agents). |
332 | from( | 332 | from( |
333 | Digest::MD5.hexdigest('Chrome 10.0.648.204 (OS X 10.6.7)') => { | 333 | Digest::MD5.hexdigest('Chrome 10.0.648.204 (OS X 10.6.7)') => { |
334 | 'value' => 'Chrome 10.0.648.204 (OS X 10.6.7)', 'count' => 1 } | 334 | 'value' => 'Chrome 10.0.648.204 (OS X 10.6.7)', 'count' => 1 } |
@@ -347,17 +347,17 @@ describe Problem, type: 'model' do | @@ -347,17 +347,17 @@ describe Problem, type: 'model' do | ||
347 | end | 347 | end |
348 | 348 | ||
349 | it "adding a comment increases #comments_count by 1" do | 349 | it "adding a comment increases #comments_count by 1" do |
350 | - expect { | 350 | + expect do |
351 | Fabricate(:comment, err: @problem) | 351 | Fabricate(:comment, err: @problem) |
352 | - }.to change(@problem, :comments_count).from(0).to(1) | 352 | + end.to change(@problem, :comments_count).from(0).to(1) |
353 | end | 353 | end |
354 | 354 | ||
355 | it "removing a comment decreases #comments_count by 1" do | 355 | it "removing a comment decreases #comments_count by 1" do |
356 | Fabricate(:comment, err: @problem) | 356 | Fabricate(:comment, err: @problem) |
357 | - expect { | 357 | + expect do |
358 | @problem.reload.comments.first.destroy | 358 | @problem.reload.comments.first.destroy |
359 | @problem.reload | 359 | @problem.reload |
360 | - }.to change(@problem, :comments_count).from(1).to(0) | 360 | + end.to change(@problem, :comments_count).from(1).to(0) |
361 | end | 361 | end |
362 | end | 362 | end |
363 | 363 | ||
@@ -420,9 +420,9 @@ describe Problem, type: 'model' do | @@ -420,9 +420,9 @@ describe Problem, type: 'model' do | ||
420 | end | 420 | end |
421 | 421 | ||
422 | it 'update the notice_count' do | 422 | it 'update the notice_count' do |
423 | - expect { | 423 | + expect do |
424 | problem.recache | 424 | problem.recache |
425 | - }.to change { | 425 | + end.to change { |
426 | problem.notices_count | 426 | problem.notices_count |
427 | }.from(0).to(1) | 427 | }.from(0).to(1) |
428 | end | 428 | end |
spec/models/user_spec.rb
@@ -39,10 +39,10 @@ describe User do | @@ -39,10 +39,10 @@ describe User do | ||
39 | 39 | ||
40 | context "First user" do | 40 | context "First user" do |
41 | it "should be created this admin access via db:seed" do | 41 | it "should be created this admin access via db:seed" do |
42 | - expect { | 42 | + expect 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 | + end.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 |
spec/requests/notices_controller_spec.rb
@@ -5,10 +5,10 @@ describe "Notices management", type: 'request' do | @@ -5,10 +5,10 @@ describe "Notices management", type: 'request' 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 do |
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 | + end.to change { |
12 | errbit_app.problems.count | 12 | errbit_app.problems.count |
13 | }.by(1) | 13 | }.by(1) |
14 | end | 14 | end |
@@ -17,10 +17,10 @@ describe "Notices management", type: 'request' do | @@ -17,10 +17,10 @@ describe "Notices management", type: 'request' do | ||
17 | context "with notice with empty backtrace" do | 17 | context "with notice with empty backtrace" 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 do |
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 | + end.to change { |
24 | errbit_app.problems.count | 24 | errbit_app.problems.count |
25 | }.by(1) | 25 | }.by(1) |
26 | end | 26 | end |
@@ -30,21 +30,21 @@ describe "Notices management", type: 'request' do | @@ -30,21 +30,21 @@ describe "Notices management", type: 'request' do | ||
30 | let(:errbit_app) { Fabricate(:app) } | 30 | let(:errbit_app) { Fabricate(:app) } |
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 do |
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 | + end.to_not change(errbit_app.problems, :count) |
38 | end | 38 | end |
39 | end | 39 | end |
40 | 40 | ||
41 | context "with GET request" do | 41 | context "with GET 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 do |
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 | + end.to change { |
48 | errbit_app.problems.count | 48 | errbit_app.problems.count |
49 | }.by(1) | 49 | }.by(1) |
50 | end | 50 | end |
spec/views/apps/edit.html.haml_spec.rb
@@ -15,21 +15,31 @@ describe "apps/edit.html.haml", type: 'view' do | @@ -15,21 +15,31 @@ describe "apps/edit.html.haml", type: 'view' do | ||
15 | 15 | ||
16 | it "should confirm the 'reset' link" do | 16 | it "should confirm the 'reset' link" do |
17 | render | 17 | render |
18 | - expect(action_bar).to have_selector('a.button[data-confirm="%s"]' % I18n.t('apps.confirm_destroy_all_problems')) | 18 | + expect(action_bar).to have_selector( |
19 | + format( | ||
20 | + 'a.button[data-confirm="%s"]', | ||
21 | + I18n.t('apps.confirm_destroy_all_problems') | ||
22 | + ) | ||
23 | + ) | ||
19 | end | 24 | end |
20 | 25 | ||
21 | it "should confirm the 'destroy' link" do | 26 | it "should confirm the 'destroy' link" do |
22 | render | 27 | render |
23 | - expect(action_bar).to have_selector('a.button[data-confirm="%s"]' % I18n.t('apps.confirm_delete')) | 28 | + expect(action_bar).to have_selector( |
29 | + format( | ||
30 | + 'a.button[data-confirm="%s"]', | ||
31 | + I18n.t('apps.confirm_delete') | ||
32 | + ) | ||
33 | + ) | ||
24 | end | 34 | end |
25 | end | 35 | end |
26 | 36 | ||
27 | context "with unvalid app" do | 37 | context "with unvalid app" do |
28 | - let(:app) { | 38 | + let(:app) do |
29 | app = stub_model(App) | 39 | app = stub_model(App) |
30 | app.errors.add(:base, 'You must specify your') | 40 | app.errors.add(:base, 'You must specify your') |
31 | app | 41 | app |
32 | - } | 42 | + end |
33 | 43 | ||
34 | it 'see the error' do | 44 | it 'see the error' do |
35 | render | 45 | render |
spec/views/apps/new.html.haml_spec.rb
@@ -21,11 +21,11 @@ describe "apps/new.html.haml", type: 'view' do | @@ -21,11 +21,11 @@ describe "apps/new.html.haml", type: 'view' do | ||
21 | end | 21 | end |
22 | 22 | ||
23 | context "with unvalid app" do | 23 | context "with unvalid app" do |
24 | - let(:app) { | 24 | + let(:app) do |
25 | app = stub_model(App) | 25 | app = stub_model(App) |
26 | app.errors.add(:base, 'You must specify your') | 26 | app.errors.add(:base, 'You must specify your') |
27 | app | 27 | app |
28 | - } | 28 | + end |
29 | 29 | ||
30 | it 'see the error' do | 30 | it 'see the error' do |
31 | render | 31 | render |
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) do |
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 | + end |
7 | 7 | ||
8 | before do | 8 | before do |
9 | allow(view).to receive(:problem).and_return(ProblemDecorator.new(problem)) | 9 | allow(view).to receive(:problem).and_return(ProblemDecorator.new(problem)) |
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) do |
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 | + end |
7 | 7 | ||
8 | before do | 8 | before do |
9 | allow(view).to receive(:problem).and_return( | 9 | allow(view).to receive(:problem).and_return( |
spec/views/problems/show.html.haml_spec.rb
1 | describe "problems/show.html.haml", type: 'view' do | 1 | describe "problems/show.html.haml", type: 'view' do |
2 | let(:problem) { Fabricate(:problem) } | 2 | let(:problem) { Fabricate(:problem) } |
3 | let(:comment) { Fabricate(:comment) } | 3 | let(:comment) { Fabricate(:comment) } |
4 | - let(:pivotal_tracker) { | 4 | + let(:pivotal_tracker) do |
5 | Class.new(ErrbitPlugin::MockIssueTracker) do | 5 | Class.new(ErrbitPlugin::MockIssueTracker) do |
6 | def self.label | 6 | def self.label |
7 | 'pivotal' | 7 | 'pivotal' |
@@ -15,8 +15,8 @@ describe "problems/show.html.haml", type: 'view' do | @@ -15,8 +15,8 @@ describe "problems/show.html.haml", type: 'view' do | ||
15 | true | 15 | true |
16 | end | 16 | end |
17 | end | 17 | end |
18 | - } | ||
19 | - let(:github_tracker) { | 18 | + end |
19 | + let(:github_tracker) do | ||
20 | Class.new(ErrbitPlugin::MockIssueTracker) do | 20 | Class.new(ErrbitPlugin::MockIssueTracker) do |
21 | def self.label | 21 | def self.label |
22 | 'github' | 22 | 'github' |
@@ -30,13 +30,13 @@ describe "problems/show.html.haml", type: 'view' do | @@ -30,13 +30,13 @@ describe "problems/show.html.haml", type: 'view' do | ||
30 | true | 30 | true |
31 | end | 31 | end |
32 | end | 32 | end |
33 | - } | ||
34 | - let(:trackers) { | 33 | + end |
34 | + let(:trackers) do | ||
35 | { | 35 | { |
36 | 'github' => github_tracker, | 36 | 'github' => github_tracker, |
37 | 'pivotal' => pivotal_tracker | 37 | 'pivotal' => pivotal_tracker |
38 | } | 38 | } |
39 | - } | 39 | + end |
40 | let(:app) { AppDecorator.new(problem.app) } | 40 | let(:app) { AppDecorator.new(problem.app) } |
41 | 41 | ||
42 | before do | 42 | before do |
@@ -66,13 +66,23 @@ describe "problems/show.html.haml", type: 'view' do | @@ -66,13 +66,23 @@ describe "problems/show.html.haml", type: 'view' do | ||
66 | 66 | ||
67 | it "should confirm the 'resolve' link by default" do | 67 | it "should confirm the 'resolve' link by default" do |
68 | render | 68 | render |
69 | - expect(action_bar).to have_selector('a.resolve[data-confirm="%s"]' % I18n.t('problems.confirm.resolve_one')) | 69 | + expect(action_bar).to have_selector( |
70 | + format( | ||
71 | + 'a.resolve[data-confirm="%s"]', | ||
72 | + I18n.t('problems.confirm.resolve_one') | ||
73 | + ) | ||
74 | + ) | ||
70 | end | 75 | end |
71 | 76 | ||
72 | it "should confirm the 'resolve' link if configuration is unset" do | 77 | it "should confirm the 'resolve' link if configuration is unset" do |
73 | allow(Errbit::Config).to receive(:confirm_err_actions).and_return(nil) | 78 | allow(Errbit::Config).to receive(:confirm_err_actions).and_return(nil) |
74 | render | 79 | render |
75 | - expect(action_bar).to have_selector('a.resolve[data-confirm="%s"]' % I18n.t('problems.confirm.resolve_one')) | 80 | + expect(action_bar).to have_selector( |
81 | + format( | ||
82 | + 'a.resolve[data-confirm="%s"]', | ||
83 | + I18n.t('problems.confirm.resolve_one') | ||
84 | + ) | ||
85 | + ) | ||
76 | end | 86 | end |
77 | 87 | ||
78 | it "should not confirm the 'resolve' link if configured not to" do | 88 | it "should not confirm the 'resolve' link if configured not to" do |
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 do |
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) |
6 | - } | 6 | + end |
7 | it 'should have per_page option' do | 7 | it 'should have per_page option' do |
8 | render | 8 | render |
9 | expect(rendered).to match(/id="user_per_page"/) | 9 | expect(rendered).to match(/id="user_per_page"/) |
spec/views/users/index.html.haml_spec.rb
1 | describe 'users/index.html.haml', type: 'view' do | 1 | describe 'users/index.html.haml', type: 'view' do |
2 | let(:user) { stub_model(User) } | 2 | let(:user) { stub_model(User) } |
3 | - before { | 3 | + before do |
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 | + end |
9 | it 'should see users option' do | 9 | it 'should see users option' do |
10 | render | 10 | render |
11 | expect(rendered).to match(/class='user_list'/) | 11 | expect(rendered).to match(/class='user_list'/) |
spec/views/users/new.html.haml_spec.rb
1 | describe 'users/new.html.haml', type: 'view' do | 1 | describe 'users/new.html.haml', type: 'view' do |
2 | let(:user) { stub_model(User) } | 2 | let(:user) { stub_model(User) } |
3 | - before { | 3 | + before do |
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) |
6 | - } | 6 | + end |
7 | it 'should have per_page option' do | 7 | it 'should have per_page option' do |
8 | render | 8 | render |
9 | expect(rendered).to match(/id="user_per_page"/) | 9 | expect(rendered).to match(/id="user_per_page"/) |
spec/views/users/show.html.haml_spec.rb
@@ -53,7 +53,12 @@ describe 'users/show.html.haml', type: 'view' do | @@ -53,7 +53,12 @@ describe 'users/show.html.haml', type: 'view' do | ||
53 | 53 | ||
54 | it "should confirm the 'resolve' link by default" do | 54 | it "should confirm the 'resolve' link by default" do |
55 | render | 55 | render |
56 | - expect(view.content_for(:action_bar)).to have_selector('a.delete[data-confirm="%s"]' % I18n.t('.users.confirm_delete')) | 56 | + expect(view.content_for(:action_bar)).to have_selector( |
57 | + format( | ||
58 | + 'a.delete[data-confirm="%s"]', | ||
59 | + I18n.t('.users.confirm_delete') | ||
60 | + ) | ||
61 | + ) | ||
57 | end | 62 | end |
58 | end | 63 | end |
59 | end | 64 | end |