gollum_rails 1.4.0.rc2 → 1.4.0.rc3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +6 -6
- data/Gemfile.lock +7 -10
- data/HISTORY.md +91 -91
- data/LICENSE +661 -661
- data/README.md +74 -74
- data/Rakefile +170 -170
- data/gollum_rails.gemspec +6 -4
- data/lib/core_ext/string.rb +3 -7
- data/lib/generators/gollum_rails/install/install_generator.rb +27 -27
- data/lib/generators/gollum_rails/install/templates/gollum_initializer.rb +22 -22
- data/lib/generators/gollum_rails/language/language_generator.rb +81 -81
- data/lib/generators/gollum_rails/model/model_generator.rb +51 -51
- data/lib/generators/gollum_rails/model/templates/model_template.erb +13 -13
- data/lib/gollum_rails.rb +26 -6
- data/lib/gollum_rails/adapters/activemodel.rb +36 -36
- data/lib/gollum_rails/adapters/activemodel/boolean.rb +15 -15
- data/lib/gollum_rails/adapters/activemodel/error.rb +27 -27
- data/lib/gollum_rails/adapters/activemodel/naming.rb +42 -42
- data/lib/gollum_rails/adapters/gollum.rb +54 -54
- data/lib/gollum_rails/adapters/gollum/.gitkeep +0 -0
- data/lib/gollum_rails/adapters/gollum/error.rb +19 -19
- data/lib/gollum_rails/adapters/gollum/page.rb +177 -177
- data/lib/gollum_rails/adapters/gollum/wiki.rb +42 -42
- data/lib/gollum_rails/page.rb +266 -266
- data/lib/gollum_rails/setup.rb +81 -81
- data/lib/grit/git-ruby/internal/pack.rb +397 -397
- data/spec/gollum_rails/adapters/activemodel/error_spec.rb +11 -11
- data/spec/gollum_rails/adapters/activemodel/naming_spec.rb +27 -27
- data/spec/gollum_rails/adapters/activemodel/validation_unused.rb +102 -102
- data/spec/gollum_rails/adapters/gollum/committer_spec.rb +0 -0
- data/spec/gollum_rails/adapters/gollum/connector_spec.rb +15 -15
- data/spec/gollum_rails/adapters/gollum/error_spec.rb +7 -7
- data/spec/gollum_rails/adapters/gollum/page_spec.rb +89 -89
- data/spec/gollum_rails/adapters/gollum/wiki_spec.rb +27 -27
- data/spec/gollum_rails/error_spec.rb +10 -0
- data/spec/gollum_rails/page_spec.rb +207 -207
- data/spec/gollum_rails/respository_spec.rb +0 -0
- data/spec/gollum_rails/setup_spec.rb +44 -44
- data/spec/gollum_rails/wiki_spec.rb +0 -0
- data/spec/gollum_rails_spec.rb +9 -0
- data/spec/spec.opts +3 -3
- data/spec/spec_helper.rb +43 -43
- metadata +4 -5
- data/lib/gollum_rails/modules/hash.rb +0 -33
- data/lib/gollum_rails/modules/loader.rb +0 -5
- data/spec/gollum_rails/modules/hash_spec.rb +0 -31
@@ -1,27 +1,27 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
require 'grit'
|
3
|
-
|
4
|
-
describe GollumRails::Adapters::Gollum::Wiki do
|
5
|
-
before(:each) do
|
6
|
-
@location = "#{File.dirname(__FILE__)}/../../../utils/wiki.git"
|
7
|
-
@repo = Grit::Repo.init_bare @location
|
8
|
-
@wiki = GollumRails::Adapters::Gollum::Wiki.new @repo
|
9
|
-
end
|
10
|
-
it "should test initializer" do
|
11
|
-
wiki = GollumRails::Adapters::Gollum::Wiki.new @location
|
12
|
-
@wiki.git.should == @repo
|
13
|
-
wiki.git.should be_instance_of(String)
|
14
|
-
wiki.git.should == @location
|
15
|
-
end
|
16
|
-
it "should test the creation of a new wiki" do
|
17
|
-
wiki = GollumRails::Adapters::Gollum::Wiki.wiki @repo
|
18
|
-
wiki.git.should == @repo
|
19
|
-
wiki = GollumRails::Adapters::Gollum::Wiki.wiki @location
|
20
|
-
wiki.git.should == @location
|
21
|
-
GollumRails::Adapters::Gollum::Connector.wiki_class.should be_instance_of(::Gollum::Wiki)
|
22
|
-
end
|
23
|
-
it "should test the error throwing and forwarding" do
|
24
|
-
expect{GollumRails::Adapters::Gollum::Wiki.write_page}.to raise_error ArgumentError
|
25
|
-
end
|
26
|
-
|
27
|
-
end
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'grit'
|
3
|
+
|
4
|
+
describe GollumRails::Adapters::Gollum::Wiki do
|
5
|
+
before(:each) do
|
6
|
+
@location = "#{File.dirname(__FILE__)}/../../../utils/wiki.git"
|
7
|
+
@repo = Grit::Repo.init_bare @location
|
8
|
+
@wiki = GollumRails::Adapters::Gollum::Wiki.new @repo
|
9
|
+
end
|
10
|
+
it "should test initializer" do
|
11
|
+
wiki = GollumRails::Adapters::Gollum::Wiki.new @location
|
12
|
+
@wiki.git.should == @repo
|
13
|
+
wiki.git.should be_instance_of(String)
|
14
|
+
wiki.git.should == @location
|
15
|
+
end
|
16
|
+
it "should test the creation of a new wiki" do
|
17
|
+
wiki = GollumRails::Adapters::Gollum::Wiki.wiki @repo
|
18
|
+
wiki.git.should == @repo
|
19
|
+
wiki = GollumRails::Adapters::Gollum::Wiki.wiki @location
|
20
|
+
wiki.git.should == @location
|
21
|
+
GollumRails::Adapters::Gollum::Connector.wiki_class.should be_instance_of(::Gollum::Wiki)
|
22
|
+
end
|
23
|
+
it "should test the error throwing and forwarding" do
|
24
|
+
expect{GollumRails::Adapters::Gollum::Wiki.write_page}.to raise_error ArgumentError
|
25
|
+
end
|
26
|
+
|
27
|
+
end
|
@@ -0,0 +1,10 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
describe GollumRails::GollumInternalError do
|
3
|
+
|
4
|
+
it "should display a fancy inspect" do
|
5
|
+
GollumRails::GollumInternalError.new("hihi").inspect.should include("{name: \"hihi\"")
|
6
|
+
end
|
7
|
+
it "should raise an error with custom message" do
|
8
|
+
expect{raise GollumRails::GollumInternalError.new("myname", "is", "i am the message")}.to raise_error
|
9
|
+
end
|
10
|
+
end
|
@@ -1,207 +1,207 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe "Gollum Page" do
|
4
|
-
before(:each) do
|
5
|
-
@commit = {
|
6
|
-
:name => "flo",
|
7
|
-
:message => "commit",
|
8
|
-
:email => "mosny@zyg.li"
|
9
|
-
}
|
10
|
-
@call = {
|
11
|
-
:name => "Goole",
|
12
|
-
:content => "content data",
|
13
|
-
:commit => @commit,
|
14
|
-
:format => :markdown
|
15
|
-
}
|
16
|
-
end
|
17
|
-
describe GollumRails::Page do
|
18
|
-
class RailsModel < GollumRails::Page
|
19
|
-
|
20
|
-
|
21
|
-
end
|
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)
|
28
|
-
end
|
29
|
-
|
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
|
34
|
-
end
|
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
|
40
|
-
end
|
41
|
-
|
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>")
|
52
|
-
end
|
53
|
-
end
|
54
|
-
|
55
|
-
it "should test exception methods" do
|
56
|
-
create = RailsModel.create! @call
|
57
|
-
end
|
58
|
-
|
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
|
66
|
-
end
|
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
|
77
|
-
end
|
78
|
-
it "should test setters" do
|
79
|
-
rr = RailsModel.new
|
80
|
-
rr.name=("google").should == "google"
|
81
|
-
rr.commit=(@commit).should == @commit
|
82
|
-
rr.content=("content").should == "content"
|
83
|
-
rr.format=(:markdown).should == :markdown
|
84
|
-
end
|
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
|
91
|
-
end
|
92
|
-
end
|
93
|
-
describe "callbacks" do
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
it "should test the callback functions" do
|
98
|
-
|
99
|
-
class SaveCallback
|
100
|
-
def self.before_save( obj )
|
101
|
-
obj.name.should == "Goole"
|
102
|
-
end
|
103
|
-
end
|
104
|
-
|
105
|
-
|
106
|
-
class CallbackTest < GollumRails::Page
|
107
|
-
|
108
|
-
before_save ::SaveCallback
|
109
|
-
after_save :after_save
|
110
|
-
after_delete :after_delete
|
111
|
-
before_delete :before_delete
|
112
|
-
before_update :before_update
|
113
|
-
after_update :after_update
|
114
|
-
|
115
|
-
def after_save
|
116
|
-
@name.should == "Goole"
|
117
|
-
end
|
118
|
-
def before_update
|
119
|
-
@name.should == "Goole"
|
120
|
-
end
|
121
|
-
|
122
|
-
def after_update
|
123
|
-
@name.should == "Goole"
|
124
|
-
end
|
125
|
-
|
126
|
-
def before_delete
|
127
|
-
@name.should == "Goole"
|
128
|
-
end
|
129
|
-
|
130
|
-
def after_delete
|
131
|
-
@name.should == "Goole"
|
132
|
-
end
|
133
|
-
|
134
|
-
end
|
135
|
-
|
136
|
-
test = CallbackTest.new @call
|
137
|
-
test.persisted?.should be_false
|
138
|
-
test.save
|
139
|
-
test.delete @commit
|
140
|
-
test.save
|
141
|
-
test.update_attributes @call
|
142
|
-
test.persisted?.should be_true
|
143
|
-
end
|
144
|
-
end
|
145
|
-
describe "rails extension" do
|
146
|
-
it "should test fetch_all" do
|
147
|
-
GollumRails::Page.all.length.should == 2
|
148
|
-
GollumRails::Page.find_all.length.should == 2
|
149
|
-
end
|
150
|
-
|
151
|
-
end
|
152
|
-
describe "testing validation" do
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
it "should test the basic validation" do
|
157
|
-
class Callbackt < GollumRails::Page
|
158
|
-
validates_presence_of :name
|
159
|
-
end
|
160
|
-
cla = Callbackt.new @call
|
161
|
-
cla.valid?.should be_true
|
162
|
-
end
|
163
|
-
class SugarBaby < GollumRails::Page
|
164
|
-
validates_presence_of :name
|
165
|
-
validates_length_of :name, :minimum => 20
|
166
|
-
validates_length_of :format, :maximum => 14
|
167
|
-
end
|
168
|
-
it "should test string validation" do
|
169
|
-
@call[:name] = "das ist zu lang"*10
|
170
|
-
cla = SugarBaby.new @call
|
171
|
-
cla.valid?.should be_true
|
172
|
-
end
|
173
|
-
it "should test the presence validator" do
|
174
|
-
@call[:name] = [ ]
|
175
|
-
bla = SugarBaby.new @call
|
176
|
-
bla.valid?.should be_false
|
177
|
-
end
|
178
|
-
it "should test the length validator for name" do
|
179
|
-
@call[:name] = "das"
|
180
|
-
res = SugarBaby.new @call
|
181
|
-
res.valid?.should be_false
|
182
|
-
end
|
183
|
-
it "should test the length validator for format" do
|
184
|
-
@call[:format] = :toolongformatstringforvalidator
|
185
|
-
res = SugarBaby.new @call
|
186
|
-
res.valid?.should be_false
|
187
|
-
end
|
188
|
-
|
189
|
-
end
|
190
|
-
describe "the thread safety" do
|
191
|
-
class ThreadModel < GollumRails::Page
|
192
|
-
|
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
|
207
|
-
end
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe "Gollum Page" do
|
4
|
+
before(:each) do
|
5
|
+
@commit = {
|
6
|
+
:name => "flo",
|
7
|
+
:message => "commit",
|
8
|
+
:email => "mosny@zyg.li"
|
9
|
+
}
|
10
|
+
@call = {
|
11
|
+
:name => "Goole",
|
12
|
+
:content => "content data",
|
13
|
+
:commit => @commit,
|
14
|
+
:format => :markdown
|
15
|
+
}
|
16
|
+
end
|
17
|
+
describe GollumRails::Page do
|
18
|
+
class RailsModel < GollumRails::Page
|
19
|
+
|
20
|
+
|
21
|
+
end
|
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)
|
28
|
+
end
|
29
|
+
|
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
|
34
|
+
end
|
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
|
40
|
+
end
|
41
|
+
|
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>")
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
it "should test exception methods" do
|
56
|
+
create = RailsModel.create! @call
|
57
|
+
end
|
58
|
+
|
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
|
66
|
+
end
|
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
|
77
|
+
end
|
78
|
+
it "should test setters" do
|
79
|
+
rr = RailsModel.new
|
80
|
+
rr.name=("google").should == "google"
|
81
|
+
rr.commit=(@commit).should == @commit
|
82
|
+
rr.content=("content").should == "content"
|
83
|
+
rr.format=(:markdown).should == :markdown
|
84
|
+
end
|
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
|
91
|
+
end
|
92
|
+
end
|
93
|
+
describe "callbacks" do
|
94
|
+
|
95
|
+
|
96
|
+
|
97
|
+
it "should test the callback functions" do
|
98
|
+
|
99
|
+
class SaveCallback
|
100
|
+
def self.before_save( obj )
|
101
|
+
obj.name.should == "Goole"
|
102
|
+
end
|
103
|
+
end
|
104
|
+
|
105
|
+
|
106
|
+
class CallbackTest < GollumRails::Page
|
107
|
+
|
108
|
+
before_save ::SaveCallback
|
109
|
+
after_save :after_save
|
110
|
+
after_delete :after_delete
|
111
|
+
before_delete :before_delete
|
112
|
+
before_update :before_update
|
113
|
+
after_update :after_update
|
114
|
+
|
115
|
+
def after_save
|
116
|
+
@name.should == "Goole"
|
117
|
+
end
|
118
|
+
def before_update
|
119
|
+
@name.should == "Goole"
|
120
|
+
end
|
121
|
+
|
122
|
+
def after_update
|
123
|
+
@name.should == "Goole"
|
124
|
+
end
|
125
|
+
|
126
|
+
def before_delete
|
127
|
+
@name.should == "Goole"
|
128
|
+
end
|
129
|
+
|
130
|
+
def after_delete
|
131
|
+
@name.should == "Goole"
|
132
|
+
end
|
133
|
+
|
134
|
+
end
|
135
|
+
|
136
|
+
test = CallbackTest.new @call
|
137
|
+
test.persisted?.should be_false
|
138
|
+
test.save
|
139
|
+
test.delete @commit
|
140
|
+
test.save
|
141
|
+
test.update_attributes @call
|
142
|
+
test.persisted?.should be_true
|
143
|
+
end
|
144
|
+
end
|
145
|
+
describe "rails extension" do
|
146
|
+
it "should test fetch_all" do
|
147
|
+
GollumRails::Page.all.length.should == 2
|
148
|
+
GollumRails::Page.find_all.length.should == 2
|
149
|
+
end
|
150
|
+
|
151
|
+
end
|
152
|
+
describe "testing validation" do
|
153
|
+
|
154
|
+
|
155
|
+
|
156
|
+
it "should test the basic validation" do
|
157
|
+
class Callbackt < GollumRails::Page
|
158
|
+
validates_presence_of :name
|
159
|
+
end
|
160
|
+
cla = Callbackt.new @call
|
161
|
+
cla.valid?.should be_true
|
162
|
+
end
|
163
|
+
class SugarBaby < GollumRails::Page
|
164
|
+
validates_presence_of :name
|
165
|
+
validates_length_of :name, :minimum => 20
|
166
|
+
validates_length_of :format, :maximum => 14
|
167
|
+
end
|
168
|
+
it "should test string validation" do
|
169
|
+
@call[:name] = "das ist zu lang"*10
|
170
|
+
cla = SugarBaby.new @call
|
171
|
+
cla.valid?.should be_true
|
172
|
+
end
|
173
|
+
it "should test the presence validator" do
|
174
|
+
@call[:name] = [ ]
|
175
|
+
bla = SugarBaby.new @call
|
176
|
+
bla.valid?.should be_false
|
177
|
+
end
|
178
|
+
it "should test the length validator for name" do
|
179
|
+
@call[:name] = "das"
|
180
|
+
res = SugarBaby.new @call
|
181
|
+
res.valid?.should be_false
|
182
|
+
end
|
183
|
+
it "should test the length validator for format" do
|
184
|
+
@call[:format] = :toolongformatstringforvalidator
|
185
|
+
res = SugarBaby.new @call
|
186
|
+
res.valid?.should be_false
|
187
|
+
end
|
188
|
+
|
189
|
+
end
|
190
|
+
describe "the thread safety" do
|
191
|
+
class ThreadModel < GollumRails::Page
|
192
|
+
|
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
|
207
|
+
end
|