typo 5.4.1 → 5.4.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (74) hide show
  1. data/CHANGELOG +10 -24
  2. data/app/controllers/accounts_controller.rb +18 -1
  3. data/app/controllers/admin/content_controller.rb +1 -0
  4. data/app/controllers/admin/resources_controller.rb +17 -3
  5. data/app/controllers/application_controller.rb +2 -5
  6. data/app/helpers/admin/base_helper.rb +16 -6
  7. data/app/helpers/admin/resources_helper.rb +6 -0
  8. data/app/helpers/application_helper.rb +7 -8
  9. data/app/models/article.rb +8 -10
  10. data/app/models/blog.rb +26 -24
  11. data/app/models/content.rb +17 -10
  12. data/app/models/feedback.rb +1 -1
  13. data/app/models/page.rb +1 -1
  14. data/app/models/resource.rb +14 -0
  15. data/app/models/user.rb +1 -0
  16. data/app/views/accounts/login.html.erb +2 -1
  17. data/app/views/accounts/recover_password.html.erb +18 -0
  18. data/app/views/admin/content/_form.html.erb +8 -5
  19. data/app/views/admin/content/_images.html.erb +14 -0
  20. data/app/views/admin/content/_visual_editor.html.erb +5 -0
  21. data/app/views/admin/pages/_visual_editor.html.erb +9 -5
  22. data/app/views/admin/resources/_upload.html.erb +10 -0
  23. data/app/views/admin/resources/get_thumbnails.html.erb +5 -0
  24. data/app/views/admin/resources/images.html.erb +28 -0
  25. data/app/views/admin/resources/index.html.erb +42 -11
  26. data/app/views/layouts/administration.html.erb +1 -1
  27. data/app/views/notification_mailer/notif_user.html.erb +1 -1
  28. data/config/environment.rb +1 -1
  29. data/config/initializers/access_rules.rb +2 -1
  30. data/config/initializers/inflector.rb +4 -1
  31. data/db/schema.rb +26 -32
  32. data/lib/tasks/release.rake +1 -1
  33. data/lib/typo_version.rb +1 -1
  34. data/public/images/thumb_blank.jpg +0 -0
  35. data/public/javascripts/base_packaged.js +377 -0
  36. data/public/javascripts/ckeditor/config.bak +27 -11
  37. data/public/javascripts/quicktags.js +11 -0
  38. data/public/javascripts/typo_carousel.js +340 -0
  39. data/public/stylesheets/administration.css +16 -0
  40. data/public/stylesheets/base_packaged.css +100 -0
  41. data/script/about +3 -2
  42. data/script/console +1 -1
  43. data/script/dbconsole +1 -1
  44. data/script/destroy +1 -1
  45. data/script/generate +1 -1
  46. data/script/performance/benchmarker +1 -1
  47. data/script/performance/profiler +1 -1
  48. data/script/plugin +2 -2
  49. data/script/runner +2 -2
  50. data/script/server +2 -2
  51. data/spec/controllers/accounts_controller_spec.rb +47 -0
  52. data/spec/controllers/admin/content_controller_spec.rb +4 -0
  53. data/spec/controllers/admin/resources_controller_spec.rb +8 -0
  54. data/spec/controllers/xml_controller_spec.rb +13 -16
  55. data/spec/factories.rb +14 -1
  56. data/spec/models/article_spec.rb +57 -14
  57. data/spec/models/blog_spec.rb +50 -3
  58. data/spec/models/trackback_spec.rb +1 -1
  59. data/spec/models/user_spec.rb +7 -12
  60. data/spec/spec_helper.rb +1 -1
  61. data/test/fixtures/users.yml +15 -8
  62. data/themes/true-blue-3/images/background.gif +0 -0
  63. data/vendor/plugins/easy-ckeditor/lib/ckeditor.rb +1 -2
  64. data/vendor/plugins/easy-ckeditor/lib/ckeditor_file_utils.rb +2 -2
  65. metadata +11 -11
  66. data/app/views/admin/resources/_resources.html.erb +0 -41
  67. data/script/benchmarker +0 -19
  68. data/script/performance/request +0 -3
  69. data/script/process/inspector +0 -3
  70. data/script/process/reaper +0 -3
  71. data/script/process/spawner +0 -3
  72. data/script/process/spinner +0 -3
  73. data/script/profiler +0 -34
  74. data/script/spec_server +0 -9
