From 3a32ff13a05df2d443410642172c2a4df1585ca1 Mon Sep 17 00:00:00 2001 From: Victor Costa Date: Fri, 17 Apr 2015 14:39:20 -0300 Subject: [PATCH] Add story content type --- lib/proposals_discussion_plugin.rb | 8 ++++++-- lib/proposals_discussion_plugin/story.rb | 12 ++++++++++++ test/unit/proposals_discussion_plugin_test.rb | 4 ++-- 3 files changed, 20 insertions(+), 4 deletions(-) create mode 100644 lib/proposals_discussion_plugin/story.rb diff --git a/lib/proposals_discussion_plugin.rb b/lib/proposals_discussion_plugin.rb index 40d4009..0cf4b8d 100644 --- a/lib/proposals_discussion_plugin.rb +++ b/lib/proposals_discussion_plugin.rb @@ -19,12 +19,16 @@ class ProposalsDiscussionPlugin < Noosfero::Plugin parent = parent_id ? context.profile.articles.find(parent_id) : nil types << ProposalsDiscussionPlugin::Discussion types << ProposalsDiscussionPlugin::Topic if parent.kind_of?(ProposalsDiscussionPlugin::Discussion) - types << ProposalsDiscussionPlugin::Proposal if parent.kind_of?(ProposalsDiscussionPlugin::Topic) || ( parent.kind_of?(ProposalsDiscussionPlugin::Discussion) && !parent.allow_topics) + if parent.kind_of?(ProposalsDiscussionPlugin::Topic) || ( parent.kind_of?(ProposalsDiscussionPlugin::Discussion) && !parent.allow_topics) + types << ProposalsDiscussionPlugin::Proposal + types << ProposalsDiscussionPlugin::Story + end types else [ProposalsDiscussionPlugin::Discussion, ProposalsDiscussionPlugin::Topic, - ProposalsDiscussionPlugin::Proposal] + ProposalsDiscussionPlugin::Proposal, + ProposalsDiscussionPlugin::Story] end end diff --git a/lib/proposals_discussion_plugin/story.rb b/lib/proposals_discussion_plugin/story.rb new file mode 100644 index 0000000..d28c9fe --- /dev/null +++ b/lib/proposals_discussion_plugin/story.rb @@ -0,0 +1,12 @@ +class ProposalsDiscussionPlugin::Story < TinyMceArticle + + def self.short_description + _("Story") + end + + def self.description + _("Discussion Story") + end + +end + diff --git a/test/unit/proposals_discussion_plugin_test.rb b/test/unit/proposals_discussion_plugin_test.rb index 3b45c07..0ebd802 100644 --- a/test/unit/proposals_discussion_plugin_test.rb +++ b/test/unit/proposals_discussion_plugin_test.rb @@ -45,13 +45,13 @@ class ProposalsDiscussionPluginTest < ActiveSupport::TestCase should 'return all content types if the context controller is not cms' do params[:controller] = 'content_viewer' - assert_equal [ProposalsDiscussionPlugin::Discussion, ProposalsDiscussionPlugin::Topic, ProposalsDiscussionPlugin::Proposal], plugin.content_types + assert_equal [ProposalsDiscussionPlugin::Discussion, ProposalsDiscussionPlugin::Topic, ProposalsDiscussionPlugin::Proposal, ProposalsDiscussionPlugin::Story], plugin.content_types end should 'return all content types if the context controller is cms and action is not new' do params[:controller] = 'cms' params[:action] = 'edit' - assert_equal [ProposalsDiscussionPlugin::Discussion, ProposalsDiscussionPlugin::Topic, ProposalsDiscussionPlugin::Proposal], plugin.content_types + assert_equal [ProposalsDiscussionPlugin::Discussion, ProposalsDiscussionPlugin::Topic, ProposalsDiscussionPlugin::Proposal, ProposalsDiscussionPlugin::Story], plugin.content_types end should 'remove new button from content page for a discussion' do -- libgit2 0.21.2