Skip to content

Commit 3ea645c

Browse files
authored
Merge pull request #702 from gitx/show-the-history-view-in-the-wiring-tests
Fix CI-Tests - solve false-negative caused by poor setup (issue #703)
2 parents b54bb4b + be838ee commit 3ea645c

1 file changed

Lines changed: 15 additions & 0 deletions

File tree

‎GitXTests/PBGitWindowWiringTests.m‎

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
#import "PBGitWindowController.h"
88
#import "PBGitRepository.h"
99
#import "PBGitSidebarController.h"
10+
#import "PBGitDefaults.h"
1011
#import "PBGitHistoryController.h"
1112
#import "PBGitHistoryList.h"
1213
#import "PBGitCommit.h"
@@ -38,6 +39,7 @@ - (PBGitRepository *)repository
3839
@interface PBGitWindowWiringTests : XCTestCase
3940
@property (nonatomic, strong) PBStubWindowController *windowController;
4041
@property (nonatomic, strong) NSURL *repositoryURL;
42+
@property (nonatomic, strong) id settingToPutBack;
4143
@end
4244

4345
@implementation PBGitWindowWiringTests
@@ -88,6 +90,14 @@ - (void)setUp
8890
{
8991
[super setUp];
9092

93+
// The sidebar opens whichever view this preference names, and the window
94+
// loads a nib only for the controller it shows, so a GitX left on the stage
95+
// view would leave the history list and its array controller nil here. The
96+
// tests run in the application, so put back what was there afterwards.
97+
self.settingToPutBack = [[NSUserDefaults standardUserDefaults] objectForKey:@"PBShowStageView"];
98+
[[NSUserDefaults standardUserDefaults] setBool:NO forKey:@"PBShowStageView"];
99+
XCTAssertFalse([PBGitDefaults showStageView], @"the preference this suite turns off is read under some other name now, so it is no longer being turned off");
100+
91101
self.repositoryURL = [self makeRepository];
92102

93103
NSError *error = nil;
@@ -126,6 +136,11 @@ - (void)tearDown
126136
self.windowController = nil;
127137
[[NSFileManager defaultManager] removeItemAtURL:self.repositoryURL error:NULL];
128138

139+
if (self.settingToPutBack)
140+
[[NSUserDefaults standardUserDefaults] setObject:self.settingToPutBack forKey:@"PBShowStageView"];
141+
else
142+
[[NSUserDefaults standardUserDefaults] removeObjectForKey:@"PBShowStageView"];
143+
129144
[super tearDown];
130145
}
131146

0 commit comments

Comments
 (0)