mirror of
https://github.com/ditkrg/active_model_serializers.git
synced 2026-01-22 22:06:50 +00:00
Merge pull request #620 from tristandunn/td-notifications
Avoid overwriting notifications for template assertions.
This commit is contained in:
commit
922dd273c9
@ -3,11 +3,11 @@ module ActionController
|
||||
extend ActiveSupport::Concern
|
||||
|
||||
included do
|
||||
setup :setup_subscriptions
|
||||
teardown :teardown_subscriptions
|
||||
setup :setup_serialization_subscriptions
|
||||
teardown :teardown_serialization_subscriptions
|
||||
end
|
||||
|
||||
def setup_subscriptions
|
||||
def setup_serialization_subscriptions
|
||||
@serializers = Hash.new(0)
|
||||
|
||||
ActiveSupport::Notifications.subscribe("!serialize.active_model_serializers") do |name, start, finish, id, payload|
|
||||
@ -16,7 +16,7 @@ module ActionController
|
||||
end
|
||||
end
|
||||
|
||||
def teardown_subscriptions
|
||||
def teardown_serialization_subscriptions
|
||||
ActiveSupport::Notifications.unsubscribe("!serialize.active_model_serializers")
|
||||
end
|
||||
|
||||
|
||||
1
test/fixtures/template.html.erb
vendored
Normal file
1
test/fixtures/template.html.erb
vendored
Normal file
@ -0,0 +1 @@
|
||||
<p>Hello.</p>
|
||||
@ -11,6 +11,11 @@ module ActionController
|
||||
def render_text
|
||||
render text: 'ok'
|
||||
end
|
||||
|
||||
def render_template
|
||||
prepend_view_path "./test/fixtures"
|
||||
render template: "template"
|
||||
end
|
||||
end
|
||||
|
||||
tests MyController
|
||||
@ -56,6 +61,11 @@ module ActionController
|
||||
end
|
||||
assert_match 'assert_serializer only accepts a String, Symbol, Regexp, ActiveModel::Serializer, or nil', e.message
|
||||
end
|
||||
|
||||
def test_does_not_overwrite_notification_subscriptions
|
||||
get :render_template
|
||||
assert_template "template"
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Loading…
Reference in New Issue
Block a user