Skip to content

Commit 58f463d

Browse files
committed
Merge branch 'release/2.0.7'
2 parents 835b467 + 601869e commit 58f463d

File tree

4 files changed

+26
-9
lines changed

4 files changed

+26
-9
lines changed

MagicalRecord.podspec

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
Pod::Spec.new do |s|
22
s.name = 'MagicalRecord'
3-
s.version = '2.0.6'
3+
s.version = '2.0.7'
44
s.license = 'MIT'
55
s.summary = 'Super Awesome Easy Fetching for Core Data 1!!!11!!!!1!.'
66
s.homepage = 'http://github.com/magicalpanda/MagicalRecord'
77
s.author = { 'Saul Mora' => '[email protected]' }
8-
s.source = { :git => 'https://github.com/magicalpanda/MagicalRecord.git', :tag => '2.0.6' }
8+
s.source = { :git => 'https://github.com/magicalpanda/MagicalRecord.git', :tag => '2.0.7' }
99
s.description = 'Handy fetching, threading and data import helpers to make Core Data a little easier to use.'
1010
s.source_files = 'MagicalRecord/**/*.{h,m}'
1111
s.framework = 'CoreData'

MagicalRecord/Categories/NSManagedObjectContext/NSManagedObjectContext+MagicalSaves.m

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -95,13 +95,13 @@ - (void) MR_saveErrorHandler:(void (^)(NSError *))errorCallback;
9595
{
9696
[self performBlockAndWait:^{
9797
[self MR_saveWithErrorCallback:errorCallback];
98+
99+
if (self.parentContext) {
100+
[[self parentContext] performBlockAndWait:^{
101+
[[self parentContext] MR_saveErrorHandler:errorCallback];
102+
}];
103+
}
98104
}];
99-
100-
if (self == [[self class] MR_defaultContext])
101-
{
102-
// Since this is a synchronous call, I made the background context save synchronous as well to reflect the intent.
103-
[[[self class] MR_rootSavingContext] MR_saveErrorHandler:errorCallback];
104-
}
105105
}
106106

107107
- (void) MR_saveInBackgroundCompletion:(void (^)(void))completion;

MagicalRecord/Core/MagicalRecord+Actions.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ + (void) saveWithBlock:(void (^)(NSManagedObjectContext *localContext))block com
6666

6767
if ([localContext hasChanges])
6868
{
69-
[localContext MR_saveNestedContextsErrorHandler:errorHandler];
69+
[localContext MR_saveErrorHandler:errorHandler];
7070
}
7171

7272
if (completion)

Project Files/Unit Tests/SaveTests.m

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,4 +65,21 @@ - (void)testBackgroundSavesActuallySave
6565
expect([fetchedObject hasChanges]).to.beFalsy();
6666
}
6767

68+
- (void)testCurrentThreadSavesActuallySave
69+
{
70+
__block NSManagedObjectID *objectId;
71+
__block NSManagedObject *fetchedObject;
72+
[MagicalRecord saveWithBlock:^(NSManagedObjectContext *localContext) {
73+
NSManagedObject *inserted = [SingleEntityWithNoRelationships MR_createInContext:localContext];
74+
expect([inserted hasChanges]).to.beTruthy();
75+
[localContext obtainPermanentIDsForObjects:@[inserted] error:nil];
76+
objectId = inserted.objectID;
77+
}];
78+
79+
fetchedObject = [[NSManagedObjectContext MR_rootSavingContext] objectWithID:objectId];
80+
81+
expect(fetchedObject).toNot.beNil();
82+
expect([fetchedObject hasChanges]).to.beFalsy();
83+
}
84+
6885
@end

0 commit comments

Comments
 (0)