irwi 0.2.4 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (64) hide show
  1. data/MIT-LICENSE +1 -1
  2. data/README.rdoc +9 -9
  3. data/app/views/base_wiki_pages/_wiki_page_info.html.erb +1 -1
  4. data/app/views/base_wiki_pages/compare.html.erb +1 -1
  5. data/app/views/base_wiki_pages/history.html.erb +1 -1
  6. data/app/views/base_wiki_pages/no.html.erb +1 -1
  7. data/lib/generators/irwi_wiki/irwi_wiki_generator.rb +29 -0
  8. data/{generators → lib/generators}/irwi_wiki/templates/controllers/wiki_pages_controller.rb +3 -3
  9. data/{generators → lib/generators}/irwi_wiki/templates/helpers/wiki_pages_helper.rb +1 -1
  10. data/{generators → lib/generators}/irwi_wiki/templates/migrate/create_wiki_pages.rb +15 -15
  11. data/{generators → lib/generators}/irwi_wiki/templates/models/wiki_page.rb +3 -3
  12. data/{generators → lib/generators}/irwi_wiki/templates/models/wiki_page_version.rb +3 -3
  13. data/lib/generators/irwi_wiki_attachments/irwi_wiki_attachments_generator.rb +22 -0
  14. data/{generators → lib/generators}/irwi_wiki_attachments/templates/migrate/create_wiki_page_attachments.rb +6 -6
  15. data/{generators → lib/generators}/irwi_wiki_attachments/templates/models/wiki_page_attachment.rb +1 -1
  16. data/lib/generators/irwi_wiki_views/irwi_wiki_views_generator.rb +13 -0
  17. data/lib/irwi.rb +34 -7
  18. data/lib/irwi/comparators/base.rb +6 -6
  19. data/lib/irwi/comparators/diff_lcs.rb +12 -12
  20. data/lib/irwi/comparators/spans/changed_span.rb +6 -6
  21. data/lib/irwi/comparators/spans/not_changed_span.rb +7 -7
  22. data/lib/irwi/config.rb +16 -14
  23. data/lib/irwi/extensions/controllers.rb +18 -0
  24. data/lib/irwi/extensions/controllers/wiki_page_attachments.rb +1 -1
  25. data/lib/irwi/extensions/controllers/wiki_pages.rb +47 -47
  26. data/lib/irwi/extensions/models.rb +24 -0
  27. data/lib/irwi/extensions/models/wiki_page.rb +16 -16
  28. data/lib/irwi/extensions/models/wiki_page_attachment.rb +4 -4
  29. data/lib/irwi/extensions/models/wiki_page_version.rb +17 -17
  30. data/lib/irwi/formatters/blue_cloth.rb +4 -4
  31. data/lib/irwi/formatters/red_cloth.rb +4 -4
  32. data/lib/irwi/helpers.rb +13 -0
  33. data/lib/irwi/helpers/wiki_page_attachments_helper.rb +4 -2
  34. data/lib/irwi/helpers/wiki_pages_helper.rb +36 -36
  35. data/lib/irwi/paginators/none.rb +6 -4
  36. data/lib/irwi/paginators/will_paginate.rb +4 -4
  37. data/lib/irwi/support/route_mapper.rb +22 -18
  38. data/lib/irwi/support/template_finder.rb +4 -4
  39. data/lib/irwi/version.rb +9 -0
  40. metadata +110 -81
  41. data/.document +0 -4
  42. data/.gitignore +0 -24
  43. data/Rakefile +0 -53
  44. data/VERSION +0 -1
  45. data/generators/irwi_wiki/irwi_wiki_generator.rb +0 -22
  46. data/generators/irwi_wiki_attachments/irwi_wiki_attachments_generator.rb +0 -18
  47. data/generators/irwi_wiki_views/irwi_wiki_views_generator.rb +0 -19
  48. data/irwi.gemspec +0 -120
  49. data/rails/init.rb +0 -44
  50. data/spec/comparators/diff_lcs_spec.rb +0 -45
  51. data/spec/config_spec.rb +0 -68
  52. data/spec/extensions/controllers/wiki_pages_spec.rb +0 -69
  53. data/spec/extensions/models/wiki_page_spec.rb +0 -79
  54. data/spec/formatters/red_cloth_spec.rb +0 -17
  55. data/spec/helpers/wiki_page_attachments_helper_spec.rb +0 -45
  56. data/spec/helpers/wiki_pages_helper_spec.rb +0 -158
  57. data/spec/paginators/none_spec.rb +0 -24
  58. data/spec/paginators/will_paginate_spec.rb +0 -28
  59. data/spec/rcov.opts +0 -2
  60. data/spec/spec.opts +0 -4
  61. data/spec/spec_helper.rb +0 -15
  62. data/spec/support/route_mapper_spec.rb +0 -66
  63. data/spec/support/template_finder_spec.rb +0 -33
  64. data/tasks/riwiki_tasks.rake +0 -4
