gollum_rails 1.5.10 → 1.5.12
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +13 -5
- data/Gemfile.lock +106 -97
- data/Rakefile +1 -2
- data/gollum_rails.gemspec +14 -8
- data/lib/generators/gollum_rails/language/language_generator.rb +1 -1
- data/lib/gollum_rails.rb +6 -6
- data/lib/gollum_rails/callbacks.rb +10 -12
- data/lib/gollum_rails/core.rb +22 -37
- data/lib/gollum_rails/error.rb +1 -2
- data/lib/gollum_rails/finders.rb +8 -10
- data/lib/gollum_rails/meta.rb +6 -7
- data/lib/gollum_rails/orm.rb +1 -4
- data/lib/gollum_rails/page.rb +6 -11
- data/lib/gollum_rails/persistance.rb +19 -30
- data/lib/gollum_rails/setup.rb +6 -6
- data/lib/gollum_rails/store.rb +11 -11
- data/lib/gollum_rails/validation.rb +2 -2
- data/spec/factories.rb +35 -0
- data/spec/gollum_rails/page_core_spec.rb +35 -0
- data/spec/gollum_rails/page_spec.rb +72 -182
- data/spec/spec_helper.rb +8 -4
- data/spec/support/default_commit.rb +3 -0
- data/spec/support/gollum_page_spec.rb +3 -0
- data/spec/support/special_commit.rb +2 -0
- metadata +75 -42
data/lib/gollum_rails/setup.rb
CHANGED
@@ -2,7 +2,7 @@ require 'gollum_rails/setup/error'
|
|
2
2
|
module GollumRails
|
3
3
|
|
4
4
|
# Setup functionality for Rails initializer
|
5
|
-
#
|
5
|
+
#
|
6
6
|
# will be generated by Rails generator: `rails g gollum_rails:install`
|
7
7
|
#
|
8
8
|
# manually:
|
@@ -16,7 +16,7 @@ module GollumRails
|
|
16
16
|
#
|
17
17
|
module Setup
|
18
18
|
autoload :Options, 'gollum_rails/setup/options'
|
19
|
-
include Options
|
19
|
+
include Options
|
20
20
|
|
21
21
|
class << self
|
22
22
|
|
@@ -37,12 +37,12 @@ module GollumRails
|
|
37
37
|
rescue NoMethodError
|
38
38
|
end
|
39
39
|
end
|
40
|
-
|
40
|
+
|
41
41
|
end
|
42
42
|
if self.repository == :application
|
43
|
-
raise GollumRailsSetupError, "Rails configuration is not defined.
|
43
|
+
raise GollumRailsSetupError, "Rails configuration is not defined.
|
44
44
|
Are you in a Rails app?" if Rails.application.nil?
|
45
|
-
|
45
|
+
|
46
46
|
initialize_wiki Rails.application.config.wiki_repository
|
47
47
|
else
|
48
48
|
raise GollumRailsSetupError, "Git repository does not exist.
|
@@ -52,7 +52,7 @@ module GollumRails
|
|
52
52
|
end
|
53
53
|
|
54
54
|
private
|
55
|
-
|
55
|
+
|
56
56
|
def path_valid?(path)
|
57
57
|
return path.exist? if path.is_a?(Pathname)
|
58
58
|
return !(path.nil? || path.empty? || ! path.is_a?(String))
|
data/lib/gollum_rails/store.rb
CHANGED
@@ -2,11 +2,11 @@ module GollumRails
|
|
2
2
|
module Store
|
3
3
|
extend ActiveSupport::Concern
|
4
4
|
|
5
|
-
|
5
|
+
|
6
6
|
ATTR_READERS = []
|
7
7
|
ATTR_WRITERS = [:name, :content, :format]
|
8
8
|
ATTR_ACCESSORS = [:commit, :gollum_page]
|
9
|
-
|
9
|
+
|
10
10
|
included do
|
11
11
|
ATTR_WRITERS.each do |a|
|
12
12
|
attr_writer a
|
@@ -14,9 +14,9 @@ module GollumRails
|
|
14
14
|
ATTR_ACCESSORS.each do |a|
|
15
15
|
attr_accessor a
|
16
16
|
end
|
17
|
-
|
17
|
+
|
18
18
|
end
|
19
|
-
|
19
|
+
|
20
20
|
module ClassMethods
|
21
21
|
# Gets the wiki instance
|
22
22
|
def wiki
|
@@ -33,26 +33,26 @@ module GollumRails
|
|
33
33
|
def name
|
34
34
|
@name ||= (@gollum_page.name || "")
|
35
35
|
end
|
36
|
-
|
36
|
+
|
37
37
|
# == Outputs the pages filename on disc
|
38
38
|
#
|
39
39
|
# ext - Wether to output extension or not
|
40
40
|
def filename(ext=true)
|
41
41
|
@filename ||= (ext) ? @gollum_page.filename : @gollum_page.filename_stripped
|
42
42
|
end
|
43
|
-
|
43
|
+
|
44
44
|
def content
|
45
45
|
@content ||= (@gollum_page.content || "")
|
46
46
|
end
|
47
47
|
|
48
|
-
|
49
|
-
private
|
48
|
+
|
49
|
+
private
|
50
50
|
# == To static
|
51
51
|
def wiki
|
52
52
|
self.class.wiki
|
53
53
|
end
|
54
|
-
|
55
|
-
|
56
|
-
|
54
|
+
|
55
|
+
|
56
|
+
|
57
57
|
end
|
58
58
|
end
|
data/spec/factories.rb
ADDED
@@ -0,0 +1,35 @@
|
|
1
|
+
FactoryGirl.define do
|
2
|
+
trait :initialize do
|
3
|
+
after(:build) do
|
4
|
+
GollumRails::Setup.build do |config|
|
5
|
+
GollumRails::Setup.repository = File.expand_path('../utils/wiki.git', __FILE__)
|
6
|
+
end
|
7
|
+
end
|
8
|
+
end
|
9
|
+
trait :markdown do
|
10
|
+
format :markdown
|
11
|
+
end
|
12
|
+
trait :mediawiki do
|
13
|
+
format :mediawiki
|
14
|
+
end
|
15
|
+
factory :commit_fakes, class: DefaultCommit do
|
16
|
+
sequence :commit do |num|
|
17
|
+
{ name: "mosny#{num}", message: "message number: #{num}", email: "mosny@zyg.li"}
|
18
|
+
end
|
19
|
+
initialize_with { attributes }
|
20
|
+
end
|
21
|
+
#factory :commit_fakes, class: DefaultCommit do
|
22
|
+
#end
|
23
|
+
factory :gollum_page_spec, traits: [:initialize, :markdown] do
|
24
|
+
name "Goole"
|
25
|
+
content "content data. content data. content data."
|
26
|
+
commit { {name: "mosny", message: "commit message", email: "mosny@zyg.li"} }
|
27
|
+
initialize_with { GollumPageSpec.new(attributes) }
|
28
|
+
end
|
29
|
+
factory :other_committer, class: GollumPageSpec, traits: [:initialize, :markdown] do
|
30
|
+
name "Google"
|
31
|
+
content "content data. content data. content data."
|
32
|
+
commit { {name: "flo", message: "other commit message", email: "info@zyg.li"} }
|
33
|
+
initialize_with { GollumPageSpec.new(attributes) }
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe GollumRails::Core do
|
4
|
+
describe "Last changed by" do
|
5
|
+
it "tests if the correct ammount of commits is in history" do
|
6
|
+
commit1 = create(:gollum_page_spec)
|
7
|
+
|
8
|
+
10.times do |page|
|
9
|
+
commit1.update_attributes(name: "Page named: #{page}", commit: build(:commit_fakes)[:commit])
|
10
|
+
end
|
11
|
+
expect(commit1.last_changed_by) == "mosny11 <mosny@zyg.li>"
|
12
|
+
commit1.destroy(build(:commit_fakes)[:commit])
|
13
|
+
|
14
|
+
end
|
15
|
+
|
16
|
+
end
|
17
|
+
describe "#format_supported?(format)" do
|
18
|
+
['markdown',
|
19
|
+
'rdoc',
|
20
|
+
'org',
|
21
|
+
'pod',
|
22
|
+
'creole',
|
23
|
+
'textile',
|
24
|
+
'rest',
|
25
|
+
'asciidoc',
|
26
|
+
'mediawiki',
|
27
|
+
'txt'
|
28
|
+
].each do |format|
|
29
|
+
it "supports format #{format}" do
|
30
|
+
expect(GollumRails::Page.format_supported?(format)) == true
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
end
|
@@ -1,5 +1,4 @@
|
|
1
1
|
require 'spec_helper'
|
2
|
-
|
3
2
|
describe "Gollum Page" do
|
4
3
|
before(:each) do
|
5
4
|
GollumRails::Setup.build do |config|
|
@@ -7,7 +6,6 @@ describe "Gollum Page" do
|
|
7
6
|
config.options={}
|
8
7
|
config.startup = true
|
9
8
|
end
|
10
|
-
|
11
9
|
@commit = {
|
12
10
|
name: "flo",
|
13
11
|
message: "commit",
|
@@ -20,26 +18,18 @@ describe "Gollum Page" do
|
|
20
18
|
format: :markdown
|
21
19
|
}
|
22
20
|
end
|
23
|
-
|
24
21
|
describe GollumRails::Page do
|
25
22
|
class RailsModel < GollumRails::Page; end
|
26
|
-
|
27
23
|
describe "the creation of a page" do
|
28
|
-
|
29
|
-
before :each do
|
24
|
+
before :each do
|
30
25
|
@rr = RailsModel.new(@call)
|
31
26
|
end
|
32
|
-
|
33
27
|
it "saves via .save" do
|
34
|
-
@rr.save.
|
28
|
+
expect(@rr.save).to be_a GollumRails::Page
|
35
29
|
end
|
36
|
-
|
37
|
-
|
38
30
|
it "saves via .create" do
|
39
|
-
RailsModel.create(@call).
|
31
|
+
expect(RailsModel.create(@call)).to be_a GollumRails::Page
|
40
32
|
end
|
41
|
-
|
42
|
-
|
43
33
|
it "fails if invalid arguments are supplied via the ! create" do
|
44
34
|
args = {
|
45
35
|
name: "Gaming",
|
@@ -51,15 +41,15 @@ describe "Gollum Page" do
|
|
51
41
|
end
|
52
42
|
it "has a history now" do
|
53
43
|
@rr.save
|
54
|
-
@rr.history.
|
44
|
+
expect(@rr.history).to be_a Array
|
55
45
|
end
|
56
46
|
it "outputs the raw_data" do
|
57
47
|
@rr.save
|
58
|
-
@rr.raw_data
|
48
|
+
expect(@rr.raw_data) == @call[:content]
|
59
49
|
end
|
60
50
|
it "has the formatted data" do
|
61
51
|
@rr.save
|
62
|
-
@rr.html_data
|
52
|
+
expect(@rr.html_data) == '<p>content data</p>'
|
63
53
|
end
|
64
54
|
it "can be saved using special characters in name" do
|
65
55
|
@rr.name = 'test-page'
|
@@ -79,29 +69,22 @@ describe "Gollum Page" do
|
|
79
69
|
expect(@rr.file_name).to match 'page'
|
80
70
|
@rr.destroy
|
81
71
|
end
|
82
|
-
it "was last changed by me" do
|
83
|
-
@rr.save
|
84
|
-
@rr.last_changed_by.should == 'flo <mosny@zyg.li>'
|
85
|
-
end
|
86
72
|
it "has a title" do
|
87
73
|
@rr.save
|
88
|
-
@rr.title
|
74
|
+
expect(@rr.title) == "Goole"
|
89
75
|
end
|
90
76
|
it "has a url" do
|
91
77
|
@rr.save
|
92
|
-
@rr.url
|
78
|
+
expect(@rr.url) =="Goole"
|
93
79
|
end
|
94
|
-
|
95
80
|
end
|
96
|
-
|
97
81
|
describe "the update of a page" do
|
98
|
-
before :each do
|
82
|
+
before :each do
|
99
83
|
@rr = RailsModel.new(@call)
|
100
84
|
@rr.save
|
101
85
|
end
|
102
|
-
|
103
|
-
|
104
|
-
@rr.update_attributes({:name => "google", :format => :wiki}).should be_a GollumRails::Page
|
86
|
+
it "updates properly without all arguments, content+commit" do
|
87
|
+
expect(@rr.update_attributes({:name => "google", :format => :wiki})).to be_a GollumRails::Page
|
105
88
|
@rr.delete(@commit)
|
106
89
|
end
|
107
90
|
it "sets the format as created" do
|
@@ -109,252 +92,189 @@ describe "Gollum Page" do
|
|
109
92
|
expect(@rr.format).to eq :textile
|
110
93
|
@rr.delete(@commit)
|
111
94
|
end
|
112
|
-
|
113
95
|
it "sets the name as created" do
|
114
96
|
@rr.update_attributes(name: "omg", format: :textile)
|
115
|
-
expect(@rr.name).to eq "omg"
|
97
|
+
expect(@rr.name).to eq "omg"
|
116
98
|
@rr.delete(@commit)
|
117
99
|
end
|
118
100
|
it "updates properly without all arguments, name, format" do
|
119
|
-
@rr.update_attributes({:content => "test"}).
|
101
|
+
expect(@rr.update_attributes({:content => "test"})).to be_a GollumRails::Page
|
120
102
|
expect(@rr.name).to match "Goole"
|
121
103
|
expect(@rr.format.to_s).to match "markdown"
|
122
104
|
@rr.delete(@commit)
|
123
105
|
end
|
124
|
-
|
125
106
|
end
|
126
|
-
|
127
|
-
|
128
107
|
describe "should test the deletion of a page" do
|
129
|
-
before :each do
|
108
|
+
before :each do
|
130
109
|
@rr = RailsModel.new @call
|
131
110
|
@cc = @rr.save
|
132
111
|
end
|
133
|
-
|
134
112
|
it "should return a string" do
|
135
113
|
delete = @rr.delete
|
136
|
-
delete.
|
114
|
+
expect(delete).to be_a String
|
137
115
|
end
|
138
|
-
|
139
116
|
it "should return a SHA1 hash" do
|
140
117
|
delete = @rr.delete
|
141
|
-
delete.length
|
118
|
+
expect(delete.length) == 40
|
142
119
|
end
|
143
|
-
|
144
120
|
it "should also work was result from save" do
|
145
121
|
delete = @cc.delete
|
146
|
-
delete.
|
122
|
+
expect(delete).to be_a String
|
147
123
|
end
|
148
|
-
|
149
124
|
end
|
150
|
-
|
151
|
-
|
152
125
|
it "should test exception methods" do
|
153
126
|
RailsModel.create @call
|
154
127
|
expect{RailsModel.create! @call}.to raise_error Gollum::DuplicatePageError
|
155
128
|
end
|
156
|
-
|
157
129
|
describe "supported formats" do
|
158
130
|
['markdown', 'rdoc', 'org', 'pod'].each do |format|
|
159
131
|
it "should support #{format}" do
|
160
|
-
RailsModel.format_supported?(format)
|
132
|
+
expect(RailsModel.format_supported?(format))== true
|
161
133
|
end
|
162
134
|
end
|
163
|
-
|
164
135
|
end
|
165
|
-
|
166
136
|
describe "accessors" do
|
167
137
|
let(:rr){RailsModel.new @call}
|
168
|
-
|
169
138
|
it "should have a name" do
|
170
139
|
expect(rr.name).to match(/^Goole$/)
|
171
140
|
end
|
172
141
|
it "should have a preview" do
|
173
|
-
expect(rr.preview).to match(
|
174
|
-
end
|
142
|
+
expect(rr.preview).to match(/content/)
|
143
|
+
end
|
175
144
|
it "should have a content" do
|
176
145
|
expect(rr.content).to match(/^content\ data$/)
|
177
146
|
end
|
178
|
-
|
179
147
|
it "should have a commit which is a Hash" do
|
180
148
|
expect(rr.commit).to be_a Hash
|
181
149
|
end
|
182
|
-
|
183
150
|
it "should be @commit" do
|
184
151
|
expect(rr.commit).to be(@commit)
|
185
152
|
end
|
186
|
-
|
187
153
|
it "should have a format" do
|
188
154
|
expect(rr.format.to_s).to match('markdown')
|
189
155
|
end
|
190
|
-
|
191
156
|
it "should be a Gollum::Page after save" do
|
192
157
|
rr.save
|
193
158
|
expect(rr.gollum_page).to be_a Gollum::Page
|
194
159
|
end
|
195
|
-
|
196
160
|
end
|
197
|
-
|
198
161
|
it "should test setters" do
|
199
162
|
rr = RailsModel.new
|
200
|
-
rr.name=("google")
|
201
|
-
rr.commit=(@commit)
|
202
|
-
rr.content=("content")
|
203
|
-
rr.format=(:markdown)
|
204
|
-
end
|
205
|
-
|
206
|
-
it "builds an url for the page" do
|
207
|
-
page = RailsModel.find('Goole')
|
208
|
-
|
209
|
-
p = RailsModel.new(name: "bla/testfa", commit: @commit, content: "[[Goole]]", format: :markdown)
|
210
|
-
#p.destroy(@commit)
|
211
|
-
|
212
|
-
|
213
|
-
|
163
|
+
expect(rr.name=("google")) == "google"
|
164
|
+
expect(rr.commit=(@commit)) == @commit
|
165
|
+
expect(rr.content=("content")) == "content"
|
166
|
+
expect(rr.format=(:markdown)) == :markdown
|
214
167
|
end
|
215
|
-
|
216
168
|
it "gets the pages filename on disk with a 'DOT' in filename" do
|
217
169
|
expect(RailsModel.find('Goole').filename).to match('.')
|
218
170
|
end
|
219
|
-
|
220
171
|
it "gets the pages filename on disk withOUT a 'dot' in filename" do
|
221
172
|
expect(RailsModel.find('Goole').filename(false)).not_to match('.md')
|
222
173
|
end
|
223
|
-
|
224
174
|
it "tests the find method to return nil if no page was found" do
|
225
175
|
expect(RailsModel.find('whoooohoo')).to be_nil
|
226
176
|
end
|
227
|
-
|
228
177
|
it "should initializes all with GollumRails::Page" do
|
229
178
|
expect(RailsModel.all.first).to be_kind_of GollumRails::Page
|
230
179
|
end
|
231
|
-
|
232
180
|
it "should have a gollum page after initializing with all" do
|
233
181
|
expect(RailsModel.all.first.gollum_page).not_to be_nil
|
234
182
|
end
|
235
|
-
|
236
183
|
it "tests the find method to return a gollum_rails:page if a page was found" do
|
237
184
|
expect(RailsModel.find('Goole')).to be_a GollumRails::Page
|
238
185
|
end
|
239
|
-
|
240
186
|
it 'should not be persisted on initialization or finding' do
|
241
187
|
init = RailsModel.find_or_initialize_by_name('totallybad', @commit)
|
242
|
-
expect(init.persisted?)
|
188
|
+
expect(init.persisted?) == false
|
243
189
|
end
|
244
|
-
|
245
190
|
it "should find the page without a commit if it exists" do
|
246
|
-
expect(RailsModel.find_or_initialize_by_name("Goole").persisted?)
|
191
|
+
expect(RailsModel.find_or_initialize_by_name("Goole").persisted?)== true
|
247
192
|
end
|
248
|
-
|
249
193
|
it "should find the page with a commit if it exists" do
|
250
|
-
expect(RailsModel.find_or_initialize_by_name("Goole", @commit).persisted?)
|
194
|
+
expect(RailsModel.find_or_initialize_by_name("Goole", @commit).persisted?)== true
|
251
195
|
end
|
252
|
-
|
253
196
|
it "should be valid on initialization or finding" do
|
254
197
|
init = RailsModel.find_or_initialize_by_name('whoooohooo', @commit)
|
255
|
-
expect(init.valid?)
|
256
|
-
|
257
|
-
#RailsModel.find_or_initialize_by_name(@call[:name], @commit).should be_a GollumRails::Page
|
258
|
-
|
198
|
+
expect(init.valid?)== true
|
199
|
+
#RailsModel.find_or_initialize_by_name(@call[:name], @commit)).to be_a GollumRails::Page
|
259
200
|
end
|
260
201
|
end
|
261
|
-
describe "
|
262
|
-
|
263
|
-
|
264
|
-
|
265
|
-
it "should test the callback functions" do
|
266
|
-
|
267
|
-
class SaveCallback
|
268
|
-
def self.before_save( obj )
|
269
|
-
obj.name.should == "Goole"
|
270
|
-
end
|
271
|
-
end
|
272
|
-
|
273
|
-
|
274
|
-
class CallbackTest < GollumRails::Page
|
275
|
-
|
276
|
-
before_save ::SaveCallback
|
277
|
-
after_save :after_save
|
278
|
-
after_destroy :after_delete
|
279
|
-
before_destroy :before_delete
|
280
|
-
before_update :before_update
|
281
|
-
after_update :after_update
|
202
|
+
describe "callback testing" do
|
282
203
|
|
283
|
-
|
284
|
-
|
285
|
-
|
286
|
-
def before_update
|
287
|
-
@name.should == "Goole"
|
288
|
-
end
|
289
|
-
|
290
|
-
def after_update
|
291
|
-
@name.should == "Goole"
|
292
|
-
end
|
204
|
+
# Callback class definition
|
205
|
+
class SaveCallbacks < GollumRails::Page
|
206
|
+
after_save :after_save
|
293
207
|
|
294
|
-
|
295
|
-
@name.should == "Goole"
|
296
|
-
end
|
297
|
-
|
298
|
-
def after_delete
|
299
|
-
@name.should == "Goole"
|
300
|
-
end
|
208
|
+
before_destroy :before_delete
|
301
209
|
|
302
|
-
|
210
|
+
before_update :before_update
|
211
|
+
after_update :after_update
|
212
|
+
def after_save; end
|
213
|
+
def before_delete; end
|
214
|
+
def before_update; end
|
215
|
+
def after_update; end
|
216
|
+
end
|
217
|
+
let(:cls) { SaveCallbacks.new(@call) }
|
218
|
+
after(:each) do
|
219
|
+
cls.destroy(@commit)
|
220
|
+
end
|
303
221
|
|
304
|
-
|
305
|
-
|
306
|
-
|
222
|
+
it "receives the after_save callback" do
|
223
|
+
expect(cls).to receive(:after_save)
|
224
|
+
cls.save
|
225
|
+
end
|
226
|
+
it "receives the before_delete callback" do
|
227
|
+
expect(cls).to receive(:before_delete)
|
228
|
+
end
|
229
|
+
it "receives the after_update callback" do
|
230
|
+
expect(cls).to receive(:after_update)
|
231
|
+
cls.save
|
232
|
+
cls.update_attributes(name: "Somepage")
|
233
|
+
end
|
234
|
+
it "receives the before_update callback" do
|
235
|
+
expect(cls).to receive(:before_update)
|
236
|
+
cls.save
|
237
|
+
cls.update_attributes(name: "Somepage")
|
307
238
|
end
|
239
|
+
|
308
240
|
end
|
309
241
|
describe "testing validation" do
|
310
|
-
|
311
|
-
|
312
|
-
|
313
242
|
it "should test the basic validation" do
|
314
243
|
class Callbackt < GollumRails::Page
|
315
244
|
validates_presence_of :name
|
316
245
|
end
|
317
|
-
|
318
246
|
cla = Callbackt.new @call
|
319
|
-
cla.valid
|
247
|
+
expect(cla.valid?)== true
|
320
248
|
end
|
321
|
-
|
322
249
|
class SugarBaby < GollumRails::Page
|
323
250
|
validates_presence_of :name
|
324
251
|
validates_length_of :name, :minimum => 20
|
325
252
|
validates_length_of :format, :maximum => 14
|
326
253
|
end
|
327
|
-
|
328
254
|
it "should test string validation" do
|
329
255
|
@call[:name] = "das ist zu lang"*10
|
330
256
|
cla = SugarBaby.new @call
|
331
|
-
cla.valid
|
257
|
+
expect(cla.valid?)== true
|
332
258
|
end
|
333
|
-
|
334
259
|
it "should test the presence validator" do
|
335
260
|
@call[:name] = [ ]
|
336
261
|
bla = SugarBaby.new @call
|
337
|
-
bla.valid
|
262
|
+
expect(bla.valid?) == false
|
338
263
|
end
|
339
|
-
|
340
264
|
it "should test the length validator for name" do
|
341
265
|
@call[:name] = "das"
|
342
266
|
res = SugarBaby.new @call
|
343
|
-
res.valid
|
267
|
+
expect(res.valid?) == false
|
344
268
|
end
|
345
|
-
|
346
269
|
it "should test the length validator for format" do
|
347
270
|
@call[:format] = :toolongformatstringforvalidator
|
348
271
|
res = SugarBaby.new @call
|
349
|
-
res.valid
|
272
|
+
expect(res.valid?) == false
|
350
273
|
end
|
351
|
-
|
352
274
|
end
|
353
|
-
|
354
275
|
describe "diffing commits" do
|
355
276
|
class CommitDiff < GollumRails::Page
|
356
277
|
end
|
357
|
-
|
358
278
|
it "should display the diff commit" do
|
359
279
|
commit = {
|
360
280
|
name: "flo",
|
@@ -367,7 +287,6 @@ describe "Gollum Page" do
|
|
367
287
|
commit: commit,
|
368
288
|
format: :markdown
|
369
289
|
}
|
370
|
-
|
371
290
|
res = CommitDiff.new call
|
372
291
|
res.save
|
373
292
|
diff = res.compare_commits(res.history.first)
|
@@ -375,14 +294,10 @@ describe "Gollum Page" do
|
|
375
294
|
expect(diff).to match(/---/)
|
376
295
|
res.delete
|
377
296
|
end
|
378
|
-
|
379
297
|
end
|
380
|
-
|
381
|
-
|
382
298
|
describe "Sub Page" do
|
383
299
|
class Fns < GollumRails::Page
|
384
300
|
end
|
385
|
-
|
386
301
|
it "should return nil if not persisted" do
|
387
302
|
res = CommitDiff.new @call
|
388
303
|
expect(res.sub_page?).to be_nil
|
@@ -390,34 +305,29 @@ describe "Gollum Page" do
|
|
390
305
|
it "should be true" do
|
391
306
|
res = CommitDiff.new @call.merge(name: '_aPage')
|
392
307
|
res.save
|
393
|
-
expect(res.sub_page?)
|
308
|
+
expect(res.sub_page?)== true
|
394
309
|
res.delete
|
395
310
|
end
|
396
|
-
|
397
311
|
it "should be false" do
|
398
312
|
res = CommitDiff.new @call
|
399
313
|
res.save
|
400
|
-
expect(res.sub_page?)
|
314
|
+
expect(res.sub_page?) == false
|
401
315
|
res.delete
|
402
316
|
end
|
403
|
-
end
|
404
|
-
|
317
|
+
end
|
405
318
|
describe "Current version" do
|
406
319
|
class Fns < GollumRails::Page
|
407
320
|
end
|
408
|
-
|
409
321
|
it "current version should have 7 digest" do
|
410
322
|
res = CommitDiff.new @call
|
411
323
|
res.save
|
412
324
|
expect(res.current_version.length).to be(7)
|
413
325
|
res.delete
|
414
326
|
end
|
415
|
-
|
416
327
|
it "should be nil if page has not been set" do
|
417
328
|
res = CommitDiff.new @call
|
418
329
|
expect(res.current_version).to be_nil
|
419
330
|
end
|
420
|
-
|
421
331
|
it "should be the latest version of the page but shortened" do
|
422
332
|
res = CommitDiff.new @call
|
423
333
|
res.save
|
@@ -430,28 +340,21 @@ describe "Gollum Page" do
|
|
430
340
|
expect(res.gollum_page.version.to_s).to match(/^#{res.current_version(true)}$/)
|
431
341
|
res.delete
|
432
342
|
end
|
433
|
-
|
434
343
|
end
|
435
|
-
|
436
344
|
describe 'History' do
|
437
345
|
class Fns < GollumRails::Page
|
438
346
|
end
|
439
|
-
|
440
347
|
it "history should return nil if no gollum_page was saved" do
|
441
348
|
res = Fns.new @call
|
442
349
|
expect(res.history).to be_nil
|
443
350
|
end
|
444
|
-
|
445
351
|
it "history should return the pages versions if there are changes" do
|
446
352
|
res = Fns.new @call
|
447
353
|
res.save
|
448
354
|
expect(res.history).to be_a Array
|
449
355
|
res.delete
|
450
356
|
end
|
451
|
-
|
452
357
|
end
|
453
|
-
|
454
|
-
|
455
358
|
describe "path names" do
|
456
359
|
class Fns < GollumRails::Page
|
457
360
|
end
|
@@ -460,7 +363,6 @@ describe "Gollum Page" do
|
|
460
363
|
expect(res.path_name).to match ''
|
461
364
|
res.destroy(@commit)
|
462
365
|
end
|
463
|
-
|
464
366
|
it "should output a path name as there was a path supplied" do
|
465
367
|
res = Fns.new @call.merge(name: 'test/pagess')
|
466
368
|
res.save
|
@@ -479,37 +381,29 @@ describe "Gollum Page" do
|
|
479
381
|
#Fns.all(folder: 'test1/').each{|p| puts p.url}
|
480
382
|
expect(Fns.all(folder: 'test4').length).to be 1
|
481
383
|
expect(Fns.all(folder: 'test5').length).to be 1
|
482
|
-
|
483
384
|
res2.destroy(@commit)
|
484
385
|
res.destroy(@commit)
|
485
|
-
|
486
386
|
end
|
487
|
-
|
488
387
|
it "should be empty for a non existing folder" do
|
489
388
|
res = Fns.new @call.merge(name: 'test/pagess')
|
490
389
|
res.save
|
491
|
-
|
492
390
|
expect(Fns.first(folder: 'test2')).to be_nil
|
493
391
|
expect(Fns.last(folder: 'test2')).to be_nil
|
494
|
-
|
495
392
|
res.destroy(@commit)
|
496
393
|
end
|
497
394
|
it "should not be empty for an existing folder" do
|
498
395
|
res = Fns.new @call.merge(name: 'test/pagess')
|
499
396
|
res.save
|
500
|
-
|
501
|
-
expect(Fns.first(folder: 'test')).not_to be_nil
|
397
|
+
expect(Fns.first(folder: 'test')).not_to be_nil
|
502
398
|
expect(Fns.last(folder: 'test')).not_to be_nil
|
503
|
-
|
504
399
|
res.destroy(@commit)
|
505
|
-
end
|
400
|
+
end
|
506
401
|
it "should change the folder" do
|
507
402
|
res = Fns.new @call.merge(name: 'test/pagess')
|
508
403
|
res.save
|
509
404
|
expect(res.path_name).not_to be_nil
|
510
405
|
res.destroy(@commit)
|
511
406
|
end
|
512
|
-
|
513
407
|
it "should create a nested page under /test" do
|
514
408
|
res = Fns.new @call.merge(name: 'test/my_page')
|
515
409
|
res.save
|
@@ -529,10 +423,6 @@ describe "Gollum Page" do
|
|
529
423
|
expect(Fns.search('content').first[:count]).to be(1)
|
530
424
|
res.destroy
|
531
425
|
end
|
532
|
-
|
533
426
|
end
|
534
|
-
|
535
|
-
|
536
|
-
|
537
427
|
#end
|
538
428
|
end
|