nunes 0.4.0 → 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +15 -7
- data/Changelog.md +8 -0
- data/Gemfile +1 -1
- data/README.md +2 -3
- data/Rakefile +10 -0
- data/lib/nunes.rb +12 -0
- data/lib/nunes/adapter.rb +4 -2
- data/lib/nunes/instrumentable.rb +1 -1
- data/lib/nunes/subscriber.rb +5 -2
- data/lib/nunes/subscribers/action_controller.rb +51 -24
- data/lib/nunes/subscribers/action_mailer.rb +2 -2
- data/lib/nunes/subscribers/action_view.rb +5 -2
- data/lib/nunes/subscribers/active_job.rb +2 -3
- data/lib/nunes/subscribers/active_record.rb +4 -1
- data/lib/nunes/version.rb +1 -1
- data/script/test +10 -13
- data/test/controller_instrumentation_test.rb +47 -5
- data/test/helper.rb +5 -1
- data/test/instrumentable_test.rb +27 -3
- data/test/job_instrumentation_test.rb +11 -8
- data/test/mailer_instrumentation_test.rb +5 -1
- data/test/namespaced_controller_instrumentation_test.rb +7 -7
- data/test/namespaced_job_instrumentation_test.rb +33 -0
- data/test/namespaced_mailer_instrumentation_test.rb +35 -0
- data/test/namespaced_model_instrumentation_test.rb +55 -0
- data/test/nunes_test.rb +8 -0
- data/test/{rails_app → rails_app_4.2.5}/.gitignore +0 -0
- data/test/{rails_app → rails_app_4.2.5}/Rakefile +0 -0
- data/test/{rails_app → rails_app_4.2.5}/app/assets/images/rails.png +0 -0
- data/test/{rails_app → rails_app_4.2.5}/app/assets/javascripts/application.js +0 -0
- data/test/{rails_app → rails_app_4.2.5}/app/assets/stylesheets/application.css +0 -0
- data/test/{rails_app → rails_app_4.2.5}/app/controllers/admin/posts_controller.rb +2 -7
- data/test/{rails_app → rails_app_4.2.5}/app/controllers/application_controller.rb +0 -0
- data/test/{rails_app → rails_app_4.2.5}/app/controllers/posts_controller.rb +1 -7
- data/test/{rails_app → rails_app_4.2.5}/app/helpers/application_helper.rb +0 -0
- data/test/rails_app_4.2.5/app/jobs/spam/detector_job.rb +11 -0
- data/test/{rails_app → rails_app_4.2.5}/app/jobs/spam_detector_job.rb +0 -0
- data/test/{rails_app → rails_app_4.2.5}/app/mailers/.gitkeep +0 -0
- data/test/rails_app_4.2.5/app/mailers/admin/post_mailer.rb +13 -0
- data/test/{rails_app → rails_app_4.2.5}/app/mailers/post_mailer.rb +0 -0
- data/test/{rails_app → rails_app_4.2.5}/app/models/.gitkeep +0 -0
- data/test/rails_app_4.2.5/app/models/admin/post.rb +5 -0
- data/test/{rails_app → rails_app_4.2.5}/app/models/post.rb +0 -0
- data/test/{rails_app/app/views → rails_app_4.2.5/app/views/admin}/post_mailer/created.text.erb +0 -0
- data/test/{rails_app → rails_app_4.2.5}/app/views/admin/posts/index.html.erb +0 -0
- data/test/{rails_app → rails_app_4.2.5}/app/views/layouts/application.html.erb +0 -0
- data/test/rails_app_4.2.5/app/views/post_mailer/created.text.erb +1 -0
- data/test/{rails_app → rails_app_4.2.5}/app/views/posts/_post.html.erb +0 -0
- data/test/{rails_app → rails_app_4.2.5}/app/views/posts/index.html.erb +0 -0
- data/test/{rails_app → rails_app_4.2.5}/config.ru +0 -0
- data/test/{rails_app → rails_app_4.2.5}/config/application.rb +0 -0
- data/test/{rails_app → rails_app_4.2.5}/config/boot.rb +0 -0
- data/test/{rails_app → rails_app_4.2.5}/config/database.yml +0 -0
- data/test/{rails_app → rails_app_4.2.5}/config/environment.rb +0 -0
- data/test/{rails_app → rails_app_4.2.5}/config/environments/development.rb +0 -0
- data/test/{rails_app → rails_app_4.2.5}/config/environments/production.rb +0 -0
- data/test/{rails_app → rails_app_4.2.5}/config/environments/test.rb +0 -0
- data/test/{rails_app → rails_app_4.2.5}/config/initializers/backtrace_silencers.rb +0 -0
- data/test/{rails_app → rails_app_4.2.5}/config/initializers/force_test_schema_load.rb +0 -0
- data/test/{rails_app → rails_app_4.2.5}/config/initializers/inflections.rb +0 -0
- data/test/{rails_app → rails_app_4.2.5}/config/initializers/mime_types.rb +0 -0
- data/test/{rails_app → rails_app_4.2.5}/config/initializers/secret_token.rb +0 -0
- data/test/{rails_app → rails_app_4.2.5}/config/initializers/session_store.rb +0 -0
- data/test/{rails_app → rails_app_4.2.5}/config/initializers/wrap_parameters.rb +0 -0
- data/test/{rails_app → rails_app_4.2.5}/config/locales/en.yml +0 -0
- data/test/{rails_app → rails_app_4.2.5}/config/routes.rb +0 -0
- data/test/{rails_app → rails_app_4.2.5}/config/secrets.yml +0 -0
- data/test/{rails_app → rails_app_4.2.5}/db/migrate/20130417154459_create_posts.rb +0 -0
- data/test/{rails_app → rails_app_4.2.5}/db/schema.rb +0 -0
- data/test/{rails_app → rails_app_4.2.5}/db/seeds.rb +0 -0
- data/test/{rails_app → rails_app_4.2.5}/lib/assets/.gitkeep +0 -0
- data/test/{rails_app → rails_app_4.2.5}/lib/tasks/.gitkeep +0 -0
- data/test/{rails_app → rails_app_4.2.5}/public/404.html +0 -0
- data/test/{rails_app → rails_app_4.2.5}/public/422.html +0 -0
- data/test/{rails_app → rails_app_4.2.5}/public/500.html +0 -0
- data/test/{rails_app → rails_app_4.2.5}/public/favicon.ico +0 -0
- data/test/{rails_app → rails_app_4.2.5}/public/index.html +0 -0
- data/test/{rails_app → rails_app_4.2.5}/public/robots.txt +0 -0
- data/test/{rails_app → rails_app_4.2.5}/script/rails +0 -0
- data/test/rails_app_5.0.0/.gitignore +21 -0
- data/test/rails_app_5.0.0/Gemfile +48 -0
- data/test/rails_app_5.0.0/README.md +24 -0
- data/test/rails_app_5.0.0/Rakefile +6 -0
- data/test/rails_app_5.0.0/app/assets/config/manifest.js +3 -0
- data/test/rails_app_5.0.0/app/assets/images/.keep +0 -0
- data/test/rails_app_5.0.0/app/assets/images/rails.png +0 -0
- data/test/rails_app_5.0.0/app/assets/javascripts/application.js +13 -0
- data/test/rails_app_5.0.0/app/assets/javascripts/cable.js +13 -0
- data/test/rails_app_5.0.0/app/assets/javascripts/channels/.keep +0 -0
- data/test/rails_app_5.0.0/app/assets/stylesheets/application.css +15 -0
- data/test/rails_app_5.0.0/app/channels/application_cable/channel.rb +4 -0
- data/test/rails_app_5.0.0/app/channels/application_cable/connection.rb +4 -0
- data/test/rails_app_5.0.0/app/controllers/admin/posts_controller.rb +14 -0
- data/test/rails_app_5.0.0/app/controllers/application_controller.rb +3 -0
- data/test/rails_app_5.0.0/app/controllers/concerns/.keep +0 -0
- data/test/rails_app_5.0.0/app/controllers/posts_controller.rb +22 -0
- data/test/rails_app_5.0.0/app/helpers/application_helper.rb +2 -0
- data/test/rails_app_5.0.0/app/jobs/application_job.rb +2 -0
- data/test/rails_app_5.0.0/app/jobs/spam/detector_job.rb +11 -0
- data/test/rails_app_5.0.0/app/jobs/spam_detector_job.rb +9 -0
- data/test/rails_app_5.0.0/app/mailers/admin/post_mailer.rb +13 -0
- data/test/rails_app_5.0.0/app/mailers/application_mailer.rb +4 -0
- data/test/rails_app_5.0.0/app/mailers/post_mailer.rb +11 -0
- data/test/rails_app_5.0.0/app/models/admin/post.rb +5 -0
- data/test/rails_app_5.0.0/app/models/application_record.rb +3 -0
- data/test/rails_app_5.0.0/app/models/concerns/.keep +0 -0
- data/test/rails_app_5.0.0/app/models/post.rb +2 -0
- data/test/rails_app_5.0.0/app/views/admin/post_mailer/created.text.erb +1 -0
- data/test/rails_app_5.0.0/app/views/admin/posts/index.html.erb +5 -0
- data/test/rails_app_5.0.0/app/views/layouts/application.html.erb +14 -0
- data/test/rails_app_5.0.0/app/views/layouts/mailer.html.erb +13 -0
- data/test/rails_app_5.0.0/app/views/layouts/mailer.text.erb +1 -0
- data/test/rails_app_5.0.0/app/views/post_mailer/created.text.erb +1 -0
- data/test/rails_app_5.0.0/app/views/posts/_post.html.erb +1 -0
- data/test/rails_app_5.0.0/app/views/posts/index.html.erb +5 -0
- data/test/rails_app_5.0.0/bin/bundle +3 -0
- data/test/rails_app_5.0.0/bin/rails +9 -0
- data/test/rails_app_5.0.0/bin/rake +9 -0
- data/test/rails_app_5.0.0/bin/setup +34 -0
- data/test/rails_app_5.0.0/bin/spring +15 -0
- data/test/rails_app_5.0.0/bin/update +29 -0
- data/test/rails_app_5.0.0/config.ru +5 -0
- data/test/rails_app_5.0.0/config/application.rb +15 -0
- data/test/rails_app_5.0.0/config/boot.rb +3 -0
- data/test/rails_app_5.0.0/config/cable.yml +9 -0
- data/test/rails_app_5.0.0/config/database.yml +25 -0
- data/test/rails_app_5.0.0/config/environment.rb +5 -0
- data/test/rails_app_5.0.0/config/environments/development.rb +54 -0
- data/test/rails_app_5.0.0/config/environments/production.rb +86 -0
- data/test/rails_app_5.0.0/config/environments/test.rb +42 -0
- data/test/rails_app_5.0.0/config/initializers/application_controller_renderer.rb +6 -0
- data/test/rails_app_5.0.0/config/initializers/assets.rb +11 -0
- data/test/rails_app_5.0.0/config/initializers/backtrace_silencers.rb +7 -0
- data/test/rails_app_5.0.0/config/initializers/cookies_serializer.rb +5 -0
- data/test/rails_app_5.0.0/config/initializers/filter_parameter_logging.rb +4 -0
- data/test/rails_app_5.0.0/config/initializers/force_test_schema_load.rb +3 -0
- data/test/rails_app_5.0.0/config/initializers/inflections.rb +16 -0
- data/test/rails_app_5.0.0/config/initializers/mime_types.rb +4 -0
- data/test/rails_app_5.0.0/config/initializers/new_framework_defaults.rb +24 -0
- data/test/rails_app_5.0.0/config/initializers/session_store.rb +3 -0
- data/test/rails_app_5.0.0/config/initializers/wrap_parameters.rb +14 -0
- data/test/rails_app_5.0.0/config/locales/en.yml +23 -0
- data/test/rails_app_5.0.0/config/puma.rb +47 -0
- data/test/rails_app_5.0.0/config/routes.rb +12 -0
- data/test/rails_app_5.0.0/config/secrets.yml +22 -0
- data/test/rails_app_5.0.0/config/spring.rb +6 -0
- data/test/rails_app_5.0.0/db/migrate/20160812134213_create_posts.rb +9 -0
- data/test/rails_app_5.0.0/db/schema.rb +21 -0
- data/test/rails_app_5.0.0/db/seeds.rb +7 -0
- data/test/rails_app_5.0.0/lib/assets/.keep +0 -0
- data/test/rails_app_5.0.0/lib/tasks/.keep +0 -0
- data/test/rails_app_5.0.0/log/.keep +0 -0
- data/test/rails_app_5.0.0/public/404.html +67 -0
- data/test/rails_app_5.0.0/public/422.html +67 -0
- data/test/rails_app_5.0.0/public/500.html +66 -0
- data/test/rails_app_5.0.0/public/apple-touch-icon-precomposed.png +0 -0
- data/test/rails_app_5.0.0/public/apple-touch-icon.png +0 -0
- data/test/rails_app_5.0.0/public/favicon.ico +0 -0
- data/test/rails_app_5.0.0/public/robots.txt +5 -0
- data/test/rails_app_5.0.0/test/controllers/.keep +0 -0
- data/test/rails_app_5.0.0/test/fixtures/.keep +0 -0
- data/test/rails_app_5.0.0/test/fixtures/files/.keep +0 -0
- data/test/rails_app_5.0.0/test/helpers/.keep +0 -0
- data/test/rails_app_5.0.0/test/integration/.keep +0 -0
- data/test/rails_app_5.0.0/test/mailers/.keep +0 -0
- data/test/rails_app_5.0.0/test/models/.keep +0 -0
- data/test/rails_app_5.0.0/test/test_helper.rb +10 -0
- data/test/rails_app_5.0.0/vendor/assets/javascripts/.keep +0 -0
- data/test/rails_app_5.0.0/vendor/assets/stylesheets/.keep +0 -0
- data/test/support/adapter_test_helpers.rb +17 -2
- metadata +295 -100
data/test/helper.rb
CHANGED
@@ -8,6 +8,8 @@ require "action_mailer"
|
|
8
8
|
root = Pathname(__FILE__).dirname.join("..").expand_path
|
9
9
|
Dir[root.join("test/support/**/*.rb")].each { |f| require f }
|
10
10
|
|
11
|
+
puts "Running tests against rails version #{Rails.version}"
|
12
|
+
|
11
13
|
class ActionController::TestCase
|
12
14
|
include AdapterTestHelpers
|
13
15
|
end
|
@@ -20,6 +22,8 @@ class ActiveSupport::TestCase
|
|
20
22
|
include AdapterTestHelpers
|
21
23
|
end
|
22
24
|
|
23
|
-
|
25
|
+
rails_version = ENV["RAILS_VERSION"] || "4.2.5"
|
26
|
+
|
27
|
+
require "rails_app_#{rails_version}/config/environment"
|
24
28
|
|
25
29
|
require "nunes"
|
data/test/instrumentable_test.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
require "helper"
|
2
2
|
|
3
3
|
class InstrumentationTest < ActiveSupport::TestCase
|
4
|
-
attr_reader :thing_class
|
4
|
+
attr_reader :thing_class, :namespaced_thing_class
|
5
5
|
|
6
6
|
setup :setup_subscriber, :setup_class
|
7
7
|
teardown :teardown_subscriber, :teardown_class
|
@@ -30,6 +30,17 @@ class InstrumentationTest < ActiveSupport::TestCase
|
|
30
30
|
'Thing'
|
31
31
|
end
|
32
32
|
|
33
|
+
def yo(args = {})
|
34
|
+
:dude
|
35
|
+
end
|
36
|
+
}
|
37
|
+
@namespaced_thing_class = Class.new {
|
38
|
+
extend Nunes::Instrumentable
|
39
|
+
|
40
|
+
def self.name
|
41
|
+
'Some::Thing'
|
42
|
+
end
|
43
|
+
|
33
44
|
def yo(args = {})
|
34
45
|
:dude
|
35
46
|
end
|
@@ -38,6 +49,7 @@ class InstrumentationTest < ActiveSupport::TestCase
|
|
38
49
|
|
39
50
|
def teardown_class
|
40
51
|
@thing_class = nil
|
52
|
+
@namespaced_thing_class = nil
|
41
53
|
end
|
42
54
|
|
43
55
|
test "adds methods when extended" do
|
@@ -59,7 +71,7 @@ class InstrumentationTest < ActiveSupport::TestCase
|
|
59
71
|
|
60
72
|
assert_not_nil event, "No events were found."
|
61
73
|
assert_equal "Thing.yo", event.payload[:metric]
|
62
|
-
|
74
|
+
assert event.duration > 0, "Expected #{event.duration} to be greater than 0"
|
63
75
|
|
64
76
|
assert_timer "Thing.yo"
|
65
77
|
end
|
@@ -80,7 +92,7 @@ class InstrumentationTest < ActiveSupport::TestCase
|
|
80
92
|
|
81
93
|
assert_not_nil event, "No events were found."
|
82
94
|
assert_equal "Thing.find", event.payload[:metric]
|
83
|
-
|
95
|
+
assert event.duration > 0, "Expected #{event.duration} to be greater than 0"
|
84
96
|
|
85
97
|
assert_timer "Thing.find"
|
86
98
|
end
|
@@ -118,6 +130,18 @@ class InstrumentationTest < ActiveSupport::TestCase
|
|
118
130
|
assert_timer "Thing.yo"
|
119
131
|
end
|
120
132
|
|
133
|
+
test "instrument_method_time for namespaced class" do
|
134
|
+
namespaced_thing_class.instrument_method_time :yo
|
135
|
+
|
136
|
+
event = slurp_events { namespaced_thing_class.new.yo(some: 'thing') }.last
|
137
|
+
|
138
|
+
assert_not_nil event, "No events were found."
|
139
|
+
assert_equal "Some-Thing.yo", event.payload[:metric]
|
140
|
+
assert event.duration > 0, "Expected #{event.duration} to be greater than 0"
|
141
|
+
|
142
|
+
assert_timer "Some-Thing.yo"
|
143
|
+
end
|
144
|
+
|
121
145
|
def slurp_events(&block)
|
122
146
|
events = []
|
123
147
|
callback = lambda { |*args| events << ActiveSupport::Notifications::Event.new(*args) }
|
@@ -1,6 +1,8 @@
|
|
1
1
|
require "helper"
|
2
2
|
|
3
3
|
class JobInstrumentationTest < ActiveSupport::TestCase
|
4
|
+
include ActiveJob::TestHelper
|
5
|
+
|
4
6
|
setup :setup_subscriber
|
5
7
|
teardown :teardown_subscriber
|
6
8
|
|
@@ -13,18 +15,19 @@ class JobInstrumentationTest < ActiveSupport::TestCase
|
|
13
15
|
end
|
14
16
|
|
15
17
|
test "perform_now" do
|
16
|
-
|
17
|
-
SpamDetectorJob.perform_now(
|
18
|
+
post = Post.new(title: 'Testing')
|
19
|
+
SpamDetectorJob.perform_now(post)
|
18
20
|
|
19
|
-
assert_timer "active_job.
|
21
|
+
assert_timer "active_job.SpamDetectorJob.perform"
|
20
22
|
end
|
21
23
|
|
22
24
|
test "perform_later" do
|
23
|
-
|
24
|
-
|
25
|
+
post = Post.create!(title: 'Testing')
|
26
|
+
perform_enqueued_jobs do
|
27
|
+
SpamDetectorJob.perform_later(post)
|
28
|
+
end
|
25
29
|
|
26
|
-
|
27
|
-
|
30
|
+
assert_counter "active_job.SpamDetectorJob.enqueue"
|
31
|
+
assert_timer "active_job.SpamDetectorJob.perform"
|
28
32
|
end
|
29
|
-
|
30
33
|
end
|
@@ -1,6 +1,8 @@
|
|
1
1
|
require "helper"
|
2
2
|
|
3
3
|
class MailerInstrumentationTest < ActionMailer::TestCase
|
4
|
+
include ActiveJob::TestHelper
|
5
|
+
|
4
6
|
tests PostMailer
|
5
7
|
|
6
8
|
setup :setup_subscriber
|
@@ -20,7 +22,9 @@ class MailerInstrumentationTest < ActionMailer::TestCase
|
|
20
22
|
end
|
21
23
|
|
22
24
|
test "deliver_later" do
|
23
|
-
|
25
|
+
perform_enqueued_jobs do
|
26
|
+
PostMailer.created.deliver_later
|
27
|
+
end
|
24
28
|
assert_timer "action_mailer.deliver.PostMailer"
|
25
29
|
end
|
26
30
|
|
@@ -19,21 +19,21 @@ class NamespacedControllerInstrumentationTest < ActionController::TestCase
|
|
19
19
|
|
20
20
|
assert_response :success
|
21
21
|
|
22
|
-
assert_timer "action_controller.controller.Admin
|
23
|
-
assert_timer "action_controller.controller.Admin
|
24
|
-
assert_timer "action_controller.controller.Admin
|
22
|
+
assert_timer "action_controller.controller.Admin-PostsController.index.runtime.total"
|
23
|
+
assert_timer "action_controller.controller.Admin-PostsController.index.runtime.view"
|
24
|
+
assert_timer "action_controller.controller.Admin-PostsController.index.runtime.db"
|
25
25
|
|
26
26
|
assert_counter "action_controller.format.html"
|
27
27
|
assert_counter "action_controller.status.200"
|
28
28
|
|
29
|
-
assert_counter "action_controller.controller.Admin
|
30
|
-
assert_counter "action_controller.controller.Admin
|
29
|
+
assert_counter "action_controller.controller.Admin-PostsController.index.format.html"
|
30
|
+
assert_counter "action_controller.controller.Admin-PostsController.index.status.200"
|
31
31
|
end
|
32
32
|
|
33
33
|
test "process_action w/ json" do
|
34
34
|
get :index, format: :json
|
35
35
|
|
36
|
-
assert_counter "action_controller.controller.Admin
|
36
|
+
assert_counter "action_controller.controller.Admin-PostsController.index.format.json"
|
37
37
|
end
|
38
38
|
|
39
39
|
test "process_action bad_request" do
|
@@ -41,6 +41,6 @@ class NamespacedControllerInstrumentationTest < ActionController::TestCase
|
|
41
41
|
|
42
42
|
assert_response :forbidden
|
43
43
|
|
44
|
-
assert_counter "action_controller.controller.Admin
|
44
|
+
assert_counter "action_controller.controller.Admin-PostsController.new.status.403"
|
45
45
|
end
|
46
46
|
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
require "helper"
|
2
|
+
|
3
|
+
class NamespacedJobInstrumentationTest < ActiveSupport::TestCase
|
4
|
+
include ActiveJob::TestHelper
|
5
|
+
|
6
|
+
setup :setup_subscriber
|
7
|
+
teardown :teardown_subscriber
|
8
|
+
|
9
|
+
def setup_subscriber
|
10
|
+
@subscriber = Nunes::Subscribers::ActiveJob.subscribe(adapter)
|
11
|
+
end
|
12
|
+
|
13
|
+
def teardown_subscriber
|
14
|
+
ActiveSupport::Notifications.unsubscribe @subscriber if @subscriber
|
15
|
+
end
|
16
|
+
|
17
|
+
test "perform_now" do
|
18
|
+
post = Post.new(title: 'Testing')
|
19
|
+
Spam::DetectorJob.perform_now(post)
|
20
|
+
|
21
|
+
assert_timer "active_job.Spam-DetectorJob.perform"
|
22
|
+
end
|
23
|
+
|
24
|
+
test "perform_later" do
|
25
|
+
post = Post.create!(title: 'Testing')
|
26
|
+
perform_enqueued_jobs do
|
27
|
+
Spam::DetectorJob.perform_later(post)
|
28
|
+
end
|
29
|
+
|
30
|
+
assert_counter "active_job.Spam-DetectorJob.enqueue"
|
31
|
+
assert_timer "active_job.Spam-DetectorJob.perform"
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
require "helper"
|
2
|
+
|
3
|
+
class NamespacedMailerInstrumentationTest < ActionMailer::TestCase
|
4
|
+
include ActiveJob::TestHelper
|
5
|
+
|
6
|
+
tests Admin::PostMailer
|
7
|
+
|
8
|
+
setup :setup_subscriber
|
9
|
+
teardown :teardown_subscriber
|
10
|
+
|
11
|
+
def setup_subscriber
|
12
|
+
@subscriber = Nunes::Subscribers::ActionMailer.subscribe(adapter)
|
13
|
+
end
|
14
|
+
|
15
|
+
def teardown_subscriber
|
16
|
+
ActiveSupport::Notifications.unsubscribe @subscriber if @subscriber
|
17
|
+
end
|
18
|
+
|
19
|
+
test "deliver_now" do
|
20
|
+
Admin::PostMailer.created.deliver_now
|
21
|
+
assert_timer "action_mailer.deliver.Admin-PostMailer"
|
22
|
+
end
|
23
|
+
|
24
|
+
test "deliver_later" do
|
25
|
+
perform_enqueued_jobs do
|
26
|
+
Admin::PostMailer.created.deliver_later
|
27
|
+
end
|
28
|
+
assert_timer "action_mailer.deliver.Admin-PostMailer"
|
29
|
+
end
|
30
|
+
|
31
|
+
test "receive" do
|
32
|
+
Admin::PostMailer.receive Admin::PostMailer.created
|
33
|
+
assert_timer "action_mailer.receive.Admin-PostMailer"
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,55 @@
|
|
1
|
+
require "helper"
|
2
|
+
|
3
|
+
class NamespacedModelInstrumentationTest < ActiveSupport::TestCase
|
4
|
+
setup :setup_subscriber
|
5
|
+
teardown :teardown_subscriber
|
6
|
+
|
7
|
+
def setup_subscriber
|
8
|
+
@subscriber = Nunes::Subscribers::ActiveRecord.subscribe(adapter)
|
9
|
+
end
|
10
|
+
|
11
|
+
def teardown_subscriber
|
12
|
+
ActiveSupport::Notifications.unsubscribe @subscriber if @subscriber
|
13
|
+
end
|
14
|
+
|
15
|
+
test "transaction" do
|
16
|
+
Admin::Post.create(title: 'Testing')
|
17
|
+
|
18
|
+
assert_timer "active_record.sql.transaction_begin"
|
19
|
+
assert_timer "active_record.sql.transaction_commit"
|
20
|
+
end
|
21
|
+
|
22
|
+
test "create" do
|
23
|
+
Admin::Post.create(title: 'Testing')
|
24
|
+
|
25
|
+
assert_timer "active_record.sql"
|
26
|
+
assert_timer "active_record.sql.insert"
|
27
|
+
end
|
28
|
+
|
29
|
+
test "update" do
|
30
|
+
post = Admin::Post.create
|
31
|
+
adapter.clear
|
32
|
+
post.update_attributes(title: "Title")
|
33
|
+
|
34
|
+
assert_timer "active_record.sql"
|
35
|
+
assert_timer "active_record.sql.update"
|
36
|
+
end
|
37
|
+
|
38
|
+
test "find" do
|
39
|
+
post = Admin::Post.create
|
40
|
+
adapter.clear
|
41
|
+
Admin::Post.find(post.id)
|
42
|
+
|
43
|
+
assert_timer "active_record.sql"
|
44
|
+
assert_timer "active_record.sql.select"
|
45
|
+
end
|
46
|
+
|
47
|
+
test "destroy" do
|
48
|
+
post = Admin::Post.create
|
49
|
+
adapter.clear
|
50
|
+
post.destroy
|
51
|
+
|
52
|
+
assert_timer "active_record.sql"
|
53
|
+
assert_timer "active_record.sql.delete"
|
54
|
+
end
|
55
|
+
end
|
data/test/nunes_test.rb
CHANGED
@@ -17,4 +17,12 @@ class NunesTest < ActiveSupport::TestCase
|
|
17
17
|
end
|
18
18
|
end
|
19
19
|
end
|
20
|
+
|
21
|
+
test "class_to_metric" do
|
22
|
+
assert_equal nil, Nunes.class_to_metric(nil)
|
23
|
+
assert_equal "Foo", Nunes.class_to_metric("Foo")
|
24
|
+
assert_equal "Nunes", Nunes.class_to_metric(Nunes)
|
25
|
+
assert_equal "Spam-DetectorJob", Nunes.class_to_metric(Spam::DetectorJob)
|
26
|
+
assert_equal "Spam-DetectorJob", Nunes.class_to_metric("Spam::DetectorJob")
|
27
|
+
end
|
20
28
|
end
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
@@ -1,12 +1,7 @@
|
|
1
1
|
class Admin::PostsController < ApplicationController
|
2
|
-
# Use fake post for controller as I don't want active record to mingle here.
|
3
|
-
Post = Struct.new(:title)
|
4
|
-
|
5
2
|
def index
|
6
|
-
@posts =
|
7
|
-
|
8
|
-
Post.new('Second'),
|
9
|
-
]
|
3
|
+
@posts = Post.all
|
4
|
+
|
10
5
|
respond_to do |format|
|
11
6
|
format.html { render }
|
12
7
|
format.json { render :json => @posts }
|
File without changes
|
@@ -1,12 +1,6 @@
|
|
1
1
|
class PostsController < ApplicationController
|
2
|
-
# Use fake post for controller as I don't want active record to mingle here.
|
3
|
-
Post = Struct.new(:title)
|
4
|
-
|
5
2
|
def index
|
6
|
-
@posts =
|
7
|
-
Post.new('First'),
|
8
|
-
Post.new('Second'),
|
9
|
-
]
|
3
|
+
@posts = Post.all
|
10
4
|
end
|
11
5
|
|
12
6
|
def some_data
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
data/test/{rails_app/app/views → rails_app_4.2.5/app/views/admin}/post_mailer/created.text.erb
RENAMED
File without changes
|
File without changes
|
File without changes
|
@@ -0,0 +1 @@
|
|
1
|
+
PostMailer#created.
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|