data/script/about CHANGED
@@ -1,3 +1,4 @@
1
1
  #!/usr/bin/env ruby
2
- require File.dirname(__FILE__) + '/../config/boot'
3
- require 'commands/about'
2
+ require File.expand_path('../../config/boot', __FILE__)
3
+ $LOAD_PATH.unshift "#{RAILTIES_PATH}/builtin/rails_info"
4
+ require 'commands/about'
data/script/console CHANGED
@@ -1,3 +1,3 @@
1
1
  #!/usr/bin/env ruby
2
- require File.dirname(__FILE__) + '/../config/boot'
2
+ require File.expand_path('../../config/boot', __FILE__)
3
3
  require 'commands/console'
data/script/dbconsole CHANGED
@@ -1,3 +1,3 @@
1
1
  #!/usr/bin/env ruby
2
- require File.dirname(__FILE__) + '/../config/boot'
2
+ require File.expand_path('../../config/boot', __FILE__)
3
3
  require 'commands/dbconsole'
data/script/destroy CHANGED
@@ -1,3 +1,3 @@
1
1
  #!/usr/bin/env ruby
2
- require File.dirname(__FILE__) + '/../config/boot'
2
+ require File.expand_path('../../config/boot', __FILE__)
3
3
  require 'commands/destroy'
data/script/generate CHANGED
@@ -1,3 +1,3 @@
1
1
  #!/usr/bin/env ruby
2
- require File.dirname(__FILE__) + '/../config/boot'
2
+ require File.expand_path('../../config/boot', __FILE__)
3
3
  require 'commands/generate'
@@ -1,3 +1,3 @@
1
1
  #!/usr/bin/env ruby
2
- require File.dirname(__FILE__) + '/../../config/boot'
2
+ require File.expand_path('../../../config/boot', __FILE__)
3
3
  require 'commands/performance/benchmarker'
@@ -1,3 +1,3 @@
1
1
  #!/usr/bin/env ruby
2
- require File.dirname(__FILE__) + '/../../config/boot'
2
+ require File.expand_path('../../../config/boot', __FILE__)
3
3
  require 'commands/performance/profiler'
data/script/plugin CHANGED
@@ -1,3 +1,3 @@
1
1
  #!/usr/bin/env ruby
2
- require File.dirname(__FILE__) + '/../config/boot'
3
- require 'commands/plugin'
2
+ require File.expand_path('../../config/boot', __FILE__)
3
+ require 'commands/plugin'
data/script/runner CHANGED
@@ -1,3 +1,3 @@
1
1
  #!/usr/bin/env ruby
2
- require File.dirname(__FILE__) + '/../config/boot'
3
- require 'commands/runner'
2
+ require File.expand_path('../../config/boot', __FILE__)
3
+ require 'commands/runner'
data/script/server CHANGED
@@ -1,3 +1,3 @@
1
1
  #!/usr/bin/env ruby
2
- require File.dirname(__FILE__) + '/../config/boot'
3
- require 'commands/server'
2
+ require File.expand_path('../../config/boot', __FILE__)
3
+ require 'commands/server'
@@ -150,6 +150,26 @@ describe 'GET /login' do
150
150
  end
151
151
  end
152
152
 
153
+ describe 'GET /login with 0 existing users' do
154
+ controller_name :accounts
155
+
156
+ before(:each) do
157
+ User.stub!(:count).and_return(0)
158
+ end
159
+
160
+ it 'should render action :signup' do
161
+ get 'login'
162
+ response.should redirect_to(:action => 'signup')
163
+ assigns[:login].should be_nil
164
+ end
165
+
166
+ it 'should render :signup' do
167
+ get 'recover_password'
168
+
169
+ response.should redirect_to(:action => 'signup')
170
+ end
171
+ end
172
+
153
173
  describe 'GET signup and >0 existing user' do
154
174
  controller_name :accounts
155
175
 
@@ -283,3 +303,30 @@ describe 'User is logged in' do
283
303
  cookies[:typo_user_profile].should == nil
284
304
  end
285
305
  end