@@ -1,79 +0,0 @@
1
- require "spec/spec_helper"
2
-
3
- require "active_record"
4
-
5
- describe Irwi::Extensions::Models::WikiPage do
6
-
7
- class AbstractPage < ActiveRecord::Base
8
-
9
-
10
- def self.columns
11
- c = ActiveRecord::ConnectionAdapters::Column
12
-
13
- [
14
- c.new("title", nil, "string", false),
15
- c.new("path", nil, "string", false),
16
- c.new("content", nil, "text", false)
17
- ]
18
- end
19
-
20
- end
21
-
22
- it { should_not be_nil }
23
-
24
- before :all do
25
- Irwi::config.page_attachment_class_name = nil
26
-
27
- @cls = Class.new AbstractPage do
28
- include Irwi::Extensions::Models::WikiPage
29
- end
30
- end
31
-
32
- context "class" do
33
-
34
- it { @cls.should respond_to(:find) }
35
- it { @cls.should respond_to(:find_by_path_or_new) }
36
-
37
- end
38
-
39
- context "instance" do
40
-
41
- before :each do
42
- @obj = @cls.new
43
- end
44
-
45
- it { @obj.should respond_to(:save) }
46
- it { @obj.should respond_to(:destroy) }
47
-
48
- it { @obj.should respond_to(:comment) }
49
- it { @obj.should respond_to(:previous_version_number) }
50
-
51
- it { @obj.should respond_to(:versions) }
52
-
53
- it { @obj.should_not respond_to(:attachments) }
54
-
55
- end
56
-
57
- context "with attachments" do
58
-
59
- before :all do
60
- Irwi::config.page_attachment_class_name = 'WikiPageAttachment'
61
-
62
- @cls = Class.new AbstractPage do
63
- include Irwi::Extensions::Models::WikiPage
64
- end
65
- end
66
-
67
- context "instance" do
68
-
69
- before :each do
70
- @obj = @cls.new
71
- end
72
-
73
- it { @obj.should respond_to(:attachments) }
74
-
75
- end
76
-
77
- end
78
-
79
- end
@@ -1,17 +0,0 @@
1
- require "spec/spec_helper"
2
-
3
- describe Irwi::Formatters::RedCloth do
4
-
5
- before(:each) do
6
- @f = Irwi::Formatters::RedCloth.new
7
- end
8
-
9
- specify "should proces bold text" do
10
- @f.format('*Place* ff').should == '<p><strong>Place</strong> ff</p>'
11
- end
12
-
13
- specify "should proces italic text" do
14
- @f.format('_Mom_ ff').should == '<p><em>Mom</em> ff</p>'
15
- end
16
-
17
- end
@@ -1,45 +0,0 @@
1
- require "spec/spec_helper"
2
-
3
- describe Irwi::Helpers::WikiPageAttachmentsHelper do
4
-
5
- it { should_not be_nil }
6
-
7
- context "included in class" do
8
-
9
- before(:each) do
10
- Irwi.config.page_attachment_class_name = 'WikiPageAttachment'
11
- @m = Object.new
12
- @m.send :extend, Irwi::Helpers::WikiPagesHelper
13
- end
14
-
15
- describe :wiki_show_attachment do
16
- before do
17
- class WikiPageAttachment; end
18
- end
19
-
20
- it 'replaces Attachment_1_thumb with its corresponding image tag' do
21
- paperclip_attachment = mock('paperclip attachment')
22
- attachment = mock(WikiPageAttachment, :wiki_page_attachment => paperclip_attachment)
23
-
24
- WikiPageAttachment.should_receive(:find).with('1').and_return(attachment)
25
- paperclip_attachment.should_receive(:url).with(:thumb).and_return(:thumb_image)
26
- @m.should_receive(:image_tag).with(:thumb_image, :class => 'wiki_page_attachment').and_return('thumb_image_markup')
27
-
28
- @m.wiki_show_attachments('Foo Attachment_1_thumb Bar').should == 'Foo thumb_image_markup Bar'
29
- end
30
-
31
- it 'does not affect text without attachments' do
32
- @m.wiki_show_attachments('Foo Bar').should == 'Foo Bar'
33
- end
34
-
35
- it 'ignores absent attachments' do
36
- paperclip_attachment = mock('paperclip attachment')
37
- attachment = mock(WikiPageAttachment, :wiki_page_attachment => paperclip_attachment)
38
- WikiPageAttachment.should_receive(:find).with('10').and_raise(ActiveRecord::RecordNotFound)
39
-
40
- @m.wiki_show_attachments('Foo Attachment_10_thumb Bar').should == 'Foo Bar'
41
- end
42
- end
43
-
44
- end
45
- end
@@ -1,158 +0,0 @@
1
- require "spec/spec_helper"
2
-
3
- describe Irwi::Helpers::WikiPagesHelper do
4
-
5
- it { should_not be_nil }
6
-
7
- context "included in class" do
8
-
9
- before(:each) do
10
- @m = Object.new
11
- @m.send :extend, Irwi::Helpers::WikiPagesHelper
12
- end
13
-
14
- it { @m.should respond_to(:wiki_page_form) }
15
-
16
- it { @m.should respond_to(:wiki_page_edit_path) }
17
- it { @m.should respond_to(:wiki_page_history_path) }
18
- it { @m.should respond_to(:wiki_page_compare_path) }
19
- it { @m.should respond_to(:wiki_page_path) }
20
-
21
- specify "should form url_for by wiki_page_edit_path" do
22
- @m.should_receive(:url_for).with(:action => :edit).and_return('epath')
23
-
24
- @m.wiki_page_edit_path.should == 'epath'
25
- end
26
-
27
- specify "should form url_for by wiki_page_edit_path with path" do
28
- @m.should_receive(:url_for).with(:action => :edit, :path => 'qwerty').and_return('epath')
29
-
30
- @m.wiki_page_edit_path('qwerty').should == 'epath'
31
- end
32
-
33
- specify "should form url_for by wiki_page_history_path" do
34
- @m.should_receive(:url_for).with(:action => :history).and_return('hpath')
35
-
36
- @m.wiki_page_history_path.should == 'hpath'
37
- end
38
-
39
- specify "should form url_for by wiki_page_compare_path" do
40
- @m.should_receive(:url_for).with(:action => :compare).and_return('cpath')
41
-
42
- @m.wiki_page_compare_path.should == 'cpath'
43
- end
44
-
45
- specify "should form url_for by wiki_page_path" do
46
- @m.should_receive(:url_for).with(:action => :show).and_return('spath')
47
-
48
- @m.wiki_page_path.should == 'spath'
49
- end
50
-
51
- specify "should form url_for by wiki_page_path with path" do
52
- @m.should_receive(:url_for).with(:action => :show, :path => '123').and_return('spath')
53
-
54
- @m.wiki_page_path('123').should == 'spath'
55
- end
56
-
57
- it { @m.should respond_to(:wiki_content) }
58
- it { @m.should respond_to(:wiki_diff) }
59
- it { @m.should respond_to(:wiki_user) }
60
-
61
- it { @m.should respond_to(:wiki_page_info) }
62
- it { @m.should respond_to(:wiki_page_actions) }
63
- it { @m.should respond_to(:wiki_page_history) }
64
- it { @m.should respond_to(:wiki_page_style) }
65
-
66
- it { @m.should respond_to(:wiki_link) }
67
- it { @m.should respond_to(:wiki_linkify) }
68
-
69
- it { @m.should respond_to(:wt) }
70
-
71
- specify "should format and sanitize content with current formatter and #sanitize" do
72
- Irwi.config.formatter = mock 'Formatter'
73
- Irwi.config.formatter.should_receive(:format).with('Page content').and_return('Formatted content')
74
-
75
- @m.should_receive(:auto_link).with('Formatted content').and_return('Formatted content with links')
76
- @m.should_receive(:sanitize).with('Formatted content with links').and_return('Formatted and sanitized content with links')
77
-
78
- @m.wiki_content( 'Page content' ).should == 'Formatted and sanitized content with links'
79
- end
80
-
81
- specify "should render wiki_page_info partial" do
82
- @m.should_receive(:template_dir).and_return('partial_dir')
83
- @m.should_receive(:render).with(:partial => "partial_dir/wiki_page_info", :locals => { :page => 'MyPage' }).and_return('partial_body')
84
-
85
- @m.wiki_page_info( 'MyPage' ).should == 'partial_body'
86
- end
87
-
88
- specify "should render wiki_page_actions partial" do
89
- @m.should_receive(:template_dir).and_return('partial_dir')
90
- @m.should_receive(:render).with(:partial => "partial_dir/wiki_page_actions", :locals => { :page => 'MyPage' }).and_return('partial_body')
91
-
92
- @m.wiki_page_actions( 'MyPage' ).should == 'partial_body'
93
- end
94
-
95
- specify "should render wiki_page_history partial" do
96
- @m.should_receive(:template_dir).and_return('partial_dir')
97
- @m.should_receive(:render).with(:partial => "partial_dir/wiki_page_history", :locals => { :page => 'MyPage', :versions => [1,2], :with_form => true }).and_return('partial_body')
98
-
99
- @m.wiki_page_history( 'MyPage', [1,2] ).should == 'partial_body'
100
- end
101
-
102
- specify "should render wiki_page_history partial (with default versions)" do
103
- page = mock 'MyPage'
104
- page.should_receive(:versions).and_return([1])
105
-
106
- @m.should_receive(:template_dir).and_return('partial_dir')
107
- @m.should_receive(:render).with(:partial => "partial_dir/wiki_page_history", :locals => { :page => page, :versions => [1], :with_form => false }).and_return('partial_body')
108
-
109
- @m.wiki_page_history( page ).should == 'partial_body'
110
- end
111
-
112
- specify "should linkify string" do
113
- @m.should_receive(:wiki_link).exactly(3).times.with('Some other page').and_return('url')
114
-
115
- @m.wiki_linkify( '[[Some other page]] - link' ).should == '<a href="url">Some other page</a> - link'
116
- @m.wiki_linkify( '[[Some other page|Go other page]] - link' ).should == '<a href="url">Go other page</a> - link'
117
- @m.wiki_linkify( '[[Some other page]]s are there' ).should == '<a href="url">Some other pages</a> are there'
118
- end
119
-
120
- specify "should linkify with anchors" do
121
- @m.should_receive(:wiki_link).once.with('Some other page').and_return('url')
122
-
123
- @m.wiki_linkify( 'And [[Some other page#other|other page]]' ).should == 'And <a href="url#other">other page</a>'
124
- end
125
-
126
- specify "should generate link for non-existent page" do
127
- page_class = mock "WikiPageClass"
128
- page_class.should_receive(:find_by_title).with('Page title').and_return(nil)
129
-
130
- Irwi.config.should_receive(:page_class).and_return(page_class)
131
-
132
- @m.should_receive(:url_for).with( :controller => 'wiki_pages', :action => :show, :path => 'Page title' ).and_return('url')
133
-
134
- @m.wiki_link( 'Page title' ).should == 'url'
135
- end
136
-
137
- specify "should generate link for existent page" do
138
- page = mock "WikiPage"
139
- page.should_receive(:path).and_return('page_path')
140
-
141
- page_class = mock "WikiPageClass"
142
- page_class.should_receive(:find_by_title).with('Page title').and_return(page)
143
-
144
- Irwi.config.should_receive(:page_class).and_return(page_class)
145
-
146
- @m.should_receive(:url_for).with( :controller => 'wiki_pages', :action => :show, :path => 'page_path' ).and_return('url')
147
-
148
- @m.wiki_link( 'Page title' ).should == 'url'
149
- end
150
-
151
- specify "not be vulnerable to XSS when showing a diff" do
152
- xss = '<script>alert("exploit")</script>'
153
- @m.wiki_diff('foo bar', "foo #{xss} bar").should_not include(xss)
154
- end
155
-
156
- end
157
-
158
- end
@@ -1,24 +0,0 @@
1
- require "spec/spec_helper"
2
-
3
- describe Irwi::Paginators::None do
4
-
5
- before(:each) do
6
- @p = Irwi::Paginators::None.new
7
- end
8
-
9
- specify "should paginate collection - call find" do
10
- coll = mock "Collection"
11
- coll.should_receive(:find).with(:all,{}).and_return("full collection")
12
-
13
- @p.paginate( coll, :page => 10 ).should == "full collection"
14
- end
15
-
16
- specify "should render paginated section" do
17
- a = nil
18
- @p.paginated_section "view", "collection" do
19
- a = true
20
- end
21
- a.should be_true
22
- end
23
-
24
- end
@@ -1,28 +0,0 @@
1
- require "spec/spec_helper"
2
-
3
- describe Irwi::Paginators::WillPaginate do
4
-
5
- before :all do
6
- end
7
-
8
- before :each do
9
- @p = Irwi::Paginators::WillPaginate.new
10
- end
11
-
12
- specify "should paginate collection" do
13
- coll = mock "Collection"
14
- coll.should_receive(:paginate).with( :page => 15 ).and_return("paginated_collection")
15
-
16
- @p.paginate( coll, :page => 15 ).should == "paginated_collection"
17
- end
18
-
19
- specify "should render paginated collection" do
20
- block = lambda { 11 }
21
- coll = []
22
- view = mock "View"
23
- view.should_receive(:paginated_section).with( coll, &block ).and_return("result")
24
-
25
- @p.paginated_section( view, coll, &block ).should == "result"
26
- end
27
-
28
- end
@@ -1,2 +0,0 @@
1
- --exclude "spec/*,gems/*"
2
- --rails
@@ -1,4 +0,0 @@
1
- --colour
2
- --format specdoc
3
- --loadby mtime
4
- --reverse
@@ -1,15 +0,0 @@
1
- require 'rubygems'
2
-
3
- require 'active_support'
4
- require 'active_support/test_case'
5
-
6
- ActiveSupport::Dependencies.load_paths << "#{File.dirname(__FILE__)}/../lib"
7
- ActiveSupport::Dependencies.load_paths << "#{File.dirname(__FILE__)}/../app/models"
8
- ActiveSupport::Dependencies.load_paths << "#{File.dirname(__FILE__)}/../app/controllers"
9
-
10
- # Requires supporting files with custom matchers and macros, etc,
11
- # in ./support/ and its subdirectories.
12
- Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f}
13
-
14
- Spec::Runner.configure do |config|
15
- end
@@ -1,66 +0,0 @@
1
- require "spec/spec_helper"
2
- require 'action_controller'
3
-
4
- describe Irwi::Support::RouteMapper do
5
-
6
- it { should_not be_nil }
7
-
8
- context "included in class" do
9
-
10
- before(:each) do
11
- @m = Object.new
12
- @m.send :extend, Irwi::Support::RouteMapper
13
- end
14
-
15
- specify "should provide wiki_root method" do
16
- @m.should respond_to(:wiki_root)
17
- end
18
-
19
- end
20
-
21
- describe 'wiki routes' do
22
- before do
23
- @set = ActionController::Routing::RouteSet.new
24
- @mapper = ActionController::Routing::RouteSet::Mapper.new(@set)
25
-
26
- ActionController::Routing::RouteSet::Mapper.instance_eval do
27
- include Irwi::Support::RouteMapper
28
- end
29
- @mapper.wiki_root('/wiki')
30
- end
31
-
32
- def check_route path, params = {}
33
- @set.generate(params).should == path
34
- @set.recognize_path(path).should == params
35
- end
36
-
37
- it 'has a route of listing all the wikis' do
38
- check_route '/wiki/all', :controller => 'wiki_pages', :action => 'all', :root => '/wiki'
39
- end
40
-
41
- %w[compare new edit history].each do |act|
42
- it "has a route for #{act} wiki" do
43
- check_route "/wiki/#{act}/wiki_path", :controller => 'wiki_pages', :action => act, :root => '/wiki', :path => ['wiki_path']
44
- end
45
- end
46
-
47
- # Unable to perform the recognize path test because of conditions. If you can , write it.
48
- %w[show update destroy].each do |act|
49
- it "has a route for #{act} wiki" do
50
- @set.generate({:controller => 'wiki_pages', :action => act, :root => '/wiki', :path => ['wiki_path']}).should == '/wiki/wiki_path'
51
- end
52
- end
53
-
54
- describe 'attachment routes' do
55
- it 'has a route for adding an attachment' do
56
- @set.generate({:controller => 'wiki_pages', :action => 'add_attachment', :root => '/wiki', :path => ['wiki_path']}).should == '/wiki/attach/wiki_path'
57
- end
58
-
59
- it 'has a route for deleting an attachment' do
60
- @set.generate({:controller => 'wiki_pages', :action => 'remove_attachment', :root => '/wiki', :attachment_id => 1}).should == '/wiki/attach/1'
61
- end
62
- end
63
-
64
- end
65
-
66
- end