This file contains hidden or 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
| begin | |
| require 'offshore/tasks' if defined?(Offshore) | |
| rescue | |
| end |
This file contains hidden or 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
| group :test do | |
| gem 'offshore' | |
| end |
This file contains hidden or 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
| describe "Integration Test", type: :request do | |
| it "should work as expected" do | |
| Offshore.test.start(example) | |
| user = users(:billy) | |
| worker = users(:robby) | |
| task = FactoryOffshore.create(:task_posted, :user_id => user.id) | |
| offer = FactoryOffshore.create(:offer, :worker_id => worker.id) | |
This file contains hidden or 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
| // MyAuthController.m | |
| -(void) didSubmitLogin { | |
| [CurrentUser loginWithEmail:self.emailField.text password:self.passwordField.text success:^{ | |
| [self closeAuthentication:YES]; | |
| } failure:^(NSError *error) { | |
| [self showError:error]; | |
| }]; | |
| } | |
| -(void) didTapCancelButton { | |
| [self closeAuthentication:NO]; |
This file contains hidden or 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
| // MyAppDelegate.m | |
| - (void) authenticateWithSuccess:(MyVoidBlock)success { | |
| if ([CurrentUser isLoggedIn]) { | |
| // return immediately if the user is already logged in | |
| success(); | |
| } | |
| else { | |
| // otherwise, launch view that allows login or signup, passing block along | |
| MyAuthController * auth = [[MyAuthController alloc] initWithSuccess:success]; | |
| auth.modalTransitionStyle = UIModalTransitionStyleCoverVertical; |
This file contains hidden or 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
| // MyAppDelegate.h | |
| - (void) authenticateWithSuccess:(MyVoidBlockWithUser)success; |
This file contains hidden or 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
| // MyIdeaViewController.m | |
| -(void) favoriteButtonPressed: { | |
| MyAppDelegate * delegate = (MyAppDelegate*) [[UIApplication sharedApplication] delegate]; | |
| [delegate authenticateWithSuccess:^{ | |
| [[CurrentUser shared] setIdeaAsFavorite: self.idea]; | |
| }]; | |
| } |
This file contains hidden or 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
| // MyAppDelegate.h | |
| #import <UIKit/UIKit.h> | |
| @interface MyAppDelegate : UIResponder <UIApplicationDelegate> | |
| - (void) authenticateWithSuccess:(MyVoidBlock)success; | |
| @end |
This file contains hidden or 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
| typedef void (^MyVoidBlock)(); | |
| typedef void (^MyVoidBlockWithBool)(BOOL); | |
| typedef void (^MyVoidBlockWithString)(NSString *); | |
| typedef void (^MyVoidBlockWithDictionary)(NSDictionary *); | |
| typedef BOOL (^MyBoolBlockWithString)(NSString *); |
This file contains hidden or 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
| NSComparator finderSortBlock = ^(id string1, id string2) { | |
| NSRange string1Range = NSMakeRange(0, [string1 length]); | |
| return [string1 compare:string2 options:comparisonOptions range:string1Range locale:currentLocale]; | |
| }; | |
| NSArray *finderSortArray = [stringsArray sortedArrayUsingComparator:finderSortBlock]; |