gollum_rails 1.0.6 → 1.4.0.rc1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +1 -2
- data/Gemfile.lock +66 -99
- data/HISTORY.md +0 -35
- data/README.md +2 -7
- data/Rakefile +5 -5
- data/gollum_rails.gemspec +13 -12
- data/lib/core_ext/string.rb +10 -0
- data/lib/gollum_rails.rb +8 -26
- data/lib/gollum_rails/adapters/gollum.rb +3 -12
- data/lib/gollum_rails/adapters/gollum/page.rb +45 -92
- data/lib/gollum_rails/adapters/gollum/wiki.rb +11 -12
- data/lib/gollum_rails/modules/hash.rb +33 -0
- data/lib/gollum_rails/modules/loader.rb +5 -0
- data/lib/gollum_rails/page.rb +72 -202
- data/lib/gollum_rails/setup.rb +2 -9
- data/lib/grit/git-ruby/internal/pack.rb +397 -0
- data/spec/gollum_rails/adapters/gollum/connector_spec.rb +2 -8
- data/spec/gollum_rails/adapters/gollum/page_spec.rb +78 -18
- data/spec/gollum_rails/adapters/gollum/{wiki_spec_off.rb → wiki_spec.rb} +0 -0
- data/spec/gollum_rails/modules/hash_spec.rb +31 -0
- data/spec/gollum_rails/page_spec.rb +79 -310
- data/spec/gollum_rails/setup_spec.rb +0 -16
- data/spec/spec.opts +3 -0
- data/spec/spec_helper.rb +23 -0
- metadata +25 -21
- data/Guardfile +0 -7
- data/spec/gollum_rails/error_spec.rb +0 -10
File without changes
|
@@ -0,0 +1,31 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe ::Hash do
|
4
|
+
before(:each) do
|
5
|
+
@hash_a = {:a => "b", :b => "c"}
|
6
|
+
@hash_b = {a: "b", b: "c"}
|
7
|
+
end
|
8
|
+
it "should initialize a new hash" do
|
9
|
+
@hash_a.should be_instance_of(Hash)
|
10
|
+
@hash_b.should be_instance_of(Hash)
|
11
|
+
@hash_b.should == @hash_a
|
12
|
+
@hash_b.a.should == @hash_b[:a]
|
13
|
+
@hash_b.b.should == @hash_b[:b]
|
14
|
+
@hash_b.a.should == @hash_a.a
|
15
|
+
@hash_b.b.should == @hash_a.b
|
16
|
+
end
|
17
|
+
it "should change the value by method missing" do
|
18
|
+
|
19
|
+
@hash_c = {:hooh => "c", :tripple => {:d => "d"}}
|
20
|
+
@hash_d = Hash.new
|
21
|
+
expect{@hash_d.x}.to raise_error
|
22
|
+
#@hash_a.d.to_s.should == "{ d: 'd', x: 'Hash.new' }"
|
23
|
+
#@hash_a.d.should be_instance_of(Hash)
|
24
|
+
#puts @hash_a.d
|
25
|
+
#expect{@hash_a.hash = {d:"d"}}.to be_equal Hash['{:a=>"b", :b=>"c", "b"=>[3], :d=>"d"}']
|
26
|
+
#puts @hash_a
|
27
|
+
#@hash_a.a = "other"
|
28
|
+
#puts @hash_a
|
29
|
+
#expect{@hash_a.a = "other"}.to be_equal "other"
|
30
|
+
end
|
31
|
+
end
|
@@ -2,173 +2,79 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
describe "Gollum Page" do
|
4
4
|
before(:each) do
|
5
|
-
GollumRails::Setup.build do |config|
|
6
|
-
config.repository = File.join(File.dirname(__FILE__),'..','utils','wiki.git')
|
7
|
-
config.options={}
|
8
|
-
config.startup = true
|
9
|
-
end
|
10
|
-
|
11
5
|
@commit = {
|
12
|
-
name
|
13
|
-
message
|
14
|
-
email
|
6
|
+
:name => "flo",
|
7
|
+
:message => "commit",
|
8
|
+
:email => "mosny@zyg.li"
|
15
9
|
}
|
16
10
|
@call = {
|
17
|
-
name
|
18
|
-
content
|
19
|
-
commit
|
20
|
-
format
|
11
|
+
:name => "Goole",
|
12
|
+
:content => "content data",
|
13
|
+
:commit => @commit,
|
14
|
+
:format => :markdown
|
21
15
|
}
|
22
16
|
end
|
23
|
-
|
24
17
|
describe GollumRails::Page do
|
25
|
-
class RailsModel < GollumRails::Page
|
18
|
+
class RailsModel < GollumRails::Page
|
26
19
|
|
27
|
-
describe "the creation of a page" do
|
28
|
-
|
29
|
-
before :each do
|
30
|
-
@rr = RailsModel.new(@call)
|
31
|
-
end
|
32
|
-
|
33
|
-
it "saves via .save" do
|
34
|
-
@rr.save.should be_a GollumRails::Page
|
35
|
-
end
|
36
|
-
|
37
20
|
|
38
|
-
|
39
|
-
RailsModel.create(@call).should be_a GollumRails::Page
|
40
|
-
end
|
41
|
-
|
42
|
-
|
43
|
-
it "fails if invalid arguments are supplied via the ! create" do
|
44
|
-
args = {
|
45
|
-
name: "Gaming",
|
46
|
-
content: "content data",
|
47
|
-
commit: {},
|
48
|
-
format: :markdown
|
49
|
-
}
|
50
|
-
expect{RailsModel.create!(args)}.to raise_error StandardError #change this
|
51
|
-
end
|
52
|
-
it "has a history now" do
|
53
|
-
@rr.save
|
54
|
-
@rr.history.should be_a Array
|
55
|
-
end
|
56
|
-
it "outputs the raw_data" do
|
57
|
-
@rr.save
|
58
|
-
@rr.raw_data.should == @call[:content]
|
59
|
-
end
|
60
|
-
it "has the formatted data" do
|
61
|
-
@rr.save
|
62
|
-
@rr.html_data.should == 'content data'
|
63
|
-
end
|
64
|
-
it "was last changed by me" do
|
65
|
-
@rr.save
|
66
|
-
@rr.last_changed_by.should == 'flo <mosny@zyg.li>'
|
67
|
-
end
|
68
|
-
it "has a title" do
|
69
|
-
@rr.save
|
70
|
-
@rr.title.should == "Goole"
|
71
|
-
end
|
72
|
-
it "has a url" do
|
73
|
-
@rr.save
|
74
|
-
@rr.url.should =="Goole"
|
75
|
-
end
|
21
|
+
end
|
76
22
|
|
23
|
+
it "should test the creation of a page" do
|
24
|
+
rr = RailsModel.new(@call)
|
25
|
+
rr.save.should be_instance_of Gollum::Page
|
26
|
+
rr.save!.should be_instance_of Gollum::Page
|
27
|
+
RailsModel.create(@call)
|
77
28
|
end
|
78
29
|
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
end
|
84
|
-
|
85
|
-
it { @rr.update_attributes({:name => "google", :format => :wiki}).should be_a Gollum::Page }
|
86
|
-
|
30
|
+
it "should test the update of a page" do
|
31
|
+
rr = RailsModel.new @call
|
32
|
+
cc = rr.save.should be_instance_of Gollum::Page
|
33
|
+
rr.update_attributes({:name => "google", :format => :wiki}).should be_instance_of Gollum::Page
|
87
34
|
end
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
end
|
95
|
-
|
35
|
+
|
36
|
+
it "should test the deletion of a page" do
|
37
|
+
rr = RailsModel.new @call
|
38
|
+
cc = rr.save.should be_instance_of Gollum::Page
|
39
|
+
rr.delete.should be_instance_of String
|
96
40
|
end
|
97
41
|
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
it "should return a SHA1 hash" do
|
110
|
-
delete = @rr.delete
|
111
|
-
delete.length.should == 40
|
112
|
-
end
|
113
|
-
|
114
|
-
it "should also work was result from save" do
|
115
|
-
delete = @cc.delete
|
116
|
-
delete.should be_a String
|
117
|
-
end
|
118
|
-
|
119
|
-
it "should test the recreation" do
|
120
|
-
delete = @rr.delete
|
121
|
-
@rr.save.should be_a GollumRails::Page
|
122
|
-
@rr.delete.should be_a String
|
123
|
-
|
42
|
+
it "should test the finding of a page" do
|
43
|
+
RailsModel.find('google').should be_instance_of Gollum::Page
|
44
|
+
|
45
|
+
#invalid input
|
46
|
+
RailsModel.find('<script type="text/javascript">alert(123);</script>').should be_nil
|
47
|
+
end
|
48
|
+
it "should test the preview" do
|
49
|
+
rr = RailsModel.new :content => "# content", :name => "somepage"
|
50
|
+
100.times do
|
51
|
+
rr.preview.should include("<h1>content<a class=\"anchor\" id=\"content\" href=\"#content\"></a></h1>")
|
124
52
|
end
|
125
53
|
end
|
126
54
|
|
127
|
-
|
128
55
|
it "should test exception methods" do
|
129
|
-
RailsModel.create @call
|
130
|
-
expect{RailsModel.create! @call}.to raise_error Gollum::DuplicatePageError
|
56
|
+
create = RailsModel.create! @call
|
131
57
|
end
|
132
58
|
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
59
|
+
it "should test the supported formats" do
|
60
|
+
RailsModel.format_supported?('ascii').should be_true
|
61
|
+
RailsModel.format_supported?('markdown').should be_true
|
62
|
+
RailsModel.format_supported?('github-markdown').should be_true
|
63
|
+
RailsModel.format_supported?('rdoc').should be_true
|
64
|
+
RailsModel.format_supported?('org').should be_true
|
65
|
+
RailsModel.format_supported?('pod').should be_true
|
140
66
|
end
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
end
|
152
|
-
|
153
|
-
it "should have a commit which is a Hash" do
|
154
|
-
expect(rr.commit).to be_a Hash
|
155
|
-
end
|
156
|
-
|
157
|
-
it "should be @commit" do
|
158
|
-
expect(rr.commit).to be(@commit)
|
159
|
-
end
|
160
|
-
|
161
|
-
it "should have a format" do
|
162
|
-
expect(rr.format.to_s).to match('markdown')
|
163
|
-
end
|
164
|
-
|
165
|
-
it "should be a Gollum::Page after save" do
|
166
|
-
rr.save
|
167
|
-
expect(rr.gollum_page).to be_a Gollum::Page
|
168
|
-
end
|
169
|
-
|
67
|
+
|
68
|
+
it "should test getters" do
|
69
|
+
rr = RailsModel.new @call
|
70
|
+
rr.name.should == "Goole"
|
71
|
+
rr.content.should == "content data"
|
72
|
+
rr.commit.should be_instance_of Hash
|
73
|
+
rr.commit.should == @commit
|
74
|
+
rr.format.should == :markdown
|
75
|
+
rr.save
|
76
|
+
rr.page.should be_instance_of GollumRails::Adapters::Gollum::Page
|
170
77
|
end
|
171
|
-
|
172
78
|
it "should test setters" do
|
173
79
|
rr = RailsModel.new
|
174
80
|
rr.name=("google").should == "google"
|
@@ -176,34 +82,12 @@ describe "Gollum Page" do
|
|
176
82
|
rr.content=("content").should == "content"
|
177
83
|
rr.format=(:markdown).should == :markdown
|
178
84
|
end
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
expect(RailsModel.find('Goole')).to be_a GollumRails::Page
|
186
|
-
end
|
187
|
-
|
188
|
-
it 'should not be persisted on initialization or finding' do
|
189
|
-
init = RailsModel.find_or_initialize_by_name('totallybad', @commit)
|
190
|
-
expect(init.persisted?).to be_false
|
191
|
-
end
|
192
|
-
|
193
|
-
it "should find the page without a commit if it exists" do
|
194
|
-
expect(RailsModel.find_or_initialize_by_name("Goole").persisted?).to be_true
|
195
|
-
end
|
196
|
-
|
197
|
-
it "should find the page with a commit if it exists" do
|
198
|
-
expect(RailsModel.find_or_initialize_by_name("Goole", @commit).persisted?).to be_true
|
199
|
-
end
|
200
|
-
|
201
|
-
it "should be valid on initialization or finding" do
|
202
|
-
init = RailsModel.find_or_initialize_by_name('whoooohooo', @commit)
|
203
|
-
expect(init.valid?).to be_true
|
204
|
-
|
205
|
-
#RailsModel.find_or_initialize_by_name(@call[:name], @commit).should be_a GollumRails::Page
|
206
|
-
|
85
|
+
|
86
|
+
|
87
|
+
it "should test find or initialize" do
|
88
|
+
rr = RailsModel.new @call
|
89
|
+
rr.save
|
90
|
+
RailsModel.find_or_initialize_by_name(@call[:name], @commit).should be_instance_of Gollum::Page
|
207
91
|
end
|
208
92
|
end
|
209
93
|
describe "callbacks" do
|
@@ -252,15 +136,16 @@ describe "Gollum Page" do
|
|
252
136
|
test = CallbackTest.new @call
|
253
137
|
test.persisted?.should be_false
|
254
138
|
test.save
|
139
|
+
test.delete @commit
|
140
|
+
test.save
|
141
|
+
test.update_attributes @call
|
142
|
+
test.persisted?.should be_true
|
255
143
|
end
|
256
144
|
end
|
257
145
|
describe "rails extension" do
|
258
|
-
|
259
146
|
it "should test fetch_all" do
|
260
|
-
GollumRails::Page.all.length.should ==
|
261
|
-
|
262
|
-
it "should test all" do
|
263
|
-
GollumRails::Page.find_all.length.should == 1
|
147
|
+
GollumRails::Page.all.length.should == 2
|
148
|
+
GollumRails::Page.find_all.length.should == 2
|
264
149
|
end
|
265
150
|
|
266
151
|
end
|
@@ -272,35 +157,29 @@ describe "Gollum Page" do
|
|
272
157
|
class Callbackt < GollumRails::Page
|
273
158
|
validates_presence_of :name
|
274
159
|
end
|
275
|
-
|
276
160
|
cla = Callbackt.new @call
|
277
161
|
cla.valid?.should be_true
|
278
162
|
end
|
279
|
-
|
280
163
|
class SugarBaby < GollumRails::Page
|
281
164
|
validates_presence_of :name
|
282
165
|
validates_length_of :name, :minimum => 20
|
283
166
|
validates_length_of :format, :maximum => 14
|
284
167
|
end
|
285
|
-
|
286
168
|
it "should test string validation" do
|
287
169
|
@call[:name] = "das ist zu lang"*10
|
288
170
|
cla = SugarBaby.new @call
|
289
171
|
cla.valid?.should be_true
|
290
172
|
end
|
291
|
-
|
292
173
|
it "should test the presence validator" do
|
293
174
|
@call[:name] = [ ]
|
294
175
|
bla = SugarBaby.new @call
|
295
176
|
bla.valid?.should be_false
|
296
177
|
end
|
297
|
-
|
298
178
|
it "should test the length validator for name" do
|
299
179
|
@call[:name] = "das"
|
300
180
|
res = SugarBaby.new @call
|
301
181
|
res.valid?.should be_false
|
302
182
|
end
|
303
|
-
|
304
183
|
it "should test the length validator for format" do
|
305
184
|
@call[:format] = :toolongformatstringforvalidator
|
306
185
|
res = SugarBaby.new @call
|
@@ -308,131 +187,21 @@ describe "Gollum Page" do
|
|
308
187
|
end
|
309
188
|
|
310
189
|
end
|
311
|
-
|
312
|
-
|
313
|
-
class CommitDiff < GollumRails::Page
|
314
|
-
end
|
315
|
-
|
316
|
-
it "should display the diff commit" do
|
317
|
-
commit = {
|
318
|
-
name: "flo",
|
319
|
-
message: "commit",
|
320
|
-
email: "mosny@zyg.li"
|
321
|
-
}
|
322
|
-
call = {
|
323
|
-
name: "a Page",
|
324
|
-
content: "my content",
|
325
|
-
commit: commit,
|
326
|
-
format: :markdown
|
327
|
-
}
|
328
|
-
|
329
|
-
res = CommitDiff.new call
|
330
|
-
res.save
|
331
|
-
res.update_attributes("content",nil,:markdown, @commit)
|
332
|
-
diff = res.compare_commits(res.history.first)
|
333
|
-
expect(diff).to be_a String
|
334
|
-
expect(diff).to match(/---/)
|
335
|
-
res.delete
|
336
|
-
end
|
337
|
-
|
338
|
-
end
|
339
|
-
|
340
|
-
describe "Filename" do
|
341
|
-
class Fns < GollumRails::Page
|
342
|
-
end
|
343
|
-
it "should assemble a filename" do
|
344
|
-
res = CommitDiff.new @call
|
345
|
-
expect(res.filename).to match(/^Goole\.md$/)
|
346
|
-
end
|
347
|
-
end
|
348
|
-
|
349
|
-
describe "Sub Page" do
|
350
|
-
class Fns < GollumRails::Page
|
351
|
-
end
|
352
|
-
|
353
|
-
it "should return nil if not persisted" do
|
354
|
-
res = CommitDiff.new @call
|
355
|
-
expect(res.sub_page?).to be_nil
|
356
|
-
end
|
357
|
-
it "should be true" do
|
358
|
-
res = CommitDiff.new @call.merge(name: '_aPage')
|
359
|
-
res.save
|
360
|
-
expect(res.sub_page?).to be_true
|
361
|
-
res.delete
|
362
|
-
end
|
363
|
-
|
364
|
-
it "should be false" do
|
365
|
-
res = CommitDiff.new @call
|
366
|
-
res.save
|
367
|
-
expect(res.sub_page?).to be_false
|
368
|
-
res.delete
|
369
|
-
end
|
370
|
-
end
|
371
|
-
|
372
|
-
describe "Current version" do
|
373
|
-
class Fns < GollumRails::Page
|
374
|
-
end
|
375
|
-
|
376
|
-
it "current version should have 7 digest" do
|
377
|
-
res = CommitDiff.new @call
|
378
|
-
res.save
|
379
|
-
expect(res.current_version.length).to be(7)
|
380
|
-
res.delete
|
381
|
-
end
|
382
|
-
|
383
|
-
it "should be nil if page has not been set" do
|
384
|
-
res = CommitDiff.new @call
|
385
|
-
expect(res.current_version).to be_nil
|
386
|
-
end
|
190
|
+
describe "the thread safety" do
|
191
|
+
class ThreadModel < GollumRails::Page
|
387
192
|
|
388
|
-
|
389
|
-
|
390
|
-
|
391
|
-
|
392
|
-
|
393
|
-
|
394
|
-
|
395
|
-
|
396
|
-
|
397
|
-
|
398
|
-
|
399
|
-
|
400
|
-
|
401
|
-
|
402
|
-
|
403
|
-
describe 'History' do
|
404
|
-
class Fns < GollumRails::Page
|
405
|
-
end
|
406
|
-
|
407
|
-
it "history should return nil if no gollum_page was saved" do
|
408
|
-
res = Fns.new @call
|
409
|
-
expect(res.history).to be_nil
|
410
|
-
end
|
411
|
-
|
412
|
-
it "history should return the pages versions if there are changes" do
|
413
|
-
res = Fns.new @call
|
414
|
-
res.save
|
415
|
-
expect(res.history).to be_a Array
|
416
|
-
res.delete
|
417
|
-
end
|
418
|
-
|
419
|
-
end
|
420
|
-
|
421
|
-
# describe "the thread safety" do
|
422
|
-
# class ThreadModel < GollumRails::Page
|
423
|
-
#
|
424
|
-
# end
|
425
|
-
# it "should save " do
|
426
|
-
# 100.times do |time|
|
427
|
-
# Thread.new do
|
428
|
-
# ThreadModel.new(@call)
|
429
|
-
# ThreadModel.save.should be_a(GollumRails::Page)
|
430
|
-
# ThreadModel.delete(@commit).length.should == 40
|
431
|
-
# end
|
432
|
-
# end
|
433
|
-
#
|
434
|
-
# end
|
435
|
-
|
436
|
-
|
437
|
-
#end
|
193
|
+
end
|
194
|
+
it "should save " do
|
195
|
+
100.times do |time|
|
196
|
+
Thread.new do
|
197
|
+
ThreadModel.new(@call)
|
198
|
+
ThreadModel.save.should be_instance_of(Gollum::Page)
|
199
|
+
ThreadModel.delete(@commit).length.should == 40
|
200
|
+
end
|
201
|
+
end
|
202
|
+
|
203
|
+
end
|
204
|
+
|
205
|
+
|
206
|
+
end
|
438
207
|
end
|