diff --git a/CHANGELOG.md b/CHANGELOG.md index cb91e3b2..5cec3aef 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/DTModelStorage.podspec b/DTModelStorage.podspec index 6f0cbc98..74dd8d16 100644 --- a/DTModelStorage.podspec +++ b/DTModelStorage.podspec @@ -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' diff --git a/DTModelStorage/Memory/MemoryStorage.swift b/DTModelStorage/Memory/MemoryStorage.swift index c4aa3ed0..05e5cf1c 100644 --- a/DTModelStorage/Memory/MemoryStorage.swift +++ b/DTModelStorage/Memory/MemoryStorage.swift @@ -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) diff --git a/DTModelStorageTests/XCTests/Specs/MemoryStorage/MemoryStorageEditSpecs.swift b/DTModelStorageTests/XCTests/Specs/MemoryStorage/MemoryStorageEditSpecs.swift index 3a236e28..5e61f499 100644 --- a/DTModelStorageTests/XCTests/Specs/MemoryStorage/MemoryStorageEditSpecs.swift +++ b/DTModelStorageTests/XCTests/Specs/MemoryStorage/MemoryStorageEditSpecs.swift @@ -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() + } + } }