typo 5.4.4 → 5.5
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +59 -28
- data/MAINTAINERS +9 -17
- data/README +28 -20
- data/UPGRADE +6 -2
- data/app/controllers/accounts_controller.rb +1 -1
- data/app/controllers/admin/content_controller.rb +1 -1
- data/app/controllers/admin/feedback_controller.rb +3 -3
- data/app/controllers/admin/pages_controller.rb +2 -0
- data/app/controllers/application_controller.rb +6 -1
- data/app/controllers/articles_controller.rb +13 -1
- data/app/helpers/application_helper.rb +5 -2
- data/app/helpers/authors_helper.rb +14 -3
- data/app/models/article.rb +6 -4
- data/app/models/blog.rb +0 -4
- data/app/models/blog_sweeper.rb +1 -1
- data/app/models/content.rb +10 -5
- data/app/models/page_cache.rb +6 -7
- data/app/models/user.rb +1 -0
- data/app/views/admin/content/_form.html.erb +13 -11
- data/app/views/admin/content/_images.html.erb +1 -1
- data/app/views/admin/content/_simple_editor.html.erb +1 -0
- data/app/views/admin/content/_visual_editor.html.erb +1 -0
- data/app/views/admin/dashboard/_overview.html.erb +7 -7
- data/app/views/admin/pages/_form.html.erb +1 -0
- data/app/views/admin/pages/_images.html.erb +18 -0
- data/app/views/admin/pages/_simple_editor.html.erb +1 -2
- data/app/views/admin/pages/_visual_editor.html.erb +2 -1
- data/app/views/admin/pages/index.html.erb +1 -1
- data/app/views/admin/settings/feedback.html.erb +2 -1
- data/app/views/admin/tags/edit.html.erb +1 -1
- data/app/views/articles/_article.html.erb +17 -13
- data/app/views/articles/_article_content.html.erb +1 -0
- data/app/views/articles/_comment_box.html.erb +1 -1
- data/app/views/articles/_password_form.html.erb +10 -0
- data/app/views/articles/groupings.html.erb +1 -1
- data/app/views/articles/index.html.erb +1 -2
- data/app/views/articles/read.html.erb +1 -4
- data/app/views/articles/search.html.erb +1 -1
- data/app/views/layouts/administration.html.erb +1 -1
- data/app/views/shared/_search.html.erb +1 -1
- data/config/ckeditor.yml +14 -0
- data/config/environment.rb +13 -25
- data/config/environments/test.rb +1 -3
- data/config/filemanager.yml +16 -0
- data/config/initializers/access_rules.rb +5 -0
- data/config/routes.rb +5 -1
- data/db/migrate/004_add_sidebars.rb +3 -9
- data/db/migrate/089_drop_cache_information_table.rb +31 -0
- data/db/migrate/090_remove_keywords_from_posts.rb +9 -0
- data/db/migrate/091_adds_password_protection_to_posts.rb +9 -0
- data/doc/CACHE.SETUP.README +36 -0
- data/lang/de_DE.rb +6 -1
- data/lang/pl_PL.rb +221 -89
- data/lib/filemanager.rb +53 -0
- data/lib/filemanager/controller.rb +217 -0
- data/lib/i18n_interpolation_deprecation.rb +26 -0
- data/lib/rails_patch/active_support.rb +4 -0
- data/lib/tasks/release.rake +4 -131
- data/lib/typo_version.rb +1 -1
- data/public/.htaccess +6 -5
- data/public/filemanager/images/avi.gif +0 -0
- data/public/filemanager/images/box.gif +0 -0
- data/public/filemanager/images/bullet.gif +0 -0
- data/public/filemanager/images/close.gif +0 -0
- data/public/filemanager/images/closelabel.gif +0 -0
- data/public/filemanager/images/doc.gif +0 -0
- data/public/filemanager/images/donate-button.gif +0 -0
- data/public/filemanager/images/download-icon.gif +0 -0
- data/public/filemanager/images/folder.gif +0 -0
- data/public/filemanager/images/gif.gif +0 -0
- data/public/filemanager/images/htm.gif +0 -0
- data/public/filemanager/images/html.gif +0 -0
- data/public/filemanager/images/image-1.jpg +0 -0
- data/public/filemanager/images/image.gif +0 -0
- data/public/filemanager/images/jpg.gif +0 -0
- data/public/filemanager/images/loading.gif +0 -0
- data/public/filemanager/images/mov.gif +0 -0
- data/public/filemanager/images/nextlabel.gif +0 -0
- data/public/filemanager/images/pdf.gif +0 -0
- data/public/filemanager/images/png.gif +0 -0
- data/public/filemanager/images/ppt.gif +0 -0
- data/public/filemanager/images/prevlabel.gif +0 -0
- data/public/filemanager/images/rar.gif +0 -0
- data/public/filemanager/images/rm.gif +0 -0
- data/public/filemanager/images/rmvb.gif +0 -0
- data/public/filemanager/images/separator.gif +0 -0
- data/public/filemanager/images/spacer.gif +0 -0
- data/public/filemanager/images/swf.gif +0 -0
- data/public/filemanager/images/thumb-1.jpg +0 -0
- data/public/filemanager/images/tool_copy.gif +0 -0
- data/public/filemanager/images/tool_cut.gif +0 -0
- data/public/filemanager/images/tool_del.gif +0 -0
- data/public/filemanager/images/tool_folder.gif +0 -0
- data/public/filemanager/images/tool_imagemanager.gif +0 -0
- data/public/filemanager/images/tool_new.gif +0 -0
- data/public/filemanager/images/tool_paste.gif +0 -0
- data/public/filemanager/images/tool_props.gif +0 -0
- data/public/filemanager/images/tool_refresh.gif +0 -0
- data/public/filemanager/images/tool_unzip.gif +0 -0
- data/public/filemanager/images/tool_upload.gif +0 -0
- data/public/filemanager/images/tool_zip.gif +0 -0
- data/public/filemanager/images/txt.gif +0 -0
- data/public/filemanager/images/unknown.gif +0 -0
- data/public/filemanager/images/wmv.gif +0 -0
- data/public/filemanager/images/xls.gif +0 -0
- data/public/filemanager/images/zip.gif +0 -0
- data/public/filemanager/javascripts/filemanager.js +6 -0
- data/public/filemanager/javascripts/lang/en.js +31 -0
- data/public/filemanager/javascripts/lang/zh_CN.js +31 -0
- data/public/filemanager/javascripts/lightbox.js +497 -0
- data/public/filemanager/javascripts/translate.js +42 -0
- data/public/filemanager/resources/resources.txt +1 -0
- data/public/filemanager/stylesheets/filelist.css +147 -0
- data/public/filemanager/stylesheets/general.css +135 -0
- data/public/filemanager/stylesheets/lightbox.css +27 -0
- data/public/javascripts/prototype_ext.js +117 -0
- data/public/stylesheets/administration.css +19 -2
- data/themes/dirtylicious/views/articles/_article.html.erb +16 -12
- data/themes/dirtylicious/views/articles/_article_content.html.erb +1 -0
- data/themes/dirtylicious/views/articles/_password_form.html.erb +10 -0
- data/themes/scribbish/views/articles/_article.html.erb +18 -14
- data/themes/scribbish/views/articles/_article_content.html.erb +1 -0
- data/themes/scribbish/views/articles/_password_form.html.erb +10 -0
- data/themes/standard_issue/views/articles/_article.html.erb +16 -12
- data/themes/standard_issue/views/articles/_article_content.html.erb +1 -0
- data/themes/standard_issue/views/articles/_password_form.html.erb +10 -0
- data/themes/true-blue-3/helpers/theme_helper.rb +2 -2
- data/themes/true-blue-3/images/submit_form.jpg +0 -0
- data/themes/true-blue-3/stylesheets/style.css +27 -3
- data/themes/true-blue-3/views/articles/_article.html.erb +13 -8
- data/themes/true-blue-3/views/articles/_article_content.html.erb +1 -0
- data/themes/true-blue-3/views/articles/_comment_form.html.erb +1 -1
- data/themes/true-blue-3/views/articles/_password_form.html.erb +10 -0
- data/themes/true-blue-3/views/categories/_article.html.erb +5 -0
- data/themes/true-blue-3/views/tags/_article.html.erb +4 -0
- data/themes/typographic/views/articles/_article.html.erb +16 -12
- data/themes/typographic/views/articles/_article_content.html.erb +1 -0
- data/themes/typographic/views/articles/_password_form.html.erb +10 -0
- data/vendor/plugins/easy-ckeditor/app/controllers/ckeditor_controller.rb +2 -1
- data/vendor/plugins/easy-ckeditor/lib/ckeditor.rb +1 -20
- data/vendor/plugins/easy-ckeditor/{tasks → lib/tasks}/ckeditor_tasks.rake +0 -0
- data/vendor/plugins/filemanager/app/controllers/fm/filemanager_controller.rb +22 -0
- data/vendor/plugins/filemanager/app/views/fm/filemanager/index.html.erb +512 -0
- data/vendor/plugins/filemanager/app/views/fm/filemanager/view.html.erb +67 -0
- data/vendor/plugins/filemanager/filemanager.yml +16 -0
- data/vendor/plugins/static_sidebar/lib/static_sidebar.rb +4 -2
- data/vendor/plugins/typo_converter/{tasks → lib/tasks}/typo_converters_tasks.rake +0 -0
- data/vendor/plugins/typo_login_system/lib/access_control.rb +24 -1
- data/vendor/plugins/typo_textfilter_code/{tasks → lib/tasks}/typo_textfilter_code_tasks.rake +0 -0
- data/vendor/plugins/typo_textfilter_code/lib/typo_textfilter_code.rb +4 -3
- data/vendor/plugins/typo_textfilter_flickr/{tasks → lib/tasks}/typo_textfilter_flickr_tasks.rake +0 -0
- data/vendor/plugins/typo_textfilter_htmlfilter/{tasks → lib/tasks}/typo_textfilter_htmlfilter_tasks.rake +0 -0
- data/vendor/plugins/typo_textfilter_lightbox/{tasks → lib/tasks}/typo_textfilter_lightbox_tasks.rake +0 -0
- data/vendor/plugins/typo_textfilter_markdown/{tasks → lib/tasks}/typo_textfilter_markdown_tasks.rake +0 -0
- data/vendor/plugins/typo_textfilter_none/{tasks → lib/tasks}/typo_textfilter_none_tasks.rake +0 -0
- data/vendor/plugins/typo_textfilter_smartypants/{tasks → lib/tasks}/typo_textfilter_smartypants_tasks.rake +0 -0
- data/vendor/plugins/typo_textfilter_textile/{tasks → lib/tasks}/typo_textfilter_textile_tasks.rake +0 -0
- data/vendor/plugins/typo_textfilter_textile_and_markdown/{tasks → lib/tasks}/typo_textfilter_textile_and_markdown_tasks.rake +0 -0
- data/vendor/plugins/xml_sidebar/views/content.rhtml +1 -1
- metadata +190 -195
- data/app/controllers/admin/cache_controller.rb +0 -9
- data/app/models/cache_information.rb +0 -19
- data/db/schema.rb +0 -242
- data/doc/test_themes.rb +0 -50
- data/public/javascripts/ckeditor/config.js +0 -27
- data/spec/controllers/accounts_controller_spec.rb +0 -414
- data/spec/controllers/admin/cache_controller_spec.rb +0 -18
- data/spec/controllers/admin/categories_controller_spec.rb +0 -73
- data/spec/controllers/admin/content_controller_spec.rb +0 -443
- data/spec/controllers/admin/dashboard_controller_spec.rb +0 -13
- data/spec/controllers/admin/feedback_controller_spec.rb +0 -308
- data/spec/controllers/admin/pages_controller_spec.rb +0 -80
- data/spec/controllers/admin/profiles_controller_spec.rb +0 -22
- data/spec/controllers/admin/resources_controller_spec.rb +0 -53
- data/spec/controllers/admin/settings_controller_spec.rb +0 -80
- data/spec/controllers/admin/tags_controller_spec.rb +0 -64
- data/spec/controllers/admin/textfilters_controller_spec.rb +0 -20
- data/spec/controllers/admin/themes_controller_spec.rb +0 -30
- data/spec/controllers/admin/users_controller_spec.rb +0 -109
- data/spec/controllers/application_controller_spec.rb +0 -18
- data/spec/controllers/articles_controller_spec.rb +0 -440
- data/spec/controllers/authors_controller_spec.rb +0 -42
- data/spec/controllers/backend_controller_spec.rb +0 -337
- data/spec/controllers/categories_controller_spec.rb +0 -117
- data/spec/controllers/comments_controller_spec.rb +0 -137
- data/spec/controllers/routes/articles_routing_spec.rb +0 -31
- data/spec/controllers/routes/xml_routing_spec.rb +0 -71
- data/spec/controllers/setup_controller_spec.rb +0 -24
- data/spec/controllers/tags_controller_spec.rb +0 -147
- data/spec/controllers/textfilter_controller_spec.rb +0 -192
- data/spec/controllers/theme_controller_spec.rb +0 -39
- data/spec/controllers/xml_controller_spec.rb +0 -185
- data/spec/factories.rb +0 -69
- data/spec/helpers/application_helper_spec.rb +0 -25
- data/spec/helpers/content_helper_spec.rb +0 -28
- data/spec/lib/text_filter_plugin_spec.rb +0 -15
- data/spec/models/amazon_sidebar_spec.rb +0 -40
- data/spec/models/article_closing_spec.rb +0 -42
- data/spec/models/article_spec.rb +0 -515
- data/spec/models/blog_spec.rb +0 -116
- data/spec/models/cache_information_spec.rb +0 -42
- data/spec/models/cache_support_spec.rb +0 -51
- data/spec/models/category_spec.rb +0 -44
- data/spec/models/comment_spec.rb +0 -240
- data/spec/models/configuration_spec.rb +0 -91
- data/spec/models/content_state/feedback_states_spec.rb +0 -64
- data/spec/models/notification_spec.rb +0 -8
- data/spec/models/page_cache_spec.rb +0 -30
- data/spec/models/page_spec.rb +0 -91
- data/spec/models/ping_pinger_spec.rb +0 -33
- data/spec/models/ping_spec.rb +0 -154
- data/spec/models/redirect_spec.rb +0 -17
- data/spec/models/resource_spec.rb +0 -39
- data/spec/models/route_cache_spec.rb +0 -11
- data/spec/models/sidebar_spec.rb +0 -7
- data/spec/models/static_sidebar_spec.rb +0 -17
- data/spec/models/tag_spec.rb +0 -65
- data/spec/models/text_filter_spec.rb +0 -34
- data/spec/models/theme_spec.rb +0 -45
- data/spec/models/trackback_spec.rb +0 -60
- data/spec/models/trigger_spec.rb +0 -40
- data/spec/models/user_spec.rb +0 -198
- data/spec/rcov.opts +0 -2
- data/spec/spec.opts +0 -4
- data/spec/spec_helper.rb +0 -133
- data/spec/views/articles/index_spec.rb +0 -63
- data/spec/views/articles/read_spec.rb +0 -67
- data/spec/views/comments/html_sanitization_spec.rb +0 -119
- data/test/fixtures/blogs.yml +0 -27
- data/test/fixtures/categories.yml +0 -29
- data/test/fixtures/categorizations.yml +0 -31
- data/test/fixtures/contents.yml +0 -231
- data/test/fixtures/feedback.yml +0 -180
- data/test/fixtures/notification_mailer/article +0 -3
- data/test/fixtures/notification_mailer/comment +0 -3
- data/test/fixtures/notification_mailer/trackback +0 -3
- data/test/fixtures/notifications.yml +0 -0
- data/test/fixtures/page_caches.yml +0 -7
- data/test/fixtures/profiles.yml +0 -27
- data/test/fixtures/redirects.yml +0 -10
- data/test/fixtures/resources.yml +0 -21
- data/test/fixtures/sidebars.yml +0 -10
- data/test/fixtures/tags.yml +0 -10
- data/test/fixtures/text_filters.yml +0 -37
- data/test/fixtures/triggers.yml +0 -1
- data/test/fixtures/users.yml +0 -101
- data/test/mocks/test/dns_mock.rb +0 -13
- data/test/mocks/test/flickr_mock.rb +0 -30
- data/test/mocks/test/http_mock.rb +0 -39
- data/test/mocks/test/theme_mock.rb +0 -5
- data/test/mocks/test/xmlrpc_mock.rb +0 -28
- data/test/mocks/themes/123-numbers-in-path/about.markdown +0 -0
- data/test/mocks/themes/CamelCaseDirectory/about.markdown +0 -0
- data/test/mocks/themes/i-have-special-chars/about.markdown +0 -0
- data/test/mocks/themes/typographic/about.markdown +0 -7
- data/test/mocks/themes/typographic/images/Thumbs.db +0 -0
- data/test/mocks/themes/typographic/images/accept.png +0 -0
- data/test/mocks/themes/typographic/images/accept50.png +0 -0
- data/test/mocks/themes/typographic/images/bg_body.jpg +0 -0
- data/test/mocks/themes/typographic/images/bg_white.png +0 -0
- data/test/mocks/themes/typographic/images/bg_wrapper.jpg +0 -0
- data/test/mocks/themes/typographic/images/bullet_bottom.png +0 -0
- data/test/mocks/themes/typographic/images/bullet_right.png +0 -0
- data/test/mocks/themes/typographic/images/email_open.png +0 -0
- data/test/mocks/themes/typographic/images/email_open50.png +0 -0
- data/test/mocks/themes/typographic/images/meta.png +0 -0
- data/test/mocks/themes/typographic/images/page_edit.png +0 -0
- data/test/mocks/themes/typographic/images/page_edit50.png +0 -0
- data/test/mocks/themes/typographic/images/tag.png +0 -0
- data/test/mocks/themes/typographic/images/user.png +0 -0
- data/test/mocks/themes/typographic/images/user50.png +0 -0
- data/test/mocks/themes/typographic/images/world_link.png +0 -0
- data/test/mocks/themes/typographic/images/world_link50.png +0 -0
- data/test/mocks/themes/typographic/layouts/default.html.erb +0 -42
- data/test/mocks/themes/typographic/preview.png +0 -0
- data/test/mocks/themes/typographic/stylesheets/colors.css +0 -51
- data/test/mocks/themes/typographic/stylesheets/layout.css +0 -346
- data/test/mocks/themes/typographic/stylesheets/reset.css +0 -5
- data/test/mocks/themes/typographic/stylesheets/style.css +0 -36
- data/test/mocks/themes/typographic/views/articles/_article.html.erb +0 -41
- data/test/mocks/themes/typographic/views/articles/_comment.html.erb +0 -14
- data/test/mocks/themes/typographic/views/articles/_comment_form.html.erb +0 -48
- data/test/mocks/themes/typographic/views/articles/_comment_list.html.erb +0 -7
- data/test/mocks/themes/typographic/views/articles/_trackback.html.erb +0 -9
- data/test/mocks/themes/typographic/views/articles/comment_preview.html.erb +0 -10
- data/test/mocks/themes/typographic/views/articles/index.html.erb +0 -5
- data/test/mocks/themes/typographic/views/articles/read.html.erb +0 -42
- data/test/mocks/themes/typographic/views/shared/_search.html.erb +0 -17
- data/test/mocks/themes/typographic/views/theme/static_view_test.html.erb +0 -1
- data/test/test_helper.rb +0 -13
- data/themes/true-blue-3/images/frederic-de-villamil.jpg +0 -0
- data/themes/true-blue-3/images/textarea_bg.jpg +0 -0
data/spec/models/article_spec.rb
DELETED
@@ -1,515 +0,0 @@
|
|
1
|
-
require File.dirname(__FILE__) + '/../spec_helper'
|
2
|
-
|
3
|
-
describe Article do
|
4
|
-
|
5
|
-
before do
|
6
|
-
@articles = []
|
7
|
-
end
|
8
|
-
|
9
|
-
describe 'Factory Girl' do
|
10
|
-
it 'should article factory valid' do
|
11
|
-
Factory(:article).should be_valid
|
12
|
-
Factory.build(:article).should be_valid
|
13
|
-
end
|
14
|
-
it 'should second_article factory valid' do
|
15
|
-
Factory(:second_article).should be_valid
|
16
|
-
Factory.build(:second_article).should be_valid
|
17
|
-
end
|
18
|
-
it 'should article_with_accent_in_html' do
|
19
|
-
Factory(:article_with_accent_in_html).should be_valid
|
20
|
-
Factory.build(:article_with_accent_in_html).should be_valid
|
21
|
-
end
|
22
|
-
it 'should store user too' do
|
23
|
-
a = Factory(:article)
|
24
|
-
a.user.should be_valid
|
25
|
-
Article.find(a.id).user.should_not be_nil
|
26
|
-
end
|
27
|
-
it 'should create multiple valid articles' do
|
28
|
-
Factory(:article).should be_valid
|
29
|
-
Factory(:article).should be_valid
|
30
|
-
end
|
31
|
-
end
|
32
|
-
|
33
|
-
def assert_results_are(*expected)
|
34
|
-
assert_equal expected.size, @articles.size
|
35
|
-
expected.each do |i|
|
36
|
-
assert @articles.include?(i.is_a?(Symbol) ? contents(i) : i)
|
37
|
-
end
|
38
|
-
end
|
39
|
-
|
40
|
-
it "test_content_fields" do
|
41
|
-
a = Article.new
|
42
|
-
assert_equal [:body, :extended], a.content_fields
|
43
|
-
end
|
44
|
-
|
45
|
-
it "test_permalink_url with hostname" do
|
46
|
-
assert_equal 'http://myblog.net/2004/06/01/article-3', contents(:article3).permalink_url(anchor=nil, only_path=false)
|
47
|
-
end
|
48
|
-
|
49
|
-
it "test_permalink_url only path" do
|
50
|
-
assert_equal '/2004/06/01/article-3', contents(:article3).permalink_url(anchor=nil, only_path=true)
|
51
|
-
end
|
52
|
-
|
53
|
-
it "test_edit_url" do
|
54
|
-
a = contents(:article3)
|
55
|
-
assert_equal "http://myblog.net/admin/content/edit/#{a.id}", a.edit_url
|
56
|
-
end
|
57
|
-
|
58
|
-
it "test_delete_url" do
|
59
|
-
a = contents(:article3)
|
60
|
-
assert_equal "http://myblog.net/admin/content/destroy/#{a.id}", a.delete_url
|
61
|
-
end
|
62
|
-
|
63
|
-
it "test_feed_url" do
|
64
|
-
a = contents(:article3)
|
65
|
-
assert_equal "http://myblog.net/2004/06/01/article-3.atom", a.feed_url(:atom10)
|
66
|
-
assert_equal "http://myblog.net/2004/06/01/article-3.rss", a.feed_url(:rss20)
|
67
|
-
end
|
68
|
-
|
69
|
-
it "test_create" do
|
70
|
-
a = Article.new
|
71
|
-
a.user_id = 1
|
72
|
-
a.body = "Foo"
|
73
|
-
a.title = "Zzz"
|
74
|
-
assert a.save
|
75
|
-
|
76
|
-
a.categories << Category.find(categories(:software).id)
|
77
|
-
assert_equal 1, a.categories.size
|
78
|
-
|
79
|
-
b = Article.find(a.id)
|
80
|
-
assert_equal 1, b.categories.size
|
81
|
-
end
|
82
|
-
|
83
|
-
it "test_permalink_with_title" do
|
84
|
-
assert_equal( contents(:article3),
|
85
|
-
Article.find_by_permalink({:year => 2004, :month => 06, :day => 01, :title => "article-3"}) )
|
86
|
-
assert_raises(ActiveRecord::RecordNotFound) do
|
87
|
-
Article.find_by_permalink :year => 2005, :month => "06", :day => "01", :title => "article-5"
|
88
|
-
end
|
89
|
-
end
|
90
|
-
|
91
|
-
it "test_strip_title" do
|
92
|
-
assert_equal "article-3", "Article-3".to_url
|
93
|
-
assert_equal "article-3", "Article 3!?#".to_url
|
94
|
-
assert_equal "there-is-sex-in-my-violence", "There is Sex in my Violence!".to_url
|
95
|
-
assert_equal "article", "-article-".to_url
|
96
|
-
assert_equal "lorem-ipsum-dolor-sit-amet-consectetaur-adipisicing-elit", "Lorem ipsum dolor sit amet, consectetaur adipisicing elit".to_url
|
97
|
-
assert_equal "my-cats-best-friend", "My Cat's Best Friend".to_url
|
98
|
-
end
|
99
|
-
|
100
|
-
it "test_perma_title" do
|
101
|
-
assert_equal "article-1", contents(:article1).stripped_title
|
102
|
-
assert_equal "article-2", contents(:article2).stripped_title
|
103
|
-
assert_equal "article-3", contents(:article3).stripped_title
|
104
|
-
end
|
105
|
-
|
106
|
-
it "test_html_title" do
|
107
|
-
a = Article.new
|
108
|
-
a.title = "This <i>is</i> a <b>test</b>"
|
109
|
-
assert a.save
|
110
|
-
|
111
|
-
assert_equal 'this-is-a-test', a.permalink
|
112
|
-
end
|
113
|
-
|
114
|
-
it "test_multibyte_title" do
|
115
|
-
a = Article.new
|
116
|
-
a.title = "ルビー"
|
117
|
-
assert a.save
|
118
|
-
|
119
|
-
assert_equal '%E3%83%AB%E3%83%93%E3%83%BC', a.permalink
|
120
|
-
end
|
121
|
-
|
122
|
-
describe "the html_urls method" do
|
123
|
-
it "test_urls" do
|
124
|
-
urls = contents(:article4).html_urls
|
125
|
-
assert_equal ["http://www.example.com/public"], urls
|
126
|
-
end
|
127
|
-
|
128
|
-
it "should only match the href attribute" do
|
129
|
-
a = Factory.create :article
|
130
|
-
a.body = '<a href="http://a/b">a</a> <a fhref="wrong">wrong</a>'
|
131
|
-
urls = a.html_urls
|
132
|
-
assert_equal ["http://a/b"], urls
|
133
|
-
end
|
134
|
-
|
135
|
-
it "should match across newlines" do
|
136
|
-
a = Factory.create :article
|
137
|
-
a.body = "<a\nhref=\"http://foo/bar\">foo</a>"
|
138
|
-
urls = a.html_urls
|
139
|
-
assert_equal ["http://foo/bar"], urls
|
140
|
-
end
|
141
|
-
|
142
|
-
it "should match with single quotes" do
|
143
|
-
a = Factory.create :article
|
144
|
-
a.body = "<a href='http://foo/bar'>foo</a>"
|
145
|
-
urls = a.html_urls
|
146
|
-
assert_equal ["http://foo/bar"], urls
|
147
|
-
end
|
148
|
-
|
149
|
-
it "should match with no quotes" do
|
150
|
-
a = Factory.create :article
|
151
|
-
a.body = "<a href=http://foo/bar>foo</a>"
|
152
|
-
urls = a.html_urls
|
153
|
-
assert_equal ["http://foo/bar"], urls
|
154
|
-
end
|
155
|
-
end
|
156
|
-
|
157
|
-
### XXX: Should we have a test here?
|
158
|
-
it "test_send_pings" do
|
159
|
-
end
|
160
|
-
|
161
|
-
### XXX: Should we have a test here?
|
162
|
-
it "test_send_multiple_pings" do
|
163
|
-
end
|
164
|
-
|
165
|
-
it "test_tags" do
|
166
|
-
a = Article.new(:title => 'Test tag article',
|
167
|
-
:keywords => 'test tag tag stuff');
|
168
|
-
|
169
|
-
assert_kind_of Article, a
|
170
|
-
assert_equal 0, a.tags.size
|
171
|
-
|
172
|
-
a.keywords_to_tags
|
173
|
-
|
174
|
-
assert_equal 3, a.tags.size
|
175
|
-
assert_equal ["test", "tag", "stuff"].sort , a.tags.collect {|t| t.name}.sort
|
176
|
-
assert a.save
|
177
|
-
|
178
|
-
a.keywords = 'tag bar stuff foo'
|
179
|
-
a.keywords_to_tags
|
180
|
-
|
181
|
-
assert_equal 4, a.tags.size
|
182
|
-
assert_equal ["foo", "bar", "tag", "stuff"].sort , a.tags.collect {|t| t.name}.sort
|
183
|
-
|
184
|
-
a.keywords='tag bar'
|
185
|
-
a.keywords_to_tags
|
186
|
-
|
187
|
-
assert_equal 2, a.tags.size
|
188
|
-
|
189
|
-
a.keywords=''
|
190
|
-
a.keywords_to_tags
|
191
|
-
|
192
|
-
assert_equal 0, a.tags.size
|
193
|
-
|
194
|
-
b = Article.new(:title => 'Tag Test 2',
|
195
|
-
:keywords => 'tag test article one two three')
|
196
|
-
|
197
|
-
assert_kind_of Article,b
|
198
|
-
assert_equal 0, b.tags.size
|
199
|
-
|
200
|
-
c = Article.new(:title => 'Foo', :keywords => 'test "tag test" web2.0')
|
201
|
-
c.keywords_to_tags
|
202
|
-
|
203
|
-
assert_equal 3, c.tags.size
|
204
|
-
assert_equal ['test', 'tagtest', 'web2-0'].sort, c.tags.collect(&:name).sort
|
205
|
-
end
|
206
|
-
|
207
|
-
it "test_find_published_by_tag_name" do
|
208
|
-
@articles = Tag.find_by_name(tags(:foo).name).published_articles
|
209
|
-
|
210
|
-
assert_results_are(:article1, :article2, :publisher_article)
|
211
|
-
end
|
212
|
-
|
213
|
-
|
214
|
-
it "test_find_published" do
|
215
|
-
@articles = Article.find_published
|
216
|
-
assert_results_are(:search_target, :article1, :article2,
|
217
|
-
:article3, :inactive_article,:xmltest,
|
218
|
-
:spammed_article, :publisher_article, :markdown_article, :utf8_article)
|
219
|
-
|
220
|
-
@articles = Article.find_published(:all,
|
221
|
-
:conditions => "title = 'Article 1!'")
|
222
|
-
assert_results_are :article1
|
223
|
-
end
|
224
|
-
|
225
|
-
it "test_just_published_flag" do
|
226
|
-
art = Article.new(:title => 'title',
|
227
|
-
:body => 'body',
|
228
|
-
:published => true)
|
229
|
-
assert art.just_changed_published_status?
|
230
|
-
assert art.save
|
231
|
-
|
232
|
-
art = Article.find(art.id)
|
233
|
-
assert !art.just_changed_published_status?
|
234
|
-
|
235
|
-
art = Article.create!(:title => 'title2',
|
236
|
-
:body => 'body',
|
237
|
-
:published => false)
|
238
|
-
|
239
|
-
assert ! art.just_changed_published_status?
|
240
|
-
end
|
241
|
-
|
242
|
-
it "test_future_publishing" do
|
243
|
-
assert_sets_trigger(Article.create!(:title => 'title', :body => 'body',
|
244
|
-
:published => true,
|
245
|
-
:published_at => Time.now + 4.seconds))
|
246
|
-
end
|
247
|
-
|
248
|
-
it "test_future_publishing_without_published_flag" do
|
249
|
-
assert_sets_trigger Article.create!(:title => 'title', :body => 'body',
|
250
|
-
:published_at => Time.now + 4.seconds)
|
251
|
-
end
|
252
|
-
|
253
|
-
it "test_triggers_are_dependent" do
|
254
|
-
art = Article.create!(:title => 'title', :body => 'body',
|
255
|
-
:published_at => Time.now + 1.hour)
|
256
|
-
assert_equal 1, Trigger.count
|
257
|
-
art.destroy
|
258
|
-
assert_equal 0, Trigger.count
|
259
|
-
end
|
260
|
-
|
261
|
-
def assert_sets_trigger(art)
|
262
|
-
assert_equal 1, Trigger.count
|
263
|
-
assert Trigger.find(:first, :conditions => ['pending_item_id = ?', art.id])
|
264
|
-
assert !art.published
|
265
|
-
t = Time.now
|
266
|
-
# We stub the Time.now answer to emulate a sleep of 4. Avoid the sleep. So
|
267
|
-
# speed up in test
|
268
|
-
Time.stub!(:now).and_return(t + 5.seconds)
|
269
|
-
Trigger.fire
|
270
|
-
art.reload
|
271
|
-
assert art.published
|
272
|
-
end
|
273
|
-
|
274
|
-
it "test_find_published_by_category" do
|
275
|
-
Article.create!(:title => "News from the future!",
|
276
|
-
:body => "The future is cool!",
|
277
|
-
:keywords => "future",
|
278
|
-
:published_at => Time.now + 12.minutes)
|
279
|
-
|
280
|
-
@articles = Category.find_by_permalink('personal').published_articles
|
281
|
-
assert_results_are :article1, :article2, :article3
|
282
|
-
|
283
|
-
@articles = Category.find_by_permalink('software').published_articles
|
284
|
-
assert_results_are :article1
|
285
|
-
end
|
286
|
-
|
287
|
-
it "test_find_published_by_nonexistent_category_raises_exception" do
|
288
|
-
assert_raises ActiveRecord::RecordNotFound do
|
289
|
-
Category.find_by_permalink('does-not-exist').published_articles
|
290
|
-
end
|
291
|
-
end
|
292
|
-
|
293
|
-
it "test_destroy_file_upload_associations" do
|
294
|
-
a = contents(:article1)
|
295
|
-
assert_equal 2, a.resources.size
|
296
|
-
a.resources << resources(:resource3)
|
297
|
-
assert_equal 3, a.resources.size
|
298
|
-
a.destroy
|
299
|
-
assert_equal 0, Resource.find(:all, :conditions => "article_id = #{a.id}").size
|
300
|
-
end
|
301
|
-
|
302
|
-
it 'should notify' do
|
303
|
-
[:randomuser, :bob].each do |tag|
|
304
|
-
u = users(tag); u.notify_on_new_articles = true; u.save!
|
305
|
-
end
|
306
|
-
a = Article.new(:title => 'New Article', :body => 'Foo', :author => 'Tobi', :user => users(:tobi))
|
307
|
-
assert a.save
|
308
|
-
|
309
|
-
assert_equal 2, a.notify_users.size
|
310
|
-
assert_equal ['bob', 'randomuser'], a.notify_users.collect {|u| u.login }.sort
|
311
|
-
end
|
312
|
-
|
313
|
-
it "test_tags_on_update" do
|
314
|
-
contents(:article3).update_attribute :keywords, "my new tags"
|
315
|
-
assert_equal 3, contents(:article3).reload.tags.size
|
316
|
-
assert contents(:article3).tags.include?(Tag.find_by_name("new"))
|
317
|
-
end
|
318
|
-
|
319
|
-
it "test_withdrawal" do
|
320
|
-
art = Article.find(contents(:article1).id)
|
321
|
-
assert art.published?
|
322
|
-
assert ! art.withdrawn?
|
323
|
-
art.withdraw!
|
324
|
-
assert ! art.published?
|
325
|
-
assert art.withdrawn?
|
326
|
-
art.reload
|
327
|
-
assert ! art.published?
|
328
|
-
assert art.withdrawn?
|
329
|
-
end
|
330
|
-
|
331
|
-
it "test_default_filter" do
|
332
|
-
a = Article.find(contents(:article1).id)
|
333
|
-
assert_equal 'textile', a.default_text_filter.name
|
334
|
-
end
|
335
|
-
|
336
|
-
it 'should get only ham not spam comment' do
|
337
|
-
contents(:article2).comments.ham.should == [feedback(:spam_comment)]
|
338
|
-
contents(:article2).comments.count.should == 2
|
339
|
-
end
|
340
|
-
|
341
|
-
describe '#access_by?' do
|
342
|
-
|
343
|
-
it 'admin should be access to an article write by another' do
|
344
|
-
contents(:article2).should be_access_by(users(:tobi))
|
345
|
-
end
|
346
|
-
|
347
|
-
it 'admin should be access to an article write by himself' do
|
348
|
-
contents(:article1).should be_access_by(users(:tobi))
|
349
|
-
end
|
350
|
-
|
351
|
-
end
|
352
|
-
|
353
|
-
describe 'body_and_extended' do
|
354
|
-
before :each do
|
355
|
-
@article = contents(:article1)
|
356
|
-
end
|
357
|
-
|
358
|
-
it 'should combine body and extended content' do
|
359
|
-
@article.body_and_extended.should ==
|
360
|
-
"#{@article.body}\n<!--more-->\n#{@article.extended}"
|
361
|
-
end
|
362
|
-
|
363
|
-
it 'should not insert <!--more--> tags if extended is empty' do
|
364
|
-
@article.extended = ''
|
365
|
-
@article.body_and_extended.should == @article.body
|
366
|
-
end
|
367
|
-
end
|
368
|
-
|
369
|
-
describe '#search' do
|
370
|
-
|
371
|
-
describe 'is an array', :shared => true do
|
372
|
-
it 'should get an array' do
|
373
|
-
@articles.should be_a(Array)
|
374
|
-
end
|
375
|
-
end
|
376
|
-
|
377
|
-
describe 'with several words and no result' do
|
378
|
-
|
379
|
-
before :each do
|
380
|
-
@articles = Article.search('hello world')
|
381
|
-
end
|
382
|
-
|
383
|
-
it_should_behave_like 'is an array'
|
384
|
-
|
385
|
-
it 'should be empty' do
|
386
|
-
@articles.should be_empty
|
387
|
-
end
|
388
|
-
end
|
389
|
-
|
390
|
-
describe 'with one word and result' do
|
391
|
-
|
392
|
-
before :each do
|
393
|
-
@articles = Article.search('extended')
|
394
|
-
end
|
395
|
-
|
396
|
-
it_should_behave_like 'is an array'
|
397
|
-
|
398
|
-
it 'should have one item' do
|
399
|
-
assert_equal 9, @articles.size
|
400
|
-
end
|
401
|
-
end
|
402
|
-
end
|
403
|
-
|
404
|
-
describe 'body_and_extended=' do
|
405
|
-
before :each do
|
406
|
-
@article = contents(:article1)
|
407
|
-
end
|
408
|
-
|
409
|
-
it 'should split apart values at <!--more-->' do
|
410
|
-
@article.body_and_extended = 'foo<!--more-->bar'
|
411
|
-
@article.body.should == 'foo'
|
412
|
-
@article.extended.should == 'bar'
|
413
|
-
end
|
414
|
-
|
415
|
-
it 'should remove newlines around <!--more-->' do
|
416
|
-
@article.body_and_extended = "foo\n<!--more-->\nbar"
|
417
|
-
@article.body.should == 'foo'
|
418
|
-
@article.extended.should == 'bar'
|
419
|
-
end
|
420
|
-
|
421
|
-
it 'should make extended empty if no <!--more--> tag' do
|
422
|
-
@article.body_and_extended = "foo"
|
423
|
-
@article.body.should == 'foo'
|
424
|
-
@article.extended.should be_empty
|
425
|
-
end
|
426
|
-
|
427
|
-
it 'should preserve extra <!--more--> tags' do
|
428
|
-
@article.body_and_extended = "foo<!--more-->bar<!--more-->baz"
|
429
|
-
@article.body.should == 'foo'
|
430
|
-
@article.extended.should == 'bar<!--more-->baz'
|
431
|
-
end
|
432
|
-
|
433
|
-
it 'should be settable via self.attributes=' do
|
434
|
-
@article.attributes = { :body_and_extended => 'foo<!--more-->bar' }
|
435
|
-
@article.body.should == 'foo'
|
436
|
-
@article.extended.should == 'bar'
|
437
|
-
end
|
438
|
-
end
|
439
|
-
|
440
|
-
describe '#comment_url' do
|
441
|
-
it 'should render complete url of comment' do
|
442
|
-
contents(:article1).comment_url.should == "http://myblog.net/comments?article_id=#{contents(:article1).id}"
|
443
|
-
end
|
444
|
-
end
|
445
|
-
|
446
|
-
describe '#preview_comment_url' do
|
447
|
-
it 'should render complete url of comment' do
|
448
|
-
contents(:article1).preview_comment_url.should == "http://myblog.net/comments/preview?article_id=#{contents(:article1).id}"
|
449
|
-
end
|
450
|
-
end
|
451
|
-
|
452
|
-
it "test_can_ping_fresh_article_iff_it_allows_pings" do
|
453
|
-
a = Article.find(contents(:article1).id)
|
454
|
-
assert_equal(false, a.pings_closed?)
|
455
|
-
a.allow_pings = false
|
456
|
-
assert_equal(true, a.pings_closed?)
|
457
|
-
end
|
458
|
-
|
459
|
-
it "test_cannot_ping_old_article" do
|
460
|
-
a = Article.find(contents(:article3).id)
|
461
|
-
assert_equal(true, a.pings_closed?)
|
462
|
-
a.allow_pings = false
|
463
|
-
assert_equal(true, a.pings_closed?)
|
464
|
-
end
|
465
|
-
|
466
|
-
describe '#published_at_like' do
|
467
|
-
before do
|
468
|
-
# Note: these choices of times depend on no other articles within
|
469
|
-
# these timeframes existing in test/fixtures/contents.yaml.
|
470
|
-
# In particular, all articles there are from 2005 or earlier, which
|
471
|
-
# is now more than two years ago, except for two, which are from
|
472
|
-
# yesterday and the day before. The existence of those two makes
|
473
|
-
# 1.month.ago not suitable, because yesterday can be last month.
|
474
|
-
@article_two_month_ago = Factory(:article, :published_at => 2.month.ago)
|
475
|
-
|
476
|
-
@article_four_months_ago = Factory(:article, :published_at => 4.month.ago)
|
477
|
-
@article_2_four_months_ago = Factory(:article, :published_at => 4.month.ago)
|
478
|
-
|
479
|
-
@article_two_year_ago = Factory(:article, :published_at => 2.year.ago)
|
480
|
-
@article_2_two_year_ago = Factory(:article, :published_at => 2.year.ago)
|
481
|
-
end
|
482
|
-
|
483
|
-
it 'should return all content for the year if only year sent' do
|
484
|
-
Article.published_at_like(2.year.ago.strftime('%Y')).map(&:id).sort.should == [@article_two_year_ago.id, @article_2_two_year_ago.id].sort
|
485
|
-
end
|
486
|
-
|
487
|
-
it 'should return all content for the month if year and month sent' do
|
488
|
-
Article.published_at_like(4.month.ago.strftime('%Y-%m')).map(&:id).sort.should == [@article_four_months_ago.id, @article_2_four_months_ago.id].sort
|
489
|
-
end
|
490
|
-
|
491
|
-
it 'should return all content on this date if date send' do
|
492
|
-
Article.published_at_like(2.month.ago.strftime('%Y-%m-%d')).map(&:id).sort.should == [@article_two_month_ago.id].sort
|
493
|
-
end
|
494
|
-
end
|
495
|
-
|
496
|
-
describe '#has_child?' do
|
497
|
-
it 'should be true if article has one to link it by parent_id' do
|
498
|
-
Factory(:article, :parent_id => contents(:article1).id)
|
499
|
-
contents(:article1).should be_has_child
|
500
|
-
end
|
501
|
-
it 'should be false if article has no article to link it by parent_id' do
|
502
|
-
contents(:article1).should_not be_has_child
|
503
|
-
end
|
504
|
-
end
|
505
|
-
|
506
|
-
describe 'self#last_draft(id)' do
|
507
|
-
it 'should return article if no draft associated' do
|
508
|
-
Article.last_draft(contents(:article1).id).should == contents(:article1)
|
509
|
-
end
|
510
|
-
it 'should return draft associated to this article if there are one' do
|
511
|
-
draft = Factory(:article, :parent_id => contents(:article1).id, :state => 'draft')
|
512
|
-
Article.last_draft(contents(:article1).id).should == draft
|
513
|
-
end
|
514
|
-
end
|
515
|
-
end
|