Skip to content

Commit

Permalink
fix insertion at zero index path in empty section
Browse files Browse the repository at this point in the history
  • Loading branch information
DenTelezhkin committed Oct 18, 2015
1 parent 4ca8a82 commit 156e9e0
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 2 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
# Change Log
All notable changes to this project will be documented in this file.

## [2.1.3](https://github.com/DenHeadless/DTModelStorage/releases/tag/2.1.3)

### Fixed

* `insertItem(_:atIndexPath:)` method now properly accepts zero index path in empty section

## [2.1.2](https://github.com/DenHeadless/DTModelStorage/releases/tag/2.1.2)

### Added
Expand Down
2 changes: 1 addition & 1 deletion DTModelStorage.podspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = 'DTModelStorage'
s.version = '2.1.2'
s.version = '2.1.3'
s.license = 'MIT'
s.summary = 'Storage classes for datasource based controls.'
s.homepage = 'https://github.com/DenHeadless/DTModelStorage'
Expand Down
2 changes: 1 addition & 1 deletion DTModelStorage/Memory/MemoryStorage.swift
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ public class MemoryStorage: BaseStorage, StorageProtocol
self.startUpdate()
let section = self.getValidSection(indexPath.section)

guard section.items.count > indexPath.item else { throw MemoryStorageErrors.Insertion.IndexPathTooBig }
guard section.items.count >= indexPath.item else { throw MemoryStorageErrors.Insertion.IndexPathTooBig }

section.items.insert(item, atIndex: indexPath.item)
self.currentUpdate?.insertedRowIndexPaths.insert(indexPath)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -408,4 +408,14 @@ class SectionSupplementariesTestCase : XCTestCase

storage.insertSection(section, atIndex: 1)
}

func testInsertionAtFirstIndexPath()
{
do {
try storage.insertItem(1, toIndexPath: indexPath(0, 0))
}
catch _ {
XCTFail()
}
}
}

0 comments on commit 156e9e0

Please sign in to comment.