spec/pull_spec.rb in eternity-3.0.1 vs spec/pull_spec.rb in eternity-4.0.0
- old
+ new
@@ -20,25 +20,31 @@
other_repository = Repository.new :other
other_repository[:countries].insert 'AR', name: 'Argentina'
commit = other_repository.commit author: 'User', message: 'Commit 1'
other_repository.push
- delta = repository.pull
+ patch = repository.pull
- delta.must_equal 'countries' => {'AR' => {'action' => 'insert', 'data' => {'name' => 'Argentina'}}}
+ patch.delta.must_equal 'countries' => {'AR' => {'action' => 'insert', 'data' => {'name' => 'Argentina'}}}
+ patch.current_commit.must_be_nil
+ patch.target_commit.must_equal commit
+
repository.current_commit.must_equal commit
repository.branches[repository.current_branch].must_equal commit.id
end
it 'Up to date' do
repository[:countries].insert 'AR', name: 'Argentina'
commit_1 = repository.commit author: 'User', message: 'Commit 1'
repository.push
- delta = repository.pull
+ patch = repository.pull
- delta.must_be_empty
+ patch.delta.must_be_empty
+ patch.current_commit.must_equal commit_1
+ patch.target_commit.must_equal commit_1
+
repository.current_commit.must_equal commit_1
end
it 'Ahead of branch' do
repository[:countries].insert 'AR', name: 'Argentina'
@@ -47,37 +53,44 @@
repository.push
repository[:countries].insert 'UY', name: 'Uruguay'
commit_2 = repository.commit author: 'User', message: 'Commit 2'
- delta = repository.pull
+ patch = repository.pull
- delta.must_be_empty
+ patch.delta.must_be_empty
+ patch.current_commit.must_equal commit_2
+ patch.target_commit.must_equal commit_1
+
repository.current_commit.must_equal commit_2
end
it 'Fast-forward' do
repository[:countries].insert 'AR', name: 'Argentina'
commit_1 = repository.commit author: 'User', message: 'Commit 1'
repository.push
other_repository = Repository.new :other
- delta = other_repository.pull
+ patch = other_repository.pull
- delta.must_equal 'countries' => {'AR' => {'action' => 'insert', 'data' => {'name' => 'Argentina'}}}
+ patch.delta.must_equal 'countries' => {'AR' => {'action' => 'insert', 'data' => {'name' => 'Argentina'}}}
+ patch.current_commit.must_be_nil
+ patch.target_commit.must_equal commit_1
repository[:countries].insert 'UY', name: 'Uruguay'
commit_2 = repository.commit author: 'User', message: 'Commit 2'
repository.push
other_repository.wont_be :changes?
other_repository.current_commit.must_equal commit_1
other_repository.branches[other_repository.current_branch].must_equal commit_1.id
- delta = other_repository.pull
+ patch = other_repository.pull
- delta.must_equal 'countries' => {'UY' => {'action' => 'insert', 'data' => {'name' => 'Uruguay'}}}
+ patch.delta.must_equal 'countries' => {'UY' => {'action' => 'insert', 'data' => {'name' => 'Uruguay'}}}
+ patch.current_commit.must_equal commit_1
+ patch.target_commit.must_equal commit_2
other_repository.wont_be :changes?
other_repository.current_commit.must_equal commit_2
other_repository.branches[other_repository.current_branch].must_equal commit_2.id
end
@@ -86,14 +99,16 @@
repository[:countries].insert 'AR', name: 'Argentina'
commit_1 = repository.commit author: 'User', message: 'Commit 1'
repository.push
other_repository = Repository.new :other
- delta = other_repository.pull
-
- delta.must_equal 'countries' => {'AR' => {'action' => 'insert', 'data' => {'name' => 'Argentina'}}}
+ patch = other_repository.pull
+ patch.delta.must_equal 'countries' => {'AR' => {'action' => 'insert', 'data' => {'name' => 'Argentina'}}}
+ patch.current_commit.must_be_nil
+ patch.target_commit.must_equal commit_1
+
other_repository[:countries].insert 'UY', name: '...'
commit_2 = other_repository.commit author: 'User', message: 'Commit 2'
other_repository[:countries].update 'UY', name: 'Uruguay'
commit_3 = other_repository.commit author: 'User', message: 'Commit 3'
@@ -101,13 +116,15 @@
other_repository.push
repository[:countries].insert 'BR', name: 'Brasil'
commit_4 = repository.commit author: 'User', message: 'Commit 4'
- delta = repository.pull
+ patch = repository.pull
- delta.must_equal 'countries' => {'UY' => {'action' => 'insert', 'data' => {'name' => 'Uruguay'}}}
+ patch.delta.must_equal 'countries' => {'UY' => {'action' => 'insert', 'data' => {'name' => 'Uruguay'}}}
+ patch.current_commit.must_equal commit_4
+ patch.target_commit.must_equal commit_3
repository.branches[repository.current_branch].must_equal repository.current_commit.id
repository.current_commit.tap do |commit|
commit.must_be :merge?
@@ -126,23 +143,27 @@
repository[:countries].insert 'AR', name: 'Argentina 1'
commit_1 = repository.commit author: 'User', message: 'Commit 1'
repository.push
other_repository = Repository.new :other
- delta = other_repository.pull
+ patch = other_repository.pull
- delta.must_equal 'countries' => {'AR' => {'action' => 'insert', 'data' => {'name' => 'Argentina 1'}}}
+ patch.delta.must_equal 'countries' => {'AR' => {'action' => 'insert', 'data' => {'name' => 'Argentina 1'}}}
+ patch.current_commit.must_be_nil
+ patch.target_commit.must_equal commit_1
other_repository[:countries].update 'AR', name: 'Argentina 2', number: 54
commit_2 = other_repository.commit author: 'User', message: 'Commit 2'
other_repository.push
repository[:countries].update 'AR', name: 'Argentina 3'
commit_3 = repository.commit author: 'User', message: 'Commit 3'
- delta = repository.pull
+ patch = repository.pull
- delta.must_equal 'countries' => {'AR' => {'action' => 'update', 'data' => {'name' => 'Argentina 3', 'number' => 54}}}
+ patch.delta.must_equal 'countries' => {'AR' => {'action' => 'update', 'data' => {'name' => 'Argentina 3', 'number' => 54}}}
+ patch.current_commit.must_equal commit_3
+ patch.target_commit.must_equal commit_2
repository.branches[repository.current_branch].must_equal repository.current_commit.id
repository.current_commit.tap do |commit|
commit.must_be :merge?
@@ -157,23 +178,27 @@
repository[:countries].insert 'AR', name: 'Argentina'
commit_1 = repository.commit author: 'User', message: 'Commit 1'
repository.push
other_repository = Repository.new :other
- delta = other_repository.pull
+ patch = other_repository.pull
- delta.must_equal 'countries' => {'AR' => {'action' => 'insert', 'data' => {'name' => 'Argentina'}}}
+ patch.delta.must_equal 'countries' => {'AR' => {'action' => 'insert', 'data' => {'name' => 'Argentina'}}}
+ patch.current_commit.must_be_nil
+ patch.target_commit.must_equal commit_1
other_repository[:countries].update 'AR', name: 'Argentina', number: 54
commit_2 = other_repository.commit author: 'User', message: 'Commit 2'
other_repository.push
repository[:countries].update 'AR', name: 'Argentina', code: 'ARG'
commit_3 = repository.commit author: 'User', message: 'Commit 3'
- delta = repository.pull
+ patch = repository.pull
- delta.must_equal 'countries' => {'AR' => {'action' => 'update', 'data' => {'name' => 'Argentina', 'code' => 'ARG', 'number' => 54}}}
+ patch.delta.must_equal 'countries' => {'AR' => {'action' => 'update', 'data' => {'name' => 'Argentina', 'code' => 'ARG', 'number' => 54}}}
+ patch.current_commit.must_equal commit_3
+ patch.target_commit.must_equal commit_2
repository.branches[repository.current_branch].must_equal repository.current_commit.id
repository.current_commit.tap do |commit|
commit.must_be :merge?
@@ -188,23 +213,27 @@
repository[:countries].insert 'AR', name: 'Argentina'
commit_1 = repository.commit author: 'User', message: 'Commit 1'
repository.push
other_repository = Repository.new :other
- delta = other_repository.pull
+ patch = other_repository.pull
+ patch.current_commit.must_be_nil
+ patch.target_commit.must_equal commit_1
- delta.must_equal 'countries' => {'AR' => {'action' => 'insert', 'data' => {'name' => 'Argentina'}}}
+ patch.delta.must_equal 'countries' => {'AR' => {'action' => 'insert', 'data' => {'name' => 'Argentina'}}}
other_repository[:countries].insert 'X', name: 'X1', code: 1
commit_2 = other_repository.commit author: 'User', message: 'Commit 2'
other_repository.push
repository[:countries].insert 'X', name: 'X2', number: 2
commit_3 = repository.commit author: 'User', message: 'Commit 3'
- delta = repository.pull
+ patch = repository.pull
- delta.must_equal 'countries' => {'X' => {'action' => 'update', 'data' => {'name' => 'X2', 'number' => 2, 'code' => 1}}}
+ patch.delta.must_equal 'countries' => {'X' => {'action' => 'update', 'data' => {'name' => 'X2', 'number' => 2, 'code' => 1}}}
+ patch.current_commit.must_equal commit_3
+ patch.target_commit.must_equal commit_2
repository.branches[repository.current_branch].must_equal repository.current_commit.id
repository.current_commit.tap do |commit|
commit.must_be :merge?
@@ -222,24 +251,28 @@
repository[:countries].insert 'AR', name: 'Argentina'
commit_1 = repository.commit author: 'User', message: 'Commit 1'
repository.push
other_repository = Repository.new :other
- delta = other_repository.pull
+ patch = other_repository.pull
- delta.must_equal 'countries' => {'AR' => {'action' => 'insert', 'data' => {'name' => 'Argentina'}}}
+ patch.delta.must_equal 'countries' => {'AR' => {'action' => 'insert', 'data' => {'name' => 'Argentina'}}}
+ patch.current_commit.must_be_nil
+ patch.target_commit.must_equal commit_1
other_repository[:countries].delete 'AR'
commit_2 = other_repository.commit author: 'User', message: 'Commit 2'
other_repository.push
repository[:countries].delete 'AR'
commit_3 = repository.commit author: 'User', message: 'Commit 3'
- delta = repository.pull
+ patch = repository.pull
- delta.must_be_empty
+ patch.delta.must_be_empty
+ patch.current_commit.must_equal commit_3
+ patch.target_commit.must_equal commit_2
repository.branches[repository.current_branch].must_equal repository.current_commit.id
repository.current_commit.tap do |commit|
commit.must_be :merge?
@@ -254,24 +287,28 @@
repository[:countries].insert 'AR', name: 'Argentina'
commit_1 = repository.commit author: 'User', message: 'Commit 1'
repository.push
other_repository = Repository.new :other
- delta = other_repository.pull
+ patch = other_repository.pull
- delta.must_equal 'countries' => {'AR' => {'action' => 'insert', 'data' => {'name' => 'Argentina'}}}
+ patch.delta.must_equal 'countries' => {'AR' => {'action' => 'insert', 'data' => {'name' => 'Argentina'}}}
+ patch.current_commit.must_be_nil
+ patch.target_commit.must_equal commit_1
other_repository[:countries].delete 'AR'
commit_2 = other_repository.commit author: 'User', message: 'Commit 2'
other_repository.push
repository[:countries].update 'AR', name: 'Argentina', code: 'ARG'
commit_3 = repository.commit author: 'User', message: 'Commit 3'
- delta = repository.pull
+ patch = repository.pull
- delta.must_be_empty
-
+ patch.delta.must_be_empty
+ patch.current_commit.must_equal commit_3
+ patch.target_commit.must_equal commit_2
+
repository.branches[repository.current_branch].must_equal repository.current_commit.id
repository.current_commit.tap do |commit|
commit.must_be :merge?
commit.parents.must_equal [commit_3, commit_2]
\ No newline at end of file