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

Prevent update block called on first time app installed. #25

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

ajmccall
Copy link
Contributor

Hey, when using your library in our code, we've found the need to _NOT_ call the updateBlock when the application is started from a fresh install. In fact, we've had to code defensively around this case.

I have since forked your code and created a private pod, but thought that this change might be something that you would want.

Being a good citizen I've written unit tests around the new method. I found it difficult to mock/change the application version and build numbers as need for my test. So I used a technique called method swizzling to properly mock out these values. See it at the bottom of the unit test class.

In addition I added an example test method to show case how much more powerful these tests can be instead of relying on the test project's bundle values. Seemed pretty important as MTMigration core is built around these bundle values.

I hope this all makes sense. Let me know what you think.

Thanks for the pod, very helpful otherwise.

Added new method `+ (void) applicationUpdateBlock:(MTExecutionBlock)updateBlock ignoreFirstInstall:(BOOL)ignoreFirstInstall;` to allow the implementing client the chance to NOT invoke the block when the app has been install.

`MTMigration.m`
Implemented new method.
Made the BOOLEAN statements read easier with `BOOL` variable breaking down the logic.
Added unit tests around the new method `+ (void) applicationUpdateBlock:(MTExecutionBlock)updateBlock ignoreFirstInstall:(BOOL)ignoreFirstInstall;`
Used a technique called method swizzling, providing the simplest solution to mocking out the `[NSBundle mainBundle]` method in this static class. This allows the testing methods to mock the appVersion and appBuild values used in `MTMigration`
@ajmccall
Copy link
Contributor Author

Wait, I didn't see that this has been discussed at length here.

#3

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.

1 participant