rails-flog 1.3.1 → 1.3.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 37349e66f4eac2a3c918f1f5dd3a0575be741be1
4
- data.tar.gz: 44b49c742fcf58e324a7406fa151c9b8248b0dde
3
+ metadata.gz: 9fbf46665254484f9fb2fcf9d209b46a8303e028
4
+ data.tar.gz: b2bdd9a21547bf84cbbbba6ebd7d54dc5baef4e1
5
5
  SHA512:
6
- metadata.gz: 79f8fa25feaae28b230481ead671bdcfb8e4a6b7c367ddf255dd76e6e047e3f320b62f179e920aae46d9c96edc5aaf6501e59dc8d15260410c8b40e450a17de8
7
- data.tar.gz: a51ab46561f273ffd74fe9c2cd50e1ac11e3e5c9e20a6af8b81721397a47531ef50b739568596a4aca7a4135e86297e7d14e997dd96ff92a3a95577fc9cdba45
6
+ metadata.gz: d737e91d22762f40a7b0b08e844408f92e8c17879e985ec07555c5eda8608650042770e1f6c5ab1c54f023c258753a22efa95a7defca591a0e6e45b589155556
7
+ data.tar.gz: 67d28e57171f04d269539e8405e874eff4c35e7ba80596a8e8484c03903a5ca987d3373f94a3b5ee8c36be7289dd40e78d0fee93c3ba8cfba546065e3c06d1ce
@@ -6,4 +6,4 @@ rvm:
6
6
  gemfile:
7
7
  - gemfiles/rails_3_2_x.gemfile
8
8
  - gemfiles/rails_4_0_x.gemfile
9
- # - gemfiles/rails_4_1_x.gemfile
9
+ - gemfiles/rails_4_1_x.gemfile
data/README.md CHANGED
@@ -5,7 +5,7 @@
5
5
 
6
6
  rails-flog provides feature that formats parameters Hash and SQL in Rails log file.
7
7
 
8
- ## Before and after (Sampla app: Redmine)
8
+ ## Before and after (Sample app: Redmine)
9
9
 
10
10
  ### Before (Default)
11
11
 
@@ -99,7 +99,7 @@ Flog.configure do |config|
99
99
  config.query_duration_threshold = 2.0
100
100
  # If key count of parameters is under this value, not format
101
101
  config.params_key_count_threshold = 2
102
- # If this value is true, force format in any situation
102
+ # If this value is true, nested Hash parameter is formatted coercively in any situation
103
103
  config.force_on_nested_params = false
104
104
  end
