Commit efa42e9668608f5175eb5c96898e199640d26434
1 parent
f4b65ea5
Exists in
theme-brasil-digital-from-staging
and in
9 other branches
workaround for the api logger
Showing
2 changed files
with
5 additions
and
7 deletions
Show diff stats
lib/noosfero/api/helpers.rb
| ... | ... | @@ -40,7 +40,9 @@ require 'grape' |
| 40 | 40 | end |
| 41 | 41 | |
| 42 | 42 | def logger |
| 43 | - Noosfero::API::API.logger | |
| 43 | + logger = Logger.new(File.join(Rails.root, 'log', "#{ENV['RAILS_ENV'] || 'production'}_api.log")) | |
| 44 | + logger.formatter = GrapeLogging::Formatters::Default.new | |
| 45 | + logger | |
| 44 | 46 | end |
| 45 | 47 | |
| 46 | 48 | def limit |
| ... | ... | @@ -251,11 +253,7 @@ require 'grape' |
| 251 | 253 | log_msg = "#{log_message}, #{log_msg}" if log_message.present? |
| 252 | 254 | log_msg = "#{log_msg}, Javascript Console Message: #{javascript_console_message}" if javascript_console_message.present? |
| 253 | 255 | logger.error log_msg unless Rails.env.test? |
| 254 | - if javascript_console_message.present? | |
| 255 | - error!(message_hash, status) | |
| 256 | - else | |
| 257 | - error!({'message' => user_message, :code => status}, status) | |
| 258 | - end | |
| 256 | + error!(message_hash, status) | |
| 259 | 257 | end |
| 260 | 258 | |
| 261 | 259 | def render_api_errors!(messages) | ... | ... |
test/unit/api/helpers_test.rb
| ... | ... | @@ -264,7 +264,7 @@ should 'captcha serpro say name or service not known' do |
| 264 | 264 | params[:txtToken_captcha_serpro_gov_br] = '4324343' |
| 265 | 265 | params[:captcha_text] = '4324343' |
| 266 | 266 | r = test_captcha('127.0.0.1', params, environment) |
| 267 | - assert_equal(_("Serpro captcha error: getaddrinfo: Name or service not known"), r[0][:javascript_console_message]) | |
| 267 | + assert (r[0][:javascript_console_message]).starts_with?("Serpro captcha error: getaddrinfo") | |
| 268 | 268 | end |
| 269 | 269 | |
| 270 | 270 | ###### END Captcha tests ###### | ... | ... |