From 32efd614a1207eb0037a2b08f431e3ec2becd354 Mon Sep 17 00:00:00 2001 From: Miguel Soriano Date: Mon, 16 Apr 2018 10:27:34 +0200 Subject: [PATCH] transactor/status_test: Add application/user_id existence testing --- test/unit/transactor/status_test.rb | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/test/unit/transactor/status_test.rb b/test/unit/transactor/status_test.rb index f3deb4460..50b199cbe 100644 --- a/test/unit/transactor/status_test.rb +++ b/test/unit/transactor/status_test.rb @@ -237,5 +237,33 @@ def setup assert_nil month['exceeded'] assert_equal 'true', day['exceeded'] end + + test '#to_xml shows the application id when OAuth is used' do + usage = {:month => {@metric_id.to_s => 429}} + status = Transactor::Status.new(service_id: @service_id, + application: @application, + values: usage, + oauth: true) + + doc = Nokogiri::XML(status.to_xml) + + assert_equal @application.id, doc.at('status application id').content + end + + test '#to_xml shows the username along with the application when OAuth and a User are used' do + usage = {:month => {@metric_id.to_s => 429}} + user = User.new(service_id: @service_id, + username: "testusername") + status = Transactor::Status.new(service_id: @service_id, + application: @application, + values: usage, + oauth: true, + user: user + ) + doc = Nokogiri::XML(status.to_xml) + + assert_equal "testusername", doc.at('status user id').content + assert_equal @application.id, doc.at('status application id').content + end end end