Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix config.log_silently? #324

Merged
merged 3 commits into from
Apr 12, 2016

Conversation

noahhaon
Copy link

@noahhaon noahhaon commented Mar 8, 2016

log_silently? would almost always return true, now it honors the config value unless the RAILS_GROUPS env var is set to assets.


it "log_silently? should always be true if ENV['RAILS_GROUPS'] == 'assets'" do
AssetSync.config.log_silently = false
expect(ENV).to receive(:[]).with('RAILS_GROUPS').and_return('assets')
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it should be allow(ENV)?
Since It looks like part of test setup to me.

If I guess it wrong please tell me what it is.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

expect(ENV) has the same behavior (stubbing) as allow(ENV) but also sets up an expectation that the var will be checked in ENV. Just adds more coverage, but I can change it if you would prefer.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK I think it's fine to have expect
But you should add a comment explaining what that line does (stub + expect)
It's easier for people to read comments than finding history => PR => Line note :)

Edit: Changed some wording

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it is self-explanatory, but I have added a comment to be sure :)

@@ -94,7 +94,7 @@ def fail_silently?
end

def log_silently?
ENV['RAILS_GROUPS'] == 'assets' || self.log_silently == false
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we consider nil as false?
I know the default value is true, but if someone accidentally assigned nil to that attribute
Should we throw warning or something?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe if we warned on nil elsewhere in handling the config options? For something as benign as logging, casting nil to false is probably OK :)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK let's do it later (maybe until someone complains)

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@PikachuEXE
Copy link
Member

Won't wait, he is too slow :(

@PikachuEXE PikachuEXE merged commit 46cfb5f into AssetSync:master Apr 12, 2016
@PikachuEXE
Copy link
Member

@noahhaon
I created a PR #330 for changing the behaviour slightly
Will merge next week if no objection

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants