gollum_rails 1.4.0.rc1 → 1.4.0.rc2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (45) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +6 -6
  3. data/Gemfile.lock +2 -1
  4. data/HISTORY.md +91 -91
  5. data/LICENSE +661 -661
  6. data/README.md +74 -74
  7. data/Rakefile +170 -170
  8. data/gollum_rails.gemspec +1 -1
  9. data/lib/core_ext/string.rb +7 -10
  10. data/lib/generators/gollum_rails/install/install_generator.rb +27 -27
  11. data/lib/generators/gollum_rails/install/templates/gollum_initializer.rb +22 -22
  12. data/lib/generators/gollum_rails/language/language_generator.rb +81 -81
  13. data/lib/generators/gollum_rails/model/model_generator.rb +51 -51
  14. data/lib/generators/gollum_rails/model/templates/model_template.erb +13 -13
  15. data/lib/gollum_rails.rb +1 -1
  16. data/lib/gollum_rails/adapters/activemodel.rb +36 -36
  17. data/lib/gollum_rails/adapters/activemodel/boolean.rb +15 -15
  18. data/lib/gollum_rails/adapters/activemodel/error.rb +27 -27
  19. data/lib/gollum_rails/adapters/activemodel/naming.rb +42 -42
  20. data/lib/gollum_rails/adapters/gollum.rb +54 -54
  21. data/lib/gollum_rails/adapters/gollum/.gitkeep +0 -0
  22. data/lib/gollum_rails/adapters/gollum/error.rb +19 -19
  23. data/lib/gollum_rails/adapters/gollum/page.rb +177 -177
  24. data/lib/gollum_rails/adapters/gollum/wiki.rb +42 -42
  25. data/lib/gollum_rails/modules/hash.rb +33 -33
  26. data/lib/gollum_rails/modules/loader.rb +5 -5
  27. data/lib/gollum_rails/page.rb +266 -266
  28. data/lib/gollum_rails/setup.rb +81 -81
  29. data/lib/grit/git-ruby/internal/pack.rb +397 -397
  30. data/spec/gollum_rails/adapters/activemodel/error_spec.rb +11 -11
  31. data/spec/gollum_rails/adapters/activemodel/naming_spec.rb +27 -27
  32. data/spec/gollum_rails/adapters/activemodel/validation_unused.rb +102 -102
  33. data/spec/gollum_rails/adapters/gollum/committer_spec.rb +0 -0
  34. data/spec/gollum_rails/adapters/gollum/connector_spec.rb +15 -15
  35. data/spec/gollum_rails/adapters/gollum/error_spec.rb +7 -7
  36. data/spec/gollum_rails/adapters/gollum/page_spec.rb +89 -89
  37. data/spec/gollum_rails/adapters/gollum/wiki_spec.rb +27 -27
  38. data/spec/gollum_rails/modules/hash_spec.rb +31 -31
  39. data/spec/gollum_rails/page_spec.rb +207 -207
  40. data/spec/gollum_rails/respository_spec.rb +0 -0
  41. data/spec/gollum_rails/setup_spec.rb +44 -44
  42. data/spec/gollum_rails/wiki_spec.rb +0 -0
  43. data/spec/spec.opts +3 -3
  44. data/spec/spec_helper.rb +43 -43
  45. metadata +2 -2
@@ -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
@@ -1,31 +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
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
@@ -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