105
105
  ```
@@ -115,7 +115,7 @@ end
115
115
 
116
116
  ## Disable temporary
117
117
 
118
- If you put a file to `<rails_app>/tmp` direcotry, `rails-flog` will disable format.
118
+ If you put a file to `<rails_app>/tmp` direcotry, `rails-flog` will disable format.
119
119
  Priority of this feature is higher than configurations.
120
120
 
121
121
  |File name |Feature |
@@ -127,7 +127,7 @@ Priority of this feature is higher than configurations.
127
127
  ## Supported versions
128
128
 
129
129
  - Ruby: 1.9.3, 2.0.0, 2.1.0
130
- - Rails: 3.2.x, 4.0.x
130
+ - Rails: 3.2.x, 4.0.x, 4.1.x
131
131
 
132
132
  ## Contributing
133
133
 
@@ -145,3 +145,4 @@ Priority of this feature is higher than configurations.
145
145
  - v1.2.0 (2014-01-14 JST): Add feature that disables format partially by no-flog-sql.txt and no-flog-params.txt
146
146
  - v1.3.0 (2014-01-26 JST): Add configuration
147
147
  - v1.3.1 (2014-01-27 JST): Refactored
148
+ - v1.3.2 (2014-04-28 JST): Confirm with Rails 4.1
data/Rakefile CHANGED
@@ -1,5 +1,6 @@
1
1
  require "bundler/gem_tasks"
2
2
  require "rake/testtask"
3
+
3
4
  task :default => :test
4
5
 
5
6
  Rake::TestTask.new do |t|
@@ -54,8 +54,7 @@ class ActionController::LogSubscriber
54
54
 
55
55
  def key_count_over?(event)
56
56
  threshold = Flog.config.params_key_count_threshold.to_i
57
- threshold += 1 if event.payload[:params].keys.include?("controller")
58
- threshold += 1 if event.payload[:params].keys.include?("action")
59
- event.payload[:params].keys.size > threshold
57
+ params = event.payload[:params].except(*INTERNAL_PARAMS)
58
+ params.keys.size > threshold
60
59
  end
61
60
  end
@@ -1,4 +1,4 @@
1
1
  # coding: utf-8
2
2
  module Flog
3
- VERSION = "1.3.1"
3
+ VERSION = "1.3.2"
4
4
  end
@@ -9,8 +9,8 @@ end
9
9
 
10
10
  Bundler.require
11
11
  require "flog"
12
- require "test/unit"
13
- require "mocha/setup"
12
+ require "minitest/autorun"
13
+ require "mocha/api"
14
14
 
15
15
  class TestLogger
16
16
  attr_accessor :debugs, :infos, :errors
@@ -68,7 +68,7 @@ class ParamsFormattableTest < ActionController::TestCase
68
68
  end
69
69
 
70
70
  def test_parameters_log_is_not_formatted_when_enabled_is_false
71
- Flog::Status.expects(:enabled?).returns(false)
71
+ Flog::Status.stubs(:enabled?).returns(false)
72
72
  get :show, foo: "foo_value", bar: "bar_value"
73
73
  assert_logger do |logger|
74
74
  assert logger.infos[1].include?(%(Parameters: {"foo"=>"foo_value", "bar"=>"bar_value"}))
@@ -76,7 +76,7 @@ class ParamsFormattableTest < ActionController::TestCase
76
76
  end
77
77
 
78
78
  def test_parameters_log_is_not_formatted_when_params_formattable_is_false
79
- Flog::Status.expects(:params_formattable?).returns(false)
79
+ Flog::Status.stubs(:params_formattable?).returns(false)
80
80
  get :show, foo: "foo_value", bar: "bar_value"
81
81
  assert_logger do |logger|
82
82
  assert logger.infos[1].include?(%(Parameters: {"foo"=>"foo_value", "bar"=>"bar_value"}))
@@ -59,18 +59,18 @@ class SqlFormattableTest < ActiveSupport::TestCase
59
59
  end
60
60
 
61
61
  def test_sql_is_not_formatted_when_enabled_is_false
62
- Flog::Status.expects(:enabled?).returns(false)
62
+ Flog::Status.stubs(:enabled?).returns(false)
63
63
  Book.where(category: "comics").to_a
64
64
  assert_logger do |logger|
65
- assert logger.debugs.first.include?(%(SELECT "books".* FROM "books" WHERE "books"."category" = 'comics'))
65
+ assert_one_line_sql logger.debugs.first
66
66
  end
67
67
  end
68
68
 
69
69
  def test_sql_is_not_formatted_when_sql_formattable_is_false
70
- Flog::Status.expects(:sql_formattable?).returns(false)
70
+ Flog::Status.stubs(:sql_formattable?).returns(false)
71
71
  Book.where(category: "comics").to_a
72
72
  assert_logger do |logger|
73
- assert logger.debugs.first.include?(%(SELECT "books".* FROM "books" WHERE "books"."category" = 'comics'))
73
+ assert_one_line_sql logger.debugs.first
74
74
  end
75
75
  end
76
76
 
@@ -81,13 +81,9 @@ class SqlFormattableTest < ActiveSupport::TestCase
81
81
  end
82
82
  assert_logger do |logger|
83
83
  logs = logger.debugs.map { |log| log.gsub("\t", " ") }
84
- assert_equal %{ SELECT} , logs[1]
85
- assert_equal %{ "books" . *} , logs[2]
86
- assert_equal %{ FROM} , logs[3]
87
- assert_equal %{ "books"} , logs[4]
88
- assert_equal %{ WHERE} , logs[5]
89
- assert_equal %{ "books" . "category" = 'comics'}, logs[6]
90
- assert logs[7].include?(%(SELECT "books".* FROM "books" WHERE "books"."category" = 'comics'))
84
+ logs.each do |log|
85
+ assert_one_line_sql log if log.include?("CACHE")
86
+ end
91
87
  end
92
88
  end
93
89
 
@@ -101,18 +97,9 @@ class SqlFormattableTest < ActiveSupport::TestCase
101
97
  end
102
98
  assert_logger do |logger|
103
99
  logs = logger.debugs.map { |log| log.gsub("\t", " ") }
104
- assert_equal %{ SELECT} , logs[1]
105
- assert_equal %{ "books" . *} , logs[2]
106
- assert_equal %{ FROM} , logs[3]
107
- assert_equal %{ "books"} , logs[4]
108
- assert_equal %{ WHERE} , logs[5]
109
- assert_equal %{ "books" . "category" = 'comics'}, logs[6]
110
- assert_equal %{ SELECT} , logs[8]
111
- assert_equal %{ "books" . *} , logs[9]
112
- assert_equal %{ FROM} , logs[10]
113
- assert_equal %{ "books"} , logs[11]
114
- assert_equal %{ WHERE} , logs[12]
115
- assert_equal %{ "books" . "category" = 'comics'}, logs[13]
100
+ logs.each do |log|
101
+ assert_equal log.include?("SELECT"), false if log.include?("CACHE")
102
+ end
116
103
  end
117
104
  end
118
105
 
@@ -122,7 +109,7 @@ class SqlFormattableTest < ActiveSupport::TestCase
122
109
  end
123
110
  Book.where(category: "comics").to_a
124
111
  assert_logger do |logger|
125
- assert logger.debugs.first.include?(%(SELECT "books".* FROM "books" WHERE "books"."category" = 'comics'))
112
+ assert_one_line_sql logger.debugs.first
126
113
  end
127
114
  end
128
115
 
@@ -134,4 +121,10 @@ class SqlFormattableTest < ActiveSupport::TestCase
134
121
  block.call(ActiveRecord::Base.logger)
135
122
  end
136
123
  end
124
+
125
+ def assert_one_line_sql(sql)
126
+ assert sql.include?("SELECT")
127
+ assert sql.include?("FROM")
128
+ assert sql.include?("WHERE")
129
+ end
137
130
  end
@@ -1,5 +1,6 @@
1
1
  # coding: utf-8
2
2
  require "rails"
3
+ require "test_helper"
3
4
 
4
5
  class StatusTest < ActiveSupport::TestCase
5
6
  def setup
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rails-flog
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.1
4
+ version: 1.3.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - pinzolo
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-01-25 00:00:00.000000000 Z
11
+ date: 2014-04-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -173,7 +173,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
173
173
  version: '0'
174
174
  requirements: []
175
175
  rubyforge_project:
176
- rubygems_version: 2.0.3
176
+ rubygems_version: 2.0.14
177
177
  signing_key:
178
178
  specification_version: 4
179
179
  summary: Rails log formatter for parameters and sql