-
Notifications
You must be signed in to change notification settings - Fork 300
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fintechqb 1967 enable service level logging (#600)
* Add total_tax_specified xml_accessor to TransactionTaxDetail In a recent update to the QBO API, if a company that uses automated sales tax has an invoice that has no tax amount, we need to specify TotalTaxSpecified = false. Not passing this results in an error from QBO indicating that sales tax was miscalculated. * Accidentally commited a binding.pry * Add condense_logs to quickbooks config & update logs to only log once per request and once per response if enabled * Update variable names & move condense_logs? checks to logging util * Update Quickbooks.log to log without condition & move condition to logging utility to allow per-service-instance logging capability * Update README to include instance configurability demo * Update log settings check to check for ivar definition instead of just memoizing to handle @log explicitly being set to false for an instance --------- Co-authored-by: Daniel Ho <[email protected]>
- Loading branch information
1 parent
dd300ed
commit 6d6422d
Showing
4 changed files
with
72 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
describe Quickbooks::Util::Logging do | ||
before { Quickbooks.log = general_log_setting } | ||
let(:general_log_setting) { true } | ||
let(:dummy_class) { Class.new { include Quickbooks::Util::Logging } } | ||
|
||
describe 'log' do | ||
context 'when one service needs to log but general logging is disabled' do | ||
let(:general_log_setting) { false } | ||
let(:control_instance) { instance = dummy_class.new } | ||
let(:loggable_instance) do | ||
instance = dummy_class.new | ||
instance.log = true | ||
instance | ||
end | ||
|
||
it 'allows one service instance to log without affecting other service instances' do | ||
expect(Quickbooks.log?).to be(false) | ||
expect(control_instance.log?).to be(false) | ||
expect(loggable_instance.log?).to be(true) | ||
end | ||
|
||
it 'does not log if disabled' do | ||
expect(Quickbooks).not_to receive(:log) | ||
control_instance.log('test message') | ||
end | ||
|
||
it 'does log if enabled' do | ||
expect(Quickbooks).to receive(:log) | ||
loggable_instance.log('test message') | ||
end | ||
end | ||
|
||
context 'when one service needs to not log but general logging is enabled' do | ||
let(:control_instance) { instance = dummy_class.new } | ||
let(:unloggable_instance) do | ||
instance = dummy_class.new | ||
instance.log = false | ||
instance | ||
end | ||
|
||
it 'allows one service instance to log without affecting other service instances' do | ||
expect(Quickbooks.log?).to be(true) | ||
expect(control_instance.log?).to be(true) | ||
expect(unloggable_instance.log?).to be(false) | ||
end | ||
|
||
it 'does not log if disabled' do | ||
expect(Quickbooks).not_to receive(:log) | ||
unloggable_instance.log('test message') | ||
end | ||
|
||
it 'does log if enabled' do | ||
expect(Quickbooks).to receive(:log) | ||
control_instance.log('test message') | ||
end | ||
end | ||
end | ||
end |
6d6422d
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ruckus hey there!
Do you plan to bump the 1.x.x version to make new additions available?
Is
2-stable
going to continue to merge functionality changes from master, or will it be merged to master in the nearish future?Thanks!
Andy
6d6422d
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @andymond
I just released both
2.0.3
and1.0.22
.The whole thing is kind of a mess and supporting both branches is not a long term solution. Maybe for sanity sake I will need to break out
2-stable
into its own gem, likequickbooks-ruby-nextgen
or whatever. Horrible name, but you get the idea.Too bad there was no ChatGPT assistant to manage all of this 🥲
6d6422d
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ruckus I can't find any commits on 2-stable and it looks like this was the only change merged since then.
Maybe you forgot to push the updates to the branch?
6d6422d
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ruckus thanks for doing that!
I guess I would think these breaking changes would be OK on master since it's a major version upgrade, projects using the gem w/o a version lock should have some kind of protection via tests that would catch this before it sets anything on fire. I know our project would be OK w quickbooks-ruby only supporting 2.6+!
6d6422d
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @andymond you're right, I did forget to push to
2-stable
🤦 . I just did6d6422d
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ruckus you got the version numbers wrong in the commit message and changelog, it should be
2.0.3
instead of2.0.2
.