Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKamil Trzcinski <ayufan@ayufan.eu>2017-04-05 00:52:59 +0300
committerKamil Trzcinski <ayufan@ayufan.eu>2017-04-06 15:32:39 +0300
commit062806e47da00dde37a2a62d7a5c6ede8341582c (patch)
treebd701e49203feee98d17de8c1444339dc70c56cc /spec/support/query_recorder.rb
parent0a4b853f2ceb0ad6c7394d1056f9139e53b38688 (diff)
Define baseline for test for pipelines serializer
Diffstat (limited to 'spec/support/query_recorder.rb')
-rw-r--r--spec/support/query_recorder.rb14
1 files changed, 11 insertions, 3 deletions
diff --git a/spec/support/query_recorder.rb b/spec/support/query_recorder.rb
index e40d5ebd9a8..55b531b4cf7 100644
--- a/spec/support/query_recorder.rb
+++ b/spec/support/query_recorder.rb
@@ -1,21 +1,29 @@
module ActiveRecord
class QueryRecorder
- attr_reader :log
+ attr_reader :log, :cached
def initialize(&block)
@log = []
+ @cached = []
ActiveSupport::Notifications.subscribed(method(:callback), 'sql.active_record', &block)
end
def callback(name, start, finish, message_id, values)
- return if %w(CACHE SCHEMA).include?(values[:name])
- @log << values[:sql]
+ if values[:name]&.include?("CACHE")
+ @cached << values[:sql]
+ elsif !values[:name]&.include?("SCHEMA")
+ @log << values[:sql]
+ end
end
def count
@log.count
end
+ def cached_count
+ @cached.count
+ end
+
def log_message
@log.join("\n\n")
end