Commit 6e1166023664cc8275c36d4ceb2733e64174f930
1 parent
904f1fb4
Exists in
master
and in
22 other branches
rails3: fix display_content plugin
Showing
2 changed files
with
12 additions
and
11 deletions
Show diff stats
plugins/display_content/lib/display_content_block.rb
@@ -26,7 +26,7 @@ class DisplayContentBlock < Block | @@ -26,7 +26,7 @@ class DisplayContentBlock < Block | ||
26 | settings_items :display_folder_children, :type => :boolean, :default => true | 26 | settings_items :display_folder_children, :type => :boolean, :default => true |
27 | settings_items :types, :type => Array, :default => ['TextileArticle', 'TinyMceArticle', 'RawHTMLArticle'] | 27 | settings_items :types, :type => Array, :default => ['TextileArticle', 'TinyMceArticle', 'RawHTMLArticle'] |
28 | 28 | ||
29 | - attr_accessible :sections, :checked_nodes, :display_folder_children | 29 | + attr_accessible :sections, :checked_nodes, :display_folder_children, :types |
30 | 30 | ||
31 | def self.description | 31 | def self.description |
32 | _('Display your contents') | 32 | _('Display your contents') |
plugins/display_content/test/unit/display_content_block_test.rb
@@ -350,10 +350,11 @@ class DisplayContentBlockTest < ActiveSupport::TestCase | @@ -350,10 +350,11 @@ class DisplayContentBlockTest < ActiveSupport::TestCase | ||
350 | should 'list links for all articles title defined in nodes' do | 350 | should 'list links for all articles title defined in nodes' do |
351 | profile = create_user('testuser').person | 351 | profile = create_user('testuser').person |
352 | Article.delete_all | 352 | Article.delete_all |
353 | - a1 = fast_create(TextArticle, :name => 'test article 1', :profile_id => profile.id) | ||
354 | - a2 = fast_create(TextArticle, :name => 'test article 2', :profile_id => profile.id) | 353 | + a1 = fast_create(TextileArticle, :name => 'test article 1', :profile_id => profile.id) |
354 | + a2 = fast_create(TextileArticle, :name => 'test article 2', :profile_id => profile.id) | ||
355 | 355 | ||
356 | block = DisplayContentBlock.new | 356 | block = DisplayContentBlock.new |
357 | + block.sections = [{:value => 'title', :checked => true}] | ||
357 | block.nodes = [a1.id, a2.id] | 358 | block.nodes = [a1.id, a2.id] |
358 | box = mock() | 359 | box = mock() |
359 | block.stubs(:box).returns(box) | 360 | block.stubs(:box).returns(box) |
@@ -366,8 +367,8 @@ class DisplayContentBlockTest < ActiveSupport::TestCase | @@ -366,8 +367,8 @@ class DisplayContentBlockTest < ActiveSupport::TestCase | ||
366 | should 'list content for all articles lead defined in nodes' do | 367 | should 'list content for all articles lead defined in nodes' do |
367 | profile = create_user('testuser').person | 368 | profile = create_user('testuser').person |
368 | Article.delete_all | 369 | Article.delete_all |
369 | - a1 = fast_create(TextArticle, :name => 'test article 1', :profile_id => profile.id, :abstract => 'abstract article 1') | ||
370 | - a2 = fast_create(TextArticle, :name => 'test article 2', :profile_id => profile.id, :abstract => 'abstract article 2') | 370 | + a1 = fast_create(TinyMceArticle, :name => 'test article 1', :profile_id => profile.id, :abstract => 'abstract article 1') |
371 | + a2 = fast_create(TinyMceArticle, :name => 'test article 2', :profile_id => profile.id, :abstract => 'abstract article 2') | ||
371 | 372 | ||
372 | block = DisplayContentBlock.new | 373 | block = DisplayContentBlock.new |
373 | block.sections = [{:value => 'abstract', :checked => true}] | 374 | block.sections = [{:value => 'abstract', :checked => true}] |
@@ -421,7 +422,7 @@ class DisplayContentBlockTest < ActiveSupport::TestCase | @@ -421,7 +422,7 @@ class DisplayContentBlockTest < ActiveSupport::TestCase | ||
421 | 422 | ||
422 | should 'show title if defined by user' do | 423 | should 'show title if defined by user' do |
423 | profile = create_user('testuser').person | 424 | profile = create_user('testuser').person |
424 | - a = fast_create(TextArticle, :name => 'test article 1', :profile_id => profile.id) | 425 | + a = fast_create(TextileArticle, :name => 'test article 1', :profile_id => profile.id) |
425 | 426 | ||
426 | block = DisplayContentBlock.new | 427 | block = DisplayContentBlock.new |
427 | block.nodes = [a.id] | 428 | block.nodes = [a.id] |
@@ -435,7 +436,7 @@ class DisplayContentBlockTest < ActiveSupport::TestCase | @@ -435,7 +436,7 @@ class DisplayContentBlockTest < ActiveSupport::TestCase | ||
435 | 436 | ||
436 | should 'show abstract if defined by user' do | 437 | should 'show abstract if defined by user' do |
437 | profile = create_user('testuser').person | 438 | profile = create_user('testuser').person |
438 | - a = fast_create(TextArticle, :name => 'test article 1', :profile_id => profile.id, :abstract => 'some abstract') | 439 | + a = fast_create(TextileArticle, :name => 'test article 1', :profile_id => profile.id, :abstract => 'some abstract') |
439 | 440 | ||
440 | block = DisplayContentBlock.new | 441 | block = DisplayContentBlock.new |
441 | block.nodes = [a.id] | 442 | block.nodes = [a.id] |
@@ -449,7 +450,7 @@ class DisplayContentBlockTest < ActiveSupport::TestCase | @@ -449,7 +450,7 @@ class DisplayContentBlockTest < ActiveSupport::TestCase | ||
449 | 450 | ||
450 | should 'show body if defined by user' do | 451 | should 'show body if defined by user' do |
451 | profile = create_user('testuser').person | 452 | profile = create_user('testuser').person |
452 | - a = fast_create(TextArticle, :name => 'test article 1', :profile_id => profile.id, :body => 'some body') | 453 | + a = fast_create(TextileArticle, :name => 'test article 1', :profile_id => profile.id, :body => 'some body') |
453 | 454 | ||
454 | block = DisplayContentBlock.new | 455 | block = DisplayContentBlock.new |
455 | block.nodes = [a.id] | 456 | block.nodes = [a.id] |
@@ -577,7 +578,7 @@ class DisplayContentBlockTest < ActiveSupport::TestCase | @@ -577,7 +578,7 @@ class DisplayContentBlockTest < ActiveSupport::TestCase | ||
577 | block.types = ['TinyMceArticle'] | 578 | block.types = ['TinyMceArticle'] |
578 | 579 | ||
579 | block.types = ['TinyMceArticle', 'Folder'] | 580 | block.types = ['TinyMceArticle', 'Folder'] |
580 | - assert_equal [TinyMceArticle, Folder, UploadedFile, Event, TextileArticle, RawHTMLArticle, Blog, Forum, Gallery, RssFeed], block.available_content_types | 581 | + assert_equivalent [TinyMceArticle, Folder, UploadedFile, Event, TextileArticle, RawHTMLArticle, Blog, Forum, Gallery, RssFeed], block.available_content_types |
581 | end | 582 | end |
582 | 583 | ||
583 | should 'return available content types' do | 584 | should 'return available content types' do |
@@ -585,7 +586,7 @@ class DisplayContentBlockTest < ActiveSupport::TestCase | @@ -585,7 +586,7 @@ class DisplayContentBlockTest < ActiveSupport::TestCase | ||
585 | block = DisplayContentBlock.create! | 586 | block = DisplayContentBlock.create! |
586 | block.types = ['TinyMceArticle'] | 587 | block.types = ['TinyMceArticle'] |
587 | block.types = [] | 588 | block.types = [] |
588 | - assert_equal [UploadedFile, Event, TinyMceArticle, TextileArticle, RawHTMLArticle, Folder, Blog, Forum, Gallery, RssFeed], block.available_content_types | 589 | + assert_equivalent [UploadedFile, Event, TinyMceArticle, TextileArticle, RawHTMLArticle, Folder, Blog, Forum, Gallery, RssFeed], block.available_content_types |
589 | end | 590 | end |
590 | 591 | ||
591 | should 'return first 2 content types' do | 592 | should 'return first 2 content types' do |
@@ -629,7 +630,7 @@ class DisplayContentBlockTest < ActiveSupport::TestCase | @@ -629,7 +630,7 @@ class DisplayContentBlockTest < ActiveSupport::TestCase | ||
629 | Noosfero::Plugin::Manager.any_instance.stubs(:enabled_plugins).returns([SomePlugin.new]) | 630 | Noosfero::Plugin::Manager.any_instance.stubs(:enabled_plugins).returns([SomePlugin.new]) |
630 | 631 | ||
631 | block.types = [] | 632 | block.types = [] |
632 | - assert_equal [UploadedFile, Event, TinyMceArticle, TextileArticle, RawHTMLArticle, Folder, Blog, Forum, Gallery, RssFeed, SomePluginContent], block.available_content_types | 633 | + assert_equivalent [UploadedFile, Event, TinyMceArticle, TextileArticle, RawHTMLArticle, Folder, Blog, Forum, Gallery, RssFeed, SomePluginContent], block.available_content_types |
633 | end | 634 | end |
634 | 635 | ||
635 | should 'do not fail if a selected article was removed' do | 636 | should 'do not fail if a selected article was removed' do |