306
+
307
+ describe 'User has lost his password and send a good email' do
308
+ controller_name :accounts
309
+
310
+ before(:each) do
311
+ @user = mock_model(User, :new_record? => false, :reload => @user)
312
+ @user.stub!(:profile).and_return(Profile.find_by_label('admin'))
313
+ User.stub!(:find_by_login).with('tobi').and_return(@user)
314
+ User.stub!(:count).and_return(1)
315
+ end
316
+
317
+ it 'should render recover_password' do
318
+ get 'recover_password'
319
+
320
+ response.should render_template('recover_password')
321
+ end
322
+
323
+ it 'should render login' do
324
+ make_request
325
+
326
+ response.should redirect_to(:action => 'login')
327
+ end
328
+
329
+ def make_request
330
+ post 'recover_password', {:user => {:login => 'tobi'}}
331
+ end
332
+ end
@@ -155,6 +155,10 @@ describe Admin::ContentController do
155
155
 
156
156
  it 'should create' do
157
157
  begin
158
+ u = users(:randomuser)
159
+ u.notify_via_email = true
160
+ u.notify_on_new_articles = true
161
+ u.save!
158
162
  ActionMailer::Base.perform_deliveries = true
159
163
  ActionMailer::Base.deliveries = []
160
164
  category = Factory(:category)
@@ -13,6 +13,14 @@ describe Admin::ResourcesController do
13
13
  assert_not_nil assigns(:resources)
14
14
  end
15
15
 
16
+ it "test_images" do
17
+ get :images
18
+ assert_response :success
19
+ assert_template 'images'
20
+ assert_template_has 'resources'
21
+ assert_not_nil assigns(:resources)
22
+ end
23
+
16
24
  it "test_destroy" do
17
25
  res_id = resources(:resource1).id
18
26
  assert_not_nil Resource.find(res_id)
@@ -1,5 +1,4 @@
1
1
  require File.dirname(__FILE__) + '/../spec_helper'
2
- require 'xml_controller'
3
2
  require 'dns_mock'
4
3
 
5
4
  describe XmlController do
@@ -11,10 +10,7 @@ describe XmlController do
11
10
  end
12
11
 
13
12
  before do
14
- Article.create!(:title => "News from the future!",
15
- :body => "The future is cool!",
16
- :keywords => "future",
17
- :created_at => Time.now + 12.minutes)
13
+ @article = Factory.create(:article)
18
14
  end
19
15
 
20
16
  def assert_moved_permanently_to(location)
@@ -42,8 +38,8 @@ describe XmlController do
42
38
  end
43
39
 
44
40
  it "redirects article feed to Article RSS feed" do
45
- get :feed, :type => 'article', :id => contents(:article1).id
46
- assert_moved_permanently_to contents(:article1).permalink_by_format(:rss)
41
+ get :feed, :type => 'article', :id => @article.id
42
+ assert_moved_permanently_to @article.permalink_by_format(:rss)
47
43
  end
48
44
 
49
45
  it "redirects category feed to Category RSS feed" do
@@ -76,8 +72,8 @@ describe XmlController do
76
72
  end
77
73
 
78
74
  it "test_feed_rss20_article" do
79
- get :feed, :format => 'rss20', :type => 'article', :id => contents(:article1).id
80
- assert_moved_permanently_to contents(:article1).permalink_by_format(:rss)
75
+ get :feed, :format => 'rss20', :type => 'article', :id => @article.id
76
+ assert_moved_permanently_to @article.permalink_by_format(:rss)
81
77
  end
82
78
 
83
79
  it "test_feed_rss20_category" do
@@ -118,8 +114,8 @@ describe XmlController do
118
114
  end
119
115
 
120
116
  it "test_feed_atom10_article" do
121
- get :feed, :format => 'atom10', :type => 'article', :id => contents(:article1).id
122
- assert_moved_permanently_to contents(:article1).permalink_by_format('atom')
117
+ get :feed, :format => 'atom10', :type => 'article', :id => @article.id
118
+ assert_moved_permanently_to @article.permalink_by_format('atom')
123
119
  end
124
120
 
125
121
  it "test_feed_atom10_category" do
@@ -133,7 +129,7 @@ describe XmlController do
133
129
  end
134
130
 
135
131
  it "test_articlerss" do
136
- get :articlerss, :id => contents(:article1).id
132
+ get :articlerss, :id => @article.id
137
133
  assert_response :redirect
138
134
  end
139
135
 
