gitdocs 0.5.0.pre1 → 0.5.0.pre2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/CHANGELOG +6 -2
- data/README.md +1 -0
- data/gitdocs.gemspec +3 -1
- data/lib/gitdocs.rb +4 -0
- data/lib/gitdocs/cli.rb +22 -21
- data/lib/gitdocs/configuration.rb +0 -14
- data/lib/gitdocs/manager.rb +2 -13
- data/lib/gitdocs/notifier.rb +38 -0
- data/lib/gitdocs/repository.rb +348 -0
- data/lib/gitdocs/runner.rb +69 -192
- data/lib/gitdocs/server.rb +20 -22
- data/lib/gitdocs/version.rb +1 -1
- data/lib/gitdocs/views/settings.haml +3 -3
- data/test/configuration_test.rb +2 -0
- data/test/integration/full_sync_test.rb +67 -0
- data/test/integration/share_management_test.rb +46 -0
- data/test/integration/status_test.rb +19 -0
- data/test/integration/test_helper.rb +130 -0
- data/test/notifier_test.rb +68 -0
- data/test/repository_test.rb +578 -0
- data/test/runner_test.rb +133 -16
- data/test/test_helper.rb +0 -1
- metadata +46 -4
data/test/runner_test.rb
CHANGED
@@ -1,25 +1,142 @@
|
|
1
1
|
require File.expand_path('../test_helper', __FILE__)
|
2
2
|
|
3
3
|
describe 'gitdocs runner' do
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
4
|
+
before { ENV['TEST'] = 'true' }
|
5
|
+
|
6
|
+
describe 'syncing' do
|
7
|
+
it 'should clone files' do
|
8
|
+
with_clones(3) do |clone1, clone2, clone3|
|
9
|
+
File.open(File.join(clone1, 'test'), 'w') { |f| f << 'testing' }
|
10
|
+
sleep 3
|
11
|
+
assert_equal 'testing', File.read(File.join(clone1, 'test'))
|
12
|
+
assert_equal 'testing', File.read(File.join(clone2, 'test'))
|
13
|
+
assert_equal 'testing', File.read(File.join(clone3, 'test'))
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
it 'should resolve conflicts files' do
|
18
|
+
with_clones(3) do |clone1, clone2, clone3|
|
19
|
+
File.open(File.join(clone1, 'test.txt'), 'w') { |f| f << 'testing' }
|
20
|
+
sleep 3
|
21
|
+
File.open(File.join(clone1, 'test.txt'), 'w') { |f| f << "testing\n1" }
|
22
|
+
File.open(File.join(clone2, 'test.txt'), 'w') { |f| f << "testing\n2" }
|
23
|
+
sleep 3
|
24
|
+
assert_includes 2..3, Dir[File.join(clone2, '*.txt')].to_a.size
|
25
|
+
assert_includes 2..3, Dir[File.join(clone3, '*.txt')].to_a.size
|
26
|
+
end
|
11
27
|
end
|
12
28
|
end
|
13
29
|
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
30
|
+
describe 'public methods' do
|
31
|
+
let(:runner) { Gitdocs::Runner.new(share)}
|
32
|
+
|
33
|
+
let(:share) { stub(polling_interval: 1, notification: true) }
|
34
|
+
let(:notifier) { stub }
|
35
|
+
let(:repository) { stub(root: 'root_path') }
|
36
|
+
before do
|
37
|
+
Gitdocs::Notifier.stubs(:new).with(true).returns(notifier)
|
38
|
+
Gitdocs::Repository.stubs(:new).with(share).returns(repository)
|
39
|
+
end
|
40
|
+
|
41
|
+
describe '#root' do
|
42
|
+
subject { runner.root }
|
43
|
+
it { subject.must_equal 'root_path' }
|
44
|
+
end
|
45
|
+
|
46
|
+
describe '#sync_changes' do
|
47
|
+
subject { runner.sync_changes }
|
48
|
+
|
49
|
+
before { repository.expects(:pull).returns(pull_result) }
|
50
|
+
|
51
|
+
describe 'when invalid' do
|
52
|
+
let(:pull_result) { nil }
|
53
|
+
it { subject.must_equal nil }
|
54
|
+
end
|
55
|
+
|
56
|
+
describe 'when no remote present' do
|
57
|
+
let(:pull_result) { :no_remote }
|
58
|
+
it { subject.must_equal nil }
|
59
|
+
end
|
60
|
+
|
61
|
+
describe 'when merge is conflicted' do
|
62
|
+
let(:pull_result) { ['file'] }
|
63
|
+
before do
|
64
|
+
notifier.expects(:warn).with(
|
65
|
+
'There were some conflicts',
|
66
|
+
"* file"
|
67
|
+
)
|
68
|
+
runner.expects(:push_changes)
|
69
|
+
end
|
70
|
+
it { subject.must_equal nil }
|
71
|
+
end
|
72
|
+
|
73
|
+
describe 'when merge is ok' do
|
74
|
+
let(:pull_result) { :ok }
|
75
|
+
before do
|
76
|
+
runner.instance_variable_set(:@last_synced_revision, :oid)
|
77
|
+
repository.stubs(:current_oid).returns(:next_oid)
|
78
|
+
repository.stubs(:author_count).with(:oid).returns('Alice' => 1, 'Bob' => 2)
|
79
|
+
notifier.expects(:info).with(
|
80
|
+
'Updated with 3 changes',
|
81
|
+
"In 'root_path':\n* Alice (1 change)\n* Bob (2 changes)"
|
82
|
+
)
|
83
|
+
runner.expects(:push_changes)
|
84
|
+
end
|
85
|
+
it { subject.must_equal nil }
|
86
|
+
it { subject ; runner.instance_variable_get(:@last_synced_revision).must_equal :next_oid }
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
90
|
+
describe '#push_changes' do
|
91
|
+
subject { runner.push_changes }
|
92
|
+
|
93
|
+
before { repository.expects(:push).returns(push_result) }
|
94
|
+
|
95
|
+
describe 'when invalid' do
|
96
|
+
let(:push_result) { nil }
|
97
|
+
it { subject.must_equal nil }
|
98
|
+
end
|
99
|
+
|
100
|
+
describe 'when no remote present' do
|
101
|
+
let(:push_result) { :no_remote }
|
102
|
+
it { subject.must_equal nil }
|
103
|
+
end
|
104
|
+
|
105
|
+
describe 'when nothing happened' do
|
106
|
+
let(:push_result) { :nothing }
|
107
|
+
it { subject.must_equal nil }
|
108
|
+
end
|
109
|
+
|
110
|
+
describe 'when there is an error' do
|
111
|
+
let(:push_result) { 'error' }
|
112
|
+
before do
|
113
|
+
notifier.expects(:error)
|
114
|
+
.with('BAD Could not push changes in root_path', 'error')
|
115
|
+
end
|
116
|
+
it { subject.must_equal nil }
|
117
|
+
end
|
118
|
+
|
119
|
+
describe 'when push is conflicted' do
|
120
|
+
let(:push_result) { :conflict }
|
121
|
+
before do
|
122
|
+
notifier.expects(:warn)
|
123
|
+
.with('There was a conflict in root_path, retrying', '')
|
124
|
+
end
|
125
|
+
it { subject.must_equal nil }
|
126
|
+
end
|
127
|
+
|
128
|
+
describe 'when merge is ok' do
|
129
|
+
let(:push_result) { :ok }
|
130
|
+
before do
|
131
|
+
runner.instance_variable_set(:@last_synced_revision, :oid)
|
132
|
+
repository.stubs(:current_oid).returns(:next_oid)
|
133
|
+
repository.stubs(:author_count).with(:oid).returns('Alice' => 1, 'Bob' => 2)
|
134
|
+
notifier.expects(:info)
|
135
|
+
.with('Pushed 3 changes', "'root_path' has been pushed")
|
136
|
+
end
|
137
|
+
it { subject.must_equal nil }
|
138
|
+
it { subject ; runner.instance_variable_get(:@last_synced_revision).must_equal :next_oid }
|
139
|
+
end
|
23
140
|
end
|
24
141
|
end
|
25
142
|
end
|
data/test/test_helper.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gitdocs
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.0.
|
4
|
+
version: 0.5.0.pre2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Josh Hull
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2014-
|
12
|
+
date: 2014-03-10 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: joshbuddy-guard
|
@@ -59,14 +59,14 @@ dependencies:
|
|
59
59
|
requirements:
|
60
60
|
- - ~>
|
61
61
|
- !ruby/object:Gem::Version
|
62
|
-
version:
|
62
|
+
version: 3.1.1
|
63
63
|
type: :runtime
|
64
64
|
prerelease: false
|
65
65
|
version_requirements: !ruby/object:Gem::Requirement
|
66
66
|
requirements:
|
67
67
|
- - ~>
|
68
68
|
- !ruby/object:Gem::Version
|
69
|
-
version:
|
69
|
+
version: 3.1.1
|
70
70
|
- !ruby/object:Gem::Dependency
|
71
71
|
name: thor
|
72
72
|
requirement: !ruby/object:Gem::Requirement
|
@@ -249,6 +249,20 @@ dependencies:
|
|
249
249
|
- - ~>
|
250
250
|
- !ruby/object:Gem::Version
|
251
251
|
version: 2.4.2
|
252
|
+
- !ruby/object:Gem::Dependency
|
253
|
+
name: rugged
|
254
|
+
requirement: !ruby/object:Gem::Requirement
|
255
|
+
requirements:
|
256
|
+
- - ~>
|
257
|
+
- !ruby/object:Gem::Version
|
258
|
+
version: 0.19.0
|
259
|
+
type: :runtime
|
260
|
+
prerelease: false
|
261
|
+
version_requirements: !ruby/object:Gem::Requirement
|
262
|
+
requirements:
|
263
|
+
- - ~>
|
264
|
+
- !ruby/object:Gem::Version
|
265
|
+
version: 0.19.0
|
252
266
|
- !ruby/object:Gem::Dependency
|
253
267
|
name: minitest
|
254
268
|
requirement: !ruby/object:Gem::Requirement
|
@@ -319,6 +333,20 @@ dependencies:
|
|
319
333
|
- - ! '>='
|
320
334
|
- !ruby/object:Gem::Version
|
321
335
|
version: '0'
|
336
|
+
- !ruby/object:Gem::Dependency
|
337
|
+
name: aruba
|
338
|
+
requirement: !ruby/object:Gem::Requirement
|
339
|
+
requirements:
|
340
|
+
- - ! '>='
|
341
|
+
- !ruby/object:Gem::Version
|
342
|
+
version: '0'
|
343
|
+
type: :development
|
344
|
+
prerelease: false
|
345
|
+
version_requirements: !ruby/object:Gem::Requirement
|
346
|
+
requirements:
|
347
|
+
- - ! '>='
|
348
|
+
- !ruby/object:Gem::Version
|
349
|
+
version: '0'
|
322
350
|
description: Open-source Dropbox using Ruby and Git.
|
323
351
|
email:
|
324
352
|
- joshbuddy@gmail.com
|
@@ -348,6 +376,7 @@ files:
|
|
348
376
|
- lib/gitdocs/migration/004_add_index_for_path.rb
|
349
377
|
- lib/gitdocs/migration/005_add_start_web_frontend.rb
|
350
378
|
- lib/gitdocs/migration/006_add_web_port_to_config.rb
|
379
|
+
- lib/gitdocs/notifier.rb
|
351
380
|
- lib/gitdocs/public/css/app.css
|
352
381
|
- lib/gitdocs/public/css/bootstrap.css
|
353
382
|
- lib/gitdocs/public/css/coderay.css
|
@@ -397,6 +426,7 @@ files:
|
|
397
426
|
- lib/gitdocs/public/js/settings.js
|
398
427
|
- lib/gitdocs/public/js/util.js
|
399
428
|
- lib/gitdocs/rendering.rb
|
429
|
+
- lib/gitdocs/repository.rb
|
400
430
|
- lib/gitdocs/runner.rb
|
401
431
|
- lib/gitdocs/server.rb
|
402
432
|
- lib/gitdocs/version.rb
|
@@ -412,6 +442,12 @@ files:
|
|
412
442
|
- lib/gitdocs/views/settings.haml
|
413
443
|
- lib/img/icon.png
|
414
444
|
- test/configuration_test.rb
|
445
|
+
- test/integration/full_sync_test.rb
|
446
|
+
- test/integration/share_management_test.rb
|
447
|
+
- test/integration/status_test.rb
|
448
|
+
- test/integration/test_helper.rb
|
449
|
+
- test/notifier_test.rb
|
450
|
+
- test/repository_test.rb
|
415
451
|
- test/runner_test.rb
|
416
452
|
- test/test_helper.rb
|
417
453
|
homepage: http://engineering.gomiso.com/2011/11/30/collaborate-and-track-tasks-with-ease-using-gitdocs/
|
@@ -439,5 +475,11 @@ specification_version: 4
|
|
439
475
|
summary: Open-source Dropbox using Ruby and Git
|
440
476
|
test_files:
|
441
477
|
- test/configuration_test.rb
|
478
|
+
- test/integration/full_sync_test.rb
|
479
|
+
- test/integration/share_management_test.rb
|
480
|
+
- test/integration/status_test.rb
|
481
|
+
- test/integration/test_helper.rb
|
482
|
+
- test/notifier_test.rb
|
483
|
+
- test/repository_test.rb
|
442
484
|
- test/runner_test.rb
|
443
485
|
- test/test_helper.rb
|