Skip to content

Commit be838ee

Browse files
committed
Fix the wiring tests inheriting whichever view ran last (issue #643)
These tests expect the window to be showing the history view, while the screenshot tests leave the application showing the stage view, so once both have run in one job every later run fails the same way. * turn PBShowStageView off in -setUp, before the window is built, so the suite asks for the view it goes on to assert on * put the old value back in -tearDown, absent or set, so the suite stops leaking the preference to whatever runs after it
1 parent b54bb4b commit be838ee

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)