@@ -147,6 +143,11 @@ describe XmlController do
147
143
  assert_response :redirect
148
144
  end
149
145
 
146
+ it "test_bad_format" do
147
+ get :feed, :format => 'atom04', :type => 'feed'
148
+ assert_response :missing
149
+ end
150
+
150
151
  it "test_bad_type" do
151
152
  get :feed, :format => 'rss20', :type => 'foobar'
152
153
  assert_response :missing
@@ -188,8 +189,4 @@ describe XmlController do
188
189
  def assert_atom10
189
190
  assert_select 'feed:root[xmlns="http://www.w3.org/2005/Atom"] > entry', :count => assigns(:items).size
190
191
  end
191
-
192
- def set_extended_on_rss(value)
193
- this_blog.show_extended_on_rss = value
194
- end
195
192
  end
data/spec/factories.rb CHANGED
@@ -4,18 +4,29 @@ Factory.sequence :user do |n|
4
4
  "user#{n}"
5
5
  end
6
6
 
7
+ Factory.sequence :guid do |n|
8
+ "deadbeef#{n}"
9
+ end
10
+
7
11
  Factory.define :user do |u|
8
12
  u.login { Factory.next(:user) }
9
13
  u.email 'some.where@out.there'
14
+ u.notify_via_email false
15
+ u.notify_on_new_articles false
16
+ u.notify_watch_my_articles false
17
+ u.notify_on_comments false
10
18
  u.password 'top-secret'
11
19
  end
12
20
 
13
21
  Factory.define :article do |a|
14
22
  a.title 'A big article'
15
23
  a.body 'A content with several data'
24
+ a.guid { Factory.next(:guid) }
16
25
  a.permalink 'a-big-article'
17
26
  a.published_at Time.now
18
- a.association :user, :factory => :user
27
+ # Using an existing user avoids the password reminder mail overhead
28
+ a.user { User.find(:first) }
29
+ #a.association :user, :factory => :user
19
30
  end
20
31
 
21
32
  Factory.define :second_article, :parent => :article do |a|
@@ -31,6 +42,8 @@ Factory.define :article_with_accent_in_html, :parent => :article do |a|
31
42
  end
32
43
 
33
44
  Factory.define :blog do |b|
45
+ b.base_url 'http://myblog.net'
46
+ b.blog_name 'test blog'
34
47
  end
35
48
 
36
49
  Factory.define :profile_admin, :class => :profile do |l|
@@ -2,7 +2,6 @@ require File.dirname(__FILE__) + '/../spec_helper'
2
2
 
3
3
  describe Article do
4
4
 
5
-
6
5
  before do
7
6
  @articles = []
8
7
  end
@@ -22,9 +21,10 @@ describe Article do
22
21
  end
23
22
  it 'should store user too' do
24
23
  a = Factory(:article)
24
+ a.user.should be_valid
25
25
  Article.find(a.id).user.should_not be_nil
26
26
  end
27
- it 'should multiple article factory valid' do
27
+ it 'should create multiple valid articles' do
28
28
  Factory(:article).should be_valid
29
29
  Factory(:article).should be_valid
30
30
  end
@@ -42,8 +42,12 @@ describe Article do
42
42
  assert_equal [:body, :extended], a.content_fields
43
43
  end
44
44
 
45
- it "test_permalink_url" do
46
- assert_equal 'http://myblog.net/2004/06/01/article-3', contents(:article3).permalink_url(anchor=nil, only_path=true)
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)
47
51
  end
48
52
 
49
53
  it "test_edit_url" do
@@ -115,9 +119,39 @@ describe Article do
115
119
  assert_equal '%E3%83%AB%E3%83%93%E3%83%BC', a.permalink
116
120
  end
117
121
 
118
- it "test_urls" do
119
- urls = contents(:article4).html_urls
120
- assert_equal ["http://www.example.com/public"], urls
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
121
155
  end
122
156
 
123
157
  ### XXX: Should we have a test here?
@@ -266,6 +300,9 @@ describe Article do
266
300
  end
267
301
 
268
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
269
306
  a = Article.new(:title => 'New Article', :body => 'Foo', :author => 'Tobi', :user => users(:tobi))
270
307
  assert a.save
271
308
 
@@ -428,21 +465,27 @@ describe Article do
428
465
 
429
466
  describe '#published_at_like' do
430
467
  before do
431
- @article_last_month = Factory(:article, :published_at => 1.month.ago)
432
- @article_2_last_month = Factory(:article, :published_at => 1.month.ago)
433
-
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.
434
474
  @article_two_month_ago = Factory(:article, :published_at => 2.month.ago)
435
- @article_2_two_month_ago = Factory(:article, :published_at => (2.month.ago - 1.day))
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
+
436
479
  @article_two_year_ago = Factory(:article, :published_at => 2.year.ago)
437
480
  @article_2_two_year_ago = Factory(:article, :published_at => 2.year.ago)
438
481
  end
439
482
 
440
- it 'should return all content on this year if year send' do
483
+ it 'should return all content for the year if only year sent' do
441
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
442
485
  end
443
486
 
444
- it 'should return all content on this month if month send' do
445
- Article.published_at_like(1.month.ago.strftime('%Y-%m')).map(&:id).sort.should == [@article_last_month.id, @article_2_last_month.id].sort
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
446
489
  end
447
490
 
448
491
  it 'should return all content on this date if date send' do
@@ -1,7 +1,11 @@
1
1
  require File.dirname(__FILE__) + '/../spec_helper'
2
2
 
3
3
  describe "Given the first Blog fixture" do
4
- before(:each) { @blog = blogs(:default) }
4
+ before(:each) {
5
+ Blog.destroy_all
6
+ RouteCache.clear
7
+ @blog = Factory.create :blog
8
+ }
5
9
 
6
10
  it ":blog_name == 'test blog'" do
7
11
  @blog.blog_name.should == 'test blog'
@@ -16,10 +20,53 @@ describe "Given the first Blog fixture" do
16
20
  end
17
21
  end
18
22
 
19
- it "blog.url_for does the right thing" do
20
- @blog.url_for(:controller => 'articles', :action => 'read', :id => 1).should == 'http://myblog.net/articles/read/1'
23
+ describe "running in the host root" do
24
+ it ":base_url == 'http://myblog.net/'" do
25
+ @blog.base_url.should == 'http://myblog.net'
26
+ end
27
+
28
+ describe "blog.url_for" do
29
+ it "should return the correct URL for a hash argument" do
30
+ @blog.url_for(:controller => 'articles', :action => 'read', :id => 1).should == 'http://myblog.net/articles/read/1'
31
+ end
32
+ it "should return the correct URL for a hash argument with only_path" do
33
+ @blog.base_url.should == 'http://myblog.net'
34
+ @blog.url_for(:controller => 'articles', :action => 'read', :id => 1,
35
+ :only_path => true).should == '/articles/read/1'
36
+ end
37
+ it "should return the correct URL for a string argument" do
38
+ @blog.url_for('articles/read/1').should == 'http://myblog.net/articles/read/1'
39
+ end
40
+ it "should return the correct URL for a hash argument with only_path" do
41
+ @blog.url_for('articles/read/1', :only_path => true).should == '/articles/read/1'
42
+ end
43
+ end
21
44
  end
22
45
 
46
+ describe "running in a sub-URI" do
47
+ before :each do
48
+ @blog.base_url = 'http://myblog.net/sub-uri'
49
+ end
50
+
51
+ describe "blog.url_for" do
52
+ it "should return the correct URL for a hash argument" do
53
+ @blog.url_for(:controller => 'articles', :action => 'read',
54
+ :id => 1).should == 'http://myblog.net/sub-uri/articles/read/1'
55
+ end
56
+ it "should return the correct URL for a hash argument with only_path" do
57
+ @blog.url_for(:controller => 'articles', :action => 'read', :id => 1,
58
+ :only_path => true).should == '/sub-uri/articles/read/1'
59
+ end
60
+ it "should return the correct URL for a string argument" do
61
+ @blog.url_for('articles/read/1'
62
+ ).should == 'http://myblog.net/sub-uri/articles/read/1'
63
+ end
64
+ it "should return the correct URL for a hash argument with only_path" do
65
+ @blog.url_for('articles/read/1',
66
+ :only_path => true).should == '/sub-uri/articles/read/1'
67
+ end
68
+ end
69
+ end
23
70
  it "should be the only blog allowed" do
24
71
  Blog.new.should_not be_valid
25
72
  end