diff --git a/app/api/helpers.rb b/app/api/helpers.rb index bfc91c5..e25f550 100644 --- a/app/api/helpers.rb +++ b/app/api/helpers.rb @@ -107,7 +107,7 @@ module Api def post_article(asset, params) return forbidden! unless current_person.can_post_content?(asset) - klass_type = params[:content_type] || params[:article].delete(:type) || TinyMceArticle.name + klass_type = params[:content_type] || params[:article].delete(:type) || TextArticle.name return forbidden! unless klass_type.constantize <= Article article = klass_type.constantize.new(params[:article]) @@ -461,11 +461,9 @@ module Api def parse_content_type(content_type) return nil if content_type.blank? - content_types = content_type.split(',').map do |content_type| - content_type = content_type.camelcase - content_type == 'TextArticle' ? Article.text_article_types : content_type + content_type.split(',').map do |content_type| + content_type.camelcase end - content_types.flatten.uniq end def period(from_date, until_date) diff --git a/app/controllers/my_profile/cms_controller.rb b/app/controllers/my_profile/cms_controller.rb index 0f76059..da635eb 100644 --- a/app/controllers/my_profile/cms_controller.rb +++ b/app/controllers/my_profile/cms_controller.rb @@ -151,6 +151,7 @@ class CmsController < MyProfileController @article.profile = profile @article.author = user + @article.editor = current_person.editor @article.last_changed_by = user @article.created_by = user @@ -399,8 +400,7 @@ class CmsController < MyProfileController def available_article_types articles = [ - TinyMceArticle, - TextileArticle, + TextArticle, Event ] articles += special_article_types if params && params[:cms] @@ -408,9 +408,6 @@ class CmsController < MyProfileController if @parent && @parent.blog? articles -= Article.folder_types.map(&:constantize) end - if user.is_admin?(profile.environment) - articles << RawHTMLArticle - end articles end diff --git a/app/controllers/my_profile/profile_editor_controller.rb b/app/controllers/my_profile/profile_editor_controller.rb index 0ad0328..f4014c6 100644 --- a/app/controllers/my_profile/profile_editor_controller.rb +++ b/app/controllers/my_profile/profile_editor_controller.rb @@ -92,7 +92,7 @@ class ProfileEditorController < MyProfileController end def welcome_page - @welcome_page = profile.welcome_page || TinyMceArticle.new(:name => 'Welcome Page', :profile => profile, :published => false) + @welcome_page = profile.welcome_page || TextArticle.new(:name => 'Welcome Page', :profile => profile, :published => false) if request.post? begin @welcome_page.update!(params[:welcome_page]) diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 5a6a812..1a1a90d 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -109,10 +109,6 @@ module ApplicationHelper content = capture(&block) end - if options[:type] == :textile - content = RedCloth.new(content).to_html - end - options[:class] = '' if ! options[:class] options[:class] += ' button icon-help' # with-text @@ -130,13 +126,6 @@ module ApplicationHelper text end - # alias for help(content, :textile). You can pass a block in the - # same way you would do if you called help directly. - def help_textile(content = nil, link_name = nil, options = {}, &block) - options[:type] = :textile - help(content, link_name, options, &block) - end - # TODO: do something more useful here # TODO: test this helper # TODO: add an icon? @@ -1243,4 +1232,15 @@ module ApplicationHelper content.html_safe end + def current_editor_is?(editor) + editor.blank? ? false : current_editor == editor + end + + def current_editor(mode = '') + editor = @article.editor || Article::Editor::TINY_MCE unless @article.nil? + editor ||= (current_person.nil? || current_person.editor.nil?) ? Article::Editor::TINY_MCE : current_person.editor + editor += '_' + mode unless mode.blank? + editor + end + end diff --git a/app/helpers/profile_editor_helper.rb b/app/helpers/profile_editor_helper.rb index ec7dab9..ea249d0 100644 --- a/app/helpers/profile_editor_helper.rb +++ b/app/helpers/profile_editor_helper.rb @@ -158,4 +158,8 @@ module ProfileEditorHelper end end + def select_editor(title, object, method, options) + labelled_form_field(title, select(object, method,[[_('TinyMCE'), Article::Editor::TINY_MCE], [_('Textile'), Article::Editor::TEXTILE], [_('Raw HTML'), Article::Editor::RAW_HTML]])) + end + end diff --git a/app/helpers/tinymce_helper.rb b/app/helpers/tinymce_helper.rb index 4f4feca..5b4d478 100644 --- a/app/helpers/tinymce_helper.rb +++ b/app/helpers/tinymce_helper.rb @@ -18,7 +18,8 @@ module TinymceHelper insertdatetime media nonbreaking save table contextmenu directionality emoticons template paste textcolor colorpicker textpattern], :image_advtab => true, - :language => tinymce_language + :language => tinymce_language, + :selector => '.' + current_editor(options[:mode]) options[:toolbar1] = toolbar1(options[:mode]) options[:menubar] = menubar(options[:mode]) diff --git a/app/models/article.rb b/app/models/article.rb index 044ebe1..5fc55c2 100644 --- a/app/models/article.rb +++ b/app/models/article.rb @@ -1,6 +1,12 @@ class Article < ApplicationRecord + module Editor + TEXTILE = 'textile' + TINY_MCE = 'tiny_mce' + RAW_HTML = 'raw_html' + end + include SanitizeHelper attr_accessible :name, :body, :abstract, :profile, :tag_list, :parent, @@ -11,7 +17,7 @@ class Article < ApplicationRecord :highlighted, :notify_comments, :display_hits, :slug, :external_feed_builder, :display_versions, :external_link, :image_builder, :show_to_followers, :archived, - :author, :display_preview, :published_at, :person_followers + :author, :display_preview, :published_at, :person_followers, :editor extend ActsAsHavingImage::ClassMethods acts_as_having_image @@ -518,17 +524,12 @@ class Article < ApplicationRecord ['Folder', 'Blog', 'Forum', 'Gallery'] end - def self.text_article_types - ['TextArticle', 'TextileArticle', 'TinyMceArticle'] - end - scope :published, -> { where 'articles.published = ?', true } scope :folders, -> profile { where 'articles.type IN (?)', profile.folder_types } scope :no_folders, -> profile { where 'articles.type NOT IN (?)', profile.folder_types } scope :galleries, -> { where "articles.type IN ('Gallery')" } scope :images, -> { where :is_image => true } scope :no_images, -> { where :is_image => false } - scope :text_articles, -> { where 'articles.type IN (?)', text_article_types } scope :files, -> { where :type => 'UploadedFile' } scope :with_types, -> types { where 'articles.type IN (?)', types } @@ -711,10 +712,6 @@ class Article < ApplicationRecord false end - def tiny_mce? - false - end - def folder? false end @@ -874,6 +871,10 @@ class Article < ApplicationRecord true end + def editor?(editor) + self.editor == editor + end + private def sanitize_tag_list diff --git a/app/models/event.rb b/app/models/event.rb index 9731d93..a4dbcbf 100644 --- a/app/models/event.rb +++ b/app/models/event.rb @@ -121,10 +121,6 @@ class Event < Article true end - def tiny_mce? - true - end - def notifiable? true end diff --git a/app/models/external_feed.rb b/app/models/external_feed.rb index 7d43f7c..1322611 100644 --- a/app/models/external_feed.rb +++ b/app/models/external_feed.rb @@ -25,7 +25,7 @@ class ExternalFeed < ApplicationRecord end content = doc.to_s - article = TinyMceArticle.new + article = TextArticle.new article.name = title article.profile = blog.profile article.body = content diff --git a/app/models/person.rb b/app/models/person.rb index a68fa4e..d343a3c 100644 --- a/app/models/person.rb +++ b/app/models/person.rb @@ -1,7 +1,7 @@ # A person is the profile of an user holding all relationships with the rest of the system class Person < Profile - attr_accessible :organization, :contact_information, :sex, :birth_date, :cell_phone, :comercial_phone, :jabber_id, :personal_website, :nationality, :address_reference, :district, :schooling, :schooling_status, :formation, :custom_formation, :area_of_study, :custom_area_of_study, :professional_activity, :organization_website, :following_articles + attr_accessible :organization, :contact_information, :sex, :birth_date, :cell_phone, :comercial_phone, :jabber_id, :personal_website, :nationality, :address_reference, :district, :schooling, :schooling_status, :formation, :custom_formation, :area_of_study, :custom_area_of_study, :professional_activity, :organization_website, :following_articles, :editor SEARCH_FILTERS = { :order => %w[more_recent more_popular more_active], @@ -613,6 +613,10 @@ class Person < Profile Profile.followed_by self end + def editor?(editor) + self.editor == editor + end + def in_social_circle?(person) self.is_a_friend?(person) || super end diff --git a/app/models/raw_html_article.rb b/app/models/raw_html_article.rb deleted file mode 100644 index 77186c2..0000000 --- a/app/models/raw_html_article.rb +++ /dev/null @@ -1,17 +0,0 @@ -class RawHTMLArticle < TextArticle - - def self.type_name - _('HTML') - end - - def self.short_description - _('Raw HTML text article') - end - - def self.description - _('Allows HTML without filter (only for admins).') - end - - xss_terminate :only => [ ] - -end diff --git a/app/models/suggest_article.rb b/app/models/suggest_article.rb index 63e87b8..15bc273 100644 --- a/app/models/suggest_article.rb +++ b/app/models/suggest_article.rb @@ -44,7 +44,7 @@ class SuggestArticle < Task type = article[:type].constantize return type if type < Article end - TinyMceArticle + TextArticle end def perform diff --git a/app/models/text_article.rb b/app/models/text_article.rb index 805cc50..98e0d86 100644 --- a/app/models/text_article.rb +++ b/app/models/text_article.rb @@ -1,7 +1,21 @@ # a base class for all text article types. class TextArticle < Article - xss_terminate :only => [ :name ], :on => 'validation' + def self.short_description + _('Text article') + end + + def self.description + _('Text article to create user content.') + end + + xss_terminate :only => [ :name, :body, :abstract ], :with => 'white_list', :on => 'validation', :if => lambda { |a| !a.editor?(Article::Editor::TEXTILE) && !a.editor?(Article::Editor::RAW_HTML) } + + include WhiteListFilter + filter_iframes :abstract, :body + def iframe_whitelist + profile && profile.environment && profile.environment.trusted_sites_for_iframe + end def self.type_name _('Article') @@ -21,6 +35,18 @@ class TextArticle < Article true end + def can_display_media_panel? + true + end + + def self.can_display_blocks? + false + end + + def notifiable? + true + end + before_save :set_relative_path def set_relative_path @@ -43,4 +69,24 @@ class TextArticle < Article parent && parent.kind_of?(Blog) && parent.display_preview end + def to_html(options ={}) + content = super(options) + content = convert_textile_to_html(content) if self.editor?(Article::Editor::TEXTILE) + content + end + + def lead(length = nil) + content = super(length) + content = convert_textile_to_html(content) if self.editor?(Article::Editor::TEXTILE) + content + end + + protected + + def convert_textile_to_html(textile) + converter = RedCloth.new(textile|| '') + converter.hard_breaks = false + sanitize_html(converter.to_html, :white_list) + end + end diff --git a/app/models/textile_article.rb b/app/models/textile_article.rb deleted file mode 100644 index f9c47b1..0000000 --- a/app/models/textile_article.rb +++ /dev/null @@ -1,44 +0,0 @@ -class TextileArticle < TextArticle - include SanitizeHelper - - def self.short_description - _('Text article with Textile markup language') - end - - def self.description - _('Accessible alternative for visually impaired users.') - end - - def to_html(options ={}) - convert_to_html(body) - end - - def lead(length = nil) - if abstract.blank? - super - else - convert_to_html(abstract) - end - end - - def notifiable? - true - end - - def can_display_media_panel? - true - end - - def self.can_display_blocks? - false - end - - protected - - def convert_to_html(textile) - converter = RedCloth.new(textile|| '') - converter.hard_breaks = false - sanitize_html(converter.to_html, :white_list) - end - -end diff --git a/app/models/tiny_mce_article.rb b/app/models/tiny_mce_article.rb deleted file mode 100644 index 53a4b23..0000000 --- a/app/models/tiny_mce_article.rb +++ /dev/null @@ -1,37 +0,0 @@ -class TinyMceArticle < TextArticle - - def self.short_description - _('Text article with visual editor') - end - - def self.description - _('Not accessible for visually impaired users.') - end - - xss_terminate :only => [ ] - - xss_terminate :only => [ :name, :abstract, :body ], :with => 'white_list', :on => 'validation' - - include WhiteListFilter - filter_iframes :abstract, :body - def iframe_whitelist - profile && profile.environment && profile.environment.trusted_sites_for_iframe - end - - def notifiable? - true - end - - def tiny_mce? - true - end - - def can_display_media_panel? - true - end - - def self.can_display_blocks? - false - end - -end diff --git a/app/views/admin_panel/_signup_intro.html.erb b/app/views/admin_panel/_signup_intro.html.erb index e60c905..a48c0ea 100644 --- a/app/views/admin_panel/_signup_intro.html.erb +++ b/app/views/admin_panel/_signup_intro.html.erb @@ -2,4 +2,4 @@ <%= _('This text will be shown to the user on the top of the sign up form.') %> -<%= labelled_form_field(_('Body'), text_area(:environment, :signup_intro, :cols => 40, :style => 'width: 100%', :class => 'mceEditor')) %> +<%= labelled_form_field(_('Body'), text_area(:environment, :signup_intro, :cols => 40, :style => 'width: 100%', :class => current_editor)) %> diff --git a/app/views/admin_panel/_signup_welcome_screen.html.erb b/app/views/admin_panel/_signup_welcome_screen.html.erb index 4ffca1a..89ebf6d 100644 --- a/app/views/admin_panel/_signup_welcome_screen.html.erb +++ b/app/views/admin_panel/_signup_welcome_screen.html.erb @@ -1,7 +1,7 @@
<%= _('If you enable this feature on the "Features" section of the Administration Panel, this text will be shown as a welcome message to users after signup.') %>
-<%= labelled_form_field(_('Body'), text_area(:environment, :signup_welcome_screen_body, :cols => 40, :style => 'width: 100%', :class => 'mceEditor')) %> +<%= labelled_form_field(_('Body'), text_area(:environment, :signup_welcome_screen_body, :cols => 40, :style => 'width: 100%', :class => current_editor)) %>
<%= _('If this content is left blank, the following page will be displayed to the user:') %> diff --git a/app/views/admin_panel/_signup_welcome_text.html.erb b/app/views/admin_panel/_signup_welcome_text.html.erb index f1d6966..0dd85f5 100644 --- a/app/views/admin_panel/_signup_welcome_text.html.erb +++ b/app/views/admin_panel/_signup_welcome_text.html.erb @@ -4,4 +4,4 @@
<%= labelled_form_field(_('Subject'), text_field(:environment, :signup_welcome_text_subject, :style => 'width:100%')) %> -<%= labelled_form_field(_('Body'), text_area(:environment, :signup_welcome_text_body, :cols => 40, :style => 'width: 100%', :class => 'mceEditor')) %> +<%= labelled_form_field(_('Body'), text_area(:environment, :signup_welcome_text_body, :cols => 40, :style => 'width: 100%', :class => current_editor)) %> diff --git a/app/views/admin_panel/_site_info.html.erb b/app/views/admin_panel/_site_info.html.erb index 8641313..9635aeb 100644 --- a/app/views/admin_panel/_site_info.html.erb +++ b/app/views/admin_panel/_site_info.html.erb @@ -31,4 +31,4 @@ <%= balanced_table(fields)%>
-<%= labelled_form_field _('Homepage content'), text_area(:environment, :description, :cols => 40, :style => 'width: 90%', :class => 'mceEditor') %> +<%= labelled_form_field _('Homepage content'), text_area(:environment, :description, :cols => 40, :style => 'width: 90%', :class => current_editor) %> diff --git a/app/views/admin_panel/_terms_of_use.html.erb b/app/views/admin_panel/_terms_of_use.html.erb index 79e3a3b..05c631c 100644 --- a/app/views/admin_panel/_terms_of_use.html.erb +++ b/app/views/admin_panel/_terms_of_use.html.erb @@ -1 +1 @@ -<%= f.text_area :terms_of_use, :cols => 40, :style => 'width: 90%', :class => 'mceEditor' %> +<%= f.text_area :terms_of_use, :cols => 40, :style => 'width: 90%', :class => current_editor %> diff --git a/app/views/admin_panel/message_for_disabled_enterprise.html.erb b/app/views/admin_panel/message_for_disabled_enterprise.html.erb index 10c6947..8af7751 100644 --- a/app/views/admin_panel/message_for_disabled_enterprise.html.erb +++ b/app/views/admin_panel/message_for_disabled_enterprise.html.erb @@ -1,10 +1,8 @@

<%= _('Site info') %>

-<%= render :file => 'shared/tiny_mce' %> - <%= labelled_form_for :environment, :url => {:action => 'site_info'} do |f| %> - <%= f.text_area :message_for_disabled_enterprise, :cols => 40, :style => 'width: 90%' %> + <%= f.text_area :message_for_disabled_enterprise, :cols => 40, :style => 'width: 90%', :class => current_editor %> <%= button_bar do %> <%= submit_button(:save, _('Save')) %> diff --git a/app/views/admin_panel/site_info.html.erb b/app/views/admin_panel/site_info.html.erb index 3d9ee97..e8f1b6d 100644 --- a/app/views/admin_panel/site_info.html.erb +++ b/app/views/admin_panel/site_info.html.erb @@ -2,8 +2,6 @@ <%= error_messages_for :environment %> -<%= render :file => 'shared/tiny_mce' %> - <%= labelled_form_for :environment do |f| %> <% tabs = [] %> <% tabs << {:title => _('Site info'), :id => 'site-info', diff --git a/app/views/cms/_article.html.erb b/app/views/cms/_article.html.erb index 0bc3e05..8ea87ab 120000 --- a/app/views/cms/_article.html.erb +++ b/app/views/cms/_article.html.erb @@ -1 +1 @@ -_tiny_mce_article.html.erb \ No newline at end of file +_text_article.html.erb \ No newline at end of file diff --git a/app/views/cms/_blog.html.erb b/app/views/cms/_blog.html.erb index 6afd174..6826056 100644 --- a/app/views/cms/_blog.html.erb +++ b/app/views/cms/_blog.html.erb @@ -2,8 +2,6 @@

<%= _('My Blog') %>

-<%= render :file => 'shared/tiny_mce' %> - <%= required f.text_field(:name, :size => '64', :maxlength => 150, :onchange => "updateUrlField(this, 'article_slug')") %> <%= render :partial => 'general_fields' %> @@ -53,7 +51,7 @@ %> -<%= labelled_form_field(_('Description:'), text_area(:article, :body, :rows => 10, :class => 'mceEditor')) %> +<%= labelled_form_field(_('Description:'), text_area(:article, :body, :rows => 10, :class => current_editor)) %>
<%= f.fields_for :image_builder, @article.image do |i| %> diff --git a/app/views/cms/_enterprise_homepage.html.erb b/app/views/cms/_enterprise_homepage.html.erb index 6f910ff..477ecc9 100644 --- a/app/views/cms/_enterprise_homepage.html.erb +++ b/app/views/cms/_enterprise_homepage.html.erb @@ -1,4 +1,2 @@ -<%= render :file => 'shared/tiny_mce' %> - -<%= labelled_form_field(_('Text'), text_area(:article, 'body', :cols => 40, :style => 'width:99%', :class => 'mceEditor')) %> +<%= labelled_form_field(_('Text'), text_area(:article, 'body', :cols => 40, :style => 'width:99%', :class => current_editor)) %> diff --git a/app/views/cms/_event.html.erb b/app/views/cms/_event.html.erb index 1a9db6c..bcc44d3 100644 --- a/app/views/cms/_event.html.erb +++ b/app/views/cms/_event.html.erb @@ -1,8 +1,5 @@ <%= required_fields_message %> -<%# TODO add Textile help here %> -<%= render :file => 'shared/tiny_mce' %> - <%= required f.text_field('name', :size => '64', :maxlength => 150) %> <%= render :partial => 'general_fields' %> @@ -15,4 +12,4 @@ <%= labelled_form_field(_('Address:'), text_field(:article, :address)) %> -<%= render :partial => 'shared/lead_and_body', :locals => {:tiny_mce => true, :body_label => 'Information about the event:'} %> +<%= render :partial => 'shared/lead_and_body', :locals => {:body_label => 'Information about the event:'} %> diff --git a/app/views/cms/_forum.html.erb b/app/views/cms/_forum.html.erb index 2233f85..ab4b0be 100644 --- a/app/views/cms/_forum.html.erb +++ b/app/views/cms/_forum.html.erb @@ -4,18 +4,16 @@ <%= required_fields_message %> -<%= render :file => 'shared/tiny_mce' %> - <%= required f.text_field(:name, :size => '64', :maxlength => 150, :onchange => "updateUrlField(this, 'article_slug')") %> <%= render :partial => 'general_fields' %> -<%= labelled_form_field(_('Description:'), text_area(:article, :body, :class => 'mceEditor', :cols => 64, :rows => 10)) %> +<%= labelled_form_field(_('Description:'), text_area(:article, :body, :class => current_editor, :cols => 64, :rows => 10)) %> <%= labelled_form_field(_('Posts per page:'), f.select(:posts_per_page, Forum.posts_per_page_options)) %> <%= labelled_form_field(_('Has terms of use:'), check_box(:article, :has_terms_of_use))%>
- <%= labelled_form_field(_('Terms of use:'), text_area(:article, :terms_of_use, :class => 'mceEditor',:cols => 64, :rows => 10)) %> + <%= labelled_form_field(_('Terms of use:'), text_area(:article, :terms_of_use, :class => current_editor,:cols => 64, :rows => 10)) %>
diff --git a/app/views/cms/_raw_html_article.html.erb b/app/views/cms/_raw_html_article.html.erb deleted file mode 100644 index 1bef734..0000000 --- a/app/views/cms/_raw_html_article.html.erb +++ /dev/null @@ -1,8 +0,0 @@ -<%= required_fields_message %> - -<%= required labelled_form_field(_('Title'), text_field(:article, 'name', :size => '64', :maxlength => 150)) %> - -<%= render :partial => 'text_fields' %> -<%= render :partial => 'general_fields' %> -<%= render :partial => 'translatable' %> -<%= render :partial => 'shared/lead_and_body' %> diff --git a/app/views/cms/_text_article.html.erb b/app/views/cms/_text_article.html.erb new file mode 100644 index 0000000..d01ee43 --- /dev/null +++ b/app/views/cms/_text_article.html.erb @@ -0,0 +1,10 @@ +<%= required_fields_message %> + +<%= required labelled_form_field(_('Title'), text_field(:article, 'name', :size => '72', :maxlength => 150)) %> + +<%= render :partial => 'text_fields' %> +<%= render :partial => 'general_fields' %> +<%= render :partial => 'translatable' %> + +<%= render :partial => 'shared/lead_and_body' %> + diff --git a/app/views/cms/_text_editor_sidebar.html.erb b/app/views/cms/_text_editor_sidebar.html.erb index f49bdf9..9caeda7 100644 --- a/app/views/cms/_text_editor_sidebar.html.erb +++ b/app/views/cms/_text_editor_sidebar.html.erb @@ -7,7 +7,7 @@
<%= _('Insert media') %><%= button('vertical-toggle', _('Show/Hide'), '#') %>
- <%= render(:partial => 'textile_quick_reference') if @article.is_a?(TextileArticle) %> + <%= render(:partial => 'textile_quick_reference') if @article.editor?(Article::Editor::TEXTILE) %>
<%= form_tag({ :action => 'media_upload' }, :multipart => true) do %> diff --git a/app/views/cms/_textile_article.html.erb b/app/views/cms/_textile_article.html.erb deleted file mode 100644 index 9e4095b..0000000 --- a/app/views/cms/_textile_article.html.erb +++ /dev/null @@ -1,10 +0,0 @@ -<%= required_fields_message %> - -<%# TODO add Textile help here %> - -<%= required labelled_form_field(_('Title'), text_field(:article, 'name', :size => '72', :maxlength => 150)) %> - -<%= render :partial => 'text_fields' %> -<%= render :partial => 'general_fields' %> -<%= render :partial => 'translatable' %> -<%= render :partial => 'shared/lead_and_body' %> diff --git a/app/views/cms/_tiny_mce_article.html.erb b/app/views/cms/_tiny_mce_article.html.erb deleted file mode 100644 index bf54166..0000000 --- a/app/views/cms/_tiny_mce_article.html.erb +++ /dev/null @@ -1,12 +0,0 @@ -<%= required_fields_message %> - -<%= render :file => 'shared/tiny_mce' %> - -
- <%= required labelled_form_field(_('Title'), text_field(:article, 'name', :size => '64', :maxlength => 150)) %> - - <%= render :partial => 'text_fields' %> - <%= render :partial => 'general_fields' %> - <%= render :partial => 'translatable' %> - <%= render :partial => 'shared/lead_and_body', :locals => {:tiny_mce => true} %> -
diff --git a/app/views/cms/suggest_an_article.html.erb b/app/views/cms/suggest_an_article.html.erb index 2ea330e..64cff26 100644 --- a/app/views/cms/suggest_an_article.html.erb +++ b/app/views/cms/suggest_an_article.html.erb @@ -2,8 +2,6 @@ <%= required_fields_message %> -<%= render :file => 'shared/tiny_mce' %> - <%= labelled_form_for 'task' do |f| %> <%= required labelled_form_field(_('Title'), text_field('task[article]', 'name', :size => 50)) %> @@ -17,7 +15,7 @@ <%= required labelled_form_field(_('Email'), text_field(:task, 'email')) %> <% end %> - <%= render :partial => 'shared/lead_and_body', :locals => {:tiny_mce => true, :object => 'task[article]'} %> + <%= render :partial => 'shared/lead_and_body', :locals => {:object => 'task[article]'} %> <%= hidden_field_tag('back_to', @back_to) %> diff --git a/app/views/contact/new.html.erb b/app/views/contact/new.html.erb index 327f045..dd2600b 100644 --- a/app/views/contact/new.html.erb +++ b/app/views/contact/new.html.erb @@ -25,8 +25,7 @@ <%= required f.text_field(:subject) %> - <%= render :file => 'shared/tiny_mce' %> - <%= required f.text_area(:message, :class => 'mceEditor') %> + <%= required f.text_area(:message, :class => current_editor) %> <%= labelled_form_field check_box(:contact, :receive_a_copy) + _('I want to receive a copy of the message in my e-mail.'), '' %> diff --git a/app/views/email_templates/_form.html.erb b/app/views/email_templates/_form.html.erb index 0473bbf..ee49a3f 100644 --- a/app/views/email_templates/_form.html.erb +++ b/app/views/email_templates/_form.html.erb @@ -19,8 +19,7 @@ <%= @template_params_allowed %>
- <%= render :file => 'shared/tiny_mce' %> - <%= labelled_form_field(_('Body:'), f.text_area(:body, :class => 'mceEditor')) %> + <%= labelled_form_field(_('Body:'), f.text_area(:body, :class => current_editor)) %>
diff --git a/app/views/layouts/application-ng.html.erb b/app/views/layouts/application-ng.html.erb index 1f74c4c..0bfb92f 100644 --- a/app/views/layouts/application-ng.html.erb +++ b/app/views/layouts/application-ng.html.erb @@ -35,6 +35,9 @@ noosfero.profile = <%= (@profile.identifier if @profile).to_json.html_safe %> + <% if current_editor_is?(Article::Editor::TINY_MCE) %> + <%= render :file => 'shared/tiny_mce' %> + <% end %> <%= _("Go to the content") %> diff --git a/app/views/profile/send_mail.html.erb b/app/views/profile/send_mail.html.erb index 86847e9..fd80173 100644 --- a/app/views/profile/send_mail.html.erb +++ b/app/views/profile/send_mail.html.erb @@ -16,8 +16,7 @@ <%= labelled_form_field(_('Subject:'), f.text_field(:subject)) %> - <%= render :file => 'shared/tiny_mce' %> - <%= labelled_form_field(_('Body:'), f.text_area(:body, :class => 'mceEditor')) %> + <%= labelled_form_field(_('Body:'), f.text_area(:body, :class => 'body ' + current_editor)) %> <%= submit_button(:send, _('Send')) %> <%= button :cancel, _('Cancel e-mail'), :back %> diff --git a/app/views/profile_editor/_person.html.erb b/app/views/profile_editor/_person.html.erb index 33ff967..045b3b0 100644 --- a/app/views/profile_editor/_person.html.erb +++ b/app/views/profile_editor/_person.html.erb @@ -16,6 +16,8 @@
+ <%= select_editor(_('Editor'), 'profile_data', 'editor', {}) %> + <%= safe_join(@plugins.dispatch(:profile_info_extra_contents).collect { |content| instance_exec(&content) }, "") %>
diff --git a/app/views/profile_editor/header_footer.html.erb b/app/views/profile_editor/header_footer.html.erb index cc464ee..00f74c6 100644 --- a/app/views/profile_editor/header_footer.html.erb +++ b/app/views/profile_editor/header_footer.html.erb @@ -1,5 +1,3 @@ -<%= render :file => 'shared/tiny_mce' %> -

<%= _('Editing header and footer') %>

<%= form_tag do %> @@ -21,9 +19,9 @@
<% end %>

<%= _('Content for header ') %>

- <%= text_area_tag(:custom_header, @header, :style => 'width: 100%; height: 150px;', :class => 'mceEditor') %> + <%= text_area_tag(:custom_header, @header, :style => 'width: 100%; height: 150px;', :class => current_editor) %>

<%= _('Content for footer') %>

- <%= text_area_tag(:custom_footer, @footer, :style => 'width: 100%; height: 150px;', :class => 'mceEditor') %> + <%= text_area_tag(:custom_footer, @footer, :style => 'width: 100%; height: 150px;', :class => current_editor) %> <%= button_bar do %> <%= submit_button(:save, _('Save')) %> <%= button(:cancel, _('Cancel'), :action => 'index') %> diff --git a/app/views/profile_editor/welcome_page.html.erb b/app/views/profile_editor/welcome_page.html.erb index f04add4..8665b34 100644 --- a/app/views/profile_editor/welcome_page.html.erb +++ b/app/views/profile_editor/welcome_page.html.erb @@ -8,7 +8,7 @@ <%= _('Your welcome page will only be displayed if this options is selected.') %> - <%= f.text_area(:body, :cols => 40, :style => 'width: 100%', :class => 'mceEditor') %> + <%= f.text_area(:body, :cols => 40, :style => 'width: 100%', :class => current_editor) %>
<%= _('This page will be displayed to the user after his signup with this template.') %>
@@ -17,5 +17,3 @@ <%= submit_button('save', _('Save'), :cancel => @back_to) %> <% end %> <% end %> - -<%= render :file => 'shared/tiny_mce' %> diff --git a/app/views/shared/_lead_and_body.html.erb b/app/views/shared/_lead_and_body.html.erb index 805c1db..01f71a2 100644 --- a/app/views/shared/_lead_and_body.html.erb +++ b/app/views/shared/_lead_and_body.html.erb @@ -3,7 +3,7 @@ <% abstract_method ||= :abstract %> <% body_label ||= 'Text' %> <% body_method ||= :body %> -<% editor_type = defined?(tiny_mce) && tiny_mce ? 'mceEditor' : '' %> +<% editor_type = current_editor %> <% lead_id ||= 0%> <% f ||= false%> diff --git a/app/views/shared/tiny_mce.html.erb b/app/views/shared/tiny_mce.html.erb index 972d3c2..5aa1591 100644 --- a/app/views/shared/tiny_mce.html.erb +++ b/app/views/shared/tiny_mce.html.erb @@ -47,7 +47,9 @@ function tinymce_macros_setup(editor) { tinymce.PluginManager.add('macrosPlugin', tinymce.plugins.MacrosPlugin); jQuery(document).ready(function () { - <%= tinymce_init_js :mode => mode %> + <%= tinymce_init_js %> + <%= tinymce_init_js :mode => 'simple' %> + <%= tinymce_init_js :mode => 'restricted' %> }); diff --git a/app/views/tasks/_approve_article_accept_details.html.erb b/app/views/tasks/_approve_article_accept_details.html.erb index 389e168..8785e26 100644 --- a/app/views/tasks/_approve_article_accept_details.html.erb +++ b/app/views/tasks/_approve_article_accept_details.html.erb @@ -1,15 +1,12 @@ <%= task_email_template(_('Select an acceptance email template:'), @acceptance_email_templates, task) %> -<%= render :file => 'shared/tiny_mce' %> - <%= labelled_form_field(_('Create a link'), f.check_box(:create_link)) %> <%= labelled_form_field(_('Name for publishing'), f.text_field(:name)) %> <%= select_profile_folder(_('Select the folder where the article must be published'), "tasks[#{task.id}][task][article_parent_id]", task.target) %> <%= labelled_form_field(_('Highlight this article'), f.check_box(:highlighted)) %> -<% tiny = task.article && task.article.tiny_mce? ? {:tiny_mce => true} : {} %> -<%= render :partial => 'shared/lead_and_body', :locals => {:lead_id => task.id, :f => f}.merge(tiny)%> +<%= render :partial => 'shared/lead_and_body', :locals => {:lead_id => task.id, :f => f}%> <%= labelled_form_field _('Comment for author'), f.text_field(:closing_statment, :style => 'width: 488px;') %> diff --git a/app/views/tasks/_suggest_article_accept_details.html.erb b/app/views/tasks/_suggest_article_accept_details.html.erb index 8f7e753..5f26841 100644 --- a/app/views/tasks/_suggest_article_accept_details.html.erb +++ b/app/views/tasks/_suggest_article_accept_details.html.erb @@ -1,5 +1,3 @@ -<%= render :file => 'shared/tiny_mce' %> - <% unless task.requestor %> <%= labelled_form_field(_("Sent by: "), f.text_field(:name)) %>

<%= label_tag(_("Email: %s") % task.email) %>

@@ -14,5 +12,5 @@ <%= labelled_form_field(_('Highlight this article'), a.check_box(:highlighted)) %> <%= a.hidden_field(:type) %> - <%= render :partial => 'shared/lead_and_body', :locals => {:tiny_mce => true, :f => a, :lead_id => task.id} %> + <%= render :partial => 'shared/lead_and_body', :locals => {:f => a, :lead_id => task.id} %> <% end %> diff --git a/app/views/users/send_mail.html.erb b/app/views/users/send_mail.html.erb index 7c2d940..eda4351 100644 --- a/app/views/users/send_mail.html.erb +++ b/app/views/users/send_mail.html.erb @@ -2,7 +2,6 @@ <%= error_messages_for :mailing %> -<%= render :file => 'shared/tiny_mce' %> <%= form_for :mailing do |f| %>
<%= label_tag(_("Recipients: "), nil, { class: "formlabel" }) %> @@ -14,7 +13,7 @@
<%= labelled_form_field(_('Subject:'), f.text_field(:subject)) %> - <%= labelled_form_field(_('Body:'), f.text_area(:body, :class => 'mceEditor')) %> + <%= labelled_form_field(_('Body:'), f.text_area(:body, :class => current_editor)) %> <%= submit_button(:send, _('Send')) %> <%= button :cancel, _('Cancel e-mail'), :controller => 'users' %> <% end %> diff --git a/db/migrate/20160809123835_add_people_and_article_editor.rb b/db/migrate/20160809123835_add_people_and_article_editor.rb new file mode 100644 index 0000000..723c356 --- /dev/null +++ b/db/migrate/20160809123835_add_people_and_article_editor.rb @@ -0,0 +1,9 @@ +class AddPeopleAndArticleEditor < ActiveRecord::Migration + def change + add_column :profiles, :editor, :string, :null => false, :default => Article::Editor::TINY_MCE + add_column :articles, :editor, :string, :null => false, :default => Article::Editor::TINY_MCE + Article.where(:type => 'TextileArticle').update_all(:type => 'TextArticle', :editor => Article::Editor::TEXTILE) + Article.where(:type => 'TinyMceArticle').update_all(:type => 'TextArticle', :editor => Article::Editor::TINY_MCE) + Article.where(:type => 'RawHTMLArticle').update_all(:type => 'TextArticle', :editor => Article::Editor::RAW_HTML) + end +end diff --git a/db/schema.rb b/db/schema.rb index a97d4ac..818d93c 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,7 +11,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 20160705162914) do +ActiveRecord::Schema.define(version: 20160809123835) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" @@ -168,6 +168,7 @@ ActiveRecord::Schema.define(version: 20160705162914) do t.boolean "show_to_followers", default: true t.integer "followers_count", default: 0 t.boolean "archived", default: false + t.string "editor", default: "tiny_mce", null: false end add_index "articles", ["comments_count"], name: "index_articles_on_comments_count", using: :btree @@ -631,15 +632,16 @@ ActiveRecord::Schema.define(version: 20160705162914) do t.boolean "is_template", default: false t.integer "template_id" t.string "redirection_after_login" - t.integer "friends_count", default: 0, null: false - t.integer "members_count", default: 0, null: false - t.integer "activities_count", default: 0, null: false + t.integer "friends_count", default: 0, null: false + t.integer "members_count", default: 0, null: false + t.integer "activities_count", default: 0, null: false t.string "personal_website" t.string "jabber_id" t.integer "welcome_page_id" t.boolean "allow_members_to_invite", default: true t.boolean "invite_friends_only", default: false t.boolean "secret", default: false + t.string "editor", default: "tiny_mce", null: false end add_index "profiles", ["activities_count"], name: "index_profiles_on_activities_count", using: :btree diff --git a/features/edit_article.feature b/features/edit_article.feature index 77ad8ff..a371f98 100644 --- a/features/edit_article.feature +++ b/features/edit_article.feature @@ -155,7 +155,7 @@ Feature: edit article Given I am on joaosilva's control panel And I follow "Manage Content" And I follow "New content" - When I follow "Text article with Textile markup language" + When I follow "Text article" Then I should see "Tag list" When I fill in "Title" with "Article with tags" And I fill in "Tag list" with "aurium, bug" @@ -168,7 +168,7 @@ Feature: edit article Given I am on joaosilva's control panel And I follow "Manage Content" When I follow "New content" - When I follow "Text article with visual editor" + When I follow "Text article" And I fill in "Title" with "My Article" And I press "Save" Then I should see "My Article" @@ -203,8 +203,8 @@ Feature: edit article And I press "Save" Then I should be on /joaosilva/my-folder When I follow "New article" - And I should see "Text article with visual editor" - And I follow "Text article with visual editor" + And I should see "Text article" + And I follow "Text article" And I fill in "Title" with "My Article" And I press "Save" Then I should see "My Article" @@ -222,12 +222,11 @@ Feature: edit article And I press "Save" Then I should be on /joaosilva/my-folder When I follow "New article" - And I should see "Text article with visual editor" - And I follow "Text article with visual editor" + And I should see "Text article" + And I follow "Text article" And I follow "Cancel" within ".no-boxes" Then I should be on /joaosilva/my-folder - @selenium Scenario: save and continue Given I am on /joaosilva/save-the-whales And I follow "Edit" @@ -240,8 +239,8 @@ Feature: edit article Given I am on joaosilva's control panel When I follow "Manage Content" And I follow "New content" - And I should see "Text article with visual editor" - And I follow "Text article with visual editor" + And I should see "Text article" + And I follow "Text article" And I fill in "Title" with "My new article" And I fill in "Text" with "text for the new article" And I press "Save and continue" @@ -287,7 +286,7 @@ Feature: edit article Given I am on joaosilva's control panel And I follow "Manage Content" And I follow "New content" - When I follow "Text article with visual editor" + When I follow "Text article" And I fill in "Title" with "My time testing Article" And I fill in "Publish date" with "1980-11-15 20:37" And I press "Save" diff --git a/features/forum.feature b/features/forum.feature index 0239c65..9e1c2b8 100644 --- a/features/forum.feature +++ b/features/forum.feature @@ -99,8 +99,8 @@ Feature: forum And I check "Has terms of use:" And I press "Save" When I follow "New discussion topic" - And I should see "Text article with visual editor" - And I follow "Text article with visual editor" + And I should see "Text article" + And I follow "Text article" And I fill in "Title" with "Topic" And I press "Save" And I am logged in as "mariasilva" diff --git a/features/media_panel_upload_files.feature b/features/media_panel_upload_files.feature index 1576bf6..9595e4b 100644 --- a/features/media_panel_upload_files.feature +++ b/features/media_panel_upload_files.feature @@ -8,7 +8,7 @@ Feature: uploads items on media panel | joaosilva | Joao Silva | And feature "media_panel" is enabled on environment And I am logged in as "joaosilva" - And I am on /myprofile/joaosilva/cms/new?type=TinyMceArticle + And I am on /myprofile/joaosilva/cms/new?type=TextArticle Scenario: see media panel collapsed Then I should see "Insert media" @@ -123,7 +123,7 @@ Feature: uploads items on media panel Given the following files | owner | file | mime | | joaosilva | other-pic.jpg | image/jpeg | - When I go to /myprofile/joaosilva/cms/new?type=TinyMceArticle + When I go to /myprofile/joaosilva/cms/new?type=TextArticle And I follow "Show/Hide" And I select "Recent media" from "parent_id" within "#published-media" Then I should see div with title "other-pic.jpg" within ".items" @@ -148,7 +148,7 @@ Feature: uploads items on media panel | owner | file | mime | parent | | joaosilva | rails.png | image/png | other-gallery | | joaosilva | other-pic.jpg | image/jpeg | gallery | - When I go to /myprofile/joaosilva/cms/new?type=TinyMceArticle + When I go to /myprofile/joaosilva/cms/new?type=TextArticle And I follow "Show/Hide" And I select "joaosilva/Gallery" from "parent_id" within "#published-media" Then I should see div with title "other-pic.jpg" within ".items" @@ -165,7 +165,7 @@ Feature: uploads items on media panel And the following files | owner | file | mime | parent | | joaosilva | other-pic.jpg | image/jpeg | gallery | - When I go to /myprofile/joaosilva/cms/new?type=TinyMceArticle + When I go to /myprofile/joaosilva/cms/new?type=TextArticle And I follow "Show/Hide" And I select "joaosilva/Gallery" from "parent_id" within "#published-media" And I select "joaosilva/Gallery" from "parent_id" within "#media-upload-form" @@ -187,7 +187,7 @@ Feature: uploads items on media panel And the following files | owner | file | mime | parent | | joaosilva | rails.png | image/png | other-gallery | - When I go to /myprofile/joaosilva/cms/new?type=TinyMceArticle + When I go to /myprofile/joaosilva/cms/new?type=TextArticle And I follow "Show/Hide" And I select "Recent media" from "parent_id" within "#published-media" And I fill in "Search" with "rails" within "#published-media" @@ -227,7 +227,7 @@ Feature: uploads items on media panel | joaosilva | other-pic.jpg | image/jpeg | my-gallery | | joaosilva | rails.png | image/png | gallery | | joaosilva | other-pic.jpg | image/jpeg | gallery | - When I go to /myprofile/joaosilva/cms/new?type=TinyMceArticle + When I go to /myprofile/joaosilva/cms/new?type=TextArticle And I follow "Show/Hide" And I should not see "View all" And I attach the file "public/503.jpg" to "file" diff --git a/features/new_content_on_cms.feature b/features/new_content_on_cms.feature index adb63c0..ba3d41d 100644 --- a/features/new_content_on_cms.feature +++ b/features/new_content_on_cms.feature @@ -15,8 +15,7 @@ Feature: create content on cms Scenario: list all content types Given I follow "New content" - Then I should see "Text article with visual editor" - And I should see "Text article with Textile markup" + Then I should see "Text article" And I should see "Folder" And I should see "Blog" And I should see "Uploaded file" @@ -30,22 +29,6 @@ Feature: create content on cms And I go to joaosilva's cms Then I should see "My Folder" - Scenario: create a tiny_mce article - Given I follow "New content" - When I follow "Text article with visual editor" - And I fill in "Title" with "My tiny_mce article" - And I press "Save" - And I go to joaosilva's cms - Then I should see "My tiny_mce article" - - Scenario: create a textile article - Given I follow "New content" - When I follow "Text article with Textile markup" - And I fill in "Title" with "My textile article" - And I press "Save" - And I go to joaosilva's cms - Then I should see "My textile article" - Scenario: create a Blog Given I follow "New content" When I follow "Blog" diff --git a/features/profile_search.feature b/features/profile_search.feature index 1a932b2..f3cb937 100644 --- a/features/profile_search.feature +++ b/features/profile_search.feature @@ -47,8 +47,8 @@ Feature: search inside a profile And I go to joaosilva's profile And I fill in "q" with "article" And I press "Search" - Then I should see "public article" within ".main-block" - And I should not see "private article" within ".main-block" + Then I should see "published article" within ".main-block" + And I should not see "unpublished article" within ".main-block" Scenario: search on environment Given I go to joaosilva's profile diff --git a/features/publish_article.feature b/features/publish_article.feature index 199db00..9b12ae7 100644 --- a/features/publish_article.feature +++ b/features/publish_article.feature @@ -60,11 +60,10 @@ Feature: publish article And I am on mariasilva's control panel And I follow "Manage Content" And I follow "New content" - And I should see "Text article with Textile markup language" - And I follow "Text article with Textile markup language" + And I should see "Text article" + And I follow "Text article" And I fill in the following: | Title | Sample Article | - | Text | this is Maria's first published article | And I press "Save" And I follow "Spread" And I type in "Sample Community" into autocomplete list "search-communities-to-publish" and I choose "Sample Community" diff --git a/features/search_contents.feature b/features/search_contents.feature index 986008c..960a520 100644 --- a/features/search_contents.feature +++ b/features/search_contents.feature @@ -22,7 +22,6 @@ Feature: search contents Then I should see "whales and dolphins" within ".search-text-article-item" And I should see "whales and dolphins" within ".only-one-result-box" And I should not see "bees and butterflies" - And The page should contain ".icon-content-textile-article" When I follow "whales and dolphins" Then I should be on article "whales and dolphins" diff --git a/features/secret_community.feature b/features/secret_community.feature index 34eeda1..d7d0f85 100644 --- a/features/secret_community.feature +++ b/features/secret_community.feature @@ -52,7 +52,7 @@ Feature: Use a secret community And I go to mycommunity's control panel And I follow "Manage Content" And I follow "New content" - And I follow "Text article with visual editor" + And I follow "Text article" And I fill in "Title" with "My public article" And I choose "Public" And I press "Save and continue" diff --git a/features/step_definitions/noosfero_steps.rb b/features/step_definitions/noosfero_steps.rb index 32a91bc..56f66e0 100644 --- a/features/step_definitions/noosfero_steps.rb +++ b/features/step_definitions/noosfero_steps.rb @@ -101,7 +101,7 @@ end Given /^the following (articles|events|blogs|folders|forums|galleries|uploaded files|rss feeds)$/ do |content, table| klass = { - 'articles' => TextileArticle, + 'articles' => TextArticle, 'events' => Event, 'blogs' => Blog, 'folders' => Folder, @@ -178,7 +178,7 @@ Given /^the following articles? with images?$/ do |table| img_tag = " owner, :name => item[:name], :body => img_tag) + article = TextArticle.new(:profile => owner, :name => item[:name], :body => img_tag) if item[:parent] article.parent = Article.find_by slug: item[:parent] end diff --git a/features/tiny_mce.feature b/features/tiny_mce.feature index e4320b4..03379f5 100644 --- a/features/tiny_mce.feature +++ b/features/tiny_mce.feature @@ -10,7 +10,7 @@ Feature: Create tinyMCE article @selenium Scenario: mce complete mode should show on message creation - Given I am on /myprofile/joaosilva/cms/new?type=TinyMceArticle + Given I am on /myprofile/joaosilva/cms/new?type=TextArticle Then The tinymce "toolbar1" should be "fullscreen | insertfile undo redo | copy paste | bold italic underline | styleselect fontsizeselect | forecolor backcolor | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | link image" And The tinymce "menubar" should be "edit insert view tools" And The tinymce "toolbar2" should contain "print preview code media | table" diff --git a/plugins/admin_notifications/views/shared/_form.html.erb b/plugins/admin_notifications/views/shared/_form.html.erb index 42596d0..b95b08a 100644 --- a/plugins/admin_notifications/views/shared/_form.html.erb +++ b/plugins/admin_notifications/views/shared/_form.html.erb @@ -1,13 +1,11 @@
- <% abstract_options = {:value => @notification.message, :style => 'width: 100%; height: 200px;', :class => 'mceEditor'} %> + <% abstract_options = {:value => @notification.message, :style => 'width: 100%; height: 200px;', :class => current_editor('restricted')} %> <%= button :back, _('Back'), :controller => 'admin_notifications_plugin_admin' %> <%= form_for :notifications do |f| %> - <%= render :file => 'shared/tiny_mce', :locals => {:mode => 'restricted'} %> - <%= labelled_form_field(_("Optional Title:"), f.text_field(:title, value: @notification.title)) %> <%= labelled_form_field(_("Enter your message here:"), f.text_area(:message, abstract_options)) %> diff --git a/plugins/comment_paragraph/lib/comment_paragraph_plugin/macros/allow_comment.rb b/plugins/comment_paragraph/lib/comment_paragraph_plugin/macros/allow_comment.rb index 1414591..284a407 100644 --- a/plugins/comment_paragraph/lib/comment_paragraph_plugin/macros/allow_comment.rb +++ b/plugins/comment_paragraph/lib/comment_paragraph_plugin/macros/allow_comment.rb @@ -1,5 +1,5 @@ class Application < Rails::Application - config.action_view.sanitized_allowed_attributes << 'data-macro-paragraph_uuid' + config.action_view.sanitized_allowed_attributes << 'data-macro-paragraph_uuid' unless config.action_view.sanitized_allowed_attributes.include?('data-macro-paragraph_uuid') end class CommentParagraphPlugin::AllowComment < Noosfero::Plugin::Macro diff --git a/plugins/comment_paragraph/test/unit/article_test.rb b/plugins/comment_paragraph/test/unit/article_test.rb index 0c81278..bf634f5 100644 --- a/plugins/comment_paragraph/test/unit/article_test.rb +++ b/plugins/comment_paragraph/test/unit/article_test.rb @@ -5,7 +5,7 @@ class ArticleTest < ActiveSupport::TestCase def setup @profile = fast_create(Community) - @article = fast_create(TinyMceArticle, :profile_id => profile.id) + @article = fast_create(TextArticle, :profile_id => profile.id) @environment = Environment.default @environment.enable_plugin(CommentParagraphPlugin) end diff --git a/plugins/comment_paragraph/test/unit/discussion_block_test.rb b/plugins/comment_paragraph/test/unit/discussion_block_test.rb index 035d067..769396f 100644 --- a/plugins/comment_paragraph/test/unit/discussion_block_test.rb +++ b/plugins/comment_paragraph/test/unit/discussion_block_test.rb @@ -74,7 +74,7 @@ class DiscussionBlockTest < ActiveSupport::TestCase b.save a1 = fast_create(CommentParagraphPlugin::Discussion, :profile_id => community.id) fast_create(Event, :profile_id => community.id) - fast_create(TinyMceArticle, :profile_id => community.id) + fast_create(TextArticle, :profile_id => community.id) a2 = fast_create(CommentParagraphPlugin::Discussion, :profile_id => community.id) assert_equivalent [a1, a2], b.discussions end @@ -183,7 +183,7 @@ class DiscussionBlockViewTest < ActionView::TestCase b.save a1 = fast_create(CommentParagraphPlugin::Discussion, :profile_id => community.id) fast_create(Event, :profile_id => community.id) - fast_create(TinyMceArticle, :profile_id => community.id) + fast_create(TextArticle, :profile_id => community.id) a2 = fast_create(CommentParagraphPlugin::Discussion, :profile_id => community.id) assert_equivalent [a2.id, a1.id], b.api_content['articles'].map {|a| a[:id]} end diff --git a/plugins/comment_paragraph/test/unit/tinymce_helper_test.rb b/plugins/comment_paragraph/test/unit/tinymce_helper_test.rb index c711702..ffa0fcd 100644 --- a/plugins/comment_paragraph/test/unit/tinymce_helper_test.rb +++ b/plugins/comment_paragraph/test/unit/tinymce_helper_test.rb @@ -7,6 +7,7 @@ class TinymceHelperTest < ActiveSupport::TestCase def setup expects(:top_url).returns('/') expects(:tinymce_language).returns('en') + expects(:current_editor).returns(Article::Editor::TINY_MCE) @plugins = mock @plugins.expects(:dispatch).returns([]).at_least_once @environment = Environment.default diff --git a/plugins/community_track/lib/community_track_plugin/step.rb b/plugins/community_track/lib/community_track_plugin/step.rb index 3848a4b..6a6e3aa 100644 --- a/plugins/community_track/lib/community_track_plugin/step.rb +++ b/plugins/community_track/lib/community_track_plugin/step.rb @@ -61,7 +61,7 @@ class CommunityTrackPlugin::Step < Folder end def enabled_tools - [TinyMceArticle, Forum] + [TextArticle, Forum] end def to_html(options = {}) diff --git a/plugins/community_track/test/functional/community_track_plugin_content_viewer_controller_test.rb b/plugins/community_track/test/functional/community_track_plugin_content_viewer_controller_test.rb index 7fea3b7..da0f891 100644 --- a/plugins/community_track/test/functional/community_track_plugin_content_viewer_controller_test.rb +++ b/plugins/community_track/test/functional/community_track_plugin_content_viewer_controller_test.rb @@ -5,7 +5,7 @@ class ContentViewerControllerTest < ActionController::TestCase def setup @profile = Community.create!(:name => 'Sample community', :identifier => 'sample-community') @track = create_track('track', @profile) - @step = CommunityTrackPlugin::Step.create!(:name => 'step1', :body => 'body', :profile => @profile, :parent => @track, :published => false, :end_date => DateTime.now.end_of_day, :start_date => DateTime.now.beginning_of_day, :tool_type => TinyMceArticle.name) + @step = CommunityTrackPlugin::Step.create!(:name => 'step1', :body => 'body', :profile => @profile, :parent => @track, :published => false, :end_date => DateTime.now.end_of_day, :start_date => DateTime.now.beginning_of_day, :tool_type => TextArticle.name) user = create_user('testinguser') login_as(user.login) @@ -49,7 +49,7 @@ class ContentViewerControllerTest < ActionController::TestCase end should 'show tools for a step' do - TinyMceArticle.create!(:profile => @profile, :name => 'article', :parent => @step) + TextArticle.create!(:profile => @profile, :name => 'article', :parent => @step) get :view_page, @step.url assert_tag :tag => 'div', :attributes => { :class => 'tools' }, :descendant => { :tag => 'div', :attributes => { :class => 'item' } } end diff --git a/plugins/community_track/test/unit/community_track_plugin/step_test.rb b/plugins/community_track/test/unit/community_track_plugin/step_test.rb index 4fe1949..df53587 100644 --- a/plugins/community_track/test/unit/community_track_plugin/step_test.rb +++ b/plugins/community_track/test/unit/community_track_plugin/step_test.rb @@ -235,7 +235,7 @@ class StepTest < ActiveSupport::TestCase end should 'return enabled tools for a step' do - assert_includes @step.enabled_tools, TinyMceArticle + assert_includes @step.enabled_tools, TextArticle assert_includes @step.enabled_tools, Forum end diff --git a/plugins/community_track/views/cms/community_track_plugin/_step.html.erb b/plugins/community_track/views/cms/community_track_plugin/_step.html.erb index df0b743..5b5ca7e 100644 --- a/plugins/community_track/views/cms/community_track_plugin/_step.html.erb +++ b/plugins/community_track/views/cms/community_track_plugin/_step.html.erb @@ -1,7 +1,5 @@ <%= required_fields_message %> -<%= render :file => 'shared/tiny_mce' %> -
<%= required f.text_field('name', :size => '64', :maxlength => 150) %> <%= labelled_form_field(_('Period'), ( @@ -19,4 +17,4 @@ <%= labelled_form_field check_box(:article, :hidden) + _('Hidden Step'), '' %> -<%= render :partial => 'shared/lead_and_body', :locals => {:tiny_mce => true, :body_label => 'Description:'} %> +<%= render :partial => 'shared/lead_and_body', :locals => {:body_label => 'Description:'} %> diff --git a/plugins/community_track/views/cms/community_track_plugin/_track.html.erb b/plugins/community_track/views/cms/community_track_plugin/_track.html.erb index 5d120e9..52f5a27 100644 --- a/plugins/community_track/views/cms/community_track_plugin/_track.html.erb +++ b/plugins/community_track/views/cms/community_track_plugin/_track.html.erb @@ -1,13 +1,11 @@
<%= required_fields_message %> - <%= render :file => 'shared/tiny_mce' %> -
<%= required labelled_form_field(c_('Title'), text_field(:article, 'name', :size => '64', :maxlength => 150)) %>
- <%= render :partial => 'shared/lead_and_body', :locals => {:tiny_mce => true, :body_label => 'Description:'} %> + <%= render :partial => 'shared/lead_and_body', :locals => {:body_label => 'Description:'} %>
<%= labelled_form_field(_('Goals:'), text_area(:article, :goals, :rows => 3, :cols => 64)) %> diff --git a/plugins/context_content/lib/context_content_plugin/context_content_block.rb b/plugins/context_content/lib/context_content_plugin/context_content_block.rb index 47298e7..850b829 100644 --- a/plugins/context_content/lib/context_content_plugin/context_content_block.rb +++ b/plugins/context_content/lib/context_content_plugin/context_content_block.rb @@ -22,7 +22,7 @@ class ContextContentPlugin::ContextContentBlock < Block end def available_content_types - @available_content_types ||= [UploadedFile, Event, TinyMceArticle, TextileArticle, RawHTMLArticle, Folder, Blog, Forum, Gallery, RssFeed] + plugins.dispatch(:content_types) + @available_content_types ||= [UploadedFile, Event, TextArticle, Folder, Blog, Forum, Gallery, RssFeed] + plugins.dispatch(:content_types) checked_types = types.map {|t| t.constantize} checked_types + (@available_content_types - checked_types) end diff --git a/plugins/context_content/test/functional/content_viewer_controller_test.rb b/plugins/context_content/test/functional/content_viewer_controller_test.rb index cf86475..450af2b 100644 --- a/plugins/context_content/test/functional/content_viewer_controller_test.rb +++ b/plugins/context_content/test/functional/content_viewer_controller_test.rb @@ -8,7 +8,7 @@ class ContentViewerControllerTest < ActionController::TestCase box = Box.create!(:owner => @profile) @block = ContextContentPlugin::ContextContentBlock.new(:box_id => box.id) - @block.types = ['TinyMceArticle'] + @block.types = ['TextArticle'] @block.limit = 1 @block.title = "New Context Block" @block.save! @@ -21,7 +21,7 @@ class ContentViewerControllerTest < ActionController::TestCase end should 'display context content block if it has contents' do - article = fast_create(TinyMceArticle, :parent_id => @page.id, :profile_id => @profile.id, :name => 'article1') + article = fast_create(TextArticle, :parent_id => @page.id, :profile_id => @profile.id, :name => 'article1') get :view_page, @page.url assert_tag 'div', :attributes => {:id => "context_content_#{@block.id}", :class => 'contents'} assert_no_tag 'div', :attributes => {:id => "context_content_more_#{@block.id}", :class => 'more_button'}, :descendant => {:tag => 'a'} @@ -31,7 +31,7 @@ class ContentViewerControllerTest < ActionController::TestCase should 'display context content block title if it is not configured to use_parent_title' do @block.use_parent_title = false @block.save - article = fast_create(TinyMceArticle, :parent_id => @page.id, :profile_id => @profile.id, :name => 'article1') + article = fast_create(TextArticle, :parent_id => @page.id, :profile_id => @profile.id, :name => 'article1') get :view_page, @page.url assert_tag 'h3', :attributes => {:class => 'block-title'}, :content => @block.title assert_no_tag 'h3', :attributes => {:class => 'block-title'}, :content => @page.name @@ -40,15 +40,15 @@ class ContentViewerControllerTest < ActionController::TestCase should 'display context content with folder title if it is configured to use_parent_title' do @block.use_parent_title = true @block.save - article = fast_create(TinyMceArticle, :parent_id => @page.id, :profile_id => @profile.id, :name => 'article1') + article = fast_create(TextArticle, :parent_id => @page.id, :profile_id => @profile.id, :name => 'article1') get :view_page, @page.url assert_tag 'h3', :attributes => {:class => 'block-title'}, :content => @page.name assert_no_tag 'h3', :attributes => {:class => 'block-title'}, :content => @block.title end should 'display context content block with pagination' do - article1 = fast_create(TinyMceArticle, :parent_id => @page.id, :profile_id => @profile.id) - article2 = fast_create(TinyMceArticle, :parent_id => @page.id, :profile_id => @profile.id) + article1 = fast_create(TextArticle, :parent_id => @page.id, :profile_id => @profile.id) + article2 = fast_create(TextArticle, :parent_id => @page.id, :profile_id => @profile.id) get :view_page, @page.url assert_tag 'div', :attributes => {:id => "context_content_#{@block.id}", :class => 'contents'} assert_tag 'div', :attributes => {:id => "context_content_more_#{@block.id}", :class => 'more_button'}, :descendant => {:tag => 'a', :attributes => {:class => 'button icon-button icon-left disabled'} } diff --git a/plugins/context_content/test/functional/context_content_plugin_profile_controller_test.rb b/plugins/context_content/test/functional/context_content_plugin_profile_controller_test.rb index 05e9e13..5cbc567 100644 --- a/plugins/context_content/test/functional/context_content_plugin_profile_controller_test.rb +++ b/plugins/context_content/test/functional/context_content_plugin_profile_controller_test.rb @@ -9,7 +9,7 @@ class ContextContentPluginProfileControllerTest < ActionController::TestCase box = create(Box, :owner_type => 'Profile', :owner_id => @profile.id) @block = ContextContentPlugin::ContextContentBlock.new @block.box = box - @block.types = ['TinyMceArticle'] + @block.types = ['TextArticle'] @block.limit = 1 owner = create_user('block-owner').person @block.box = owner.boxes.last @@ -23,14 +23,14 @@ class ContextContentPluginProfileControllerTest < ActionController::TestCase end should 'render error if page do not exists' do - article = fast_create(TinyMceArticle, :parent_id => @page.id, :profile_id => @profile.id) + article = fast_create(TextArticle, :parent_id => @page.id, :profile_id => @profile.id) xhr :get, :view_content, :id => @block.id, :article_id => @page.id, :page => 2, :profile => @profile.identifier assert_response 500 end should 'replace div with content for page passed as parameter' do - article1 = fast_create(TinyMceArticle, :parent_id => @page.id, :profile_id => @profile.id, :name => 'article1') - article2 = fast_create(TinyMceArticle, :parent_id => @page.id, :profile_id => @profile.id, :name => 'article2') + article1 = fast_create(TextArticle, :parent_id => @page.id, :profile_id => @profile.id, :name => 'article1') + article2 = fast_create(TextArticle, :parent_id => @page.id, :profile_id => @profile.id, :name => 'article2') xhr :get, :view_content, :id => @block.id, :article_id => @page.id, :page => 2, :profile => @profile.identifier assert_response :success assert_match /context_content_#{@block.id}/, @response.body @@ -39,7 +39,7 @@ class ContextContentPluginProfileControllerTest < ActionController::TestCase end should 'do not render pagination buttons if it has only one page' do - article1 = fast_create(TinyMceArticle, :parent_id => @page.id, :profile_id => @profile.id, :name => 'article1') + article1 = fast_create(TextArticle, :parent_id => @page.id, :profile_id => @profile.id, :name => 'article1') xhr :get, :view_content, :id => @block.id, :article_id => @page.id, :page => 2, :profile => @profile.identifier assert_no_match /context_content_more_#{@block.id}/, @response.body end diff --git a/plugins/context_content/test/functional/profile_design_controller_test.rb b/plugins/context_content/test/functional/profile_design_controller_test.rb index edc3d56..aa2eb88 100644 --- a/plugins/context_content/test/functional/profile_design_controller_test.rb +++ b/plugins/context_content/test/functional/profile_design_controller_test.rb @@ -13,7 +13,7 @@ class ProfileDesignControllerTest < ActionController::TestCase box = Box.create!(:owner => @profile) @block = ContextContentPlugin::ContextContentBlock.new(:box_id => box.id) - @block.types = ['TinyMceArticle'] + @block.types = ['TextArticle'] @block.limit = 1 @block.save! @@ -38,11 +38,11 @@ class ProfileDesignControllerTest < ActionController::TestCase @block.show_parent_content = false @block.save! get :edit, :id => @block.id, :profile => @profile.identifier - post :save, :id => @block.id, :block => {:title => 'context', :show_image => '0', :show_name => '0', :show_parent_content => '0', :types => ['TinyMceArticle', '', nil, 'Folder'] }, :profile => @profile.identifier + post :save, :id => @block.id, :block => {:title => 'context', :show_image => '0', :show_name => '0', :show_parent_content => '0', :types => ['TextArticle', '', nil, 'Folder'] }, :profile => @profile.identifier @block.reload assert_equal 'context', @block.title refute @block.show_image && !@block.show_name && !@block.show_parent_content - assert_equal ['TinyMceArticle', 'Folder'], @block.types + assert_equal ['TextArticle', 'Folder'], @block.types end end diff --git a/plugins/context_content/test/unit/context_content_block_test.rb b/plugins/context_content/test/unit/context_content_block_test.rb index e598929..13fa04f 100644 --- a/plugins/context_content/test/unit/context_content_block_test.rb +++ b/plugins/context_content/test/unit/context_content_block_test.rb @@ -5,7 +5,7 @@ class ContextContentBlockTest < ActiveSupport::TestCase def setup Noosfero::Plugin::Manager.any_instance.stubs(:enabled_plugins).returns([]) @block = ContextContentPlugin::ContextContentBlock.create! - @block.types = ['TinyMceArticle'] + @block.types = ['TextArticle'] end should 'describe itself' do @@ -22,13 +22,13 @@ class ContextContentBlockTest < ActiveSupport::TestCase should 'return children of page' do folder = fast_create(Folder) - article = fast_create(TinyMceArticle, :parent_id => folder.id) + article = fast_create(TextArticle, :parent_id => folder.id) assert_equal [article], @block.contents(folder) end should 'return parent name of the contents' do folder = fast_create(Folder, :name => " New Folder") - article = fast_create(TinyMceArticle, :parent_id => folder.id) + article = fast_create(TextArticle, :parent_id => folder.id) assert_equal folder.name, @block.parent_title([article]) end @@ -39,40 +39,40 @@ class ContextContentBlockTest < ActiveSupport::TestCase should 'limit number of children to display' do @block.limit = 2 folder = fast_create(Folder) - article1 = fast_create(TinyMceArticle, :parent_id => folder.id) - article2 = fast_create(TinyMceArticle, :parent_id => folder.id) - article3 = fast_create(TinyMceArticle, :parent_id => folder.id) + article1 = fast_create(TextArticle, :parent_id => folder.id) + article2 = fast_create(TextArticle, :parent_id => folder.id) + article3 = fast_create(TextArticle, :parent_id => folder.id) assert_equal 2, @block.contents(folder).length end should 'show contents for next page' do @block.limit = 2 folder = fast_create(Folder) - article1 = fast_create(TinyMceArticle, :name => 'article 1', :parent_id => folder.id) - article2 = fast_create(TinyMceArticle, :name => 'article 2', :parent_id => folder.id) - article3 = fast_create(TinyMceArticle, :name => 'article 3', :parent_id => folder.id) + article1 = fast_create(TextArticle, :name => 'article 1', :parent_id => folder.id) + article2 = fast_create(TextArticle, :name => 'article 2', :parent_id => folder.id) + article3 = fast_create(TextArticle, :name => 'article 3', :parent_id => folder.id) assert_equal [article3], @block.contents(folder, 2) end should 'show parent contents for next page' do @block.limit = 2 folder = fast_create(Folder) - article1 = fast_create(TinyMceArticle, :name => 'article 1', :parent_id => folder.id) - article2 = fast_create(TinyMceArticle, :name => 'article 2', :parent_id => folder.id) - article3 = fast_create(TinyMceArticle, :name => 'article 3', :parent_id => folder.id) + article1 = fast_create(TextArticle, :name => 'article 1', :parent_id => folder.id) + article2 = fast_create(TextArticle, :name => 'article 2', :parent_id => folder.id) + article3 = fast_create(TextArticle, :name => 'article 3', :parent_id => folder.id) assert_equal [article3], @block.contents(article1, 2) end should 'return parent children if page has no children' do folder = fast_create(Folder) - article = fast_create(TinyMceArticle, :parent_id => folder.id) + article = fast_create(TextArticle, :parent_id => folder.id) assert_equal [article], @block.contents(article) end should 'do not return parent children if show_parent_content is false' do @block.show_parent_content = false folder = fast_create(Folder) - article = fast_create(TinyMceArticle, :parent_id => folder.id) + article = fast_create(TextArticle, :parent_id => folder.id) assert_equal [], @block.contents(article) end @@ -82,13 +82,13 @@ class ContextContentBlockTest < ActiveSupport::TestCase end should 'return available content types with checked types first' do - @block.types = ['TinyMceArticle', 'Folder'] - assert_equal [TinyMceArticle, Folder, UploadedFile, Event, TextileArticle, RawHTMLArticle, Blog, Forum, Gallery, RssFeed], @block.available_content_types + @block.types = ['TextArticle', 'Folder'] + assert_equal [TextArticle, Folder, UploadedFile, Event, Blog, Forum, Gallery, RssFeed], @block.available_content_types end should 'return available content types' do @block.types = [] - assert_equal [UploadedFile, Event, TinyMceArticle, TextileArticle, RawHTMLArticle, Folder, Blog, Forum, Gallery, RssFeed], @block.available_content_types + assert_equal [UploadedFile, Event, TextArticle, Folder, Blog, Forum, Gallery, RssFeed], @block.available_content_types end should 'return first 2 content types' do @@ -120,7 +120,7 @@ class ContextContentBlockTest < ActiveSupport::TestCase Noosfero::Plugin::Manager.any_instance.stubs(:enabled_plugins).returns([SomePlugin.new]) @block.types = [] - assert_equal [UploadedFile, Event, TinyMceArticle, TextileArticle, RawHTMLArticle, Folder, Blog, Forum, Gallery, RssFeed, SomePluginContent], @block.available_content_types + assert_equal [UploadedFile, Event, TextArticle, Folder, Blog, Forum, Gallery, RssFeed, SomePluginContent], @block.available_content_types end should 'return box owner on profile method call' do @@ -144,7 +144,7 @@ class ContextContentBlockViewTest < ActionView::TestCase def setup Noosfero::Plugin::Manager.any_instance.stubs(:enabled_plugins).returns([]) @block = ContextContentPlugin::ContextContentBlock.create! - @block.types = ['TinyMceArticle'] + @block.types = ['TextArticle'] end should 'render nothing if it has no content to show' do @@ -153,7 +153,7 @@ class ContextContentBlockViewTest < ActionView::TestCase should 'render context content block view' do @page = fast_create(Folder) - article = fast_create(TinyMceArticle, :parent_id => @page.id) + article = fast_create(TextArticle, :parent_id => @page.id) contents = [article] @block.use_parent_title = true @@ -178,9 +178,9 @@ class ContextContentBlockViewTest < ActionView::TestCase should 'display pagination links if it has more than one page' do @block.limit = 2 @page = fast_create(Folder) - article1 = fast_create(TinyMceArticle, :parent_id => @page.id) - article2 = fast_create(TinyMceArticle, :parent_id => @page.id) - article3 = fast_create(TinyMceArticle, :parent_id => @page.id) + article1 = fast_create(TextArticle, :parent_id => @page.id) + article2 = fast_create(TextArticle, :parent_id => @page.id) + article3 = fast_create(TextArticle, :parent_id => @page.id) contents = [article1, article2, article3] contents.each do |article| article.expects(:view_url).returns('http://test.noosfero.plugins') diff --git a/plugins/custom_forms/test/functional/custom_forms_plugin_myprofile_controller_test.rb b/plugins/custom_forms/test/functional/custom_forms_plugin_myprofile_controller_test.rb index dc966ea..799da6d 100644 --- a/plugins/custom_forms/test/functional/custom_forms_plugin_myprofile_controller_test.rb +++ b/plugins/custom_forms/test/functional/custom_forms_plugin_myprofile_controller_test.rb @@ -180,8 +180,9 @@ class CustomFormsPluginMyprofileControllerTest < ActionController::TestCase form = CustomFormsPlugin::Form.create!(:profile => profile, :name => 'Free Software') get :edit, :profile => profile.identifier, :id => form.id + expects(:current_editor).returns(Article::Editor::TINY_MCE) - assert_tag :tag => 'textarea', :attributes => { :id => 'form_description', :class => 'mceEditor' } + assert_tag :tag => 'textarea', :attributes => { :id => 'form_description', :class => /#{current_editor}/ } end should 'export submissions as csv' do diff --git a/plugins/custom_forms/views/custom_forms_plugin_myprofile/_form.html.erb b/plugins/custom_forms/views/custom_forms_plugin_myprofile/_form.html.erb index bc6dddd..2d8a86d 100644 --- a/plugins/custom_forms/views/custom_forms_plugin_myprofile/_form.html.erb +++ b/plugins/custom_forms/views/custom_forms_plugin_myprofile/_form.html.erb @@ -1,5 +1,4 @@ <% self.extend(CustomFormsPlugin::Helper) %> -<%= render :file => 'shared/tiny_mce', :locals => {:mode => 'simple'} %> <%= error_messages_for :form %> <%= required labelled_form_field _('Name'), f.text_field(:name) %> @@ -17,7 +16,7 @@ <%= labelled_check_box _('Triggered after membership'), 'form[on_membership]', '1', @form.on_membership %>

<% end %> -<%= labelled_form_field c_('Description'), f.text_area(:description, :style => 'width: 100%', :class => 'mceEditor') %> +<%= labelled_form_field c_('Description'), f.text_area(:description, :style => 'width: 100%', :class => current_editor('simple')) %>

<%= c_('Fields') %>

diff --git a/plugins/delivery/views/delivery_plugin/admin_method/_edit.html.slim b/plugins/delivery/views/delivery_plugin/admin_method/_edit.html.slim index a1f5b24..9a14d56 100644 --- a/plugins/delivery/views/delivery_plugin/admin_method/_edit.html.slim +++ b/plugins/delivery/views/delivery_plugin/admin_method/_edit.html.slim @@ -12,7 +12,7 @@ = labelled_field f, :name, t('delivery_plugin.models.method.name'), f.text_field(:name), help: t('delivery_plugin.models.method.name_help') = labelled_field f, :description, t('delivery_plugin.models.method.instructions'), - f.text_area(:description, rows: 5, class: 'mceEditor'), help: t('delivery_plugin.models.method.instructions_help') + f.text_area(:description, rows: 5, class: current_editor('simple')), help: t('delivery_plugin.models.method.instructions_help') fieldset legend= t'delivery_plugin.models.method.costs_legend' @@ -34,5 +34,3 @@ = submit_button :save, if delivery_method.new_record? then t('delivery_plugin.views.method.edit.add') else t('delivery_plugin.views.method.edit.save') end = link_to_function t('delivery_plugin.views.method.edit.back'), "delivery.method.view.toggle()" -= render file: 'shared/tiny_mce', locals: {mode: 'simple'} - diff --git a/plugins/display_content/lib/display_content_block.rb b/plugins/display_content/lib/display_content_block.rb index 6a76499..3e9c72c 100644 --- a/plugins/display_content/lib/display_content_block.rb +++ b/plugins/display_content/lib/display_content_block.rb @@ -24,7 +24,7 @@ class DisplayContentBlock < Block {:value => 'title', :checked => true}, {:value => 'abstract', :checked => true}] settings_items :display_folder_children, :type => :boolean, :default => true - settings_items :types, :type => Array, :default => ['TextileArticle', 'TinyMceArticle', 'RawHTMLArticle'] + settings_items :types, :type => Array, :default => ['TextArticle'] settings_items :order_by_recent, :type => :boolean, :default => :true settings_items :content_with_translations, :type => :boolean, :default => :true settings_items :limit_to_show, :type => :integer, :default => 6 @@ -61,7 +61,7 @@ class DisplayContentBlock < Block end def available_content_types - @available_content_types ||= [TinyMceArticle, RawHTMLArticle, TextileArticle, UploadedFile, Event, Folder, Blog, Forum, Gallery, RssFeed] + plugins.dispatch(:content_types) + @available_content_types ||= [TextArticle, UploadedFile, Event, Folder, Blog, Forum, Gallery, RssFeed] + plugins.dispatch(:content_types) checked_types = types.map {|t| t.constantize} checked_types + (@available_content_types - checked_types) end @@ -108,7 +108,7 @@ class DisplayContentBlock < Block @parent_nodes ||= self.holder.articles.where(:id => nodes).map { |article| get_parent(article) }.compact.flatten end - VALID_CONTENT = ['RawHTMLArticle', 'TextArticle', 'TextileArticle', 'TinyMceArticle', 'Folder', 'Blog', 'Forum'] + VALID_CONTENT = ['TextArticle', 'Folder', 'Blog', 'Forum'] include Noosfero::Plugin::HotSpot diff --git a/plugins/display_content/test/functional/display_content_plugin_admin_controller_test.rb b/plugins/display_content/test/functional/display_content_plugin_admin_controller_test.rb index adf2a3b..18b0c78 100644 --- a/plugins/display_content/test/functional/display_content_plugin_admin_controller_test.rb +++ b/plugins/display_content/test/functional/display_content_plugin_admin_controller_test.rb @@ -39,7 +39,7 @@ class DisplayContentPluginAdminControllerTest < ActionController::TestCase should 'index action returns an json with node content' do Article.delete_all - article = fast_create(TextileArticle, :name => 'test article 1', :profile_id => environment.portal_community.id) + article = fast_create(TextArticle, :name => 'test article 1', :profile_id => environment.portal_community.id) get :index, :block_id => block.id json_response = ActiveSupport::JSON.decode(@response.body) @@ -51,7 +51,7 @@ class DisplayContentPluginAdminControllerTest < ActionController::TestCase should 'index action returns an json with node checked if the node is in the nodes list' do Article.delete_all - article = fast_create(TextileArticle, :name => 'test article 1', :profile_id => environment.portal_community.id) + article = fast_create(TextArticle, :name => 'test article 1', :profile_id => environment.portal_community.id) block.nodes= [article.id] block.save! @@ -67,8 +67,8 @@ class DisplayContentPluginAdminControllerTest < ActionController::TestCase should 'index action returns an json with node undetermined if the node is in the parent nodes list' do Article.delete_all f = fast_create(Folder, :name => 'test folder 1', :profile_id => environment.portal_community.id) - article = fast_create(TextileArticle, :name => 'test article 1', :profile_id => environment.portal_community.id, :parent_id => f.id) - article2 = fast_create(TextileArticle, :name => 'test article 2', :profile_id => environment.portal_community.id, :parent_id => f.id) + article = fast_create(TextArticle, :name => 'test article 1', :profile_id => environment.portal_community.id, :parent_id => f.id) + article2 = fast_create(TextArticle, :name => 'test article 2', :profile_id => environment.portal_community.id, :parent_id => f.id) block.nodes = [article.id] block.save! @@ -81,7 +81,7 @@ class DisplayContentPluginAdminControllerTest < ActionController::TestCase should 'index action returns an json with node closed if the node has article with children' do Article.delete_all f = fast_create(Folder, :name => 'test folder 1', :profile_id => environment.portal_community.id) - article = fast_create(TextileArticle, :name => 'test article 1', :profile_id => environment.portal_community.id, :parent_id => f.id) + article = fast_create(TextArticle, :name => 'test article 1', :profile_id => environment.portal_community.id, :parent_id => f.id) get :index, :block_id => block.id json_response = ActiveSupport::JSON.decode(@response.body) @@ -95,8 +95,8 @@ class DisplayContentPluginAdminControllerTest < ActionController::TestCase should 'index action returns an json with all the children nodes if some parent is in the parents list' do Article.delete_all f = fast_create(Folder, :name => 'test folder 1', :profile_id => environment.portal_community.id) - a1 = fast_create(TextileArticle, :name => 'test article 1', :profile_id => environment.portal_community.id, :parent_id => f.id) - a2 = fast_create(TextileArticle, :name => 'test article 2', :profile_id => environment.portal_community.id, :parent_id => f.id) + a1 = fast_create(TextArticle, :name => 'test article 1', :profile_id => environment.portal_community.id, :parent_id => f.id) + a2 = fast_create(TextArticle, :name => 'test article 2', :profile_id => environment.portal_community.id, :parent_id => f.id) block.checked_nodes= {a1.id => true} block.save! @@ -118,9 +118,9 @@ class DisplayContentPluginAdminControllerTest < ActionController::TestCase should 'index action returns an json with all the children nodes and root nodes if some parent is in the parents list and there is others root articles' do Article.delete_all f = fast_create(Folder, :name => 'test folder 1', :profile_id => environment.portal_community.id) - a1 = fast_create(TextileArticle, :name => 'test article 1', :profile_id => environment.portal_community.id, :parent_id => f.id) - a2 = fast_create(TextileArticle, :name => 'test article 2', :profile_id => environment.portal_community.id, :parent_id => f.id) - a3 = fast_create(TextileArticle, :name => 'test article 3', :profile_id => environment.portal_community.id) + a1 = fast_create(TextArticle, :name => 'test article 1', :profile_id => environment.portal_community.id, :parent_id => f.id) + a2 = fast_create(TextArticle, :name => 'test article 2', :profile_id => environment.portal_community.id, :parent_id => f.id) + a3 = fast_create(TextArticle, :name => 'test article 3', :profile_id => environment.portal_community.id) block.checked_nodes= {a2.id => true, a3.id => true} block.save! @@ -148,9 +148,9 @@ class DisplayContentPluginAdminControllerTest < ActionController::TestCase should 'index action returns an json without children nodes if the parent is not in the parents list' do Article.delete_all f = fast_create(Folder, :name => 'test folder 1', :profile_id => environment.portal_community.id) - a1 = fast_create(TextileArticle, :name => 'test article 1', :profile_id => environment.portal_community.id, :parent_id => f.id) - a2 = fast_create(TextileArticle, :name => 'test article 2', :profile_id => environment.portal_community.id, :parent_id => f.id) - a3 = fast_create(TextileArticle, :name => 'test article 3', :profile_id => environment.portal_community.id) + a1 = fast_create(TextArticle, :name => 'test article 1', :profile_id => environment.portal_community.id, :parent_id => f.id) + a2 = fast_create(TextArticle, :name => 'test article 2', :profile_id => environment.portal_community.id, :parent_id => f.id) + a3 = fast_create(TextArticle, :name => 'test article 3', :profile_id => environment.portal_community.id) get :index, :block_id => block.id json_response = ActiveSupport::JSON.decode(@response.body) diff --git a/plugins/display_content/test/functional/display_content_plugin_myprofile_controller_test.rb b/plugins/display_content/test/functional/display_content_plugin_myprofile_controller_test.rb index e7cbbeb..c963712 100644 --- a/plugins/display_content/test/functional/display_content_plugin_myprofile_controller_test.rb +++ b/plugins/display_content/test/functional/display_content_plugin_myprofile_controller_test.rb @@ -40,7 +40,7 @@ class DisplayContentPluginMyprofileControllerTest < ActionController::TestCase should 'index action returns an json with node content' do Article.delete_all - article = fast_create(TextileArticle, :name => 'test article 1', :profile_id => profile.id) + article = fast_create(TextArticle, :name => 'test article 1', :profile_id => profile.id) get :index, :block_id => block.id, :profile => profile.identifier json_response = ActiveSupport::JSON.decode(@response.body) @@ -52,7 +52,7 @@ class DisplayContentPluginMyprofileControllerTest < ActionController::TestCase should 'index action returns an json with node checked if the node is in the nodes list' do Article.delete_all - article = fast_create(TextileArticle, :name => 'test article 1', :profile_id => profile.id) + article = fast_create(TextArticle, :name => 'test article 1', :profile_id => profile.id) block.nodes= [article.id] block.save! @@ -68,8 +68,8 @@ class DisplayContentPluginMyprofileControllerTest < ActionController::TestCase should 'index action returns an json with node undetermined if the node is in the parent nodes list' do Article.delete_all f = fast_create(Folder, :name => 'test folder 1', :profile_id => profile.id) - article = fast_create(TextileArticle, :name => 'test article 1', :profile_id => profile.id, :parent_id => f.id) - article2 = fast_create(TextileArticle, :name => 'test article 2', :profile_id => profile.id, :parent_id => f.id) + article = fast_create(TextArticle, :name => 'test article 1', :profile_id => profile.id, :parent_id => f.id) + article2 = fast_create(TextArticle, :name => 'test article 2', :profile_id => profile.id, :parent_id => f.id) block.nodes = [article.id] block.save! @@ -82,7 +82,7 @@ class DisplayContentPluginMyprofileControllerTest < ActionController::TestCase should 'index action returns an json with node closed if the node has article with children' do Article.delete_all f = fast_create(Folder, :name => 'test folder 1', :profile_id => profile.id) - article = fast_create(TextileArticle, :name => 'test article 1', :profile_id => profile.id, :parent_id => f.id) + article = fast_create(TextArticle, :name => 'test article 1', :profile_id => profile.id, :parent_id => f.id) block.save! get :index, :block_id => block.id, :profile => profile.identifier @@ -97,8 +97,8 @@ class DisplayContentPluginMyprofileControllerTest < ActionController::TestCase should 'index action returns an json with all the children nodes if some parent is in the parents list' do Article.delete_all f = fast_create(Folder, :name => 'test folder 1', :profile_id => profile.id) - a1 = fast_create(TextileArticle, :name => 'test article 1', :profile_id => profile.id, :parent_id => f.id) - a2 = fast_create(TextileArticle, :name => 'test article 2', :profile_id => profile.id, :parent_id => f.id) + a1 = fast_create(TextArticle, :name => 'test article 1', :profile_id => profile.id, :parent_id => f.id) + a2 = fast_create(TextArticle, :name => 'test article 2', :profile_id => profile.id, :parent_id => f.id) block.checked_nodes = {a1.id => true} block.save! @@ -120,9 +120,9 @@ class DisplayContentPluginMyprofileControllerTest < ActionController::TestCase should 'index action returns an json with all the children nodes and root nodes if some parent is in the parents list and there is others root articles' do Article.delete_all f = fast_create(Folder, :name => 'test folder 1', :profile_id => profile.id) - a1 = fast_create(TextileArticle, :name => 'test article 1', :profile_id => profile.id, :parent_id => f.id) - a2 = fast_create(TextileArticle, :name => 'test article 2', :profile_id => profile.id, :parent_id => f.id) - a3 = fast_create(TextileArticle, :name => 'test article 3', :profile_id => profile.id) + a1 = fast_create(TextArticle, :name => 'test article 1', :profile_id => profile.id, :parent_id => f.id) + a2 = fast_create(TextArticle, :name => 'test article 2', :profile_id => profile.id, :parent_id => f.id) + a3 = fast_create(TextArticle, :name => 'test article 3', :profile_id => profile.id) block.checked_nodes = {a1.id => true} block.save! @@ -150,9 +150,9 @@ class DisplayContentPluginMyprofileControllerTest < ActionController::TestCase should 'index action returns an json without children nodes if the parent is not in the parents list' do Article.delete_all f = fast_create(Folder, :name => 'test folder 1', :profile_id => profile.id) - a1 = fast_create(TextileArticle, :name => 'test article 1', :profile_id => profile.id, :parent_id => f.id) - a2 = fast_create(TextileArticle, :name => 'test article 2', :profile_id => profile.id, :parent_id => f.id) - a3 = fast_create(TextileArticle, :name => 'test article 3', :profile_id => profile.id) + a1 = fast_create(TextArticle, :name => 'test article 1', :profile_id => profile.id, :parent_id => f.id) + a2 = fast_create(TextArticle, :name => 'test article 2', :profile_id => profile.id, :parent_id => f.id) + a3 = fast_create(TextArticle, :name => 'test article 3', :profile_id => profile.id) get :index, :block_id => block.id, :profile => profile.identifier json_response = ActiveSupport::JSON.decode(@response.body) diff --git a/plugins/display_content/test/unit/display_content_block_test.rb b/plugins/display_content/test/unit/display_content_block_test.rb index 4a73a96..bd4849b 100644 --- a/plugins/display_content/test/unit/display_content_block_test.rb +++ b/plugins/display_content/test/unit/display_content_block_test.rb @@ -2,7 +2,7 @@ require_relative '../test_helper' class DisplayContentBlockTest < ActiveSupport::TestCase INVALID_KIND_OF_ARTICLE = [Event, RssFeed, UploadedFile, Gallery] - VALID_KIND_OF_ARTICLE = [RawHTMLArticle, TextArticle, TextileArticle, TinyMceArticle, Folder, Blog, Forum] + VALID_KIND_OF_ARTICLE = [TextArticle, Folder, Blog, Forum] should 'describe itself' do assert_not_equal Block.description, DisplayContentBlock.description @@ -39,9 +39,9 @@ class DisplayContentBlockTest < ActiveSupport::TestCase should 'nodes be the article ids in hash of checked nodes' do profile = create_user('testuser').person Article.delete_all - a1 = fast_create(TextileArticle, :name => 'test article 1', :profile_id => profile.id) - a2 = fast_create(TextileArticle, :name => 'test article 2', :profile_id => profile.id) - a3 = fast_create(TextileArticle, :name => 'test article 3', :profile_id => profile.id) + a1 = fast_create(TextArticle, :name => 'test article 1', :profile_id => profile.id) + a2 = fast_create(TextArticle, :name => 'test article 2', :profile_id => profile.id) + a3 = fast_create(TextArticle, :name => 'test article 3', :profile_id => profile.id) checked_articles= {a1.id => true, a2.id => true, a3.id => false} block = DisplayContentBlock.new @@ -54,9 +54,9 @@ class DisplayContentBlockTest < ActiveSupport::TestCase should 'nodes be save in database' do profile = create_user('testuser').person Article.delete_all - a1 = fast_create(TextileArticle, :name => 'test article 1', :profile_id => profile.id) - a2 = fast_create(TextileArticle, :name => 'test article 2', :profile_id => profile.id) - a3 = fast_create(TextileArticle, :name => 'test article 3', :profile_id => profile.id) + a1 = fast_create(TextArticle, :name => 'test article 1', :profile_id => profile.id) + a2 = fast_create(TextArticle, :name => 'test article 2', :profile_id => profile.id) + a3 = fast_create(TextArticle, :name => 'test article 3', :profile_id => profile.id) checked_articles= {a1.id => true, a2.id => true, a3.id => false} block = DisplayContentBlock.new @@ -71,10 +71,10 @@ class DisplayContentBlockTest < ActiveSupport::TestCase should 'be able to update nodes' do profile = create_user('testuser').person Article.delete_all - a1 = fast_create(TextileArticle, :name => 'test article 1', :profile_id => profile.id) - a2 = fast_create(TextileArticle, :name => 'test article 2', :profile_id => profile.id) - a3 = fast_create(TextileArticle, :name => 'test article 3', :profile_id => profile.id) - a4 = fast_create(TextileArticle, :name => 'test article 4', :profile_id => profile.id) + a1 = fast_create(TextArticle, :name => 'test article 1', :profile_id => profile.id) + a2 = fast_create(TextArticle, :name => 'test article 2', :profile_id => profile.id) + a3 = fast_create(TextArticle, :name => 'test article 3', :profile_id => profile.id) + a4 = fast_create(TextArticle, :name => 'test article 4', :profile_id => profile.id) checked_articles= {a1.id => true, a2.id => true, a3.id => false} block = DisplayContentBlock.new @@ -95,13 +95,13 @@ class DisplayContentBlockTest < ActiveSupport::TestCase should "save selected folders and articles" do profile = create_user('testuser').person Article.delete_all - a1 = fast_create(TextileArticle, :name => 'test article 1', :profile_id => profile.id) - a2 = fast_create(TextileArticle, :name => 'test article 2', :profile_id => profile.id) + a1 = fast_create(TextArticle, :name => 'test article 1', :profile_id => profile.id) + a2 = fast_create(TextArticle, :name => 'test article 2', :profile_id => profile.id) f1 = fast_create(Folder, :name => 'test folder 1', :profile_id => profile.id) - a3 = fast_create(TextileArticle, :name => 'test article 3', :profile_id => profile.id, :parent_id => f1.id) + a3 = fast_create(TextArticle, :name => 'test article 3', :profile_id => profile.id, :parent_id => f1.id) f2 = fast_create(Folder, :name => 'test folder 1', :profile_id => profile.id, :parent_id => f1.id) - a4 = fast_create(TextileArticle, :name => 'test article 4', :profile_id => profile.id, :parent_id => f2.id) - a5 = fast_create(TextileArticle, :name => 'test article 5', :profile_id => profile.id, :parent_id => f2.id) + a4 = fast_create(TextArticle, :name => 'test article 4', :profile_id => profile.id, :parent_id => f2.id) + a5 = fast_create(TextArticle, :name => 'test article 5', :profile_id => profile.id, :parent_id => f2.id) checked_articles= {a1.id => true, a2.id => true, f1.id => false} @@ -115,13 +115,13 @@ class DisplayContentBlockTest < ActiveSupport::TestCase should "save selected articles and blogs" do profile = create_user('testuser').person Article.delete_all - a1 = fast_create(TextileArticle, :name => 'test article 1', :profile_id => profile.id) - a2 = fast_create(TextileArticle, :name => 'test article 2', :profile_id => profile.id) + a1 = fast_create(TextArticle, :name => 'test article 1', :profile_id => profile.id) + a2 = fast_create(TextArticle, :name => 'test article 2', :profile_id => profile.id) b1 = fast_create(Blog, :name => 'test blog 1', :profile_id => profile.id) - a3 = fast_create(TextileArticle, :name => 'test article 3', :profile_id => profile.id, :parent_id => b1.id) + a3 = fast_create(TextArticle, :name => 'test article 3', :profile_id => profile.id, :parent_id => b1.id) b2 = fast_create(Blog, :name => 'test blog 2', :profile_id => profile.id) - a4 = fast_create(TextileArticle, :name => 'test article 4', :profile_id => profile.id, :parent_id => b2.id) - a5 = fast_create(TextileArticle, :name => 'test article 5', :profile_id => profile.id, :parent_id => b2.id) + a4 = fast_create(TextArticle, :name => 'test article 4', :profile_id => profile.id, :parent_id => b2.id) + a5 = fast_create(TextArticle, :name => 'test article 5', :profile_id => profile.id, :parent_id => b2.id) checked_articles= {a1.id => true, a2.id => true, b1.id => false, b2.id => true} @@ -132,36 +132,10 @@ class DisplayContentBlockTest < ActiveSupport::TestCase assert_equivalent [a1.id, a2.id, b1.id, b2.id], block.nodes end - should 'TextileArticle be saved as node' do + should 'TextArticle be saved as node' do profile = create_user('testuser').person Article.delete_all - a1 = fast_create(TextileArticle, :name => 'test article 1', :profile_id => profile.id) - - checked_articles= {a1.id => true} - block = DisplayContentBlock.new - block.stubs(:holder).returns(profile) - block.checked_nodes= checked_articles - assert_equal [], [a1.id] - block.nodes - assert_equal [], block.nodes - [a1.id] - end - - should 'TinyMceArticle be saved as node' do - profile = create_user('testuser').person - Article.delete_all - a1 = fast_create(TinyMceArticle, :name => 'test article 1', :profile_id => profile.id) - - checked_articles= {a1.id => true} - block = DisplayContentBlock.new - block.stubs(:holder).returns(profile) - block.checked_nodes= checked_articles - assert_equal [], [a1.id] - block.nodes - assert_equal [], block.nodes - [a1.id] - end - - should 'RawHTMLArticle be saved as node' do - profile = create_user('testuser').person - Article.delete_all - a1 = fast_create(RawHTMLArticle, :name => 'test article 1', :profile_id => profile.id) + a1 = fast_create(TextArticle, :name => 'test article 1', :profile_id => profile.id) checked_articles= {a1.id => true} block = DisplayContentBlock.new @@ -230,9 +204,9 @@ class DisplayContentBlockTest < ActiveSupport::TestCase should "return all root articles from profile" do profile = create_user('testuser').person Article.delete_all - a1 = fast_create(TextileArticle, :name => 'test article 1', :profile_id => profile.id) - a2 = fast_create(TextileArticle, :name => 'test article 2', :profile_id => profile.id) - a3 = fast_create(TextileArticle, :name => 'test article 3', :profile_id => profile.id, :parent_id => a2.id) + a1 = fast_create(TextArticle, :name => 'test article 1', :profile_id => profile.id) + a2 = fast_create(TextArticle, :name => 'test article 2', :profile_id => profile.id) + a3 = fast_create(TextArticle, :name => 'test article 3', :profile_id => profile.id, :parent_id => a2.id) block = DisplayContentBlock.new block.nodes= [a1.id, a2.id, a3.id] @@ -247,9 +221,9 @@ class DisplayContentBlockTest < ActiveSupport::TestCase should "return all children of an articles's profile" do profile = create_user('testuser').person Article.delete_all - a1 = fast_create(TextileArticle, :name => 'test article 1', :profile_id => profile.id) - a2 = fast_create(TextileArticle, :name => 'test article 2', :profile_id => profile.id) - a3 = fast_create(TextileArticle, :name => 'test article 3', :profile_id => profile.id, :parent_id => a2.id) + a1 = fast_create(TextArticle, :name => 'test article 1', :profile_id => profile.id) + a2 = fast_create(TextArticle, :name => 'test article 2', :profile_id => profile.id) + a3 = fast_create(TextArticle, :name => 'test article 3', :profile_id => profile.id, :parent_id => a2.id) block = DisplayContentBlock.new box = mock() @@ -264,9 +238,9 @@ class DisplayContentBlockTest < ActiveSupport::TestCase profile = fast_create(Community, :name => 'my test community', :identifier => 'mytestcommunity') environment = Environment.default Article.delete_all - a1 = fast_create(TextileArticle, :name => 'test article 1', :profile_id => profile.id) - a2 = fast_create(TextileArticle, :name => 'test article 2', :profile_id => profile.id) - a3 = fast_create(TextileArticle, :name => 'test article 3', :profile_id => profile.id, :parent_id => a2.id) + a1 = fast_create(TextArticle, :name => 'test article 1', :profile_id => profile.id) + a2 = fast_create(TextArticle, :name => 'test article 2', :profile_id => profile.id) + a3 = fast_create(TextArticle, :name => 'test article 3', :profile_id => profile.id, :parent_id => a2.id) block = DisplayContentBlock.new box = mock() @@ -283,9 +257,9 @@ class DisplayContentBlockTest < ActiveSupport::TestCase profile = fast_create(Community, :name => 'my test community', :identifier => 'mytestcommunity') environment = Environment.default Article.delete_all - a1 = fast_create(TextileArticle, :name => 'test article 1', :profile_id => profile.id) - a2 = fast_create(TextileArticle, :name => 'test article 2', :profile_id => profile.id) - a3 = fast_create(TextileArticle, :name => 'test article 3', :profile_id => profile.id, :parent_id => a2.id) + a1 = fast_create(TextArticle, :name => 'test article 1', :profile_id => profile.id) + a2 = fast_create(TextArticle, :name => 'test article 2', :profile_id => profile.id) + a3 = fast_create(TextArticle, :name => 'test article 3', :profile_id => profile.id, :parent_id => a2.id) block = DisplayContentBlock.new box = mock() @@ -404,9 +378,9 @@ class DisplayContentBlockTest < ActiveSupport::TestCase profile = create_user('testuser').person Article.delete_all f1 = fast_create(Folder, :name => 'test folder 1', :profile_id => profile.id) - a1 = fast_create(TextileArticle, :name => 'test article 1', :profile_id => profile.id, :parent_id => f1.id) - a2 = fast_create(TextileArticle, :name => 'test article 2', :profile_id => profile.id, :parent_id => f1.id) - a3 = fast_create(TextileArticle, :name => 'test article 3', :profile_id => profile.id, :parent_id => f1.id) + a1 = fast_create(TextArticle, :name => 'test article 1', :profile_id => profile.id, :parent_id => f1.id) + a2 = fast_create(TextArticle, :name => 'test article 2', :profile_id => profile.id, :parent_id => f1.id) + a3 = fast_create(TextArticle, :name => 'test article 3', :profile_id => profile.id, :parent_id => f1.id) checked_articles= {f1.id => true, a1.id => true, a2.id => true, a3.id => false} block = DisplayContentBlock.new @@ -420,9 +394,9 @@ class DisplayContentBlockTest < ActiveSupport::TestCase profile = create_user('testuser').person Article.delete_all f1 = fast_create(Folder, :name => 'test folder 1', :profile_id => profile.id) - a1 = fast_create(TextileArticle, :name => 'test article 1', :profile_id => profile.id, :parent_id => f1.id) - a2 = fast_create(TextileArticle, :name => 'test article 2', :profile_id => profile.id, :parent_id => f1.id) - a3 = fast_create(TextileArticle, :name => 'test article 3', :profile_id => profile.id, :parent_id => f1.id) + a1 = fast_create(TextArticle, :name => 'test article 1', :profile_id => profile.id, :parent_id => f1.id) + a2 = fast_create(TextArticle, :name => 'test article 2', :profile_id => profile.id, :parent_id => f1.id) + a3 = fast_create(TextArticle, :name => 'test article 3', :profile_id => profile.id, :parent_id => f1.id) checked_articles= {f1.id => true, a1.id => true, a2.id => true, a3.id => false} block = DisplayContentBlock.new @@ -472,37 +446,37 @@ class DisplayContentBlockTest < ActiveSupport::TestCase should 'return available content types with checked types first' do Noosfero::Plugin::Manager.any_instance.stubs(:enabled_plugins).returns([]) block = DisplayContentBlock.create! - block.types = ['TinyMceArticle'] + block.types = ['TextArticle'] - block.types = ['TinyMceArticle', 'Folder'] - assert_equivalent [TinyMceArticle, Folder, UploadedFile, Event, TextileArticle, RawHTMLArticle, Blog, Forum, Gallery, RssFeed], block.available_content_types + block.types = ['TextArticle', 'Folder'] + assert_equivalent [TextArticle, Folder, UploadedFile, Event, Blog, Forum, Gallery, RssFeed], block.available_content_types end should 'return available content types' do Noosfero::Plugin::Manager.any_instance.stubs(:enabled_plugins).returns([]) block = DisplayContentBlock.create! - block.types = ['TinyMceArticle'] + block.types = ['TextArticle'] block.types = [] - assert_equivalent [UploadedFile, Event, TinyMceArticle, TextileArticle, RawHTMLArticle, Folder, Blog, Forum, Gallery, RssFeed], block.available_content_types + assert_equivalent [UploadedFile, Event, TextArticle, Folder, Blog, Forum, Gallery, RssFeed], block.available_content_types end should 'return first 2 content types' do Noosfero::Plugin::Manager.any_instance.stubs(:enabled_plugins).returns([]) block = DisplayContentBlock.create! - block.types = ['TinyMceArticle'] + block.types = ['TextArticle'] assert_equal 2, block.first_content_types.length end should 'return all but first 2 content types' do Noosfero::Plugin::Manager.any_instance.stubs(:enabled_plugins).returns([]) block = DisplayContentBlock.create! - block.types = ['TinyMceArticle'] + block.types = ['TextArticle'] assert_equal block.available_content_types.length - 2, block.more_content_types.length end should 'return 2 as default value for first_types_count' do block = DisplayContentBlock.create! - block.types = ['TinyMceArticle'] + block.types = ['TextArticle'] assert_equal 2, block.first_types_count end @@ -527,14 +501,14 @@ class DisplayContentBlockTest < ActiveSupport::TestCase Noosfero::Plugin::Manager.any_instance.stubs(:enabled_plugins).returns([SomePlugin.new]) block.types = [] - assert_equivalent [UploadedFile, Event, TinyMceArticle, TextileArticle, RawHTMLArticle, Folder, Blog, Forum, Gallery, RssFeed, SomePluginContent], block.available_content_types + assert_equivalent [UploadedFile, Event, TextArticle, Folder, Blog, Forum, Gallery, RssFeed, SomePluginContent], block.available_content_types end should 'do not fail if a selected article was removed' do profile = create_user('testuser').person Article.delete_all f1 = fast_create(Folder, :name => 'test folder 1', :profile_id => profile.id) - a1 = fast_create(TextileArticle, :name => 'test article 1', :profile_id => profile.id, :parent_id => f1.id) + a1 = fast_create(TextArticle, :name => 'test article 1', :profile_id => profile.id, :parent_id => f1.id) checked_articles= {a1.id => true} @@ -547,16 +521,16 @@ class DisplayContentBlockTest < ActiveSupport::TestCase end -require 'boxes_helper' - class DisplayContentBlockViewTest < ActionView::TestCase include BoxesHelper + include DatesHelper + helper :dates should 'list links for all articles title defined in nodes' do profile = create_user('testuser').person Article.delete_all - a1 = fast_create(TextileArticle, :name => 'test article 1', :profile_id => profile.id) - a2 = fast_create(TextileArticle, :name => 'test article 2', :profile_id => profile.id) + a1 = fast_create(TextArticle, :name => 'test article 1', :profile_id => profile.id) + a2 = fast_create(TextArticle, :name => 'test article 2', :profile_id => profile.id) block = DisplayContentBlock.new block.sections = [{:value => 'title', :checked => true}] @@ -572,8 +546,8 @@ class DisplayContentBlockViewTest < ActionView::TestCase should 'list content for all articles lead defined in nodes' do profile = create_user('testuser').person Article.delete_all - a1 = fast_create(TinyMceArticle, :name => 'test article 1', :profile_id => profile.id, :abstract => 'abstract article 1') - a2 = fast_create(TinyMceArticle, :name => 'test article 2', :profile_id => profile.id, :abstract => 'abstract article 2') + a1 = fast_create(TextArticle, :name => 'test article 1', :profile_id => profile.id, :abstract => 'abstract article 1') + a2 = fast_create(TextArticle, :name => 'test article 2', :profile_id => profile.id, :abstract => 'abstract article 2') block = DisplayContentBlock.new block.sections = [{:value => 'abstract', :checked => true}] @@ -602,7 +576,7 @@ class DisplayContentBlockViewTest < ActionView::TestCase should 'show title if defined by user' do profile = create_user('testuser').person - a = fast_create(TextileArticle, :name => 'test article 1', :profile_id => profile.id) + a = fast_create(TextArticle, :name => 'test article 1', :profile_id => profile.id) block = DisplayContentBlock.new block.nodes = [a.id] @@ -616,7 +590,7 @@ class DisplayContentBlockViewTest < ActionView::TestCase should 'show abstract if defined by user' do profile = create_user('testuser').person - a = fast_create(TextileArticle, :name => 'test article 1', :profile_id => profile.id, :abstract => 'some abstract') + a = fast_create(TextArticle, :name => 'test article 1', :profile_id => profile.id, :abstract => 'some abstract') block = DisplayContentBlock.new block.nodes = [a.id] @@ -630,7 +604,7 @@ class DisplayContentBlockViewTest < ActionView::TestCase should 'show body if defined by user' do profile = create_user('testuser').person - a = fast_create(TextileArticle, :name => 'test article 1', :profile_id => profile.id, :body => 'some body') + a = fast_create(TextArticle, :name => 'test article 1', :profile_id => profile.id, :body => 'some body') block = DisplayContentBlock.new block.nodes = [a.id] @@ -642,7 +616,7 @@ class DisplayContentBlockViewTest < ActionView::TestCase assert_match /#{a.body}/, render_block_content(block) end - should 'show publishd date if defined by user' do + should 'show published date if defined by user' do profile = create_user('testuser').person a = fast_create(TextArticle, :name => 'test article 1', :profile_id => profile.id, :body => 'some body') @@ -658,7 +632,7 @@ class DisplayContentBlockViewTest < ActionView::TestCase should 'show image if defined by user' do profile = create_user('testuser').person - a = create(TinyMceArticle, :name => 'test article 1', :profile_id => profile.id, :image_builder => { :uploaded_data => fixture_file_upload('/files/rails.png', 'image/png')}) + a = create(TextArticle, :name => 'test article 1', :profile_id => profile.id, :image_builder => { :uploaded_data => fixture_file_upload('/files/rails.png', 'image/png')}) a.save! process_delayed_job_queue @@ -676,8 +650,8 @@ class DisplayContentBlockViewTest < ActionView::TestCase should 'show articles in recent order' do profile = create_user('testuser').person Article.delete_all - a1 = fast_create(TextileArticle, :name => 'test article 1', :profile_id => profile.id, :published_at => DateTime.current) - a2 = fast_create(TextileArticle, :name => 'test article 2', :profile_id => profile.id, :published_at => (DateTime.current + 1)) + a1 = fast_create(TextArticle, :name => 'test article 1', :profile_id => profile.id, :published_at => DateTime.current) + a2 = fast_create(TextArticle, :name => 'test article 2', :profile_id => profile.id, :published_at => (DateTime.current + 1)) block = DisplayContentBlock.new block.sections = [{:value => 'title', :checked => true}] @@ -697,8 +671,8 @@ class DisplayContentBlockViewTest < ActionView::TestCase should 'show articles in oldest order' do profile = create_user('testuser').person Article.delete_all - a1 = fast_create(TextileArticle, :name => 'test article 1', :profile_id => profile.id, :published_at => DateTime.current) - a2 = fast_create(TextileArticle, :name => 'test article 2', :profile_id => profile.id, :published_at => (DateTime.current + 1)) + a1 = fast_create(TextArticle, :name => 'test article 1', :profile_id => profile.id, :published_at => DateTime.current) + a2 = fast_create(TextArticle, :name => 'test article 2', :profile_id => profile.id, :published_at => (DateTime.current + 1)) block = DisplayContentBlock.new block.sections = [{:value => 'title', :checked => true}] @@ -718,8 +692,8 @@ class DisplayContentBlockViewTest < ActionView::TestCase should 'show articles in recent order with limit option' do profile = create_user('testuser').person Article.delete_all - a1 = fast_create(TextileArticle, :name => 'test article 1', :profile_id => profile.id, :published_at => DateTime.current) - a2 = fast_create(TextileArticle, :name => 'test article 2', :profile_id => profile.id, :published_at => (DateTime.current + 1)) + a1 = fast_create(TextArticle, :name => 'test article 1', :profile_id => profile.id, :published_at => DateTime.current) + a2 = fast_create(TextArticle, :name => 'test article 2', :profile_id => profile.id, :published_at => (DateTime.current + 1)) block = DisplayContentBlock.new block.sections = [{:value => 'title', :checked => true}] @@ -741,10 +715,10 @@ class DisplayContentBlockViewTest < ActionView::TestCase profile = create_user('testuser').person Article.delete_all - en_article = fast_create(TextileArticle, :profile_id => profile.id, :name => 'en_article', :language => 'en') - en_article2 = fast_create(TextileArticle, :profile_id => profile.id, :name => 'en_article 2', :language => 'en') + en_article = fast_create(TextArticle, :profile_id => profile.id, :name => 'en_article', :language => 'en') + en_article2 = fast_create(TextArticle, :profile_id => profile.id, :name => 'en_article 2', :language => 'en') - pt_article = fast_create TextileArticle, profile_id: profile.id, name: 'pt_article', language: 'pt', translation_of_id: en_article.id + pt_article = fast_create TextArticle, profile_id: profile.id, name: 'pt_article', language: 'pt', translation_of_id: en_article.id block = DisplayContentBlock.new block.sections = [{:value => 'title', :checked => true}] @@ -771,8 +745,8 @@ class DisplayContentBlockViewTest < ActionView::TestCase profile = create_user('testuser').person Article.delete_all - en_article = fast_create(TextileArticle, :profile_id => profile.id, :name => 'en_article', :language => 'en') - pt_article = fast_create(TextileArticle, :profile_id => profile.id, :name => 'pt_article', :language => 'pt', :translation_of_id => en_article) + en_article = fast_create(TextArticle, :profile_id => profile.id, :name => 'en_article', :language => 'en') + pt_article = fast_create(TextArticle, :profile_id => profile.id, :name => 'pt_article', :language => 'pt', :translation_of_id => en_article) block = DisplayContentBlock.new block.sections = [{:value => 'title', :checked => true}] @@ -794,7 +768,7 @@ class DisplayContentBlockViewTest < ActionView::TestCase should 'not escape abstract html of articles' do profile = create_user('testuser').person - a1 = fast_create(TextileArticle, abstract: "

Test

", name: 'test article 1', profile_id: profile.id, published_at: DateTime.current) + a1 = fast_create(TextArticle, abstract: "

Test

", name: 'test article 1', profile_id: profile.id, published_at: DateTime.current) block = DisplayContentBlock.new block.sections = [{:value => 'abstract', :checked => true}] @@ -807,7 +781,7 @@ class DisplayContentBlockViewTest < ActionView::TestCase should 'not raise if abstract of article is nil' do profile = create_user('testuser').person - a1 = fast_create(TextileArticle, name: 'test article 1', profile_id: profile.id, published_at: DateTime.current) + a1 = fast_create(TextArticle, name: 'test article 1', profile_id: profile.id, published_at: DateTime.current) block = DisplayContentBlock.new block.sections = [{:value => 'abstract', :checked => true}] @@ -823,7 +797,7 @@ class DisplayContentBlockViewTest < ActionView::TestCase should 'not escape body html of articles' do profile = create_user('testuser').person - a1 = fast_create(TextileArticle, body: "

Test

", name: 'test article 1', profile_id: profile.id, published_at: DateTime.current) + a1 = fast_create(TextArticle, body: "

Test

", name: 'test article 1', profile_id: profile.id, published_at: DateTime.current) block = DisplayContentBlock.new block.sections = [{:value => 'body', :checked => true}] @@ -836,7 +810,7 @@ class DisplayContentBlockViewTest < ActionView::TestCase should 'not raise if body of article is nil' do profile = create_user('testuser').person - a1 = fast_create(TextileArticle, name: 'test article 1', profile_id: profile.id, published_at: DateTime.current) + a1 = fast_create(TextArticle, name: 'test article 1', profile_id: profile.id, published_at: DateTime.current) block = DisplayContentBlock.new block.sections = [{:value => 'abstract', :checked => true}] diff --git a/plugins/fb_app/views/fb_app_plugin_page_tab/_configure_form.html.slim b/plugins/fb_app/views/fb_app_plugin_page_tab/_configure_form.html.slim index 3f3ffa7..6c4e76e 100644 --- a/plugins/fb_app/views/fb_app_plugin_page_tab/_configure_form.html.slim +++ b/plugins/fb_app/views/fb_app_plugin_page_tab/_configure_form.html.slim @@ -15,7 +15,7 @@ = f.text_field :title, class: 'form-control' = f.label :subtitle, t("fb_app_plugin.views.myprofile.catalogs.catalog_subtitle_label") - = f.text_area :subtitle, class: 'form-control mceEditor', id: "page-tab-subtitle-#{page_tab.id}" + = f.text_area :subtitle, class: 'form-control ' + current_editor, id: "page-tab-subtitle-#{page_tab.id}" = f.label :config_type, t("fb_app_plugin.views.myprofile.catalogs.catalog_type_chooser_label") = f.select :config_type, diff --git a/plugins/mark_comment_as_read/test/functional/mark_comment_as_read_plugin_profile_controller_test.rb b/plugins/mark_comment_as_read/test/functional/mark_comment_as_read_plugin_profile_controller_test.rb index e1d8559..359d461 100644 --- a/plugins/mark_comment_as_read/test/functional/mark_comment_as_read_plugin_profile_controller_test.rb +++ b/plugins/mark_comment_as_read/test/functional/mark_comment_as_read_plugin_profile_controller_test.rb @@ -6,7 +6,7 @@ class MarkCommentAsReadPluginProfileControllerTest < ActionController::TestCase @controller = MarkCommentAsReadPluginProfileController.new @profile = create_user('profile').person - @article = TinyMceArticle.create!(:profile => @profile, :name => 'An article') + @article = TextArticle.create!(:profile => @profile, :name => 'An article') @comment = Comment.new(:source => @article, :author => @profile, :body => 'test') @comment.save! login_as(@profile.identifier) diff --git a/plugins/mark_comment_as_read/test/unit/mark_comment_as_read_plugin/comment_test.rb b/plugins/mark_comment_as_read/test/unit/mark_comment_as_read_plugin/comment_test.rb index c925791..97b7a73 100644 --- a/plugins/mark_comment_as_read/test/unit/mark_comment_as_read_plugin/comment_test.rb +++ b/plugins/mark_comment_as_read/test/unit/mark_comment_as_read_plugin/comment_test.rb @@ -4,7 +4,7 @@ class MarkCommentAsReadPlugin::CommentTest < ActiveSupport::TestCase def setup @person = create_user('user').person - @article = TinyMceArticle.create!(:profile => @person, :name => 'An article') + @article = TextArticle.create!(:profile => @person, :name => 'An article') @comment = Comment.create!(:title => 'title', :body => 'body', :author => @person, :source => @article) end diff --git a/plugins/mark_comment_as_read/test/unit/mark_comment_as_read_test.rb b/plugins/mark_comment_as_read/test/unit/mark_comment_as_read_test.rb index 5ae3130..fd78210 100644 --- a/plugins/mark_comment_as_read/test/unit/mark_comment_as_read_test.rb +++ b/plugins/mark_comment_as_read/test/unit/mark_comment_as_read_test.rb @@ -5,7 +5,7 @@ class MarkCommentAsReadPluginTest < ActionView::TestCase def setup @plugin = MarkCommentAsReadPlugin.new @person = create_user('user').person - @article = TinyMceArticle.create!(:profile => @person, :name => 'An article') + @article = TextArticle.create!(:profile => @person, :name => 'An article') @comment = Comment.create!(:source => @article, :author => @person, :body => 'test') self.stubs(:user).returns(@person) self.stubs(:profile).returns(@person) diff --git a/plugins/metadata/test/functional/content_viewer_controller_test.rb b/plugins/metadata/test/functional/content_viewer_controller_test.rb index d6c88a7..c12a740 100644 --- a/plugins/metadata/test/functional/content_viewer_controller_test.rb +++ b/plugins/metadata/test/functional/content_viewer_controller_test.rb @@ -21,7 +21,7 @@ class ContentViewerControllerTest < ActionController::TestCase end should 'add meta tags with article info' do - a = TinyMceArticle.create(name: 'Article to be shared', body: '

This article should be shared with all social networks

', profile: profile) + a = TextArticle.create(name: 'Article to be shared', body: '

This article should be shared with all social networks

', profile: profile) get :view_page, profile: profile.identifier, page: [ a.name.to_slug ] @@ -37,7 +37,7 @@ class ContentViewerControllerTest < ActionController::TestCase end should 'add meta tags with article images' do - a = TinyMceArticle.create(name: 'Article to be shared with images', body: 'This article should be shared with all social networks ', profile: profile) + a = TextArticle.create(name: 'Article to be shared with images', body: 'This article should be shared with all social networks ', profile: profile) get :view_page, profile: profile.identifier, page: [ a.name.to_slug ] assert_tag tag: 'meta', attributes: { name: 'twitter:image', content: /\/images\/x.png/ } @@ -45,7 +45,7 @@ class ContentViewerControllerTest < ActionController::TestCase end should 'escape utf8 characters correctly' do - a = TinyMceArticle.create(name: 'Article to be shared with images', body: 'This article should be shared with all social networks ', profile: profile) + a = TextArticle.create(name: 'Article to be shared with images', body: 'This article should be shared with all social networks ', profile: profile) get :view_page, profile: profile.identifier, page: [ a.name.to_slug ] assert_tag tag: 'meta', attributes: { property: 'og:image', content: /\/images\/%C3%A7.png/ } @@ -63,7 +63,7 @@ class ContentViewerControllerTest < ActionController::TestCase should 'not expose metadata on private pages' do profile.update_column :public_profile, false - a = TinyMceArticle.create(name: 'Article to be shared with images', body: 'This article should be shared with all social networks ', profile: profile) + a = TextArticle.create(name: 'Article to be shared with images', body: 'This article should be shared with all social networks ', profile: profile) get :view_page, profile: profile.identifier, page: [ a.name.to_slug ] assert_no_tag tag: 'meta', attributes: { property: 'og:image', content: /\/images\/x.png/ } diff --git a/plugins/newsletter/test/integration/safe_strings_test.rb b/plugins/newsletter/test/integration/safe_strings_test.rb index 9d90f6e..11ad3ae 100644 --- a/plugins/newsletter/test/integration/safe_strings_test.rb +++ b/plugins/newsletter/test/integration/safe_strings_test.rb @@ -10,7 +10,7 @@ class NewsletterPluginSafeStringsTest < ActionDispatch::IntegrationTest environment.add_admin(person) blog = fast_create(Blog, :profile_id => person.id) - post = fast_create(TextileArticle, :name => 'First post', :profile_id => person.id, :parent_id => blog.id, :body => 'Test') + post = fast_create(TextArticle, :name => 'First post', :profile_id => person.id, :parent_id => blog.id, :body => 'Test') newsletter = NewsletterPlugin::Newsletter.create!(:environment => environment, :person => person, :enabled => true) newsletter.blog_ids = [blog.id] newsletter.save! diff --git a/plugins/newsletter/test/unit/newsletter_plugin_moderate_newsletter_test.rb b/plugins/newsletter/test/unit/newsletter_plugin_moderate_newsletter_test.rb index 649f55d..6da4c79 100644 --- a/plugins/newsletter/test/unit/newsletter_plugin_moderate_newsletter_test.rb +++ b/plugins/newsletter/test/unit/newsletter_plugin_moderate_newsletter_test.rb @@ -28,9 +28,9 @@ class NewsletterPluginModerateNewsletterTest < ActiveSupport::TestCase should 'set posts for mailing body on perform' do person = create_user('john').person blog = fast_create(Blog, profile_id: person.id) - post_1 = fast_create(TextileArticle, :name => 'First post', :profile_id => person.id, :parent_id => blog.id, :body => 'Test') - post_2 = fast_create(TextileArticle, :name => 'Second post', :profile_id => person.id, :parent_id => blog.id, :body => 'Test') - post_3 = fast_create(TextileArticle, :name => 'Third post', :profile_id => person.id, :parent_id => blog.id, :body => 'Test') + post_1 = fast_create(TextArticle, :name => 'First post', :profile_id => person.id, :parent_id => blog.id, :body => 'Test') + post_2 = fast_create(TextArticle, :name => 'Second post', :profile_id => person.id, :parent_id => blog.id, :body => 'Test') + post_3 = fast_create(TextArticle, :name => 'Third post', :profile_id => person.id, :parent_id => blog.id, :body => 'Test') newsletter = NewsletterPlugin::Newsletter.create!(:environment => person.environment, :person => person, :enabled => true) newsletter.blog_ids = [blog.id] diff --git a/plugins/newsletter/test/unit/newsletter_plugin_newsletter_test.rb b/plugins/newsletter/test/unit/newsletter_plugin_newsletter_test.rb index 031c781..3be1b40 100644 --- a/plugins/newsletter/test/unit/newsletter_plugin_newsletter_test.rb +++ b/plugins/newsletter/test/unit/newsletter_plugin_newsletter_test.rb @@ -381,9 +381,9 @@ EOS person = fast_create(Person) blog = fast_create(Blog, profile_id: person.id) - post_1 = fast_create(TextileArticle, :name => 'First post', :profile_id => person.id, :parent_id => blog.id, :body => 'Test') - post_2 = fast_create(TextileArticle, :name => 'Second post', :profile_id => person.id, :parent_id => blog.id, :body => 'Test') - post_3 = fast_create(TextileArticle, :name => 'Third post', :profile_id => person.id, :parent_id => blog.id, :body => 'Test') + post_1 = fast_create(TextArticle, :name => 'First post', :profile_id => person.id, :parent_id => blog.id, :body => 'Test') + post_2 = fast_create(TextArticle, :name => 'Second post', :profile_id => person.id, :parent_id => blog.id, :body => 'Test') + post_3 = fast_create(TextArticle, :name => 'Third post', :profile_id => person.id, :parent_id => blog.id, :body => 'Test') newsletter = NewsletterPlugin::Newsletter.create!( :environment => person.environment, @@ -397,9 +397,9 @@ EOS person = fast_create(Person) blog = fast_create(Blog, profile_id: person.id) - post_1 = fast_create(TextileArticle, :name => 'First post', :profile_id => person.id, :parent_id => blog.id, :body => 'Test') - post_2 = fast_create(TextileArticle, :name => 'Second post', :profile_id => person.id, :parent_id => blog.id, :body => 'Test') - post_3 = fast_create(TextileArticle, :name => 'Third post', :profile_id => person.id, :parent_id => blog.id, :body => 'Test') + post_1 = fast_create(TextArticle, :name => 'First post', :profile_id => person.id, :parent_id => blog.id, :body => 'Test') + post_2 = fast_create(TextArticle, :name => 'Second post', :profile_id => person.id, :parent_id => blog.id, :body => 'Test') + post_3 = fast_create(TextArticle, :name => 'Third post', :profile_id => person.id, :parent_id => blog.id, :body => 'Test') newsletter = NewsletterPlugin::Newsletter.create!( :environment => person.environment, diff --git a/plugins/newsletter/views/newsletter_plugin_admin/index.html.erb b/plugins/newsletter/views/newsletter_plugin_admin/index.html.erb index cb756c0..415dded 100644 --- a/plugins/newsletter/views/newsletter_plugin_admin/index.html.erb +++ b/plugins/newsletter/views/newsletter_plugin_admin/index.html.erb @@ -1,7 +1,5 @@

<%= _('Newsletter settings') %>

-<%= render :file => 'shared/tiny_mce' %> - <%= error_messages_for :newsletter %> <%= form_for(:newsletter, html: { multipart: true }) do |f| %> @@ -81,7 +79,7 @@ content_tag('h3', ui_icon('ui-icon-triangle-1-s') + _('Newsletter footer'), :class => 'newsletter-toggle-link', :element_id => '#newsletter-footer-field'), content_tag('div', - f.text_area(:footer, :style => 'width: 100%', :class => 'mceEditor'), + f.text_area(:footer, :style => 'width: 100%', :class => current_editor), :id => 'newsletter-footer-field' )) %> diff --git a/plugins/open_graph/test/unit/open_graph_graph/publisher_test.rb b/plugins/open_graph/test/unit/open_graph_graph/publisher_test.rb index d73c3be..dd4c95f 100644 --- a/plugins/open_graph/test/unit/open_graph_graph/publisher_test.rb +++ b/plugins/open_graph/test/unit/open_graph_graph/publisher_test.rb @@ -51,7 +51,7 @@ class OpenGraphPlugin::PublisherTest < ActiveSupport::TestCase user = User.current.person blog = Blog.create! profile: user, name: 'blog' - blog_post = TinyMceArticle.create! profile: user, parent: blog, name: 'blah', author: user + blog_post = TextArticle.create! profile: user, parent: blog, name: 'blah', author: user assert_last_activity user, :create_an_article, url_for(blog_post) gallery = Gallery.create! name: 'gallery', profile: user @@ -65,7 +65,7 @@ class OpenGraphPlugin::PublisherTest < ActiveSupport::TestCase assert_last_activity user, :create_an_event, url_for(event) forum = Forum.create! name: 'forum', profile: user - topic = TinyMceArticle.create! profile: user, parent: forum, name: 'blah2', author: user + topic = TextArticle.create! profile: user, parent: forum, name: 'blah2', author: user assert_last_activity user, :start_a_discussion, url_for(topic, topic.url.merge(og_type: MetadataPlugin.og_types[:forum])) AddFriend.create!(person: user, friend: @other_actor).finish @@ -82,7 +82,7 @@ class OpenGraphPlugin::PublisherTest < ActiveSupport::TestCase User.current = @actor.user user = User.current.person - blog_post = TinyMceArticle.create! profile: @enterprise, parent: @enterprise.blog, name: 'blah', author: user + blog_post = TextArticle.create! profile: @enterprise, parent: @enterprise.blog, name: 'blah', author: user story = :announce_news_from_a_sse_initiative assert_last_activity user, story, passive_url_for(blog_post, nil, OpenGraphPlugin::Stories::Definitions[story]) @@ -91,13 +91,13 @@ class OpenGraphPlugin::PublisherTest < ActiveSupport::TestCase user = User.current.person # fan - blog_post = TinyMceArticle.create! profile: @enterprise, parent: @enterprise.blog, name: 'blah2', author: user + blog_post = TextArticle.create! profile: @enterprise, parent: @enterprise.blog, name: 'blah2', author: user assert_last_activity user, :announce_news_from_a_sse_initiative, 'http://noosfero.net/coop/blog/blah2' # member - blog_post = TinyMceArticle.create! profile: @myenterprise, parent: @myenterprise.blog, name: 'blah2', author: user + blog_post = TextArticle.create! profile: @myenterprise, parent: @myenterprise.blog, name: 'blah2', author: user assert_last_activity user, :announce_news_from_a_sse_initiative, 'http://noosfero.net/mycoop/blog/blah2' - blog_post = TinyMceArticle.create! profile: @community, parent: @community.blog, name: 'blah', author: user + blog_post = TextArticle.create! profile: @community, parent: @community.blog, name: 'blah', author: user assert_last_activity user, :announce_news_from_a_community, 'http://noosfero.net/comm/blog/blah' end diff --git a/plugins/orders_cycle/views/orders_cycle_plugin_cycle/_edit_fields.html.slim b/plugins/orders_cycle/views/orders_cycle_plugin_cycle/_edit_fields.html.slim index 241b9a2..1b13e5f 100644 --- a/plugins/orders_cycle/views/orders_cycle_plugin_cycle/_edit_fields.html.slim +++ b/plugins/orders_cycle/views/orders_cycle_plugin_cycle/_edit_fields.html.slim @@ -5,8 +5,7 @@ h3= t('views.cycle._edit_fields.general_settings') = form_for @cycle, as: :cycle , remote: true, url: {action: @cycle.new? ? :new : :edit, id: @cycle.id }, html: {data: {loading: '#cycle-fields form'}} do |f| = labelled_field f, :name, t('views.cycle._edit_fields.name'), f.text_field(:name), class: 'cycle-field-name' - = labelled_field f, :description, t('views.cycle._edit_fields.description'), f.text_area(:description, class: 'mceEditor'), class: 'cycle-field-description' - = render file: 'shared/tiny_mce', locals: {mode: 'simple'} + = labelled_field f, :description, t('views.cycle._edit_fields.description'), f.text_area(:description, class: current_editor('simple')), class: 'cycle-field-description' .cycle-fields-block = labelled_datetime_range_field f, :start, :finish, t('views.cycle._edit_fields.orders_interval'), class: 'cycle-orders-period' diff --git a/plugins/products/views/products_plugin/page/_display_description.html.erb b/plugins/products/views/products_plugin/page/_display_description.html.erb index 45d6f7a..87d00cb 100644 --- a/plugins/products/views/products_plugin/page/_display_description.html.erb +++ b/plugins/products/views/products_plugin/page/_display_description.html.erb @@ -1,7 +1,7 @@ <%= render :file => 'shared/tiny_mce', :locals => {:mode => 'simple'} %> <% if !@product.description.blank? %> <%= @product.description %> - <%= edit_product_button_to_remote(@product, 'description', _('Edit description'), :title => _('Edit the description of your product and give consumers more information about what you are advertising')) %> + <%= edit_product_button_to_remote(@product, 'description', _('Edit description'), {:title => _('Edit the description of your product and give consumers more information about what you are advertising'), :class => current_editor}) %> <% else %> <%= edit_product_ui_button_to_remote( @product, diff --git a/plugins/products/views/products_plugin/page/_edit_description.html.erb b/plugins/products/views/products_plugin/page/_edit_description.html.erb index 81cb9b9..e0681ab 100644 --- a/plugins/products/views/products_plugin/page/_edit_description.html.erb +++ b/plugins/products/views/products_plugin/page/_edit_description.html.erb @@ -1,11 +1,10 @@ -<%= render file: 'shared/tiny_mce', locals: {mode: 'simple'} %> <%= remote_form_for(@product, loading: "small_loading('product-description-form')", update: 'product-description', url: {controller: 'products_plugin/page', action: 'edit', id: @product, field: 'description'}, html: {id: 'product-description-form', method: 'post'}) do |f| %> - <%= labelled_form_field(_('Description:'), f.text_area(:description, rows: 15, style: 'width: 90%;', class: 'mceEditor')) %> + <%= labelled_form_field(_('Description:'), f.text_area(:description, rows: 15, style: 'width: 90%;', class: current_editor('simple'))) %> <%= button_bar do %> <%= submit_button :save, _('Save') %> <%= cancel_edit_product_link(@product, 'description') %> diff --git a/plugins/products/views/products_plugin/page/_form.html.erb b/plugins/products/views/products_plugin/page/_form.html.erb index 67da716..656b1fc 100644 --- a/plugins/products/views/products_plugin/page/_form.html.erb +++ b/plugins/products/views/products_plugin/page/_form.html.erb @@ -5,7 +5,7 @@ <%= display_form_field( _('Name:'), f.text_field(:name) ) %> <%= display_form_field( _('Price:'), f.text_field(:price) ) %> - <%= display_form_field( _('Description:'), f.text_area(:description, :rows => 10, :class => 'mceEditor') ) %> + <%= display_form_field( _('Description:'), f.text_area(:description, :rows => 10, :class => current_editor('simples')) ) %> <%= labelled_form_field(f.check_box(:highlighted) + _('Highlight this product'),'') %> <%= f.fields_for :image_builder, @product.image do |i| %> <%= file_field_or_thumbnail(_('Image:'), @product.image, i) %> diff --git a/plugins/profile_members_headlines/test/unit/profile_members_headlines_block_test.rb b/plugins/profile_members_headlines/test/unit/profile_members_headlines_block_test.rb index 96df07c..60a3f23 100644 --- a/plugins/profile_members_headlines/test/unit/profile_members_headlines_block_test.rb +++ b/plugins/profile_members_headlines/test/unit/profile_members_headlines_block_test.rb @@ -42,7 +42,7 @@ class ProfileMembersHeadlinesBlockTest < ActiveSupport::TestCase block = ProfileMembersHeadlinesBlock.create block.stubs(:owner).returns(community) blog = fast_create(Blog, :profile_id => member1.id) - post = fast_create(TinyMceArticle, :name => 'headlines', :profile_id => member1.id, :parent_id => blog.id) + post = fast_create(TextArticle, :name => 'headlines', :profile_id => member1.id, :parent_id => blog.id) self.expects(:render).with(:template => 'blocks/profile_members_headlines', :locals => { :block => block }).returns('file-with-authors-and-headlines') assert_equal 'file-with-authors-and-headlines', render_block_content(block) end @@ -53,7 +53,7 @@ class ProfileMembersHeadlinesBlockTest < ActiveSupport::TestCase block = ProfileMembersHeadlinesBlock.new(:limit => 1, :filtered_roles => [role.id]) block.expects(:owner).returns(community) blog = fast_create(Blog, :profile_id => member1.id) - post = fast_create(TinyMceArticle, :name => 'headlines', :profile_id => member1.id, :parent_id => blog.id) + post = fast_create(TextArticle, :name => 'headlines', :profile_id => member1.id, :parent_id => blog.id) assert_equal [member1], block.authors_list end @@ -62,7 +62,7 @@ class ProfileMembersHeadlinesBlockTest < ActiveSupport::TestCase block.expects(:owner).returns(community) private_author = fast_create(Person, :public_profile => false) blog = fast_create(Blog, :profile_id => private_author.id) - post = fast_create(TinyMceArticle, :name => 'headlines', :profile_id => private_author.id, :parent_id => blog.id) + post = fast_create(TextArticle, :name => 'headlines', :profile_id => private_author.id, :parent_id => blog.id) assert_equal [], block.authors_list end @@ -76,7 +76,7 @@ class ProfileMembersHeadlinesBlockTest < ActiveSupport::TestCase block.stubs(:owner).returns(community) community.members.each do |member| blog = fast_create(Blog, :profile_id => member.id) - post = fast_create(TinyMceArticle, :name => 'headlines', :profile_id => member.id, :parent_id => blog.id) + post = fast_create(TextArticle, :name => 'headlines', :profile_id => member.id, :parent_id => blog.id) end assert_equal [author], block.authors_list end diff --git a/plugins/recent_content/lib/recent_content_block.rb b/plugins/recent_content/lib/recent_content_block.rb index 839fe65..f407cc3 100644 --- a/plugins/recent_content/lib/recent_content_block.rb +++ b/plugins/recent_content/lib/recent_content_block.rb @@ -7,7 +7,7 @@ class RecentContentBlock < Block attr_accessible :presentation_mode, :total_items, :show_blog_picture, :selected_folder - VALID_CONTENT = ['RawHTMLArticle', 'TextArticle', 'TextileArticle', 'TinyMceArticle'] + VALID_CONTENT = ['TextArticle'] def self.description c_('Recent content') diff --git a/plugins/recent_content/test/unit/recent_content_block_test.rb b/plugins/recent_content/test/unit/recent_content_block_test.rb index ef34a83..fc4f802 100644 --- a/plugins/recent_content/test/unit/recent_content_block_test.rb +++ b/plugins/recent_content/test/unit/recent_content_block_test.rb @@ -2,7 +2,7 @@ require_relative '../test_helper' class RecentContentBlockTest < ActiveSupport::TestCase INVALID_KIND_OF_ARTICLE = [RssFeed, UploadedFile, Gallery, Folder, Blog, Forum] - VALID_KIND_OF_ARTICLE = [RawHTMLArticle, TextArticle, TextileArticle, TinyMceArticle] + VALID_KIND_OF_ARTICLE = [TextArticle] should 'describe itself' do assert_not_equal Block.description, RecentContentBlock.description @@ -61,9 +61,9 @@ class RecentContentBlockTest < ActiveSupport::TestCase root = fast_create(Blog, :name => 'test-blog', :profile_id => profile.id) - a1 = fast_create(TextileArticle, :name => 'article #1', :profile_id => profile.id, :parent_id => root.id, :created_at => Time.now - 2.days) - a2 = fast_create(TextileArticle, :name => 'article #2', :profile_id => profile.id, :parent_id => root.id, :created_at => Time.now - 1.days) - a3 = fast_create(TextileArticle, :name => 'article #3', :profile_id => profile.id, :parent_id => root.id, :created_at => Time.now) + a1 = fast_create(TextArticle, :name => 'article #1', :profile_id => profile.id, :parent_id => root.id, :created_at => Time.now - 2.days) + a2 = fast_create(TextArticle, :name => 'article #2', :profile_id => profile.id, :parent_id => root.id, :created_at => Time.now - 1.days) + a3 = fast_create(TextArticle, :name => 'article #3', :profile_id => profile.id, :parent_id => root.id, :created_at => Time.now) block = RecentContentBlock.new block.stubs(:holder).returns(profile) diff --git a/plugins/relevant_content/test/unit/article.rb b/plugins/relevant_content/test/unit/article.rb index 877f81c..f0ebdff 100644 --- a/plugins/relevant_content/test/unit/article.rb +++ b/plugins/relevant_content/test/unit/article.rb @@ -29,9 +29,9 @@ class RelevantContentBlockTest < ActiveSupport::TestCase should 'list most commented articles' do Article.delete_all - a1 = create(TextileArticle, :name => "art 1", :profile_id => profile.id) - a2 = create(TextileArticle, :name => "art 2", :profile_id => profile.id) - a3 = create(TextileArticle, :name => "art 3", :profile_id => profile.id) + a1 = create(TextArticle, :name => "art 1", :profile_id => profile.id) + a2 = create(TextArticle, :name => "art 2", :profile_id => profile.id) + a3 = create(TextArticle, :name => "art 3", :profile_id => profile.id) 2.times { Comment.create(:title => 'test', :body => 'asdsad', :author => profile, :source => a2).save! } 4.times { Comment.create(:title => 'test', :body => 'asdsad', :author => profile, :source => a3).save! } diff --git a/plugins/send_email/doc/send_email.textile b/plugins/send_email/doc/send_email.textile index 65f7f83..afae2e6 100644 --- a/plugins/send_email/doc/send_email.textile +++ b/plugins/send_email/doc/send_email.textile @@ -4,7 +4,7 @@ Allows to send e-mails through an e-mail form. h2. Usage -* Create a HTML form using RawHTMLBlock or RawHTMLArticle that invokes the {sendemail} action +* Create a HTML form using RawHTMLBlock that invokes the {sendemail} action * Add a "to" and "message" field and a submit button * Make sure to fill in allowed 'to' addresses in plugin settings diff --git a/plugins/send_email/test/unit/send_email_plugin_test.rb b/plugins/send_email/test/unit/send_email_plugin_test.rb index 72aa150..62a38b9 100644 --- a/plugins/send_email/test/unit/send_email_plugin_test.rb +++ b/plugins/send_email/test/unit/send_email_plugin_test.rb @@ -29,8 +29,7 @@ class SendEmailPluginTest < ActiveSupport::TestCase should 'expand macro used on form on profile context' do profile = fast_create(Community) @plugin.context.stubs(:profile).returns(profile) - article = RawHTMLArticle.create!(:name => 'Raw HTML', :body => "
", :profile => profile) - + article = TextArticle.create!(:name => 'Text HTML', :body => "
", :profile => profile, :editor => Article::Editor::RAW_HTML) assert_match /profile\/#{profile.identifier}\/plugin\/send_email\/deliver/, @plugin.parse_content(article.to_html, nil).first end diff --git a/plugins/solr/lib/ext/article.rb b/plugins/solr/lib/ext/article.rb index 1559abd..3bbe7ac 100644 --- a/plugins/solr/lib/ext/article.rb +++ b/plugins/solr/lib/ext/article.rb @@ -72,13 +72,7 @@ class Article end def solr_plugin_f_type - #join common types - case self.class.name - when 'TinyMceArticle', 'TextileArticle' - TextArticle.name - else - self.class.name - end + self.class.name end def solr_plugin_f_profile_type @@ -111,8 +105,6 @@ class Article # see http://stackoverflow.com/questions/4138957/activerecordsubclassnotfound-error-when-using-sti-in-rails/4139245 UploadedFile TextArticle - TinyMceArticle - TextileArticle Folder EnterpriseHomepage Gallery diff --git a/plugins/solr/test/unit/article_test.rb b/plugins/solr/test/unit/article_test.rb index 788db95..426a178 100644 --- a/plugins/solr/test/unit/article_test.rb +++ b/plugins/solr/test/unit/article_test.rb @@ -82,7 +82,7 @@ class ArticleTest < ActiveSupport::TestCase should 'index comments body together with article' do TestSolr.enable owner = create_user('testuser').person - art = fast_create(TinyMceArticle, :profile_id => owner.id, :name => 'ytest') + art = fast_create(TextArticle, :profile_id => owner.id, :name => 'ytest') c1 = Comment.create!(:title => 'test comment', :body => 'anything', :author => owner, :source => art) assert_includes Article.find_by_contents('anything')[:results], art diff --git a/plugins/solr/test/unit/profile_test.rb b/plugins/solr/test/unit/profile_test.rb index 0c8cf04..9847685 100644 --- a/plugins/solr/test/unit/profile_test.rb +++ b/plugins/solr/test/unit/profile_test.rb @@ -131,7 +131,7 @@ class ProfileTest < ActiveSupport::TestCase should 'index comments title together with article' do TestSolr.enable owner = create_user('testuser').person - art = fast_create(TinyMceArticle, :profile_id => owner.id, :name => 'ytest') + art = fast_create(TextArticle, :profile_id => owner.id, :name => 'ytest') c1 = Comment.create(:title => 'a nice comment', :body => 'anything', :author => owner, :source => art ); c1.save! assert_includes Article.find_by_contents('nice')[:results], art diff --git a/plugins/solr/test/unit/text_article_test.rb b/plugins/solr/test/unit/text_article_test.rb index 85bacf3..f46a022 100644 --- a/plugins/solr/test/unit/text_article_test.rb +++ b/plugins/solr/test/unit/text_article_test.rb @@ -8,10 +8,10 @@ class TextArticleTest < ActiveSupport::TestCase attr_accessor :environment - should 'found TextileArticle by TextArticle indexes' do + should 'found TextArticle by TextArticle indexes' do TestSolr.enable person = create_user('testuser').person - article = TextileArticle.create!(:name => 'found article test', :profile => person) - assert_equal TextileArticle.find_by_contents('found')[:results].docs, TextArticle.find_by_contents('found')[:results].docs + article = TextArticle.create!(:name => 'found article test', :profile => person) + assert_equal TextArticle.find_by_contents('found')[:results].docs, TextArticle.find_by_contents('found')[:results].docs end end diff --git a/plugins/solr/test/unit/textile_article_test.rb b/plugins/solr/test/unit/textile_article_test.rb deleted file mode 100644 index c570d4c..0000000 --- a/plugins/solr/test/unit/textile_article_test.rb +++ /dev/null @@ -1,10 +0,0 @@ -require "#{File.dirname(__FILE__)}/../test_helper" - -class TextileArticleTest < ActiveSupport::TestCase - - should 'define type facet' do - a = TextileArticle.new - assert_equal TextArticle.type_name, TextileArticle.send(:solr_plugin_f_type_proc, a.send(:solr_plugin_f_type)) - end - -end diff --git a/plugins/solr/test/unit/tiny_mce_article_test.rb b/plugins/solr/test/unit/tiny_mce_article_test.rb index 566127b..cdc1583 100644 --- a/plugins/solr/test/unit/tiny_mce_article_test.rb +++ b/plugins/solr/test/unit/tiny_mce_article_test.rb @@ -11,13 +11,13 @@ class TinyMceArticleTest < ActiveSupport::TestCase should 'be found when searching for articles by query' do TestSolr.enable - tma = TinyMceArticle.create!(:name => 'test tinymce article', :body => '---', :profile => profile) - assert_includes TinyMceArticle.find_by_contents('article')[:results], tma + tma = TextArticle.create!(:name => 'test tinymce article', :body => '---', :profile => profile) + assert_includes TextArticle.find_by_contents('article')[:results], tma assert_includes Article.find_by_contents('article')[:results], tma end should 'define type facet' do - a = TinyMceArticle.new - assert_equal TextArticle.type_name, TinyMceArticle.send(:solr_plugin_f_type_proc, a.send(:solr_plugin_f_type)) + a = TextArticle.new + assert_equal TextArticle.type_name, TextArticle.send(:solr_plugin_f_type_proc, a.send(:solr_plugin_f_type)) end end diff --git a/plugins/variables/doc/variables.textile b/plugins/variables/doc/variables.textile index c29934d..e717ccb 100644 --- a/plugins/variables/doc/variables.textile +++ b/plugins/variables/doc/variables.textile @@ -4,12 +4,12 @@ A set of simple variables to be used in a macro context. h2. Usage -* Create a HTML content using RawHTMLBlock, TinyMceArticle or other +* Create a HTML content using TextArticle or other article with HTML support * Add a HTML div tag with css class "macro" (see Example) * Add inner that div tag the variable desired, like {profile} -h2. Usage with TinyMceArticle +h2. Usage with TextArticle The Noosfero's macros add a extra button in toolbar of the editor to use macros in a single way, that way this plugin add a option diff --git a/plugins/vote/test/functional/vote_plugin_profile_controller_test.rb b/plugins/vote/test/functional/vote_plugin_profile_controller_test.rb index 128b0f5..e7aad59 100644 --- a/plugins/vote/test/functional/vote_plugin_profile_controller_test.rb +++ b/plugins/vote/test/functional/vote_plugin_profile_controller_test.rb @@ -5,7 +5,7 @@ class VotePluginProfileControllerTest < ActionController::TestCase def setup @profile = create_user('profile').person - @article = TinyMceArticle.create!(:profile => @profile, :name => 'An article') + @article = TextArticle.create!(:profile => @profile, :name => 'An article') @comment = Comment.new(:source => @article, :author => @profile, :body => 'test') @comment.save! login_as(@profile.identifier) diff --git a/plugins/vote/test/unit/vote_plugin_test.rb b/plugins/vote/test/unit/vote_plugin_test.rb index c020fe3..9db07dd 100644 --- a/plugins/vote/test/unit/vote_plugin_test.rb +++ b/plugins/vote/test/unit/vote_plugin_test.rb @@ -5,7 +5,7 @@ class VotePluginTest < ActiveSupport::TestCase def setup @plugin = VotePlugin.new @person = create_user('user').person - @article = TinyMceArticle.create!(:profile => @person, :name => 'An article') + @article = TextArticle.create!(:profile => @person, :name => 'An article') @comment = Comment.create!(:source => @article, :author => @person, :body => 'test') end diff --git a/public/javascripts/email_templates.js b/public/javascripts/email_templates.js index 87a35d8..9ddceb3 100644 --- a/public/javascripts/email_templates.js +++ b/public/javascripts/email_templates.js @@ -4,7 +4,7 @@ jQuery(document).ready(function($) { $.getJSON($(this).data('url'), {id: $(this).val()}, function(data) { $('#mailing-form #mailing_subject').val(data.parsed_subject); - $('#mailing-form .mceEditor').val(data.parsed_body); + $('#mailing-form .body').val(data.parsed_body); }); }); }); diff --git a/public/javascripts/tinymce.js b/public/javascripts/tinymce.js index 441f7b5..1295de7 100644 --- a/public/javascripts/tinymce.js +++ b/public/javascripts/tinymce.js @@ -13,10 +13,13 @@ noosfero.tinymce = { }, init: function(_options) { - var options = jQuery.extend({}, this.defaultOptions, _options) + var options = jQuery.extend({}, this.defaultOptions, _options); // just init. initing this is necessary to add some buttons to the toolbar - tinymce.init(options) - // apply to selector - jQuery('.mceEditor').tinymce(options); + tinymce.init(options); +// var options = jQuery.extend({selector: '.tiny_mce_simple'}, this.defaultOptions, _options); +// delete options['toolbar2']; +// options['menubar'] = false; + // just init. initing this is necessary to add some buttons to the toolbar +// tinymce.init(options); }, }; diff --git a/script/sample-articles b/script/sample-articles index 6dfd74f..9d3fe48 100755 --- a/script/sample-articles +++ b/script/sample-articles @@ -9,13 +9,13 @@ TAGS = ['free-software', 'noosfero', 'development', 'rails', 'ruby'] EVENT_SUBJECTS = ['International Conference on %s', '%s day', '%s World Congress', '%s World Forum', '%s Summit', '%s Week'] THEMES = ['Sustainability', 'Free Software', 'Climate Change', 'Environment', 'Agile Development', 'Solidarity Economy', 'Debian', 'Perl'] -print "Creating some TinyMce articles: " +print "Creating some Text articles: " for subject in SUBJECTS rand(20).times do |i| profile = profiles.sample name = "%s #{subject}" % profile.name next if profile.articles.where(:slug => name.to_slug).first - article = TinyMceArticle.new( + article = TextArticle.new( :name => name, :body => name, :tag_list => [TAGS.sample, TAGS.sample], @@ -71,7 +71,7 @@ for subject in SUBJECTS rand(20).times do |i| profile = profiles.sample name = "%s #{subject}" % profile.name - article = TinyMceArticle.new( + article = TextArticle.new( :name => name, :body => name, :tag_list => [TAGS.sample, TAGS.sample], diff --git a/test/api/activities_test.rb b/test/api/activities_test.rb index 15e9f43..4ce9b5c 100644 --- a/test/api/activities_test.rb +++ b/test/api/activities_test.rb @@ -107,7 +107,7 @@ class ActivitiesTest < ActiveSupport::TestCase should 'scrap activity return leave_scrap verb' do ActionTracker::Record.destroy_all - create(TinyMceArticle, :name => 'Tracked Article 1', :profile_id => person.id) + create(TextArticle, :name => 'Tracked Article 1', :profile_id => person.id) create(Scrap, :sender_id => person.id, :receiver_id => person.id) get "/api/v1/profiles/#{person.id}/activities?#{params.to_query}" json = JSON.parse(last_response.body) diff --git a/test/api/articles_test.rb b/test/api/articles_test.rb index 7f2dd0f..b1cdaf2 100644 --- a/test/api/articles_test.rb +++ b/test/api/articles_test.rb @@ -37,8 +37,8 @@ class ArticlesTest < ActiveSupport::TestCase should 'list all text articles' do profile = Community.create(identifier: 'my-community', name: 'name-my-community') a1 = fast_create(TextArticle, :profile_id => profile.id) - a2 = fast_create(TextileArticle, :profile_id => profile.id) - a3 = fast_create(TinyMceArticle, :profile_id => profile.id) + a2 = fast_create(TextArticle, :profile_id => profile.id) + a3 = fast_create(TextArticle, :profile_id => profile.id) params['content_type']='TextArticle' get "api/v1/communities/#{profile.id}/articles?#{params.to_query}" json = JSON.parse(last_response.body) @@ -138,8 +138,8 @@ class ArticlesTest < ActiveSupport::TestCase should 'list all text articles of children' do article = fast_create(Article, :profile_id => user.person.id, :name => "Some thing") child1 = fast_create(TextArticle, :parent_id => article.id, :profile_id => user.person.id, :name => "Some thing 1") - child2 = fast_create(TextileArticle, :parent_id => article.id, :profile_id => user.person.id, :name => "Some thing 2") - child3 = fast_create(TinyMceArticle, :parent_id => article.id, :profile_id => user.person.id, :name => "Some thing 3") + child2 = fast_create(TextArticle, :parent_id => article.id, :profile_id => user.person.id, :name => "Some thing 2") + child3 = fast_create(TextArticle, :parent_id => article.id, :profile_id => user.person.id, :name => "Some thing 3") get "/api/v1/articles/#{article.id}/children?#{params.to_query}" json = JSON.parse(last_response.body) assert_equivalent [child1.id, child2.id, child3.id], json["articles"].map { |a| a["id"] } @@ -473,7 +473,7 @@ class ArticlesTest < ActiveSupport::TestCase assert_kind_of TextArticle, Article.last end - should "#{kind}: create article of TinyMceArticle type if no content type is passed as parameter" do + should "#{kind}: create article of TexrArticle type if no content type is passed as parameter" do profile = fast_create(kind.camelcase.constantize, :environment_id => environment.id) Person.any_instance.stubs(:can_post_content?).with(profile).returns(true) @@ -481,7 +481,7 @@ class ArticlesTest < ActiveSupport::TestCase post "/api/v1/#{kind.pluralize}/#{profile.id}/articles?#{params.to_query}" json = JSON.parse(last_response.body) - assert_kind_of TinyMceArticle, Article.last + assert_kind_of TextArticle, Article.last end should "#{kind}: not create article with invalid article content type" do @@ -567,12 +567,12 @@ class ArticlesTest < ActiveSupport::TestCase assert_kind_of TextArticle, Article.last end - should 'person create article of TinyMceArticle type if no content type is passed as parameter' do + should 'person create article of TextArticle type if no content type is passed as parameter' do params[:article] = {:name => "Title"} post "/api/v1/people/#{user.person.id}/articles?#{params.to_query}" json = JSON.parse(last_response.body) - assert_kind_of TinyMceArticle, Article.last + assert_kind_of TextArticle, Article.last end should 'person not create article with invalid article content type' do diff --git a/test/api/helpers_test.rb b/test/api/helpers_test.rb index 2408805..87d80bb 100644 --- a/test/api/helpers_test.rb +++ b/test/api/helpers_test.rb @@ -99,7 +99,7 @@ class Api::HelpersTest < ActiveSupport::TestCase end should 'parse_content_type return all content types as an array' do - assert_equivalent ['TextileArticle','TinyMceArticle'], parse_content_type("TextileArticle,TinyMceArticle") + assert_equivalent ['Event','TextArticle'], parse_content_type("Event,TextArticle") end should 'find_article return article by id in list passed for user with permission' do diff --git a/test/api/search_test.rb b/test/api/search_test.rb index 8b581ed..28ff473 100644 --- a/test/api/search_test.rb +++ b/test/api/search_test.rb @@ -42,16 +42,16 @@ class SearchTest < ActiveSupport::TestCase should 'not list articles of wrong type' do Article.delete_all fast_create(Article, :profile_id => person.id) - get "/api/v1/search/article?type=TinyMceArticle" + get "/api/v1/search/article?type=TextArticle" json = JSON.parse(last_response.body) assert_empty json['articles'] end should 'list articles of one type' do fast_create(Article, :profile_id => person.id) - article = fast_create(TinyMceArticle, :profile_id => person.id) + article = fast_create(TextArticle, :profile_id => person.id) - get "/api/v1/search/article?type=TinyMceArticle" + get "/api/v1/search/article?type=TextArticle" json = JSON.parse(last_response.body) assert_equal article.id, json['articles'].first['id'] end @@ -59,8 +59,8 @@ class SearchTest < ActiveSupport::TestCase should 'list articles of one type and query string' do fast_create(Article, :profile_id => person.id, :name => 'some article') fast_create(Article, :profile_id => person.id, :name => 'Some thing') - article = fast_create(TinyMceArticle, :profile_id => person.id, :name => 'Some thing') - get "/api/v1/search/article?type=TinyMceArticle&query=thing" + article = fast_create(TextArticle, :profile_id => person.id, :name => 'Some thing') + get "/api/v1/search/article?type=TextArticle&query=thing" json = JSON.parse(last_response.body) assert_equal 1, json['articles'].count assert_equal article.id, json['articles'].first['id'] diff --git a/test/fixtures/articles.yml b/test/fixtures/articles.yml deleted file mode 100644 index e8f74d9..0000000 --- a/test/fixtures/articles.yml +++ /dev/null @@ -1,5 +0,0 @@ -ze_homepage: - id: 1 - name: 'Ze home page' - profile_id: 4 - type: 'TinyMceArticle' diff --git a/test/functional/application_controller_test.rb b/test/functional/application_controller_test.rb index b84c00d..437f97c 100644 --- a/test/functional/application_controller_test.rb +++ b/test/functional/application_controller_test.rb @@ -97,38 +97,6 @@ class ApplicationControllerTest < ActionController::TestCase }) end - def test_should_generate_help_box_expanding_textile_markup_when_passing_string - get :help_textile_with_string - assert_tag({ - :tag => 'div', - :attributes => { :class => 'help_box'}, - :descendant => { - :tag => 'div', - :attributes => { :class => 'help_message', :style => /display:\s+none/}, - :descendant => { - :tag => 'strong', - :content => /my_bold_help_message/ - } - } - }) - end - - def test_should_generate_help_box_expanding_textile_markup_when_passing_block - get :help_textile_with_block - assert_tag({ - :tag => 'div', - :attributes => { :class => 'help_box'}, - :descendant => { - :tag => 'div', - :attributes => { :class => 'help_message', :style => /display:\s+none/}, - :descendant => { - :tag => 'strong', - :content => /my_bold_help_message/ - } - } - }) - end - def test_shouldnt_generate_help_box_markup_when_no_block_is_passed get :help_without_block assert_no_tag({ diff --git a/test/functional/cms_controller_test.rb b/test/functional/cms_controller_test.rb index 4f1b81b..d688ad8 100644 --- a/test/functional/cms_controller_test.rb +++ b/test/functional/cms_controller_test.rb @@ -50,26 +50,26 @@ class CmsControllerTest < ActionController::TestCase assert_template 'select_article_type' # TODO add more types here !! - [ TinyMceArticle, TextileArticle ].each do |item| + [TextArticle ].each do |item| assert_tag :tag => 'a', :attributes => { :href => "/myprofile/#{profile.identifier}/cms/new?type=#{item.name}" } end end should 'present edit screen after choosing article type' do - get :new, :profile => profile.identifier, :type => 'TinyMceArticle' + get :new, :profile => profile.identifier, :type => 'TextArticle' assert_template 'edit' - assert_tag :tag => 'form', :attributes => { :action => "/myprofile/#{profile.identifier}/cms/new", :method => /post/i }, :descendant => { :tag => "input", :attributes => { :type => 'hidden', :value => 'TinyMceArticle' }} + assert_tag :tag => 'form', :attributes => { :action => "/myprofile/#{profile.identifier}/cms/new", :method => /post/i }, :descendant => { :tag => "input", :attributes => { :type => 'hidden', :value => 'TextArticle' }} end should 'be able to save a document' do assert_difference 'Article.count' do - post :new, :type => 'TinyMceArticle', :profile => profile.identifier, :article => { :name => 'a test article', :body => 'the text of the article ...' } + post :new, :type => 'TextArticle', :profile => profile.identifier, :article => { :name => 'a test article', :body => 'the text of the article ...' } end end should 'display set as home page link to non folder' do - a = fast_create(TextileArticle, :profile_id => profile.id, :updated_at => DateTime.now) + a = fast_create(TextArticle, :profile_id => profile.id, :updated_at => DateTime.now) Article.stubs(:short_description).returns('bli') get :index, :profile => profile.identifier assert_tag :tag => 'a', :content => 'Use as homepage', :attributes => { :href => "/myprofile/#{profile.identifier}/cms/set_home_page/#{a.id}" } @@ -198,7 +198,7 @@ class CmsControllerTest < ActionController::TestCase should 'set last_changed_by when creating article' do login_as(profile.identifier) - post :new, :type => 'TinyMceArticle', :profile => profile.identifier, :article => { :name => 'changed by me', :body => 'content ...' } + post :new, :type => 'TextArticle', :profile => profile.identifier, :article => { :name => 'changed by me', :body => 'content ...' } a = profile.articles.find_by(path: 'changed-by-me') assert_not_nil a @@ -222,7 +222,7 @@ class CmsControllerTest < ActionController::TestCase should 'be able to set label to article image' do login_as(profile.identifier) - post :new, :type => TextileArticle.name, :profile => profile.identifier, + post :new, :type => TextArticle.name, :profile => profile.identifier, :article => { :name => 'adding-image-label', :image_builder => { @@ -449,7 +449,7 @@ class CmsControllerTest < ActionController::TestCase article.save! get :new, :profile => profile.identifier, :parent_id => article.id, :cms => true - assert_tag :tag => 'a', :attributes => { :href => "/myprofile/#{profile.identifier}/cms/new?parent_id=#{article.id}&type=TextileArticle"} + assert_tag :tag => 'a', :attributes => { :href => "/myprofile/#{profile.identifier}/cms/new?parent_id=#{article.id}&type=TextArticle"} end should 'not offer to create children if article does not accept them' do @@ -510,7 +510,7 @@ class CmsControllerTest < ActionController::TestCase c3 = env.categories.build(:name => "Test Category 3"); c3.save! # post is in c1 and c3 - post :new, :type => TextileArticle.name, :profile => profile.identifier, :article => { :name => 'adding-categories-test', :category_ids => [ c1.id, c3.id] } + post :new, :type => TextArticle.name, :profile => profile.identifier, :article => { :name => 'adding-categories-test', :category_ids => [ c1.id, c3.id] } saved = profile.articles.find_by(name: 'adding-categories-test') assert_includes saved.categories, c1 @@ -525,34 +525,34 @@ class CmsControllerTest < ActionController::TestCase c3 = env.categories.build(:name => "Test Category 3"); c3.save! # post is in c1, c3 and c3 - post :new, :type => TextileArticle.name, :profile => profile.identifier, :article => { :name => 'adding-categories-test', :category_ids => [ c1.id, c3.id, c3.id ] } + post :new, :type => TextArticle.name, :profile => profile.identifier, :article => { :name => 'adding-categories-test', :category_ids => [ c1.id, c3.id, c3.id ] } saved = profile.articles.find_by(name: 'adding-categories-test') assert_equivalent [c1, c3], saved.categories.all end should 'filter html with white_list from tiny mce article name' do - post :new, :type => 'TinyMceArticle', :profile => profile.identifier, :article => { :name => "test", :body => 'the text of the article ...' } + post :new, :type => 'TextArticle', :profile => profile.identifier, :article => { :name => "test", :body => 'the text of the article ...' } assert_equal "test", assigns(:article).name end should 'filter html with white_list from tiny mce article abstract' do - post :new, :type => 'TinyMceArticle', :profile => profile.identifier, :article => { :name => 'article', :abstract => " article", :body => 'the text of the article ...' } + post :new, :type => 'TextArticle', :profile => profile.identifier, :article => { :name => 'article', :abstract => " article", :body => 'the text of the article ...' } assert_equal "alert('text') article", assigns(:article).abstract end should 'filter html with white_list from tiny mce article body' do - post :new, :type => 'TinyMceArticle', :profile => profile.identifier, :article => { :name => 'article', :abstract => 'abstract', :body => "the of article ..." } + post :new, :type => 'TextArticle', :profile => profile.identifier, :article => { :name => 'article', :abstract => 'abstract', :body => "the of article ..." } assert_equal "the alert('text') of article ...", assigns(:article).body end should 'not filter html tags permitted from tiny mce article body' do - post :new, :type => 'TinyMceArticle', :profile => profile.identifier, :article => { :name => 'article', :abstract => 'abstract', :body => "the of article ..." } + post :new, :type => 'TextArticle', :profile => profile.identifier, :article => { :name => 'article', :abstract => 'abstract', :body => "the of article ..." } assert_equal "the alert('text') of article ...", assigns(:article).body end should 'sanitize tags' do - post :new, :type => 'TextileArticle', :profile => profile.identifier, :article => { :name => 'a test article', :body => 'the text of the article ...', :tag_list => 'tag1, tag2' } + post :new, :type => 'TextArticle', :profile => profile.identifier, :article => { :name => 'a test article', :body => 'the text of the article ...', :tag_list => 'tag1, tag2' } assert_sanitized assigns(:article).tag_list.join(', ') end @@ -562,7 +562,7 @@ class CmsControllerTest < ActionController::TestCase profile.home_page = profile.blogs.find_by name: "Sample blog" profile.save! - get :new, :profile => @profile.identifier, :parent_id => profile.home_page.id, :type => 'TextileArticle' + get :new, :profile => @profile.identifier, :parent_id => profile.home_page.id, :type => 'TextArticle' assert_tag :tag => 'select', :attributes => { :id => 'article_parent_id' }, :child => { @@ -574,7 +574,7 @@ class CmsControllerTest < ActionController::TestCase profile.articles.destroy_all folder1 = fast_create(Folder, :profile_id => profile.id, :updated_at => DateTime.now - 1.hour) - article = fast_create(TextileArticle, :profile_id => profile.id, :updated_at => DateTime.now) + article = fast_create(TextArticle, :profile_id => profile.id, :updated_at => DateTime.now) folder2 = fast_create(Folder, :profile_id => profile.id, :updated_at => DateTime.now + 1.hour) get :index, :profile => profile.identifier @@ -586,7 +586,7 @@ class CmsControllerTest < ActionController::TestCase parent = fast_create(Folder, :profile_id => profile.id) folder1 = fast_create(Folder, :parent_id => parent.id, :profile_id => profile.id, :updated_at => DateTime.now - 1.hour) - article = fast_create(TextileArticle, :parent_id => parent.id, :profile_id => profile.id, :updated_at => DateTime.now) + article = fast_create(TextArticle, :parent_id => parent.id, :profile_id => profile.id, :updated_at => DateTime.now) folder2 = fast_create(Folder, :parent_id => parent.id, :profile_id => profile.id, :updated_at => DateTime.now + 1.hour) get :view, :profile => profile.identifier, :id => parent.id @@ -606,14 +606,14 @@ class CmsControllerTest < ActionController::TestCase end should 'redirect to article after creating top-level article' do - post :new, :profile => profile.identifier, :type => 'TextileArticle', :article => { :name => 'top-level-article' } + post :new, :profile => profile.identifier, :type => 'TextArticle', :article => { :name => 'top-level-article' } assert_redirected_to @profile.articles.find_by(name: 'top-level-article').url end should 'redirect to article after creating article inside a folder' do f = Folder.new(:name => 'f'); profile.articles << f; f.save! - post :new, :profile => profile.identifier, :type => 'TextileArticle', :parent_id => f.id, :article => { :name => 'article-inside-folder' } + post :new, :profile => profile.identifier, :type => 'TextArticle', :parent_id => f.id, :article => { :name => 'article-inside-folder' } assert_redirected_to @profile.articles.find_by(name: 'article-inside-folder').url end @@ -626,7 +626,7 @@ class CmsControllerTest < ActionController::TestCase should 'redirect back to article after editing article inside a folder' do f = Folder.new(:name => 'f'); profile.articles << f; f.save! - a = create(TextileArticle, :parent => f, :name => 'article-inside-folder', :profile_id => profile.id) + a = create(TextArticle, :parent => f, :name => 'article-inside-folder', :profile_id => profile.id) post :edit, :profile => profile.identifier, :id => a.id assert_redirected_to @profile.articles.find_by(name: 'article-inside-folder').url @@ -653,7 +653,7 @@ class CmsControllerTest < ActionController::TestCase should 'point back to folder when cancelling edition of an article inside it' do f = Folder.new(:name => 'f'); profile.articles << f; f.save! - a = create(TextileArticle, :name => 'test', :parent => f, :profile_id => profile.id) + a = create(TextArticle, :name => 'test', :parent => f, :profile_id => profile.id) get :edit, :profile => profile.identifier, :id => a.id assert_tag :tag => 'a', :attributes => { :href => "/myprofile/#{profile.identifier}/cms/view/#{f.id}" }, :descendant => { :content => /Cancel/ } @@ -723,15 +723,15 @@ class CmsControllerTest < ActionController::TestCase end should 'be able to add image with alignment' do - post :new, :type => 'TinyMceArticle', :profile => profile.identifier, :article => { :name => 'image-alignment', :body => "the text of the article with image right align..." } - saved = TinyMceArticle.find_by(name: 'image-alignment') + post :new, :type => 'TextArticle', :profile => profile.identifier, :article => { :name => 'image-alignment', :body => "the text of the article with image right align..." } + saved = TextArticle.find_by(name: 'image-alignment') assert_match //, saved.body assert_match //, saved.body end should 'be able to add image with alignment when textile' do - post :new, :type => 'TextileArticle', :profile => profile.identifier, :article => { :name => 'image-alignment', :body => "the text of the article with image right align..." } - saved = TextileArticle.find_by(name: 'image-alignment') + post :new, :type => 'TextArticle', :profile => profile.identifier, :article => { :name => 'image-alignment', :body => "the text of the article with image right align..." } + saved = TextArticle.find_by(name: 'image-alignment') assert_match /align="right"/, saved.body end @@ -778,19 +778,19 @@ class CmsControllerTest < ActionController::TestCase should 'record as coming from public view when creating article' do @request.expects(:referer).returns('http://colivre.net/testinguser/testingusers-home-page').at_least_once - get :new, :profile => 'testinguser', :type => 'TextileArticle' + get :new, :profile => 'testinguser', :type => 'TextArticle' assert_tag :tag => 'input', :attributes => { :type => 'hidden', :name => 'back_to', :value => @request.referer } assert_tag :tag => 'a', :descendant => { :content => 'Cancel' }, :attributes => { :href => 'http://colivre.net/testinguser/testingusers-home-page' } end should 'go to public view after creating article coming from there' do - post :new, :profile => 'testinguser', :type => 'TextileArticle', :back_to => 'public_view', :article => { :name => 'new-article-from-public-view' } + post :new, :profile => 'testinguser', :type => 'TextArticle', :back_to => 'public_view', :article => { :name => 'new-article-from-public-view' } assert_response :redirect assert_redirected_to @profile.articles.find_by(name: 'new-article-from-public-view').url end should 'keep the back_to hint in unsuccessfull saves' do - post :new, :profile => 'testinguser', :type => 'TextileArticle', :back_to => 'public_view', :article => { } + post :new, :profile => 'testinguser', :type => 'TextArticle', :back_to => 'public_view', :article => { } assert_response :success assert_tag :tag => "input", :attributes => { :type => 'hidden', :name => 'back_to', :value => 'public_view' } end @@ -798,7 +798,7 @@ class CmsControllerTest < ActionController::TestCase should 'create a private article child of private folder' do folder = build(Folder, :name => 'my intranet', :published => false); profile.articles << folder; folder.save! - post :new, :profile => profile.identifier, :type => 'TextileArticle', :parent_id => folder.id, :article => { :name => 'new-private-article'} + post :new, :profile => profile.identifier, :type => 'TextArticle', :parent_id => folder.id, :article => { :name => 'new-private-article'} folder.reload refute assigns(:article).published? @@ -1198,7 +1198,7 @@ class CmsControllerTest < ActionController::TestCase end end - should 'display media listing when it is TinyMceArticle and enabled on environment' do + should 'display media listing when it is TextArticle and enabled on environment' do e = Environment.default e.enable('media_panel') e.save! @@ -1209,7 +1209,7 @@ class CmsControllerTest < ActionController::TestCase image = UploadedFile.create!(:profile => profile, :parent => image_folder, :uploaded_data => fixture_file_upload('/files/rails.png', 'image/png')) file = UploadedFile.create!(:profile => profile, :parent => non_image_folder, :uploaded_data => fixture_file_upload('/files/test.txt', 'text/plain')) - get :new, :profile => profile.identifier, :type => 'TinyMceArticle' + get :new, :profile => profile.identifier, :type => 'TextArticle' assert_tag :div, :attributes => { :class => "text-editor-sidebar" } end @@ -1225,7 +1225,7 @@ class CmsControllerTest < ActionController::TestCase end should "display 'Publish' when profile is a person and is member of communities" do - a = fast_create(TextileArticle, :profile_id => profile.id, :updated_at => DateTime.now) + a = fast_create(TextArticle, :profile_id => profile.id, :updated_at => DateTime.now) c1 = fast_create(Community) c2 = fast_create(Community) c1.add_member(profile) @@ -1235,7 +1235,7 @@ class CmsControllerTest < ActionController::TestCase end should "display 'Publish' when profile is a person and there is a portal community" do - a = fast_create(TextileArticle, :profile_id => profile.id, :updated_at => DateTime.now) + a = fast_create(TextArticle, :profile_id => profile.id, :updated_at => DateTime.now) environment = profile.environment environment.portal_community = fast_create(Community) environment.enable('use_portal_community') @@ -1247,7 +1247,7 @@ class CmsControllerTest < ActionController::TestCase should "display 'Publish' when profile is a community" do community = fast_create(Community) community.add_admin(profile) - a = fast_create(TextileArticle, :profile_id => community.id, :updated_at => DateTime.now) + a = fast_create(TextArticle, :profile_id => community.id, :updated_at => DateTime.now) Article.stubs(:short_description).returns('bli') get :index, :profile => community.identifier assert_tag :tag => 'a', :attributes => {:href => "/myprofile/#{community.identifier}/cms/publish/#{a.id}"} @@ -1279,7 +1279,7 @@ class CmsControllerTest < ActionController::TestCase login_as :test_user @controller.stubs(:user).returns(u) - get :new, :profile => c.identifier, :type => 'TinyMceArticle' + get :new, :profile => c.identifier, :type => 'TextArticle' assert_response :success assert_template 'edit' end @@ -1496,12 +1496,14 @@ class CmsControllerTest < ActionController::TestCase assert_select '#dynamic_recaptcha', 0 end - should 'render TinyMce Editor on suggestion of article' do + should 'render TinyMce Editor on suggestion of article if editor is TinyMCE' do logout + profile.editor = Article::Editor::TINY_MCE + profile.save get :suggest_an_article, :profile => profile.identifier - assert_tag :tag => 'textarea', :attributes => { :name => /task\[article\]\[abstract\]/, :class => 'mceEditor' } - assert_tag :tag => 'textarea', :attributes => { :name => /task\[article\]\[body\]/, :class => 'mceEditor' } + assert_tag :tag => 'textarea', :attributes => { :name => /task\[article\]\[abstract\]/, :class => Article::Editor::TINY_MCE } + assert_tag :tag => 'textarea', :attributes => { :name => /task\[article\]\[body\]/, :class => Article::Editor::TINY_MCE } end should 'create a task suggest task to a profile' do @@ -1537,7 +1539,7 @@ class CmsControllerTest < ActionController::TestCase e = Environment.default e.languages = ['ru'] e.save - textile = fast_create(TextileArticle, :profile_id => @profile.id, :path => 'textile', :language => 'ru') + textile = fast_create(TextArticle, :profile_id => @profile.id, :path => 'textile', :language => 'ru') get :edit, :profile => @profile.identifier, :id => textile.id assert_tag :option, :attributes => { :selected => 'selected', :value => 'ru' }, :parent => { :tag => 'select', :attributes => { :id => 'article_language'} } @@ -1547,16 +1549,16 @@ class CmsControllerTest < ActionController::TestCase e = Environment.default e.languages = ['en', 'pt','fr','hy','de', 'ru', 'es', 'eo', 'it'] e.save - get :new, :profile => @profile.identifier, :type => 'TextileArticle' + get :new, :profile => @profile.identifier, :type => 'TextArticle' assert_equal Noosfero.locales.invert, assigns(:locales) assert_tag :option, :attributes => { :value => '' }, :parent => { :tag => 'select', :attributes => { :id => 'article_language'} } end should 'add translation to an article' do - textile = fast_create(TextileArticle, :profile_id => @profile.id, :path => 'textile', :language => 'ru') + textile = fast_create(TextArticle, :profile_id => @profile.id, :path => 'textile', :language => 'ru') assert_difference 'Article.count' do - post :new, :profile => @profile.identifier, :type => 'TextileArticle', :article => { :name => 'english translation', :translation_of_id => textile.id, :language => 'en' } + post :new, :profile => @profile.identifier, :type => 'TextArticle', :article => { :name => 'english translation', :translation_of_id => textile.id, :language => 'en' } end end @@ -1616,20 +1618,20 @@ class CmsControllerTest < ActionController::TestCase should 'display accept comments option when creating forum post' do profile.articles << f = Forum.new(:name => 'Forum for test') - get :new, :profile => profile.identifier, :type => 'TinyMceArticle', :parent_id => f.id + get :new, :profile => profile.identifier, :type => 'TextArticle', :parent_id => f.id assert_no_tag :tag => 'input', :attributes => {:name => 'article[accept_comments]', :value => 1, :type => 'hidden'} assert_tag :tag => 'input', :attributes => {:name => 'article[accept_comments]', :value => 1, :type => 'checkbox'} end should 'display accept comments option when creating an article that is not a forum post' do - get :new, :profile => profile.identifier, :type => 'TinyMceArticle' + get :new, :profile => profile.identifier, :type => 'TextArticle' assert_no_tag :tag => 'input', :attributes => {:name => 'article[accept_comments]', :value => 1, :type => 'hidden'} assert_tag :tag => 'input', :attributes => {:name => 'article[accept_comments]', :value => 1, :type => 'checkbox'} end should 'display accept comments option when editing forum post' do profile.articles << f = Forum.new(:name => 'Forum for test') - profile.articles << a = TinyMceArticle.new(:name => 'Forum post for test', :parent => f) + profile.articles << a = TextArticle.new(:name => 'Forum post for test', :parent => f) get :edit, :profile => profile.identifier, :id => a.id assert_no_tag :tag => 'input', :attributes => {:name => 'article[accept_comments]', :value => 1, :type => 'hidden'} assert_tag :tag => 'input', :attributes => {:name => 'article[accept_comments]', :value => 1, :type => 'checkbox'} @@ -1642,7 +1644,7 @@ class CmsControllerTest < ActionController::TestCase :topic_creation => 'self', :body => 'Forum Body') - post :new, :profile => profile.identifier, :type => 'TinyMceArticle', + post :new, :profile => profile.identifier, :type => 'TextArticle', :article => {:name => 'New Topic by linux', :body => 'Article Body', :parent_id => f.id} @@ -1657,7 +1659,7 @@ class CmsControllerTest < ActionController::TestCase :topic_creation => 'related', :body => 'Forum Body') - post :new, :profile => profile.identifier, :type => 'TinyMceArticle', + post :new, :profile => profile.identifier, :type => 'TextArticle', :article => {:name => 'New Topic by linux', :body => 'Article Body', :parent_id => f.id} @@ -1672,7 +1674,7 @@ class CmsControllerTest < ActionController::TestCase :topic_creation => 'users', :body => 'Forum Body') - post :new, :profile => profile.identifier, :type => 'TinyMceArticle', + post :new, :profile => profile.identifier, :type => 'TextArticle', :article => {:name => 'New Topic by linux', :body => 'Article Body', :parent_id => f.id} @@ -1681,13 +1683,13 @@ class CmsControllerTest < ActionController::TestCase should 'display accept comments option when editing forum post with a different label' do profile.articles << f = Forum.new(:name => 'Forum for test') - profile.articles << a = TinyMceArticle.new(:name => 'Forum post for test', :parent => f) + profile.articles << a = TextArticle.new(:name => 'Forum post for test', :parent => f) get :edit, :profile => profile.identifier, :id => a.id assert_tag :tag => 'label', :attributes => { :for => 'article_accept_comments' }, :content => _('This topic is opened for replies') end should 'display correct label for accept comments option for an article that is not a forum post' do - profile.articles << a = TinyMceArticle.new(:name => 'Forum post for test') + profile.articles << a = TextArticle.new(:name => 'Forum post for test') get :edit, :profile => profile.identifier, :id => a.id assert_tag :tag => 'label', :attributes => { :for => 'article_accept_comments' }, :content => _('I want to receive comments about this article') end @@ -1711,7 +1713,7 @@ class CmsControllerTest < ActionController::TestCase end should 'update article and be redirect to view_page' do - a = fast_create(TextileArticle, :profile_id => @profile.id) + a = fast_create(TextArticle, :profile_id => @profile.id) post :edit, :profile => @profile.identifier, :id => a.id, :article => { } assert_redirected_to a.view_url end @@ -1730,12 +1732,14 @@ class CmsControllerTest < ActionController::TestCase end should 'render TinyMce Editor for events' do + profile.editor = Article::Editor::TINY_MCE + profile.save get :new, :profile => @profile.identifier, :type => 'Event' - assert_tag :tag => 'textarea', :attributes => { :class => 'mceEditor' } + assert_tag :tag => 'textarea', :attributes => { :class => Article::Editor::TINY_MCE } end should 'identify form with classname of edited article' do - [Blog, TinyMceArticle, Forum].each do |klass| + [Blog, TextArticle, Forum].each do |klass| a = fast_create(klass, :profile_id => profile.id) get :edit, :profile => profile.identifier, :id => a.id assert_tag :tag => 'form', :attributes => {:class => "#{a.type} #{a.type.to_css_class}"} @@ -1771,14 +1775,6 @@ class CmsControllerTest < ActionController::TestCase assert_response :bad_request end - should 'make RawHTMLArticle available only to environment admins' do - @controller.stubs(:profile).returns(profile) - @controller.stubs(:user).returns(profile) - assert_not_includes available_article_types, RawHTMLArticle - profile.environment.add_admin(profile) - assert_includes available_article_types, RawHTMLArticle - end - should 'include new contents special types from plugins' do class TestContentTypesPlugin < Noosfero::Plugin def content_types @@ -1810,7 +1806,7 @@ class CmsControllerTest < ActionController::TestCase License.delete_all login_as(profile.identifier) - get :new, :profile => profile.identifier, :type => 'TinyMceArticle' + get :new, :profile => profile.identifier, :type => 'TextArticle' assert_no_tag :tag => 'select', :attributes => {:id => 'article_license_id'} end @@ -1843,7 +1839,7 @@ class CmsControllerTest < ActionController::TestCase should 'set author when creating article' do login_as(profile.identifier) - post :new, :type => 'TinyMceArticle', :profile => profile.identifier, :article => { :name => 'Sample Article', :body => 'content ...' } + post :new, :type => 'TextArticle', :profile => profile.identifier, :article => { :name => 'Sample Article', :body => 'content ...' } a = profile.articles.find_by(path: 'sample-article') assert_not_nil a @@ -1869,7 +1865,7 @@ class CmsControllerTest < ActionController::TestCase folder = fast_create(Folder, :name=>'a', :profile_id => profile.id) gallery = fast_create(Gallery, :name=>'b', :profile_id => profile.id) blog = fast_create(Blog, :name=>'c', :profile_id => profile.id) - article = fast_create(TinyMceArticle, :profile_id => profile.id) + article = fast_create(TextArticle, :profile_id => profile.id) get :edit, :profile => profile.identifier, :id => article.id assert_template 'edit' assert_tag :tag => 'select', :attributes => { :name => "parent_id" }, @@ -1897,7 +1893,7 @@ class CmsControllerTest < ActionController::TestCase end should 'go back to specified url when saving with success' do - post :new, :type => 'TinyMceArticle', :profile => profile.identifier, :article => { :name => 'changed by me', :body => 'content ...' }, :success_back_to => '/' + post :new, :type => 'TextArticle', :profile => profile.identifier, :article => { :name => 'changed by me', :body => 'content ...' }, :success_back_to => '/' assert_redirected_to '/' end @@ -1927,7 +1923,7 @@ class CmsControllerTest < ActionController::TestCase should 'set created_by when creating article' do login_as(profile.identifier) - post :new, :type => 'TinyMceArticle', :profile => profile.identifier, :article => { :name => 'changed by me', :body => 'content ...' } + post :new, :type => 'TextArticle', :profile => profile.identifier, :article => { :name => 'changed by me', :body => 'content ...' } a = profile.articles.find_by(path: 'changed-by-me') assert_not_nil a @@ -1973,13 +1969,13 @@ class CmsControllerTest < ActionController::TestCase profile.articles << f f.save! - post :new, :type => 'TinyMceArticle', :profile => profile.identifier, :parent_id => f.id, + post :new, :type => 'TextArticle', :profile => profile.identifier, :parent_id => f.id, :article => { :name => 'Main Article', :body => 'some content' } main_article = profile.articles.find_by(name: 'Main Article') assert_not_nil main_article - post :new, :type => 'TinyMceArticle', :profile => profile.identifier, :parent_id => f.id, + post :new, :type => 'TextArticle', :profile => profile.identifier, :parent_id => f.id, :id => main_article.id, :clone => true cloned_main_article = profile.articles.find_by(name: 'Main Article') @@ -1988,7 +1984,7 @@ class CmsControllerTest < ActionController::TestCase assert_equal main_article.parent_id, cloned_main_article.parent_id get :new, :profile => profile.identifier, :id => cloned_main_article.id, - :clone => true, :type => 'TinyMceArticle' + :clone => true, :type => 'TextArticle' assert_match main_article.body, @response.body end @@ -2005,7 +2001,7 @@ class CmsControllerTest < ActionController::TestCase end end - [TextileArticle, Event, TinyMceArticle].each do |klass| + [TextArticle, Event].each do |klass| should "set no_design_blocks as true when create #{klass.name}" do get :new, profile: profile.identifier, type: klass.name assert assigns(:no_design_blocks) @@ -2018,7 +2014,7 @@ class CmsControllerTest < ActionController::TestCase assert !assigns(:no_design_blocks) end - [TextileArticle, Event, TinyMceArticle].each do |klass| + [TextArticle, Event].each do |klass| should "set no_design_blocks as true when edit #{klass.name}" do article = fast_create(klass, profile_id: profile.id) get :edit, profile: profile.identifier, id: article.id diff --git a/test/functional/content_viewer_controller_test.rb b/test/functional/content_viewer_controller_test.rb index 3fbc5e8..86e6ba3 100644 --- a/test/functional/content_viewer_controller_test.rb +++ b/test/functional/content_viewer_controller_test.rb @@ -119,7 +119,7 @@ class ContentViewerControllerTest < ActionController::TestCase end should "display image label on article image" do - page = TinyMceArticle.create!( + page = TextArticle.create!( :profile => profile, :name => 'myarticle', :image_builder => { @@ -453,7 +453,7 @@ class ContentViewerControllerTest < ActionController::TestCase should 'list unpublished posts to owner with a different class' do login_as('testinguser') blog = Blog.create!(:name => 'A blog test', :profile => profile) - blog.posts << TextileArticle.create!(:name => 'Post', :profile => profile, :parent => blog, :published => false) + blog.posts << TextArticle.create!(:name => 'Post', :profile => profile, :parent => blog, :published => false) get :view_page, :profile => profile.identifier, :page => [blog.path] assert_tag :tag => 'div', :attributes => {:class => /not-published/} @@ -461,7 +461,7 @@ class ContentViewerControllerTest < ActionController::TestCase should 'not list unpublished posts to a not logged person' do blog = Blog.create!(:name => 'A blog test', :profile => profile) - blog.posts << TextileArticle.create!(:name => 'Post', :profile => profile, :parent => blog, :published => false) + blog.posts << TextArticle.create!(:name => 'Post', :profile => profile, :parent => blog, :published => false) get :view_page, :profile => profile.identifier, :page => [blog.path] assert_no_tag :tag => 'a', :content => "Post" @@ -470,7 +470,7 @@ class ContentViewerControllerTest < ActionController::TestCase should 'display pagination links of blog' do blog = Blog.create!(:name => 'A blog test', :profile => profile, :posts_per_page => 5) for n in 1..10 - blog.posts << TextileArticle.create!(:name => "Post #{n}", :profile => profile, :parent => blog) + blog.posts << TextArticle.create!(:name => "Post #{n}", :profile => profile, :parent => blog) end assert_equal 10, blog.posts.size @@ -481,7 +481,7 @@ class ContentViewerControllerTest < ActionController::TestCase should 'display first page of blog posts' do blog = Blog.create!(:name => 'My blog', :profile => profile, :posts_per_page => 5) for n in 1..10 - blog.children << TextileArticle.create!(:name => "Post #{n}", :profile => profile, :parent => blog) + blog.children << TextArticle.create!(:name => "Post #{n}", :profile => profile, :parent => blog) end assert_equal 10, blog.posts.size @@ -497,7 +497,7 @@ class ContentViewerControllerTest < ActionController::TestCase should 'display others pages of blog posts' do blog = Blog.create!(:name => 'My blog', :profile => profile, :posts_per_page => 5) for n in 1..10 - blog.children << TextileArticle.create!(:name => "Post #{n}", :profile => profile, :parent => blog) + blog.children << TextArticle.create!(:name => "Post #{n}", :profile => profile, :parent => blog) end assert_equal 10, blog.posts.size @@ -514,8 +514,8 @@ class ContentViewerControllerTest < ActionController::TestCase blog = Blog.create!(:name => "blog", :profile => profile) profile.articles << blog - past_post = create(TextileArticle, :name => "past post", :profile => profile, :parent => blog, :published_at => blog.created_at - 1.year) - current_post = TextileArticle.create!(:name => "current post", :profile => profile, :parent => blog) + past_post = create(TextArticle, :name => "past post", :profile => profile, :parent => blog, :published_at => blog.created_at - 1.year) + current_post = TextArticle.create!(:name => "current post", :profile => profile, :parent => blog) blog.children << past_post blog.children << current_post @@ -530,7 +530,7 @@ class ContentViewerControllerTest < ActionController::TestCase should 'give link to create new article inside folder when view child of folder' do login_as('testinguser') folder = Folder.create!(:name => 'myfolder', :profile => @profile) - folder.children << TextileArticle.new(:name => 'children-article', :profile => @profile) + folder.children << TextArticle.new(:name => 'children-article', :profile => @profile) xhr :get, :view_page, :profile => 'testinguser', :page => [ 'myfolder', 'children-article' ], :toolbar => true assert_tag :tag => 'div', :attributes => { :id => 'article-actions' }, :descendant => { :tag => 'a', :attributes => { :href => "/myprofile/testinguser/cms/new?parent_id=#{folder.id}" } } end @@ -555,14 +555,14 @@ class ContentViewerControllerTest < ActionController::TestCase login_as(profile.identifier) a = Blog.create!(:name => 'article folder', :profile => profile) Article.stubs(:short_description).returns('bli') - t = TextileArticle.create!(:name => 'first post', :parent => a, :profile => profile) + t = TextArticle.create!(:name => 'first post', :parent => a, :profile => profile) xhr :get, :view_page, :profile => profile.identifier, :page => [t.path], :toolbar => true assert_tag :tag => 'a', :content => 'New post' end should 'display button to remove article' do login_as(profile.identifier) - t = TextileArticle.create!(:name => 'article to destroy', :profile => profile) + t = TextArticle.create!(:name => 'article to destroy', :profile => profile) xhr :get, :view_page, :profile => profile.identifier, :page => [t.path], :toolbar => true assert_tag :tag => 'a', :content => 'Delete', :attributes => {:href => "/myprofile/#{profile.identifier}/cms/destroy/#{t.id}"} end @@ -584,7 +584,7 @@ class ContentViewerControllerTest < ActionController::TestCase should 'add meta tag to rss feed on view post blog' do login_as(profile.identifier) blog = Blog.create!(:name => 'Blog', :profile => profile) - TextileArticle.create!(:name => 'first post', :parent => blog, :profile => profile) + TextArticle.create!(:name => 'first post', :parent => blog, :profile => profile) get :view_page, :profile => profile.identifier, :page => ['blog', 'first-post'] assert_tag :tag => 'link', :attributes => { :rel => 'alternate', :type => 'application/rss+xml', :title => 'Blog', :href => "http://#{environment.default_hostname}/testinguser/blog/feed" } end @@ -718,13 +718,13 @@ class ContentViewerControllerTest < ActionController::TestCase end should 'display source from article' do - profile.articles << TextileArticle.new(:name => "Article one", :profile => profile, :source => 'http://www.original-source.invalid') + profile.articles << TextArticle.new(:name => "Article one", :profile => profile, :source => 'http://www.original-source.invalid') get :view_page, :profile => profile.identifier, :page => ['article-one'] assert_tag :tag => 'div', :attributes => { :id => 'article-source' }, :content => /http:\/\/www.original-source.invalid/ end should 'not display source if article has no source' do - profile.articles << TextileArticle.new(:name => "Article one", :profile => profile) + profile.articles << TextArticle.new(:name => "Article one", :profile => profile) get :view_page, :profile => profile.identifier, :page => ['article-one'] assert_no_tag :tag => 'div', :attributes => { :id => 'article-source' } end @@ -745,7 +745,7 @@ class ContentViewerControllerTest < ActionController::TestCase should "not display 'Upload files' when viewing post from a blog" do login_as(profile.identifier) b = Blog.create!(:name => 'article folder', :profile => profile) - blog_post = TextileArticle.create!(:name => 'children-article', :profile => profile, :parent => b) + blog_post = TextArticle.create!(:name => 'children-article', :profile => profile, :parent => b) xhr :get, :view_page, :profile => profile.identifier, :page => blog_post.path, :toolbar => true assert_no_tag :tag => 'a', :content => 'Upload files', :attributes => {:href => /parent_id=#{b.id}/} end @@ -799,7 +799,7 @@ class ContentViewerControllerTest < ActionController::TestCase blog = Blog.create!(:name => 'A blog test', :profile => profile, :visualization_format => 'short') - blog.posts << TinyMceArticle.create!(:name => 'first post', :parent => blog, :profile => profile, :body => '

Content to be displayed.

Anything') + blog.posts << TextArticle.create!(:name => 'first post', :parent => blog, :profile => profile, :body => '

Content to be displayed.

Anything') get :view_page, :profile => profile.identifier, :page => blog.path @@ -812,7 +812,7 @@ class ContentViewerControllerTest < ActionController::TestCase blog = Blog.create!(:name => 'A blog test', :profile => profile, :visualization_format => 'short+pic') - blog.posts << TinyMceArticle.create!(:name => 'first post', :parent => blog, :profile => profile, :body => '

Content to be displayed.

') + blog.posts << TextArticle.create!(:name => 'first post', :parent => blog, :profile => profile, :body => '

Content to be displayed.

') get :view_page, :profile => profile.identifier, :page => blog.path @@ -833,7 +833,7 @@ class ContentViewerControllerTest < ActionController::TestCase should 'list unpublished forum posts to owner with a different class' do login_as('testinguser') forum = Forum.create!(:name => 'A forum test', :profile => profile) - forum.posts << TextileArticle.create!(:name => 'Post', :profile => profile, :parent => forum, :published => false) + forum.posts << TextArticle.create!(:name => 'Post', :profile => profile, :parent => forum, :published => false) get :view_page, :profile => profile.identifier, :page => [forum.path] assert_tag :tag => 'tr', :attributes => {:class => /not-published/} @@ -841,7 +841,7 @@ class ContentViewerControllerTest < ActionController::TestCase should 'not list unpublished forum posts to a not logged person' do forum = Forum.create!(:name => 'A forum test', :profile => profile) - forum.posts << TextileArticle.create!(:name => 'Post', :profile => profile, :parent => forum, :published => false) + forum.posts << TextArticle.create!(:name => 'Post', :profile => profile, :parent => forum, :published => false) get :view_page, :profile => profile.identifier, :page => [forum.path] assert_no_tag :tag => 'a', :content => "Post" @@ -850,7 +850,7 @@ class ContentViewerControllerTest < ActionController::TestCase should 'display pagination links of forum' do forum = Forum.create!(:name => 'A forum test', :profile => profile, :posts_per_page => 5) for n in 1..10 - forum.posts << TextileArticle.create!(:name => "Post #{n}", :profile => profile, :parent => forum) + forum.posts << TextArticle.create!(:name => "Post #{n}", :profile => profile, :parent => forum) end assert_equal 10, forum.posts.size @@ -861,7 +861,7 @@ class ContentViewerControllerTest < ActionController::TestCase should 'display first page of forum posts' do forum = Forum.create!(:name => 'My forum', :profile => profile, :posts_per_page => 5) for n in 1..10 - art = TextileArticle.create!(:name => "Post #{n}", :profile => profile, :parent => forum) + art = TextArticle.create!(:name => "Post #{n}", :profile => profile, :parent => forum) art.updated_at = (10 - n).days.ago art.stubs(:record_timestamps).returns(false) art.save! @@ -882,7 +882,7 @@ class ContentViewerControllerTest < ActionController::TestCase now = Time.now for n in 1..10 Time.stubs(:now).returns(now - 10.days + n.days) - forum.children << art = TextileArticle.create!(:name => "Post #{n}", :profile => profile, :parent => forum) + forum.children << art = TextArticle.create!(:name => "Post #{n}", :profile => profile, :parent => forum) end assert_equal 10, forum.posts.size @@ -899,8 +899,8 @@ class ContentViewerControllerTest < ActionController::TestCase forum = Forum.create!(:name => "forum", :profile => profile) profile.articles << forum - past_post = create(TextileArticle, :name => "past post", :profile => profile, :parent => forum, :published_at => forum.created_at - 1.year) - current_post = TextileArticle.create!(:name => "current post", :profile => profile, :parent => forum) + past_post = create(TextArticle, :name => "past post", :profile => profile, :parent => forum, :published_at => forum.created_at - 1.year) + current_post = TextArticle.create!(:name => "current post", :profile => profile, :parent => forum) forum.children << past_post forum.children << current_post @@ -924,7 +924,7 @@ class ContentViewerControllerTest < ActionController::TestCase login_as(profile.identifier) a = Forum.create!(:name => 'article folder', :profile => profile) Article.stubs(:short_description).returns('bli') - t = TextileArticle.create!(:name => 'first post', :parent => a, :profile => profile) + t = TextArticle.create!(:name => 'first post', :parent => a, :profile => profile) xhr :get, :view_page, :profile => profile.identifier, :page => [t.path], :toolbar => true assert_tag :tag => 'a', :content => 'New discussion topic' end @@ -937,7 +937,7 @@ class ContentViewerControllerTest < ActionController::TestCase community.add_member(author) forum = Forum.create(:profile => community, :name => 'Forum test', :body => 'Forum test') - post = fast_create(TextileArticle, :name => 'First post', :profile_id => community.id, :parent_id => forum.id, :author_id => author.id) + post = fast_create(TextArticle, :name => 'First post', :profile_id => community.id, :parent_id => forum.id, :author_id => author.id) login_as(author.identifier) get :view_page, :profile => community.identifier, :page => post.path.split('/') @@ -953,7 +953,7 @@ class ContentViewerControllerTest < ActionController::TestCase community.add_member(author) forum = Forum.create(:profile => community, :name => 'Forum test', :body => 'Forum test') - post = fast_create(TextileArticle, :name => 'First post', :profile_id => community.id, :parent_id => forum.id, :author_id => author.id) + post = fast_create(TextArticle, :name => 'First post', :profile_id => community.id, :parent_id => forum.id, :author_id => author.id) login_as(author.identifier) get :view_page, :profile => community.identifier, :page => post.path.split('/') @@ -971,7 +971,7 @@ class ContentViewerControllerTest < ActionController::TestCase should 'add meta tag to rss feed on view post forum' do login_as(profile.identifier) profile.articles << Forum.new(:name => 'Forum', :profile => profile) - profile.forum.posts << TextileArticle.new(:name => 'first post', :parent => profile.forum, :profile => profile) + profile.forum.posts << TextArticle.new(:name => 'first post', :parent => profile.forum, :profile => profile) get :view_page, :profile => profile.identifier, :page => ['forum', 'first-post'] assert_tag :tag => 'link', :attributes => { :rel => 'alternate', :type => 'application/rss+xml', :title => 'Forum', :href => "http://#{environment.default_hostname}/testinguser/forum/feed" } end @@ -986,7 +986,7 @@ class ContentViewerControllerTest < ActionController::TestCase should "not display 'Upload files' when viewing post from a forum" do login_as(profile.identifier) b = Forum.create!(:name => 'article folder', :profile => profile) - forum_post = TextileArticle.create!(:name => 'children-article', :profile => profile, :parent => b) + forum_post = TextArticle.create!(:name => 'children-article', :profile => profile, :parent => b) xhr :get, :view_page, :profile => profile.identifier, :page => forum_post.path, :toolbar => true assert_no_tag :tag => 'a', :content => 'Upload files', :attributes => {:href => /parent_id=#{b.id}/} end @@ -1002,9 +1002,9 @@ class ContentViewerControllerTest < ActionController::TestCase environment.languages = ['en'] environment.save login_as @profile.identifier - textile = fast_create(TextileArticle, :profile_id => @profile.id, :path => 'textile', :language => 'en') + textile = fast_create(TextArticle, :profile_id => @profile.id, :path => 'textile', :language => 'en') xhr :get, :view_page, :profile => @profile.identifier, :page => textile.path, :toolbar => true - assert_tag :a, :attributes => { :href => "/myprofile/#{profile.identifier}/cms/new?article%5Btranslation_of_id%5D=#{textile.id}&type=#{TextileArticle}" } + assert_tag :a, :attributes => { :href => "/myprofile/#{profile.identifier}/cms/new?article%5Btranslation_of_id%5D=#{textile.id}&type=#{TextArticle}" } end should 'not display add translation link if article is not translatable' do @@ -1016,22 +1016,22 @@ class ContentViewerControllerTest < ActionController::TestCase should 'not display add translation link if article hasnt a language defined' do login_as @profile.identifier - textile = fast_create(TextileArticle, :profile_id => @profile.id, :path => 'textile') + textile = fast_create(TextArticle, :profile_id => @profile.id, :path => 'textile') xhr :get, :view_page, :profile => @profile.identifier, :page => textile.path, :toolbar => true assert_no_tag :a, :attributes => { :content => 'Add translation', :class => /icon-locale/ } end should 'display translations link if article has translations' do login_as @profile.identifier - textile = fast_create(TextileArticle, :profile_id => @profile.id, :path => 'textile', :language => 'en') - translation = fast_create(TextileArticle, :profile_id => @profile.id, :path => 'translation', :language => 'es', :translation_of_id => textile) + textile = fast_create(TextArticle, :profile_id => @profile.id, :path => 'textile', :language => 'en') + translation = fast_create(TextArticle, :profile_id => @profile.id, :path => 'translation', :language => 'es', :translation_of_id => textile) xhr :get, :view_page, :profile => @profile.identifier, :page => textile.path, :toolbar => true assert_tag :a, :attributes => { :class => /article-translations-menu/, :onmouseover => /toggleSubmenu/ } end should 'not be redirected if already in translation' do - en_article = fast_create(TextileArticle, :profile_id => @profile.id, :path => 'en_article', :language => 'en') - es_article = fast_create(TextileArticle, :profile_id => @profile.id, :path => 'es_article', :language => 'es', :translation_of_id => en_article) + en_article = fast_create(TextArticle, :profile_id => @profile.id, :path => 'en_article', :language => 'en') + es_article = fast_create(TextArticle, :profile_id => @profile.id, :path => 'es_article', :language => 'es', :translation_of_id => en_article) @request.env['HTTP_REFERER'] = "http://localhost:3000/#{@profile.identifier}/#{es_article.path}" FastGettext.stubs(:locale).returns('es') get :view_page, :profile => @profile.identifier, :page => es_article.path @@ -1041,15 +1041,15 @@ class ContentViewerControllerTest < ActionController::TestCase should 'not be redirected if article does not have a language' do FastGettext.stubs(:locale).returns('es') - article = fast_create(TextileArticle, :profile_id => @profile.id, :path => 'article') + article = fast_create(TextArticle, :profile_id => @profile.id, :path => 'article') get :view_page, :profile => @profile.identifier, :page => article.path assert_response :success assert_equal article, assigns(:page) end should 'not be redirected if http_referer is a translation' do - en_article = fast_create(TextileArticle, :profile_id => @profile.id, :path => 'en_article', :language => 'en') - es_article = fast_create(TextileArticle, :profile_id => @profile.id, :path => 'es_article', :language => 'es', :translation_of_id => en_article) + en_article = fast_create(TextArticle, :profile_id => @profile.id, :path => 'en_article', :language => 'en') + es_article = fast_create(TextArticle, :profile_id => @profile.id, :path => 'es_article', :language => 'es', :translation_of_id => en_article) @request.env['HTTP_REFERER'] = "http://localhost:3000/#{@profile.identifier}/#{es_article.path}" FastGettext.stubs(:locale).returns('es') get :view_page, :profile => @profile.identifier, :page => en_article.path @@ -1058,8 +1058,8 @@ class ContentViewerControllerTest < ActionController::TestCase end should 'not be redirected to transition if came from edit' do - en_article = fast_create(TextileArticle, :profile_id => @profile.id, :path => 'en_article', :language => 'en') - es_article = fast_create(TextileArticle, :profile_id => @profile.id, :path => 'es_article', :language => 'es', :translation_of_id => en_article) + en_article = fast_create(TextArticle, :profile_id => @profile.id, :path => 'en_article', :language => 'en') + es_article = fast_create(TextArticle, :profile_id => @profile.id, :path => 'es_article', :language => 'es', :translation_of_id => en_article) FastGettext.stubs(:locale).returns('es') @request.env['HTTP_REFERER'] = "http://localhost/myprofile/#{@profile.identifier}/cms/edit/#{en_article.id}" get :view_page, :profile => @profile.identifier, :page => es_article.path @@ -1068,8 +1068,8 @@ class ContentViewerControllerTest < ActionController::TestCase end should 'not be redirected to transition if came from new' do - en_article = fast_create(TextileArticle, :profile_id => @profile.id, :path => 'en_article', :language => 'en') - es_article = fast_create(TextileArticle, :profile_id => @profile.id, :path => 'es_article', :language => 'es', :translation_of_id => en_article) + en_article = fast_create(TextArticle, :profile_id => @profile.id, :path => 'en_article', :language => 'en') + es_article = fast_create(TextArticle, :profile_id => @profile.id, :path => 'es_article', :language => 'es', :translation_of_id => en_article) FastGettext.stubs(:locale).returns('es') @request.env['HTTP_REFERER'] = "http://localhost/myprofile/#{@profile.identifier}/cms/new" get :view_page, :profile => @profile.identifier, :page => es_article.path @@ -1082,8 +1082,8 @@ class ContentViewerControllerTest < ActionController::TestCase blog = fast_create(Blog, :profile_id => profile.id, :path => 'blog') blog.display_posts_in_current_language = true blog.save - en_article = fast_create(TextileArticle, :profile_id => @profile.id, :path => 'en_article', :language => 'en', :parent_id => blog.id) - es_article = fast_create(TextileArticle, :profile_id => @profile.id, :path => 'es_article', :language => 'es', :parent_id => blog.id, :translation_of_id => en_article) + en_article = fast_create(TextArticle, :profile_id => @profile.id, :path => 'en_article', :language => 'en', :parent_id => blog.id) + es_article = fast_create(TextArticle, :profile_id => @profile.id, :path => 'es_article', :language => 'es', :parent_id => blog.id, :translation_of_id => en_article) get :view_page, :profile => @profile.identifier, :page => blog.path assert_tag :div, :attributes => { :id => "post-#{es_article.id}" } @@ -1095,12 +1095,12 @@ class ContentViewerControllerTest < ActionController::TestCase blog = fast_create(Blog, :profile_id => profile.id, :path => 'blog') blog.display_posts_in_current_language = true blog.save - en_article = fast_create(TextileArticle, :profile_id => @profile.id, :path => 'en_article', :language => 'en', :parent_id => blog.id) - es_article = fast_create(TextileArticle, :profile_id => @profile.id, :path => 'es_article', :language => 'es', :parent_id => blog.id, :translation_of_id => en_article) - pt_article = fast_create(TextileArticle, :profile_id => @profile.id, :path => 'es_article', :language => 'pt', :parent_id => blog.id, :translation_of_id => en_article) + en_article = fast_create(TextArticle, :profile_id => @profile.id, :path => 'en_article', :language => 'en', :parent_id => blog.id) + es_article = fast_create(TextArticle, :profile_id => @profile.id, :path => 'es_article', :language => 'es', :parent_id => blog.id, :translation_of_id => en_article) + pt_article = fast_create(TextArticle, :profile_id => @profile.id, :path => 'es_article', :language => 'pt', :parent_id => blog.id, :translation_of_id => en_article) - en_article2 = fast_create(TextileArticle, :profile_id => @profile.id, :path => 'en_article', :language => 'en', :parent_id => blog.id) - es_article2 = fast_create(TextileArticle, :profile_id => @profile.id, :path => 'es_article', :language => 'es', :parent_id => blog.id, :translation_of_id => en_article2) + en_article2 = fast_create(TextArticle, :profile_id => @profile.id, :path => 'en_article', :language => 'en', :parent_id => blog.id) + es_article2 = fast_create(TextArticle, :profile_id => @profile.id, :path => 'es_article', :language => 'es', :parent_id => blog.id, :translation_of_id => en_article2) get :view_page, :profile => @profile.identifier, :page => blog.path @@ -1111,8 +1111,8 @@ class ContentViewerControllerTest < ActionController::TestCase should 'list all posts at blog listing if blog option is disabled' do FastGettext.stubs(:locale).returns('es') blog = Blog.create!(:name => 'A blog test', :profile => profile, :display_posts_in_current_language => false) - blog.posts << es_post = TextileArticle.create!(:name => 'Spanish Post', :profile => profile, :parent => blog, :language => 'es') - blog.posts << en_post = TextileArticle.create!(:name => 'English Post', :profile => profile, :parent => blog, :language => 'en', :translation_of_id => es_post.id) + blog.posts << es_post = TextArticle.create!(:name => 'Spanish Post', :profile => profile, :parent => blog, :language => 'es') + blog.posts << en_post = TextArticle.create!(:name => 'English Post', :profile => profile, :parent => blog, :language => 'en', :translation_of_id => es_post.id) get :view_page, :profile => profile.identifier, :page => [blog.path] assert_equal 2, assigns(:posts).size assert_tag :div, :attributes => { :id => "post-#{es_post.id}" } @@ -1124,8 +1124,8 @@ class ContentViewerControllerTest < ActionController::TestCase blog = fast_create(Blog, :profile_id => profile.id, :path => 'blog') blog.display_posts_in_current_language = true blog.save! - en_article = fast_create(TextileArticle, :profile_id => @profile.id, :path => 'en_article', :language => 'en', :parent_id => blog.id) - es_article = fast_create(TextileArticle, :profile_id => @profile.id, :path => 'es_article', :language => 'es', :parent_id => blog.id, :translation_of_id => en_article) + en_article = fast_create(TextArticle, :profile_id => @profile.id, :path => 'en_article', :language => 'en', :parent_id => blog.id) + es_article = fast_create(TextArticle, :profile_id => @profile.id, :path => 'es_article', :language => 'es', :parent_id => blog.id, :translation_of_id => en_article) blog.posts = [en_article, es_article] get :view_page, :profile => @profile.identifier, :page => blog.path @@ -1177,7 +1177,7 @@ class ContentViewerControllerTest < ActionController::TestCase should 'add an zero width space every 4 caracters of comment urls' do url = 'www.an.url.to.be.splited.com' - a = fast_create(TextileArticle, :profile_id => @profile.id, :language => 'en') + a = fast_create(TextArticle, :profile_id => @profile.id, :language => 'en') c = a.comments.create!(:author => @profile, :title => 'An url', :body => url) get :view_page, :profile => @profile.identifier, :page => a.path assert_tag :a, :attributes => { :href => "http://" + url}, :content => url.scan(/.{4}/).join('​') @@ -1375,7 +1375,7 @@ class ContentViewerControllerTest < ActionController::TestCase should 'not escape acceptable HTML in list of blog posts' do login_as('testinguser') blog = Blog.create!(:name => 'A blog test', :profile => profile) - blog.posts << TinyMceArticle.create!( + blog.posts << TextArticle.create!( :name => 'Post', :profile => profile, :parent => blog, @@ -1443,7 +1443,7 @@ class ContentViewerControllerTest < ActionController::TestCase blog = community.articles.find_by(name: "Blog") - article = TinyMceArticle.create(:name => 'Article to be shared with images', + article = TextArticle.create(:name => 'Article to be shared with images', :body => 'This article should be shared with all social networks', :profile => community, :published => false, @@ -1571,7 +1571,7 @@ class ContentViewerControllerTest < ActionController::TestCase blog.visualization_format = 'compact' blog.save! - article = TinyMceArticle.create(:name => 'Article to be shared with images', + article = TextArticle.create(:name => 'Article to be shared with images', :body => 'This article should be shared with all social networks', :profile => @profile, :published => false, diff --git a/test/functional/enterprise_registration_controller_test.rb b/test/functional/enterprise_registration_controller_test.rb index d9abdc8..4d18884 100644 --- a/test/functional/enterprise_registration_controller_test.rb +++ b/test/functional/enterprise_registration_controller_test.rb @@ -58,7 +58,7 @@ class EnterpriseRegistrationControllerTest < ActionController::TestCase region = fast_create(Region, {}) template = Enterprise.create!(:name => 'Enterprise Template', :identifier => 'enterprise-template', :is_template => true) - welcome_page = TinyMceArticle.create!(:name => 'Welcome Page', :profile => template, :body => 'This is the welcome page of enterprise template.', :published => true) + welcome_page = TextArticle.create!(:name => 'Welcome Page', :profile => template, :body => 'This is the welcome page of enterprise template.', :published => true) template.welcome_page = welcome_page template.save! diff --git a/test/functional/home_controller_test.rb b/test/functional/home_controller_test.rb index 7b15e22..292276b 100644 --- a/test/functional/home_controller_test.rb +++ b/test/functional/home_controller_test.rb @@ -47,14 +47,14 @@ class HomeControllerTest < ActionController::TestCase env = Environment.default env.enable('use_portal_community') c = fast_create(Community) - a1 = TextileArticle.create!(:name => "Article 1", + a1 = TextArticle.create!(:name => "Article 1", :profile => c, :abstract => "This is the article1 lead.", - :body => "This is the article1 body.", + :body => "

This is the article1 body.

", :highlighted => true) - a2 = TextileArticle.create!(:name => "Article 2", + a2 = TextArticle.create!(:name => "Article 2", :profile => c, - :body => "This is the article2 body.", + :body => "

This is the article2 body.

", :highlighted => true) env.portal_community = c env.save! @@ -62,8 +62,8 @@ class HomeControllerTest < ActionController::TestCase get :index assert_tag :attributes => { :class => 'headline' }, :content => a1.abstract - assert_no_tag :attributes => { :class => 'headline' }, :content => a1.body - assert_tag :attributes => { :class => 'headline' }, :content => a2.body + assert_no_tag :attributes => { :class => 'headline' }, :content => 'This is the article1 body.' + assert_tag :attributes => { :class => 'headline' }, :content => 'This is the article2 body.' end should 'display block in index page if it\'s configured to display on homepage and its an environment block' do @@ -128,7 +128,7 @@ class HomeControllerTest < ActionController::TestCase should 'display template welcome page' do template = create_user('template').person template.is_template = true - welcome_page = TinyMceArticle.create!(:name => 'Welcome page', :profile => template, :published => true, :body => 'Template welcome page') + welcome_page = TextArticle.create!(:name => 'Welcome page', :profile => template, :published => true, :body => 'Template welcome page') template.welcome_page = welcome_page template.save! get :welcome, :template_id => template.id @@ -138,7 +138,7 @@ class HomeControllerTest < ActionController::TestCase should 'not display template welcome page if it is not published' do template = create_user('template').person template.is_template = true - welcome_page = TinyMceArticle.create!(:name => 'Welcome page', :profile => template, :published => false, :body => 'Template welcome page') + welcome_page = TextArticle.create!(:name => 'Welcome page', :profile => template, :published => false, :body => 'Template welcome page') template.welcome_page = welcome_page template.save! get :welcome, :template_id => template.id diff --git a/test/functional/profile_controller_test.rb b/test/functional/profile_controller_test.rb index 4fddb9c..369e888 100644 --- a/test/functional/profile_controller_test.rb +++ b/test/functional/profile_controller_test.rb @@ -518,9 +518,9 @@ class ProfileControllerTest < ActionController::TestCase should 'show number of published posts in index' do profile.articles << blog = create(Blog, :name => 'Blog', :profile_id => profile.id) - fast_create(TextileArticle, :name => 'Published post', :parent_id => profile.blog.id, :profile_id => profile.id) - fast_create(TextileArticle, :name => 'Other published post', :parent_id => profile.blog.id, :profile_id => profile.id) - fast_create(TextileArticle, :name => 'Unpublished post', :parent_id => profile.blog.id, :profile_id => profile.id, :published => false) + fast_create(TextArticle, :name => 'Published post', :parent_id => profile.blog.id, :profile_id => profile.id) + fast_create(TextArticle, :name => 'Other published post', :parent_id => profile.blog.id, :profile_id => profile.id) + fast_create(TextArticle, :name => 'Unpublished post', :parent_id => profile.blog.id, :profile_id => profile.id, :published => false) get :index, :profile => profile.identifier assert_tag :tag => 'a', :content => '2 posts', :attributes => { :href => /\/testuser\/#{blog.slug}/ } @@ -604,8 +604,8 @@ class ProfileControllerTest < ActionController::TestCase end should 'reverse the order of posts in tag feed' do - create(TextileArticle, :name => 'First post', :profile => profile, :tag_list => 'tag1', :published_at => Time.now) - create(TextileArticle, :name => 'Second post', :profile => profile, :tag_list => 'tag1', :published_at => Time.now + 1.day) + create(TextArticle, :name => 'First post', :profile => profile, :tag_list => 'tag1', :published_at => Time.now) + create(TextArticle, :name => 'Second post', :profile => profile, :tag_list => 'tag1', :published_at => Time.now + 1.day) get :tag_feed, :profile => profile.identifier, :id => 'tag1' assert_match(/Second.*First/, @response.body) @@ -613,11 +613,11 @@ class ProfileControllerTest < ActionController::TestCase should 'display the most recent posts in tag feed' do start = Time.now - 30.days - first = create(TextileArticle, :name => 'First post', :profile => profile, :tag_list => 'tag1', :published_at => start) + first = create(TextArticle, :name => 'First post', :profile => profile, :tag_list => 'tag1', :published_at => start) 20.times do |i| - create(TextileArticle, :name => 'Post #' + i.to_s, :profile => profile, :tag_list => 'tag1', :published_at => start + i.days) + create(TextArticle, :name => 'Post #' + i.to_s, :profile => profile, :tag_list => 'tag1', :published_at => start + i.days) end - last = create(TextileArticle, :name => 'Last post', :profile => profile, :tag_list => 'tag1', :published_at => Time.now) + last = create(TextArticle, :name => 'Last post', :profile => profile, :tag_list => 'tag1', :published_at => Time.now) get :tag_feed, :profile => profile.identifier, :id => 'tag1' assert_no_match(/First post/, @response.body) # First post is older than other 20 posts already @@ -755,7 +755,7 @@ class ProfileControllerTest < ActionController::TestCase scrap2 = create(Scrap, defaults_for_scrap(:sender => p2, :receiver => p1)) User.current = p1.user - create(TinyMceArticle, :profile => p1, :name => 'An article about free software') + create(TextArticle, :profile => p1, :name => 'An article about free software') a1 = ActionTracker::Record.last login_as(profile.identifier) @@ -787,10 +787,10 @@ class ProfileControllerTest < ActionController::TestCase scrap2 = create(Scrap, defaults_for_scrap(:sender => p2, :receiver => profile)) User.current = p3.user - article1 = TinyMceArticle.create!(:profile => p3, :name => 'An article about free software') + article1 = TextArticle.create!(:profile => p3, :name => 'An article about free software') User.current = p2.user - article2 = TinyMceArticle.create!(:profile => p2, :name => 'Another article about free software') + article2 = TextArticle.create!(:profile => p2, :name => 'Another article about free software') login_as(profile.identifier) get :index, :profile => p3.identifier @@ -1181,7 +1181,7 @@ class ProfileControllerTest < ActionController::TestCase should "view more activities paginated" do login_as(profile.identifier) - article = TinyMceArticle.create!(:profile => profile, :name => 'An Article about Free Software') + article = TextArticle.create!(:profile => profile, :name => 'An Article about Free Software') ActionTracker::Record.destroy_all 40.times{ create(ActionTracker::Record, :user_id => profile.id, :user_type => 'Profile', :verb => 'create_article', :target_id => article.id, :target_type => 'Article', :params => {'name' => article.name, 'url' => article.url, 'lead' => article.lead, 'first_image' => article.first_image})} assert_equal 40, profile.tracked_actions.count @@ -1214,7 +1214,7 @@ class ProfileControllerTest < ActionController::TestCase should "not index display activities comments" do login_as(profile.identifier) - article = TinyMceArticle.create!(:profile => profile, :name => 'An Article about Free Software') + article = TextArticle.create!(:profile => profile, :name => 'An Article about Free Software') ActionTracker::Record.destroy_all activity = create(ActionTracker::Record, :user_id => profile.id, :user_type => 'Profile', :verb => 'create_article', :target_id => article.id, :target_type => 'Article', :params => {'name' => article.name, 'url' => article.url, 'lead' => article.lead, 'first_image' => article.first_image}) 20.times {comment = fast_create(Comment, :source_id => article, :title => 'a comment', :body => 'lalala', :created_at => Time.now)} @@ -1225,7 +1225,7 @@ class ProfileControllerTest < ActionController::TestCase should "view more comments paginated" do login_as(profile.identifier) - article = TinyMceArticle.create!(:profile => profile, :name => 'An Article about Free Software') + article = TextArticle.create!(:profile => profile, :name => 'An Article about Free Software') ActionTracker::Record.destroy_all activity = create(ActionTracker::Record, :user_id => profile.id, :user_type => 'Profile', :verb => 'create_article', :target_id => article.id, :target_type => 'Article', :params => {'name' => article.name, 'url' => article.url, 'lead' => article.lead, 'first_image' => article.first_image}) 20.times {comment = fast_create(Comment, :source_id => article, :title => 'a comment', :body => 'lalala', :created_at => Time.now)} @@ -1341,7 +1341,7 @@ class ProfileControllerTest < ActionController::TestCase should 'register abuse report with content' do reported = fast_create(Profile) - content = fast_create(RawHTMLArticle, :profile_id => reported.id) + content = fast_create(TextArticle, :profile_id => reported.id) login_as(profile.identifier) @controller.stubs(:verify_recaptcha).returns(true) @@ -1368,7 +1368,7 @@ class ProfileControllerTest < ActionController::TestCase User.current = profile.user ActionTracker::Record.destroy_all - TinyMceArticle.create!(:profile => profile, :name => 'An article about free software') + TextArticle.create!(:profile => profile, :name => 'An article about free software') login_as(profile.identifier) get :index, :profile => profile.identifier @@ -1383,7 +1383,7 @@ class ProfileControllerTest < ActionController::TestCase User.current = profile.user ActionTracker::Record.destroy_all - TinyMceArticle.create!(:profile => profile, :name => 'An article about free software') + TextArticle.create!(:profile => profile, :name => 'An article about free software') activity = ActionTracker::Record.last login_as(profile.identifier) @@ -1393,14 +1393,14 @@ class ProfileControllerTest < ActionController::TestCase end should "follow an article" do - article = TinyMceArticle.create!(:profile => profile, :name => 'An article about free software') + article = TextArticle.create!(:profile => profile, :name => 'An article about free software') login_as(@profile.identifier) post :follow_article, :profile => profile.identifier, :article_id => article.id assert_includes article.person_followers, @profile end should "unfollow an article" do - article = TinyMceArticle.create!(:profile => profile, :name => 'An article about free software') + article = TextArticle.create!(:profile => profile, :name => 'An article about free software') article.person_followers << @profile article.save! assert_includes article.person_followers, @profile @@ -1411,7 +1411,7 @@ class ProfileControllerTest < ActionController::TestCase end should "be logged in to leave comment on an activity" do - article = TinyMceArticle.create!(:profile => profile, :name => 'An article about free software') + article = TextArticle.create!(:profile => profile, :name => 'An article about free software') activity = ActionTracker::Record.last count = activity.comments.count @@ -1422,7 +1422,7 @@ class ProfileControllerTest < ActionController::TestCase should "leave a comment in own activity" do login_as(profile.identifier) - TinyMceArticle.create!(:profile => profile, :name => 'An article about free software') + TextArticle.create!(:profile => profile, :name => 'An article about free software') activity = ActionTracker::Record.last count = activity.comments.count @@ -1436,7 +1436,7 @@ class ProfileControllerTest < ActionController::TestCase should "leave a comment on another profile's activity" do login_as(profile.identifier) another_person = fast_create(Person) - TinyMceArticle.create!(:profile => another_person, :name => 'An article about free software') + TextArticle.create!(:profile => another_person, :name => 'An article about free software') activity = ActionTracker::Record.last count = activity.comments.count assert_equal 0, count @@ -1448,7 +1448,7 @@ class ProfileControllerTest < ActionController::TestCase should 'display comment in wall if user was removed after click in view all comments' do User.current = profile.user - article = TinyMceArticle.create!(:profile => profile, :name => 'An article about free software') + article = TextArticle.create!(:profile => profile, :name => 'An article about free software') to_be_removed = create_user('removed_user').person comment = create(Comment, :author => to_be_removed, :title => 'Test Comment', :body => 'My author does not exist =(', :source_id => article.id, :source_type => 'Article') to_be_removed.destroy @@ -1465,7 +1465,7 @@ class ProfileControllerTest < ActionController::TestCase should 'not display spam comments in wall' do User.current = profile.user - article = TinyMceArticle.create!(:profile => profile, :name => 'An article about spam\'s nutritional attributes') + article = TextArticle.create!(:profile => profile, :name => 'An article about spam\'s nutritional attributes') comment = create(Comment, :author => profile, :title => 'Test Comment', :body => 'This article makes me hungry', :source_id => article.id, :source_type => 'Article') comment.spam! login_as(profile.identifier) @@ -1476,7 +1476,7 @@ class ProfileControllerTest < ActionController::TestCase should 'display comment in wall from non logged users after click in view all comments' do User.current = profile.user - article = TinyMceArticle.create!(:profile => profile, :name => 'An article about free software') + article = TextArticle.create!(:profile => profile, :name => 'An article about free software') comment = create(Comment, :name => 'outside user', :email => 'outside@localhost.localdomain', :title => 'Test Comment', :body => 'My author does not exist =(', :source_id => article.id, :source_type => 'Article') login_as(profile.identifier) diff --git a/test/functional/profile_editor_controller_test.rb b/test/functional/profile_editor_controller_test.rb index 000d132..a4b8522 100644 --- a/test/functional/profile_editor_controller_test.rb +++ b/test/functional/profile_editor_controller_test.rb @@ -534,8 +534,8 @@ class ProfileEditorControllerTest < ActionController::TestCase should 'render TinyMce Editor for header and footer' do get :header_footer, :profile => profile.identifier - assert_tag :tag => 'textarea', :attributes => { :id => 'custom_header', :class => 'mceEditor' } - assert_tag :tag => 'textarea', :attributes => { :id => 'custom_footer', :class => 'mceEditor' } + assert_tag :tag => 'textarea', :attributes => { :id => 'custom_header', :class => Article::Editor::TINY_MCE } + assert_tag :tag => 'textarea', :attributes => { :id => 'custom_footer', :class => Article::Editor::TINY_MCE } end should 'save footer and header' do @@ -966,7 +966,7 @@ class ProfileEditorControllerTest < ActionController::TestCase person_template = create_user('person_template').person person_template.is_template = true - welcome_page = fast_create(TinyMceArticle, :body => 'Initial welcome page') + welcome_page = fast_create(TextArticle, :body => 'Initial welcome page') person_template.welcome_page = welcome_page person_template.save! welcome_page.profile = person_template diff --git a/test/functional/profile_search_controller_test.rb b/test/functional/profile_search_controller_test.rb index c9c219c..afa4f81 100644 --- a/test/functional/profile_search_controller_test.rb +++ b/test/functional/profile_search_controller_test.rb @@ -21,15 +21,15 @@ class ProfileSearchControllerTest < ActionController::TestCase end should 'search for articles' do - article = TextileArticle.create(:name => 'My article', :body => 'Article to test profile search', :profile => person) + article = TextArticle.create(:name => 'My article', :body => 'Article to test profile search', :profile => person) get 'index', :profile => person.identifier, :q => 'article to test' assert_includes assigns(:results), article end should 'not display articles from another profile' do - article = TextileArticle.create(:name => 'My article', :body => 'Article to test profile search', :profile => person) - article2 = TextileArticle.create(:name => 'Another article', :body => 'Article from someone else', :profile => fast_create(Person)) + article = TextArticle.create(:name => 'My article', :body => 'Article to test profile search', :profile => person) + article2 = TextArticle.create(:name => 'Another article', :body => 'Article from someone else', :profile => fast_create(Person)) get 'index', :profile => person.identifier, :q => 'article' assert_includes assigns(:results), article @@ -49,7 +49,7 @@ class ProfileSearchControllerTest < ActionController::TestCase should 'paginate results listing' do (1..11).each do |i| - TextileArticle.create!(:name => "Article #{i}", :profile => person, :language => 'en') + TextArticle.create!(:name => "Article #{i}", :profile => person, :language => 'en') end get 'index', :profile => person.identifier, :q => 'Article' @@ -59,20 +59,20 @@ class ProfileSearchControllerTest < ActionController::TestCase end should 'display abstract if given' do - article1 = TextileArticle.create(:name => 'Article 1', :abstract => 'Abstract to test', :body => 'Article to test profile search', :profile => person) - article2 = TextileArticle.create(:name => 'Article 2', :body => 'Another article to test profile search', :profile => person) + article1 = TextArticle.create(:name => 'Article 1', :abstract => 'Abstract to test', :body => '

Article to test profile search

', :profile => person) + article2 = TextArticle.create(:name => 'Article 2', :body => '

Another article to test profile search

', :profile => person) get 'index', :profile => person.identifier, :q => 'article to test' assert_tag :tag => 'li', :descendant => { :tag => 'a', :content => article1.abstract, :attributes => { :class => /article-details/ }} - assert_no_tag :tag => 'li', :descendant => { :tag => 'a', :content => article1.body, :attributes => { :class => /article-details/ }} + assert_no_tag :tag => 'li', :descendant => { :tag => 'a', :content => 'Article to test profile search', :attributes => { :class => /article-details/ }} - assert_tag :tag => 'li', :descendant => { :tag => 'a', :content => article2.body, :attributes => { :class => /article-details/ }} + assert_tag :tag => 'li', :descendant => { :tag => 'a', :content => 'Another article to test profile search', :attributes => { :class => /article-details/ }} end should 'display nothing if search is blank' do - article1 = TextileArticle.create(:name => 'Article 1', :body => 'Article to test profile search', :profile => person) - article2 = TextileArticle.create(:name => 'Article 2', :body => 'Another article to test profile search', :profile => person) + article1 = TextArticle.create(:name => 'Article 1', :body => 'Article to test profile search', :profile => person) + article2 = TextArticle.create(:name => 'Article 2', :body => 'Another article to test profile search', :profile => person) get 'index', :profile => person.identifier, :q => '' @@ -80,19 +80,19 @@ class ProfileSearchControllerTest < ActionController::TestCase end should 'not display private articles' do - article1 = TextileArticle.create(:name => 'Article 1', :body => 'Article to test profile search', :profile => person, :published => false) - article2 = TextileArticle.create(:name => 'Article 2', :body => 'Another article to test profile search', :profile => person) + article1 = TextArticle.create(:name => 'Article 1', :body => '

Article to test profile search

', :profile => person, :published => false) + article2 = TextArticle.create(:name => 'Article 2', :body => '

Another article to test profile search

', :profile => person) get 'index', :profile => person.identifier, :q => 'article to test' - assert_no_tag :tag => 'li', :descendant => { :tag => 'a', :content => article1.body, :attributes => { :class => /article-details/ }} + assert_no_tag :tag => 'li', :descendant => { :tag => 'a', :content => 'Article to test profile search', :attributes => { :class => /article-details/ }} - assert_tag :tag => 'li', :descendant => { :tag => 'a', :content => article2.body, :attributes => { :class => /article-details/ }} + assert_tag :tag => 'li', :descendant => { :tag => 'a', :content => 'Another article to test profile search', :attributes => { :class => /article-details/ }} end should 'display number of results found' do - article1 = TextileArticle.create(:name => 'Article 1', :body => 'Article to test profile search', :profile => person) - article2 = TextileArticle.create(:name => 'Article 2', :body => 'Another article to test profile search', :profile => person) + article1 = TextArticle.create(:name => 'Article 1', :body => 'Article to test profile search', :profile => person) + article2 = TextArticle.create(:name => 'Article 2', :body => 'Another article to test profile search', :profile => person) get 'index', :profile => person.identifier, :q => 'article to test' diff --git a/test/functional/search_controller_test.rb b/test/functional/search_controller_test.rb index 6e8dadf..8dd5510 100644 --- a/test/functional/search_controller_test.rb +++ b/test/functional/search_controller_test.rb @@ -309,9 +309,9 @@ class SearchControllerTest < ActionController::TestCase assert_tag :tag => 'table', :attributes => {:class => /current-month/}, :descendant => {:tag => 'caption', :content => /August 2008/} end - should 'found TextileArticle in articles' do + should 'found TextArticle in articles' do person = create_user('teste').person - art = TextileArticle.create!(:name => 'an text_article article to be found', :profile => person) + art = TextArticle.create!(:name => 'an text_article article to be found', :profile => person) get 'articles', :query => 'article to be found' diff --git a/test/functional/spam_controller_test.rb b/test/functional/spam_controller_test.rb index dfa2c7d..c63ed11 100644 --- a/test/functional/spam_controller_test.rb +++ b/test/functional/spam_controller_test.rb @@ -7,7 +7,7 @@ class SpamControllerTest < ActionController::TestCase @community = fast_create(Community, :name => 'testcommunity') @community.add_admin(@profile) - @article = fast_create(TextileArticle, :profile_id => @community.id) + @article = fast_create(TextArticle, :profile_id => @community.id) @spam_comment = fast_create(Comment, :source_id => @article.id, :spam => true, :name => 'foo', :email => 'foo@example.com') @spam_suggest_article = SuggestArticle.create!(:name => 'spammer', :article => {:name => 'Spam article', :body => "Something you don't need"}, :email => 'spammer@shady.place', :target => @community, :spam => true) diff --git a/test/functional/tasks_controller_test.rb b/test/functional/tasks_controller_test.rb index 33ecf99..4d437ae 100644 --- a/test/functional/tasks_controller_test.rb +++ b/test/functional/tasks_controller_test.rb @@ -325,23 +325,23 @@ class TasksControllerTest < ActionController::TestCase t = SuggestArticle.create!(:article => {:name => 'test name', :abstract => 'test abstract', :body => 'test body'}, :name => 'some name', :email => 'test@localhost.com', :target => c) get :index - assert_tag :tag => 'textarea', :content => /test abstract/, :attributes => { :name => /tasks\[#{t.id}\]\[task\]\[article\]\[abstract\]/, :class => 'mceEditor' } - assert_tag :tag => 'textarea', :content => /test body/, :attributes => { :name => /tasks\[#{t.id}\]\[task\]\[article\]\[body\]/, :class => 'mceEditor' } + assert_tag :tag => 'textarea', :content => /test abstract/, :attributes => { :name => /tasks\[#{t.id}\]\[task\]\[article\]\[abstract\]/, :class => Article::Editor::TINY_MCE } + assert_tag :tag => 'textarea', :content => /test body/, :attributes => { :name => /tasks\[#{t.id}\]\[task\]\[article\]\[body\]/, :class => Article::Editor::TINY_MCE } end - should 'create TinyMceArticle article after finish approve suggested article task' do - TinyMceArticle.destroy_all + should 'create TextArticle article after finish approve suggested article task' do + TextArticle.destroy_all c = fast_create(Community) c.affiliate(profile, Profile::Roles.all_roles(profile.environment.id)) @controller.stubs(:profile).returns(c) t = SuggestArticle.create!(:article => {:name => 'test name', :body => 'test body'}, :name => 'some name', :email => 'test@localhost.com', :target => c) post :close, :tasks => {t.id => { :task => {}, :decision => "finish"}} - assert_not_nil TinyMceArticle.first + assert_not_nil TextArticle.first end should "change the article's attributes on suggested article task approval" do - TinyMceArticle.destroy_all + TextArticle.destroy_all c = fast_create(Community) c.affiliate(profile, Profile::Roles.all_roles(profile.environment.id)) @controller.stubs(:profile).returns(c) @@ -353,11 +353,11 @@ class TasksControllerTest < ActionController::TestCase t.save! post :close, :tasks => {t.id => { :task => {:article => {:name => 'new article name', :body => 'new body', :source => 'http://www.noosfero.com', :source_name => 'new source'}, :name => 'new name'}, :decision => "finish"}} - assert_equal 'new article name', TinyMceArticle.first.name - assert_equal 'new name', TinyMceArticle.first.author_name - assert_equal 'new body', TinyMceArticle.first.body - assert_equal 'http://www.noosfero.com', TinyMceArticle.first.source - assert_equal 'new source', TinyMceArticle.first.source_name + assert_equal 'new article name', TextArticle.first.name + assert_equal 'new name', TextArticle.first.author_name + assert_equal 'new body', TextArticle.first.body + assert_equal 'http://www.noosfero.com', TextArticle.first.source + assert_equal 'new source', TextArticle.first.source_name end should "display name from article suggestion when requestor was not setted" do @@ -372,7 +372,7 @@ class TasksControllerTest < ActionController::TestCase end should "not crash when article suggestion task fails" do - TinyMceArticle.destroy_all + TextArticle.destroy_all c = fast_create(Community) c.affiliate(profile, Profile::Roles.all_roles(profile.environment.id)) @controller.stubs(:profile).returns(c) diff --git a/test/integration/manage_documents_test.rb b/test/integration/manage_documents_test.rb index 33a8150..8b4a97e 100644 --- a/test/integration/manage_documents_test.rb +++ b/test/integration/manage_documents_test.rb @@ -17,14 +17,14 @@ class ManageDocumentsTest < ActionDispatch::IntegrationTest get '/myprofile/myuser/cms/new' assert_response :success - assert_tag :tag => 'a', :attributes => { :href => '/myprofile/myuser/cms/new?type=TinyMceArticle' } + assert_tag :tag => 'a', :attributes => { :href => '/myprofile/myuser/cms/new?type=TextArticle' } - get '/myprofile/myuser/cms/new?type=TinyMceArticle' + get '/myprofile/myuser/cms/new?type=TextArticle' assert_response :success assert_tag :tag => 'form', :attributes => { :action => '/myprofile/myuser/cms/new', :method => /post/i } assert_difference 'Article.count' do - post_via_redirect '/myprofile/myuser/cms/new', :type => 'TinyMceArticle', :article => { :name => 'my article', :body => 'this is the body of ther article'} + post_via_redirect '/myprofile/myuser/cms/new', :type => 'TextArticle', :article => { :name => 'my article', :body => 'this is the body of ther article'} end assert_response :success @@ -96,7 +96,7 @@ class ManageDocumentsTest < ActionDispatch::IntegrationTest protected def create_article(profile, options) - a = TinyMceArticle.new(options) + a = TextArticle.new(options) a.profile = profile a.save! a diff --git a/test/integration/performance_test.rb b/test/integration/performance_test.rb index f09dc8d..df2dc6d 100644 --- a/test/integration/performance_test.rb +++ b/test/integration/performance_test.rb @@ -49,7 +49,7 @@ class PerformanceTest < ActionDispatch::IntegrationTest blog = profile.blog n.times do |i| postnumber += 1 - TinyMceArticle.create!(:profile => profile, :parent => blog, :name => "post number #{postnumber}") + TextArticle.create!(:profile => profile, :parent => blog, :name => "post number #{postnumber}") end end diff --git a/test/integration/profile_blocks_test.rb b/test/integration/profile_blocks_test.rb index eedae82..4ab06b8 100644 --- a/test/integration/profile_blocks_test.rb +++ b/test/integration/profile_blocks_test.rb @@ -5,8 +5,8 @@ class ProfileBlocksTest < ActionDispatch::IntegrationTest def blog_on_article_block_bootstrap profile = fast_create(Profile) blog = fast_create(Blog, :name => 'Blog', :profile_id => profile.id) - fast_create(TinyMceArticle, :name => "First Post", :profile_id => profile.id, :parent_id => blog.id, :body => '

Wasserstoffbombe

') - fast_create(TinyMceArticle, :name => "A Post", :profile_id => profile.id, :parent_id => blog.id, :body => '

Lorem ipsum dolor sit amet

Second paragraph

') + fast_create(TextArticle, :name => "First Post", :profile_id => profile.id, :parent_id => blog.id, :body => '

Wasserstoffbombe

') + fast_create(TextArticle, :name => "A Post", :profile_id => profile.id, :parent_id => blog.id, :body => '

Lorem ipsum dolor sit amet

Second paragraph

') block = ArticleBlock.new block.article = blog profile.boxes << Box.new diff --git a/test/integration/safe_strings_test.rb b/test/integration/safe_strings_test.rb index f1868d3..7c4b42a 100644 --- a/test/integration/safe_strings_test.rb +++ b/test/integration/safe_strings_test.rb @@ -122,7 +122,7 @@ class SafeStringsTest < ActionDispatch::IntegrationTest create_user('jimi', :password => 'test', :password_confirmation => 'test').activate person = Person['jimi'] login 'jimi', 'test' - get "/myprofile/jimi/cms/new?type=TinyMceArticle" + get "/myprofile/jimi/cms/new?type=TextArticle" assert_no_match /title: "Safestringstest::plugin1::macro"/, response.body end @@ -134,7 +134,7 @@ class SafeStringsTest < ActionDispatch::IntegrationTest expected_content = 'something' html_content = "

#{expected_content}

" - article = TinyMceArticle.create!(:profile => profile, :name => 'An Article about Free Software', :body => html_content) + article = TextArticle.create!(:profile => profile, :name => 'An Article about Free Software', :body => html_content) ActionTracker::Record.destroy_all activity = create(ActionTracker::Record, :user_id => profile.id, :user_type => 'Profile', :verb => 'create_article', :target_id => article.id, :target_type => 'Article', :params => {'name' => article.name, 'url' => article.url, 'lead' => article.lead, 'first_image' => article.first_image}) get "/profile/marley" @@ -178,7 +178,7 @@ class SafeStringsTest < ActionDispatch::IntegrationTest should 'not escape read more link to article on display short format' do profile = fast_create Profile blog = fast_create Blog, :name => 'Blog', :profile_id => profile.id - fast_create(TinyMceArticle, :name => "Post Test", :profile_id => profile.id, :parent_id => blog.id, :accept_comments => false, :body => '

Lorem ipsum dolor sit amet

') + fast_create(TextArticle, :name => "Post Test", :profile_id => profile.id, :parent_id => blog.id, :accept_comments => false, :body => '

Lorem ipsum dolor sit amet

') blog.update_attribute(:visualization_format, 'short') get "/#{profile.identifier}/blog" diff --git a/test/support/factories.rb b/test/support/factories.rb index 3c853c4..aadc416 100644 --- a/test/support/factories.rb +++ b/test/support/factories.rb @@ -118,7 +118,7 @@ module Noosfero::Factory }.merge(options) user = fast_insert_with_timestamps(User, data) person = fast_insert_with_timestamps(Person, { :type => 'Person', :identifier => name, :name => name, :user_id => user.id, :environment_id => environment_id }.merge(person_options)) - homepage = fast_insert_with_timestamps(TextileArticle, { :type => 'TextileArticle', :name => 'homepage', :slug => 'homepage', :path => 'homepage', :profile_id => person.id }) + homepage = fast_insert_with_timestamps(TextArticle, { :type => 'TextArticle', :name => 'homepage', :slug => 'homepage', :path => 'homepage', :profile_id => person.id }) fast_update(person, {:home_page_id => homepage.id}) box = fast_insert(Box, { :owner_type => "Profile", :owner_id => person.id, :position => 1}) block = fast_insert(Block, { :box_id => box.id, :type => 'MainBlock', :position => 0}) diff --git a/test/unit/action_tracker_notification_test.rb b/test/unit/action_tracker_notification_test.rb index 513b7d1..9a70f14 100644 --- a/test/unit/action_tracker_notification_test.rb +++ b/test/unit/action_tracker_notification_test.rb @@ -91,7 +91,7 @@ class ActionTrackerNotificationTest < ActiveSupport::TestCase should "have comments through article action_tracker" do user = User.current = create_user person = user.person - article = create(TextileArticle, :profile_id => person.id) + article = create(TextArticle, :profile_id => person.id) process_delayed_job_queue notification = ActionTrackerNotification.last diff --git a/test/unit/application_helper_test.rb b/test/unit/application_helper_test.rb index 736a036..e924baa 100644 --- a/test/unit/application_helper_test.rb +++ b/test/unit/application_helper_test.rb @@ -615,7 +615,7 @@ class ApplicationHelperTest < ActionView::TestCase should 'reference to article' do c = fast_create(Community) - a = fast_create(TinyMceArticle, :profile_id => c.id) + a = fast_create(TextArticle, :profile_id => c.id) assert_equal( "x", reference_to_article('x', a) ) @@ -623,7 +623,7 @@ class ApplicationHelperTest < ActionView::TestCase should 'reference to article, with anchor' do c = fast_create(Community) - a = fast_create(TinyMceArticle, :profile_id => c.id) + a = fast_create(TextArticle, :profile_id => c.id) assert_equal( "x", reference_to_article('x', a, 'place') ) @@ -632,7 +632,7 @@ class ApplicationHelperTest < ActionView::TestCase should 'reference to article, in a blog' do c = fast_create(Community) b = fast_create(Blog, :profile_id => c.id) - a = fast_create(TinyMceArticle, :profile_id => c.id, :parent_id => b.id) + a = fast_create(TextArticle, :profile_id => c.id, :parent_id => b.id) a.save! # needed to link to the parent blog assert_equal( "x", @@ -643,7 +643,7 @@ class ApplicationHelperTest < ActionView::TestCase c = fast_create(Community) c.domains << build(Domain, :name=>'domain.xyz') b = fast_create(Blog, :profile_id => c.id) - a = fast_create(TinyMceArticle, :profile_id => c.id, :parent_id => b.id) + a = fast_create(TextArticle, :profile_id => c.id, :parent_id => b.id) a.save! assert_equal( "x", @@ -856,7 +856,7 @@ class ApplicationHelperTest < ActionView::TestCase assert_equal "Clone Blog", label_for_clone_article(Blog.new) assert_equal "Clone Event", label_for_clone_article(Event.new) assert_equal "Clone Forum", label_for_clone_article(Forum.new) - assert_equal "Clone Article", label_for_clone_article(TinyMceArticle.new) + assert_equal "Clone Article", label_for_clone_article(TextArticle.new) end should "return top url of environment" do @@ -880,6 +880,86 @@ class ApplicationHelperTest < ActionView::TestCase assert_equal c.top_url, top_url end + should "current editor return the editor defined in article" do + person = fast_create(Person) + @article = fast_create(Article) + @article.editor = Article::Editor::TEXTILE + @article.save + stubs(:current_person).returns(person) + assert_equal Article::Editor::TEXTILE, current_editor + end + + should "current editor be tiny mce if an article is present and no editor is defined" do + person = fast_create(Person) + @article = fast_create(Article) + @article.editor = nil + @article.save + stubs(:current_person).returns(person) + assert_equal Article::Editor::TINY_MCE, current_editor + end + + should "current editor be the person editor if there is no article" do + person = fast_create(Person) + request = mock() + stubs(:current_person).returns(person) + person.stubs(:editor).returns(Article::Editor::TEXTILE) + assert_equal Article::Editor::TEXTILE, current_editor + end + + + should "current editor be tiny mce if there is no article and no person editor is defined" do + person = fast_create(Person) + stubs(:current_person).returns(person) + person.stubs(:editor).returns(nil) + assert_equal Article::Editor::TINY_MCE, current_editor + end + + should "current editor return the editor defined in article even if there is a person editor defined" do + person = fast_create(Person) + @article = fast_create(Article) + @article.editor = Article::Editor::TEXTILE + @article.save + stubs(:current_person).returns(person) + person.stubs(:editor).returns(Article::Editor::TINY_MCE) + assert_equal Article::Editor::TEXTILE, current_editor + end + + should "current editor be tiny mce if an article is present and no editor is defined even if there is a person editor defined" do + person = fast_create(Person) + @article = fast_create(Article) + @article.editor = nil + @article.save + stubs(:current_person).returns(person) + person.stubs(:editor).returns(Article::Editor::TINY_MCE) + assert_equal Article::Editor::TINY_MCE, current_editor + end + + should "current editor concat the mode passed as parameter" do + person = fast_create(Person) + @article = fast_create(Article) + @article.editor = Article::Editor::TEXTILE + @article.save + stubs(:current_person).returns(person) + mode = 'something' + assert_equal Article::Editor::TEXTILE + '_' + mode, current_editor(mode) + end + should "current_editor_is? be true if the test editor is equal to defined one" do + stubs(:current_editor).returns(Article::Editor::TEXTILE) + assert current_editor_is?(Article::Editor::TEXTILE) + end + + should "current_editor_is? be false if the test editor is different to defined one" do + stubs(:current_editor).returns(Article::Editor::TINY_MCE) + refute current_editor_is?(Article::Editor::TEXTILE) + end + + should "current_editor_is? be false if the test editor is nil" do + stubs(:current_editor).returns(Article::Editor::TEXTILE) + refute current_editor_is?(nil) + stubs(:current_editor).returns(Article::Editor::TINY_MCE) + refute current_editor_is?(nil) + end + protected include NoosferoTestHelper @@ -892,3 +972,4 @@ class ApplicationHelperTest < ActionView::TestCase end end + diff --git a/test/unit/approve_article_test.rb b/test/unit/approve_article_test.rb index db5c002..3bc3227 100644 --- a/test/unit/approve_article_test.rb +++ b/test/unit/approve_article_test.rb @@ -8,7 +8,7 @@ class ApproveArticleTest < ActiveSupport::TestCase ActionMailer::Base.deliveries = [] User.current = @user = create_user 'test_user' @profile = @user.person - @article = fast_create(TextileArticle, :profile_id => @profile.id, :name => 'test name', :abstract => 'Lead of article', :body => 'This is my article') + @article = fast_create(TextArticle, :profile_id => @profile.id, :name => 'test name', :abstract => 'Lead of article', :body => 'This is my article') @community = fast_create(Community) @community.add_member(@profile) end @@ -257,15 +257,15 @@ class ApproveArticleTest < ActiveSupport::TestCase other_community.add_member(profile) ActionTracker::Record.delete_all - article = fast_create(TextileArticle) + article = fast_create(TextArticle) a = create(ApproveArticle, :name => 'bar', :article => article, :target => community, :requestor => profile) a.finish - article = fast_create(TextileArticle) + article = fast_create(TextArticle) a = create(ApproveArticle, :name => 'another bar', :article => article, :target => community, :requestor => profile) a.finish - article = fast_create(TextileArticle) + article = fast_create(TextArticle) a = create(ApproveArticle, :name => 'another bar', :article => article, :target => other_community, :requestor => profile) a.finish assert_equal 3, ActionTracker::Record.count @@ -275,11 +275,11 @@ class ApproveArticleTest < ActiveSupport::TestCase other_community = fast_create(Community) other_community.add_member(profile) ActionTracker::Record.delete_all - article1 = fast_create(TextileArticle) + article1 = fast_create(TextArticle) a = create(ApproveArticle, :name => 'bar', :article => article1, :target => community, :requestor => profile) a.finish - article2 = fast_create(TinyMceArticle) + article2 = fast_create(TextArticle) a = create(ApproveArticle, :name => 'another bar', :article => article2, :target => other_community, :requestor => profile) a.finish assert_equal 2, ActionTracker::Record.count diff --git a/test/unit/approve_comment_test.rb b/test/unit/approve_comment_test.rb index a2fe7a7..0201572 100644 --- a/test/unit/approve_comment_test.rb +++ b/test/unit/approve_comment_test.rb @@ -7,7 +7,7 @@ class ApproveCommentTest < ActiveSupport::TestCase ActionMailer::Base.perform_deliveries = true ActionMailer::Base.deliveries = [] @profile = create_user('test_user', :email => "someone@anyhost.com").person - @article = fast_create(TextileArticle, :profile_id => @profile.id, :name => 'test name', :abstract => 'Lead of article', :body => 'This is my article') + @article = fast_create(TextArticle, :profile_id => @profile.id, :name => 'test name', :abstract => 'Lead of article', :body => 'This is my article') @community = create(Community, :contact_email => "someone@anyhost.com") @comment = build(Comment, :article => @article, :title => 'any comment', :body => "any text", :author => create_user('someperson').person) end diff --git a/test/unit/article_test.rb b/test/unit/article_test.rb index ce46e2d..ac4d45e 100644 --- a/test/unit/article_test.rb +++ b/test/unit/article_test.rb @@ -341,9 +341,9 @@ class ArticleTest < ActiveSupport::TestCase should 'list most commented articles' do Article.delete_all - a1 = create(TextileArticle, :name => "art 1", :profile_id => profile.id) - a2 = create(TextileArticle, :name => "art 2", :profile_id => profile.id) - a3 = create(TextileArticle, :name => "art 3", :profile_id => profile.id) + a1 = create(TextArticle, :name => "art 1", :profile_id => profile.id) + a2 = create(TextArticle, :name => "art 2", :profile_id => profile.id) + a3 = create(TextArticle, :name => "art 3", :profile_id => profile.id) 2.times { create(Comment, :title => 'test', :body => 'asdsad', :author => profile, :source => a2).save! } 4.times { create(Comment, :title => 'test', :body => 'asdsad', :author => profile, :source => a3).save! } @@ -643,14 +643,14 @@ class ArticleTest < ActiveSupport::TestCase should 'identify if belongs to blog' do p = create_user('user_blog_test').person blog = fast_create(Blog, :name => 'Blog test', :profile_id => p.id) - post = fast_create(TextileArticle, :name => 'First post', :profile_id => p.id, :parent_id => blog.id) + post = fast_create(TextArticle, :name => 'First post', :profile_id => p.id, :parent_id => blog.id) assert post.belongs_to_blog? end should 'not belongs to blog' do p = create_user('user_blog_test').person folder = fast_create(Folder, :name => 'Not Blog', :profile_id => p.id) - a = fast_create(TextileArticle, :name => 'Not blog post', :profile_id => p.id, :parent_id => folder.id) + a = fast_create(TextArticle, :name => 'Not blog post', :profile_id => p.id, :parent_id => folder.id) refute a.belongs_to_blog? end @@ -955,7 +955,7 @@ class ArticleTest < ActiveSupport::TestCase end should 'have short lead' do - a = fast_create(TinyMceArticle, :body => '

' + ('a' *180) + '

') + a = fast_create(TextArticle, :body => '

' + ('a' *180) + '

') assert_equal 170, a.short_lead.length end @@ -965,7 +965,7 @@ class ArticleTest < ActiveSupport::TestCase end should 'track action when a published article is created outside a community' do - article = create(TinyMceArticle, :profile_id => profile.id) + article = create(TextArticle, :profile_id => profile.id) ta = article.activity assert_equal article.name, ta.get_name assert_equal article.url, ta.get_url @@ -980,7 +980,7 @@ class ArticleTest < ActiveSupport::TestCase community.add_member(p2) User.current = p1.user - article = create(TinyMceArticle, :profile_id => community.id) + article = create(TextArticle, :profile_id => community.id) activity = article.activity process_delayed_job_queue @@ -989,7 +989,7 @@ class ArticleTest < ActiveSupport::TestCase end should 'destroy activity when a published article is removed' do - a = create(TinyMceArticle, :profile_id => profile.id) + a = create(TextArticle, :profile_id => profile.id) assert_difference 'ActionTracker::Record.count', -1 do a.destroy end @@ -1022,7 +1022,7 @@ class ArticleTest < ActiveSupport::TestCase end should 'create activity' do - a = create TextileArticle, :name => 'bar', :profile_id => profile.id, :published => true + a = create TextArticle, :name => 'bar', :profile_id => profile.id, :published => true a.activity.destroy assert_nil a.activity @@ -1068,7 +1068,7 @@ class ArticleTest < ActiveSupport::TestCase should "not be trackable if article is inside a private community" do private_community = fast_create(Community, :public_profile => false) - a = fast_create(TinyMceArticle, :profile_id => private_community.id) + a = fast_create(TextArticle, :profile_id => private_community.id) assert_equal false, a.is_trackable? end @@ -1081,7 +1081,7 @@ class ArticleTest < ActiveSupport::TestCase member_1 = User.current.person community.add_member(member_1) - article = create TinyMceArticle, :name => 'Tracked Article 1', :profile_id => community.id + article = create TextArticle, :name => 'Tracked Article 1', :profile_id => community.id first_activity = article.activity assert_equal [first_activity], ActionTracker::Record.where(verb: 'create_article') @@ -1091,7 +1091,7 @@ class ArticleTest < ActiveSupport::TestCase member_2 = fast_create(Person) community.add_member(member_2) - article2 = create TinyMceArticle, :name => 'Tracked Article 2', :profile_id => community.id + article2 = create TextArticle, :name => 'Tracked Article 2', :profile_id => community.id second_activity = article2.activity assert_equivalent [first_activity, second_activity], ActionTracker::Record.where(verb: 'create_article') @@ -1107,7 +1107,7 @@ class ArticleTest < ActiveSupport::TestCase ActionTracker::Record.destroy_all ActionTrackerNotification.destroy_all User.current = profile.user - article = create(TinyMceArticle, :profile_id => profile.id) + article = create(TextArticle, :profile_id => profile.id) process_delayed_job_queue assert_equal friend, ActionTrackerNotification.last.profile @@ -1119,7 +1119,7 @@ class ArticleTest < ActiveSupport::TestCase f1.follow(profile, circle) User.current = profile.user - article = create TinyMceArticle, :name => 'Tracked Article 1', :profile_id => profile.id + article = create TextArticle, :name => 'Tracked Article 1', :profile_id => profile.id assert_equal 1, ActionTracker::Record.where(verb: 'create_article').count process_delayed_job_queue assert_equal 2, ActionTrackerNotification.where(action_tracker_id: article.activity.id).count @@ -1128,7 +1128,7 @@ class ArticleTest < ActiveSupport::TestCase circle2 = Circle.create!(:person=> f2, :name => "Zombies", :profile_type => 'Person') f2.follow(profile, circle2) - article2 = create TinyMceArticle, :name => 'Tracked Article 2', :profile_id => profile.id + article2 = create TextArticle, :name => 'Tracked Article 2', :profile_id => profile.id assert_equal 2, ActionTracker::Record.where(verb: 'create_article').count process_delayed_job_queue assert_equal 3, ActionTrackerNotification.where(action_tracker_id: article2.activity.id).count @@ -1145,7 +1145,7 @@ class ArticleTest < ActiveSupport::TestCase ActionTracker::Record.destroy_all ActionTrackerNotification.destroy_all User.current = profile.user - article = create(TinyMceArticle, :profile_id => profile.id) + article = create(TextArticle, :profile_id => profile.id) activity = article.activity process_delayed_job_queue @@ -1168,7 +1168,7 @@ class ArticleTest < ActiveSupport::TestCase community.add_member(p2) User.current = p1.user - article = create(TinyMceArticle, :profile_id => community.id) + article = create(TextArticle, :profile_id => community.id) activity = article.activity process_delayed_job_queue @@ -1410,7 +1410,7 @@ class ArticleTest < ActiveSupport::TestCase should 'retrieve latest info from topic when has no comments' do forum = fast_create(Forum, :name => 'Forum test', :profile_id => profile.id) - post = fast_create(TextileArticle, :name => 'First post', :profile_id => profile.id, :parent_id => forum.id, :updated_at => Time.now.in_time_zone, :author_id => profile.id) + post = fast_create(TextArticle, :name => 'First post', :profile_id => profile.id, :parent_id => forum.id, :updated_at => Time.now.in_time_zone, :author_id => profile.id) assert_equal post.updated_at, post.info_from_last_update[:date] assert_equal profile.name, post.info_from_last_update[:author_name] assert_equal profile.url, post.info_from_last_update[:author_url] @@ -1418,19 +1418,15 @@ class ArticleTest < ActiveSupport::TestCase should 'retrieve latest info from comment when has comments' do forum = fast_create(Forum, :name => 'Forum test', :profile_id => profile.id) - post = fast_create(TextileArticle, :name => 'First post', :profile_id => profile.id, :parent_id => forum.id, :updated_at => Time.now.in_time_zone) + post = fast_create(TextArticle, :name => 'First post', :profile_id => profile.id, :parent_id => forum.id, :updated_at => Time.now.in_time_zone) post.comments << build(Comment, :name => 'Guest', :email => 'guest@example.com', :title => 'test comment', :body => 'hello!') assert_equal post.comments.last.created_at, post.info_from_last_update[:date] assert_equal "Guest", post.info_from_last_update[:author_name] assert_nil post.info_from_last_update[:author_url] end - should 'tiny mce editor is disabled by default' do - refute Article.new.tiny_mce? - end - should 'return only folders' do - not_folders = [RssFeed, TinyMceArticle, Event, TextileArticle] + not_folders = [RssFeed, TextArticle, Event, TextArticle] folders = [Folder, Blog, Gallery, Forum] not_folders.each do |klass| @@ -1445,7 +1441,7 @@ class ArticleTest < ActiveSupport::TestCase end should 'return no folders' do - not_folders = [RssFeed, TinyMceArticle, Event, TextileArticle] + not_folders = [RssFeed, TextArticle, Event, TextArticle] folders = [Folder, Blog, Gallery, Forum] not_folders.each do |klass| @@ -1485,7 +1481,7 @@ class ArticleTest < ActiveSupport::TestCase should 'get images paths in article body' do Environment.any_instance.stubs(:default_hostname).returns('noosfero.org') - a = build TinyMceArticle, :profile => @profile + a = build TextArticle, :profile => @profile a.body = 'Noosfero test ' assert_includes a.body_images_paths, 'http://noosfero.com/test.png' assert_includes a.body_images_paths, 'http://test.com/noosfero.png' @@ -1493,7 +1489,7 @@ class ArticleTest < ActiveSupport::TestCase should 'always put article image first in images paths list in article body' do Environment.any_instance.stubs(:default_hostname).returns('noosfero.org') - a = create(TinyMceArticle, :name => 'test', :image_builder => { + a = create(TextArticle, :name => 'test', :image_builder => { :uploaded_data => fixture_file_upload('/files/rails.png', 'image/png') }, :profile_id => @profile.id) a.save! @@ -1504,7 +1500,7 @@ class ArticleTest < ActiveSupport::TestCase should 'escape utf8 characters correctly' do Environment.any_instance.stubs(:default_hostname).returns('noosfero.org') - a = build TinyMceArticle, profile: @profile + a = build TextArticle, profile: @profile a.body = 'Noosfero ' assert_includes a.body_images_paths, 'http://noosfero.com/cabe%C3%A7a.png' @@ -1515,7 +1511,7 @@ class ArticleTest < ActiveSupport::TestCase should 'get absolute images paths in article body' do Environment.any_instance.stubs(:default_hostname).returns('noosfero.org') - a = build TinyMceArticle, :profile => @profile + a = build TextArticle, :profile => @profile a.body = 'Noosfero Absolute test ' assert_includes a.body_images_paths, 'http://noosfero.org/test.png' assert_includes a.body_images_paths, 'http://noosfero.org/relative/path.png' @@ -1545,13 +1541,13 @@ class ArticleTest < ActiveSupport::TestCase should 'find more recent contents' do Article.delete_all - c1 = fast_create(TinyMceArticle, :name => 'Testing article 1', :body => 'Article body 1', :profile_id => profile.id, :created_at => DateTime.now - 4) - c2 = fast_create(TinyMceArticle, :name => 'Testing article 2', :body => 'Article body 2', :profile_id => profile.id, :created_at => DateTime.now - 1) - c3 = fast_create(TinyMceArticle, :name => 'Testing article 3', :body => 'Article body 3', :profile_id => profile.id, :created_at => DateTime.now - 3) + c1 = fast_create(TextArticle, :name => 'Testing article 1', :body => 'Article body 1', :profile_id => profile.id, :created_at => DateTime.now - 4) + c2 = fast_create(TextArticle, :name => 'Testing article 2', :body => 'Article body 2', :profile_id => profile.id, :created_at => DateTime.now - 1) + c3 = fast_create(TextArticle, :name => 'Testing article 3', :body => 'Article body 3', :profile_id => profile.id, :created_at => DateTime.now - 3) assert_equal [c2,c3,c1] , Article.more_recent - c4 = fast_create(TinyMceArticle, :name => 'Testing article 4', :body => 'Article body 4', :profile_id => profile.id, :created_at => DateTime.now - 2) + c4 = fast_create(TextArticle, :name => 'Testing article 4', :body => 'Article body 4', :profile_id => profile.id, :created_at => DateTime.now - 2) assert_equal [c2,c4,c3,c1] , Article.more_recent end @@ -1604,18 +1600,6 @@ class ArticleTest < ActiveSupport::TestCase assert_equal "4 views", a.more_popular_label end - should 'return only text articles' do - Article.delete_all - - c1 = fast_create(TinyMceArticle, :name => 'Testing article 1', :body => 'Article body 1', :profile_id => profile.id) - c2 = fast_create(TextArticle, :name => 'Testing article 2', :body => 'Article body 2', :profile_id => profile.id) - c3 = fast_create(Event, :name => 'Testing article 3', :body => 'Article body 3', :profile_id => profile.id) - c4 = fast_create(RssFeed, :name => 'Testing article 4', :body => 'Article body 4', :profile_id => profile.id) - c5 = fast_create(TextileArticle, :name => 'Testing article 5', :body => 'Article body 5', :profile_id => profile.id) - - assert_equivalent [c1,c2,c5], Article.text_articles - end - should 'delegate region info to profile' do Person.any_instance.expects(:region) Person.any_instance.expects(:region_id) @@ -1708,7 +1692,7 @@ class ArticleTest < ActiveSupport::TestCase author = fast_create(Person) community.add_member(author) forum = Forum.create(:profile => community, :name => 'Forum test', :body => 'Forum test') - post = fast_create(TextileArticle, :name => 'First post', :profile_id => community.id, :parent_id => forum.id, :author_id => author.id) + post = fast_create(TextArticle, :name => 'First post', :profile_id => community.id, :parent_id => forum.id, :author_id => author.id) assert post.allow_edit?(author) end @@ -1742,7 +1726,7 @@ class ArticleTest < ActiveSupport::TestCase end should 'store first image in tracked action' do - a = create TinyMceArticle, :name => 'Tracked Article', :body => '

FooBar

', :profile_id => profile.id + a = create TextArticle, :name => 'Tracked Article', :body => '

FooBar

', :profile_id => profile.id assert_equal 'foo.png', a.first_image assert_equal 'foo.png', ActionTracker::Record.last.get_first_image end @@ -1766,7 +1750,7 @@ class ArticleTest < ActiveSupport::TestCase should 'update path if parent is changed' do f1 = create(Folder, :name => 'Folder 1', :profile => profile) f2 = create(Folder, :name => 'Folder 2', :profile => profile) - article = create(TinyMceArticle, :name => 'Sample Article', :parent_id => f1.id, :profile => profile) + article = create(TextArticle, :name => 'Sample Article', :parent_id => f1.id, :profile => profile) assert_equal [f1.path,article.slug].join('/'), article.path article.parent = f2 @@ -1836,20 +1820,20 @@ class ArticleTest < ActiveSupport::TestCase should 'identify if belongs to forum' do p = create_user('user_forum_test').person forum = fast_create(Forum, :name => 'Forum test', :profile_id => p.id) - post = fast_create(TextileArticle, :name => 'First post', :profile_id => p.id, :parent_id => forum.id) + post = fast_create(TextArticle, :name => 'First post', :profile_id => p.id, :parent_id => forum.id) assert post.belongs_to_forum? end should 'not belongs to forum' do p = create_user('user_forum_test').person blog = fast_create(Blog, :name => 'Not Forum', :profile_id => p.id) - a = fast_create(TextileArticle, :name => 'Not forum post', :profile_id => p.id, :parent_id => blog.id) + a = fast_create(TextArticle, :name => 'Not forum post', :profile_id => p.id, :parent_id => blog.id) refute a.belongs_to_forum? end should 'not belongs to forum if do not have a parent' do p = create_user('user_forum_test').person - a = fast_create(TextileArticle, :name => 'Orphan post', :profile_id => p.id) + a = fast_create(TextArticle, :name => 'Orphan post', :profile_id => p.id) refute a.belongs_to_forum? end @@ -1865,13 +1849,12 @@ class ArticleTest < ActiveSupport::TestCase should 'return articles with specific types' do Article.delete_all - c1 = fast_create(TinyMceArticle, :name => 'Testing article 1', :body => 'Article body 1', :profile_id => profile.id) - c2 = fast_create(TextArticle, :name => 'Testing article 2', :body => 'Article body 2', :profile_id => profile.id) + c1 = fast_create(TextArticle, :name => 'Testing article 1', :body => 'Article body 2', :profile_id => profile.id) c3 = fast_create(Event, :name => 'Testing article 3', :body => 'Article body 3', :profile_id => profile.id) c4 = fast_create(RssFeed, :name => 'Testing article 4', :body => 'Article body 4', :profile_id => profile.id) - c5 = fast_create(TextileArticle, :name => 'Testing article 5', :body => 'Article body 5', :profile_id => profile.id) + c5 = fast_create(TextArticle, :name => 'Testing article 5', :body => 'Article body 5', :profile_id => profile.id) - assert_equivalent [c1,c2], Article.with_types(['TinyMceArticle', 'TextArticle']) + assert_equivalent [c1,c5], Article.with_types(['TextArticle']) assert_equivalent [c3], Article.with_types(['Event']) end @@ -2338,4 +2321,23 @@ class ArticleTest < ActiveSupport::TestCase should 'have can_display_blocks with default true' do assert Article.can_display_blocks? end + + should 'is_editor true if the article editor is the same as te editor parameter' do + article = Article.new(:editor => Article::Editor::TEXTILE) + assert article.editor?(Article::Editor::TEXTILE) + article = Article.new(:editor => Article::Editor::TINY_MCE) + assert article.editor?(Article::Editor::TINY_MCE) + article = Article.new(:editor => Article::Editor::RAW_HTML) + assert article.editor?(Article::Editor::RAW_HTML) + end + + should 'is_editor false if the article editor is not the same as te editor parameter' do + article = Article.new(:editor => Article::Editor::TEXTILE) + assert !article.editor?(Article::Editor::TINY_MCE) + article = Article.new(:editor => Article::Editor::TINY_MCE) + assert !article.editor?(Article::Editor::TEXTILE) + article = Article.new(:editor => Article::Editor::RAW_HTML) + assert !article.editor?(Article::Editor::TINY_MCE) + end + end diff --git a/test/unit/blog_archives_block_test.rb b/test/unit/blog_archives_block_test.rb index 1f2799a..dcbb193 100644 --- a/test/unit/blog_archives_block_test.rb +++ b/test/unit/blog_archives_block_test.rb @@ -60,8 +60,8 @@ class BlogArchivesBlockTest < ActiveSupport::TestCase # block.stubs(:blog).returns(blog) # block.stubs(:owner).returns(profile) # -# public_post = fast_create(TextileArticle, :profile_id => profile.id, :parent_id => blog.id, :published => true, :published_at => Time.mktime(2012, 'jan')) -# private_post = fast_create(TextileArticle, :profile_id => profile.id, :parent_id => blog.id, :published => false, :published_at => Time.mktime(2012, 'jan')) +# public_post = fast_create(TextArticle, :profile_id => profile.id, :parent_id => blog.id, :published => true, :published_at => Time.mktime(2012, 'jan')) +# private_post = fast_create(TextArticle, :profile_id => profile.id, :parent_id => blog.id, :published => false, :published_at => Time.mktime(2012, 'jan')) # # assert_match /January \(1\)/, block.content({:person => person}) # assert_match /January \(1\)/, block.content() @@ -84,7 +84,7 @@ class BlogArchivesBlockViewTest < ActionView::TestCase date = DateTime.parse('2008-01-10') blog = profile.blog for i in 1..10 do - post = fast_create(TextileArticle, :name => "post #{i} test", :profile_id => profile.id, :parent_id => blog.id) + post = fast_create(TextArticle, :name => "post #{i} test", :profile_id => profile.id, :parent_id => blog.id) post.update_attribute(:published_at, date) end block = BlogArchivesBlock.new @@ -98,7 +98,7 @@ class BlogArchivesBlockViewTest < ActionView::TestCase date = DateTime.parse('2008-01-10') blog = profile.blog for i in 1..10 do - post = fast_create(TextileArticle, :name => "post #{i} test", :profile_id => profile.id, :parent_id => blog.id) + post = fast_create(TextArticle, :name => "post #{i} test", :profile_id => profile.id, :parent_id => blog.id) assert post.update_attribute(:published_at, date) end block = BlogArchivesBlock.new @@ -120,7 +120,7 @@ class BlogArchivesBlockViewTest < ActionView::TestCase should 'order list of amount posts' do blog = profile.blog for i in 1..10 do - post = fast_create(TextileArticle, :name => "post #{i} test", :profile_id => profile.id, :parent_id => blog.id) + post = fast_create(TextArticle, :name => "post #{i} test", :profile_id => profile.id, :parent_id => blog.id) post.update_attribute(:published_at, DateTime.parse("2008-#{i}-01")) end block = BlogArchivesBlock.new @@ -146,7 +146,7 @@ class BlogArchivesBlockViewTest < ActionView::TestCase should 'order years' do blog = profile.blog for year in 2005..2009 - post = create(TextileArticle, :name => "post #{year}", :profile => profile, :parent => blog, :published_at => Date.new(year, 1, 1)) + post = create(TextArticle, :name => "post #{year}", :profile => profile, :parent => blog, :published_at => Date.new(year, 1, 1)) end block = BlogArchivesBlock.new block.stubs(:owner).returns(profile) @@ -158,7 +158,7 @@ class BlogArchivesBlockViewTest < ActionView::TestCase should 'order months from later to former' do blog = profile.blog for month in 1..3 - post = create(TextileArticle, :name => "post #{month}", :profile => profile, :parent => blog, :published_at => Date.new(2009, month, 1)) + post = create(TextArticle, :name => "post #{month}", :profile => profile, :parent => blog, :published_at => Date.new(2009, month, 1)) end block = BlogArchivesBlock.new block.stubs(:owner).returns(profile) @@ -182,8 +182,8 @@ class BlogArchivesBlockViewTest < ActionView::TestCase profile.articles << Blog.new(:name => 'Blog Two', :profile => profile) (blog_one, blog_two) = profile.blogs for month in 1..3 - create(TextileArticle, :name => "blog one - post #{month}", :profile_id => profile.id, :parent_id => blog_one.id) - create(TextileArticle, :name => "blog two - post #{month}", :profile_id => profile.id, :parent_id => blog_two.id) + create(TextArticle, :name => "blog one - post #{month}", :profile_id => profile.id, :parent_id => blog_one.id) + create(TextArticle, :name => "blog two - post #{month}", :profile_id => profile.id, :parent_id => blog_two.id) end block = BlogArchivesBlock.new block.stubs(:owner).returns(profile) @@ -197,10 +197,10 @@ class BlogArchivesBlockViewTest < ActionView::TestCase date = DateTime.parse('2008-01-10') blog = profile.blog 2.times do |i| - post = fast_create(TextileArticle, :name => "post #{i} test", :profile_id => profile.id, + post = fast_create(TextArticle, :name => "post #{i} test", :profile_id => profile.id, :parent_id => blog.id, :language => 'en') post.update_attribute(:published_at, date) - translation = fast_create(TextileArticle, :name => "post #{i} test", :profile_id => profile.id, + translation = fast_create(TextArticle, :name => "post #{i} test", :profile_id => profile.id, :parent_id => blog.id, :language => 'en', :translation_of_id => post.id) translation.update_attribute(:published_at, date) end @@ -215,10 +215,10 @@ class BlogArchivesBlockViewTest < ActionView::TestCase date = DateTime.parse('2008-01-10') blog = profile.blog 2.times do |i| - post = fast_create(TextileArticle, :name => "post #{i} test", :profile_id => profile.id, + post = fast_create(TextArticle, :name => "post #{i} test", :profile_id => profile.id, :parent_id => blog.id, :language => 'en') post.update_attribute(:published_at, date) - translation = fast_create(TextileArticle, :name => "post #{i} test", :profile_id => profile.id, + translation = fast_create(TextArticle, :name => "post #{i} test", :profile_id => profile.id, :parent_id => blog.id, :language => 'en', :translation_of_id => post.id) translation.update_attribute(:published_at, date) end diff --git a/test/unit/blog_helper_test.rb b/test/unit/blog_helper_test.rb index da5563a..5af1c9f 100644 --- a/test/unit/blog_helper_test.rb +++ b/test/unit/blog_helper_test.rb @@ -23,13 +23,13 @@ class BlogHelperTest < ActionView::TestCase def h(s); s; end should 'list blog posts with identifiers and classes' do - blog.children << older_post = create(TextileArticle, :name => 'First post', + blog.children << older_post = create(TextArticle, :name => 'First post', :profile => profile, :parent => blog, :published => true) - blog.children << some_post = create(TextileArticle, :name => 'Some post', + blog.children << some_post = create(TextArticle, :name => 'Some post', :profile => profile, :parent => blog, :published => true) - blog.children << hidden_post = create(TextileArticle, :name => 'Hidden post', + blog.children << hidden_post = create(TextArticle, :name => 'Hidden post', :profile => profile, :parent => blog, :published => false) - blog.children << newer_post = create(TextileArticle, :name => 'Last post', + blog.children << newer_post = create(TextArticle, :name => 'Last post', :profile => profile, :parent => blog, :published => true) def content_tag(tag, content_or_options_with_block = nil, options = nil, &block) @@ -57,7 +57,7 @@ class BlogHelperTest < ActionView::TestCase should 'display post' do - blog.children << article = create(TextileArticle, :name => 'Second post', :profile => profile, :parent => blog, :published => true) + blog.children << article = create(TextArticle, :name => 'Second post', :profile => profile, :parent => blog, :published => true) expects(:article_title).with(article, anything).returns('TITLE') expects(:content_tag).with('p', article.to_html).returns(' TO_HTML') self.stubs(:params).returns({:npage => nil}) diff --git a/test/unit/blog_test.rb b/test/unit/blog_test.rb index 779935e..b4dc650 100644 --- a/test/unit/blog_test.rb +++ b/test/unit/blog_test.rb @@ -66,7 +66,7 @@ class BlogTest < ActiveSupport::TestCase should 'has posts' do p = create_user('testuser').person blog = fast_create(Blog, :profile_id => p.id, :name => 'Blog test') - post = fast_create(TextileArticle, :name => 'First post', :profile_id => p.id, :parent_id => blog.id) + post = fast_create(TextArticle, :name => 'First post', :profile_id => p.id, :parent_id => blog.id) blog.children << post assert_includes blog.posts, post end @@ -81,8 +81,8 @@ class BlogTest < ActiveSupport::TestCase should 'list posts ordered by published at' do p = create_user('testuser').person blog = fast_create(Blog, :profile_id => p.id, :name => 'Blog test') - newer = create(TextileArticle, :name => 'Post 2', :parent => blog, :profile => p) - older = create(TextileArticle, :name => 'Post 1', :parent => blog, :profile => p, :published_at => Time.now - 1.month) + newer = create(TextArticle, :name => 'Post 2', :parent => blog, :profile => p) + older = create(TextArticle, :name => 'Post 1', :parent => blog, :profile => p, :published_at => Time.now - 1.month) assert_equal [newer, older], blog.posts end @@ -215,7 +215,7 @@ class BlogTest < ActiveSupport::TestCase p = create_user('testuser').person blog = Blog.create!(:profile => p, :name => 'Blog test') folder = fast_create(Folder, :parent_id => blog.id) - article = fast_create(TextileArticle, :parent_id => blog.id) + article = fast_create(TextArticle, :parent_id => blog.id) assert_not_includes blog.posts, folder assert_includes blog.posts, article @@ -230,7 +230,7 @@ class BlogTest < ActiveSupport::TestCase p = create_user('testuser').person blog = Blog.create!(:profile => p, :name => 'Blog test') assert blog.empty? - fast_create(TextileArticle, :parent_id => blog.id) + fast_create(TextArticle, :parent_id => blog.id) refute blog.empty? end @@ -270,18 +270,18 @@ class BlogTest < ActiveSupport::TestCase should 'count total number of posts by year' do p = create_user('testuser').person blog = fast_create(Blog, :profile_id => p.id, :name => 'Blog test') - create(TextileArticle, :name => 'Post 1', :parent => blog, :profile => p, :published_at => DateTime.parse('16-08-2010')) - create(TextileArticle, :name => 'Post 2', :parent => blog, :profile => p, :published_at => DateTime.parse('17-08-2010')) - create(TextileArticle, :name => 'Post 3', :parent => blog, :profile => p, :published_at => DateTime.parse('10-05-2012')) + create(TextArticle, :name => 'Post 1', :parent => blog, :profile => p, :published_at => DateTime.parse('16-08-2010')) + create(TextArticle, :name => 'Post 2', :parent => blog, :profile => p, :published_at => DateTime.parse('17-08-2010')) + create(TextArticle, :name => 'Post 3', :parent => blog, :profile => p, :published_at => DateTime.parse('10-05-2012')) assert_equal [[2012.0, 1], [2010.0, 2]], blog.total_number_of_posts(:by_year) end should 'count total number of posts by month' do p = create_user('testuser').person blog = fast_create(Blog, :profile_id => p.id, :name => 'Blog test') - create(TextileArticle, :name => 'Post 1', :parent => blog, :profile => p, :published_at => DateTime.parse('16-08-2010')) - create(TextileArticle, :name => 'Post 2', :parent => blog, :profile => p, :published_at => DateTime.parse('17-08-2010')) - create(TextileArticle, :name => 'Post 3', :parent => blog, :profile => p, :published_at => DateTime.parse('11-10-2010')) + create(TextArticle, :name => 'Post 1', :parent => blog, :profile => p, :published_at => DateTime.parse('16-08-2010')) + create(TextArticle, :name => 'Post 2', :parent => blog, :profile => p, :published_at => DateTime.parse('17-08-2010')) + create(TextArticle, :name => 'Post 3', :parent => blog, :profile => p, :published_at => DateTime.parse('11-10-2010')) assert_equal [[10.0, 1], [8.0, 2]], blog.total_number_of_posts(:by_month, 2010) end diff --git a/test/unit/clone_article_test.rb b/test/unit/clone_article_test.rb index fb0c64d..b99ab56 100644 --- a/test/unit/clone_article_test.rb +++ b/test/unit/clone_article_test.rb @@ -5,7 +5,7 @@ class CloneArticleTest < ActiveSupport::TestCase should 'cloned article have its source attributes' do community = fast_create(Community) folder = fast_create(Folder, :profile_id => community.id) - article = fast_create(TinyMceArticle, :profile_id => community.id) + article = fast_create(TextArticle, :profile_id => community.id) article.parent_id = folder.id article.save! @@ -18,4 +18,4 @@ class CloneArticleTest < ActiveSupport::TestCase assert_equal article.setting, cloned_article.setting end -end \ No newline at end of file +end diff --git a/test/unit/cms_helper_test.rb b/test/unit/cms_helper_test.rb index 2dd86ea..10593cf 100644 --- a/test/unit/cms_helper_test.rb +++ b/test/unit/cms_helper_test.rb @@ -31,7 +31,7 @@ class CmsHelperTest < ActionView::TestCase should 'display link to article if article is not folder' do profile = fast_create(Profile) - article = fast_create(TinyMceArticle, :name => 'My article', :profile_id => profile.id) + article = fast_create(TextArticle, :name => 'My article', :profile_id => profile.id) expects(:link_to).with('My article', article.url, :class => icon_for_article(article)) result = link_to_article(article) @@ -51,7 +51,7 @@ class CmsHelperTest < ActionView::TestCase should 'display spread button' do plugins.stubs(:dispatch).returns([]) profile = fast_create(Person) - article = fast_create(TinyMceArticle, :name => 'My article', :profile_id => profile.id) + article = fast_create(TextArticle, :name => 'My article', :profile_id => profile.id) expects(:link_to).with('Spread this', {:action => 'publish', :id => article.id}, :class => 'modal-toggle button with-text icon-spread', :title => nil) result = display_spread_button(article) @@ -72,7 +72,7 @@ class CmsHelperTest < ActionView::TestCase plugins.stubs(:dispatch).returns([]) profile = fast_create(Profile) name = 'My article' - article = fast_create(TinyMceArticle, :name => name, :profile_id => profile.id) + article = fast_create(TextArticle, :name => name, :profile_id => profile.id) confirm_message = "Are you sure that you want to remove the item \"#{name}\"?" expects(:link_to).with('Delete', {action: 'destroy', id: article.id}, method: :post, 'data-confirm' => confirm_message, class: 'button with-text icon-delete', title: nil) diff --git a/test/unit/comment_test.rb b/test/unit/comment_test.rb index d6b653e..b58537c 100644 --- a/test/unit/comment_test.rb +++ b/test/unit/comment_test.rb @@ -65,7 +65,7 @@ class CommentTest < ActiveSupport::TestCase should 'update counter cache in article' do owner = create_user('testuser').person - art = create(TextileArticle, :profile_id => owner.id) + art = create(TextArticle, :profile_id => owner.id) cc = art.comments_count comment = create(Comment, :source => art, :author_id => owner.id) @@ -75,7 +75,7 @@ class CommentTest < ActiveSupport::TestCase should 'update counter cache in article activity' do User.current = user = create_user 'testuser' owner = user.person - article = create(TextileArticle, :profile_id => owner.id) + article = create(TextArticle, :profile_id => owner.id) action = article.activity cc = action.comments_count @@ -290,7 +290,7 @@ class CommentTest < ActiveSupport::TestCase should "return activities comments as a thread" do User.current = user = create_user person = user.person - a = TextileArticle.create!(:profile => person, :name => 'My article', :body => 'Article body') + a = TextArticle.create!(:profile => person, :name => 'My article', :body => 'Article body') c0 = Comment.create!(:source => a, :body => 'My comment', :author => person) c1 = Comment.create!(:reply_of_id => c0.id, :source => a, :body => 'bla', :author => person) c2 = Comment.create!(:reply_of_id => c1.id, :source => a, :body => 'bla', :author => person) @@ -308,7 +308,7 @@ class CommentTest < ActiveSupport::TestCase should "return activities comments when some comment on thread is spam and not display its replies" do User.current = user = create_user person = user.person - a = TextileArticle.create!(:profile => person, :name => 'My article', :body => 'Article body') + a = TextArticle.create!(:profile => person, :name => 'My article', :body => 'Article body') c0 = Comment.create(:source => a, :body => 'Root comment', :author => person) c1 = Comment.create(:reply_of_id => c0.id, :source => a, :body => 'c1', :author => person) c2 = Comment.create(:source => a, :body => 'c2', :author => person) @@ -385,7 +385,7 @@ class CommentTest < ActiveSupport::TestCase User.current = user = create_user 'testuser' profile = user.person - article = create(TinyMceArticle, :profile => profile) + article = create(TextArticle, :profile => profile) ActionTracker::Record.record_timestamps = false article.activity.update_attribute(:updated_at, Time.now - 1.day) @@ -400,7 +400,7 @@ class CommentTest < ActiveSupport::TestCase should 'create a new activity when add a comment and the activity was removed' do User.current = user = create_user 'testuser' profile = user.person - article = create(TinyMceArticle, :profile => profile) + article = create(TextArticle, :profile => profile) article.activity.destroy assert_nil article.activity @@ -776,7 +776,7 @@ class CommentTest < ActiveSupport::TestCase def create_comment(args = {}) owner = create_user('testuser').person - article = create(TextileArticle, :profile_id => owner.id) + article = create(TextArticle, :profile_id => owner.id) create(Comment, { :name => 'foo', :email => 'foo@example.com', :source => article }.merge(args)) end diff --git a/test/unit/community_test.rb b/test/unit/community_test.rb index a17c849..6a1a3d2 100644 --- a/test/unit/community_test.rb +++ b/test/unit/community_test.rb @@ -145,25 +145,25 @@ class CommunityTest < ActiveSupport::TestCase c = fast_create(Community, :name => 'test_com') f = fast_create(Folder, :name => 'folder', :profile_id => c.id) u = create(UploadedFile, :profile => c, :uploaded_data => fixture_file_upload('/files/rails.png', 'image/png')) - older_t = fast_create(TinyMceArticle, :name => 'old news', :profile_id => c.id) - t = fast_create(TinyMceArticle, :name => 'news', :profile_id => c.id) - t_in_f = fast_create(TinyMceArticle, :name => 'news', :profile_id => c.id, :parent_id => f.id) + older_t = fast_create(TextArticle, :name => 'old news', :profile_id => c.id) + t = fast_create(TextArticle, :name => 'news', :profile_id => c.id) + t_in_f = fast_create(TextArticle, :name => 'news', :profile_id => c.id, :parent_id => f.id) assert_equal [t_in_f, t], c.news(2) end should 'not return highlighted news when not asked' do c = fast_create(Community, :name => 'test_com') - highlighted_t = fast_create(TinyMceArticle, :name => 'high news', :profile_id => c.id, :highlighted => true) - t = fast_create(TinyMceArticle, :name => 'news', :profile_id => c.id) + highlighted_t = fast_create(TextArticle, :name => 'high news', :profile_id => c.id, :highlighted => true) + t = fast_create(TextArticle, :name => 'news', :profile_id => c.id) assert_equal [t].map(&:slug), c.news(2).map(&:slug) end should 'return highlighted news when asked' do c = fast_create(Community, :name => 'test_com') - highlighted_t = fast_create(TinyMceArticle, :name => 'high news', :profile_id => c.id, :highlighted => true) - t = fast_create(TinyMceArticle, :name => 'news', :profile_id => c.id) + highlighted_t = fast_create(TextArticle, :name => 'high news', :profile_id => c.id, :highlighted => true) + t = fast_create(TextArticle, :name => 'news', :profile_id => c.id) assert_equal [highlighted_t].map(&:slug), c.news(2, true).map(&:slug) end @@ -293,7 +293,7 @@ class CommunityTest < ActiveSupport::TestCase p2 = create_user.person p3 = create_user.person community.add_member(p3) - article = create(TextileArticle, :profile_id => community.id) + article = create(TextArticle, :profile_id => community.id) time = article.activity.updated_at + 1.day Time.stubs(:now).returns(time) create(Comment, :source_id => article.id, :title => 'some', :body => 'some', :author_id => p2.id) @@ -366,7 +366,7 @@ class CommunityTest < ActiveSupport::TestCase User.current = person.user assert_difference 'ActionTracker::Record.count', 1 do - article = create(TinyMceArticle, :profile => community, :name => 'An article about free software') + article = create(TextArticle, :profile => community, :name => 'An article about free software') assert_equal [article.activity], community.activities.map(&:activity) end end @@ -377,7 +377,7 @@ class CommunityTest < ActiveSupport::TestCase community2 = fast_create(Community) User.current = person.user - article = create(TinyMceArticle, :profile => community2, :name => 'Another article about free software') + article = create(TextArticle, :profile => community2, :name => 'Another article about free software') assert_not_includes community.activities.map { |a| a.klass.constantize.find(a.id) }, article.activity end diff --git a/test/unit/content_viewer_helper_test.rb b/test/unit/content_viewer_helper_test.rb index 370b856..767a62e 100644 --- a/test/unit/content_viewer_helper_test.rb +++ b/test/unit/content_viewer_helper_test.rb @@ -16,27 +16,27 @@ class ContentViewerHelperTest < ActionView::TestCase should 'display published-at for blog posts' do blog = fast_create(Blog, :name => 'Blog test', :profile_id => profile.id) - post = create(TextileArticle, :name => 'post test', :profile => profile, :parent => blog) + post = create(TextArticle, :name => 'post test', :profile => profile, :parent => blog) result = article_title(post) assert_tag_in_string result, :tag => 'span', :content => show_time(post.published_at) end should 'display published-at for forum posts' do forum = fast_create(Forum, :name => 'Forum test', :profile_id => profile.id) - post = TextileArticle.create!(:name => 'post test', :profile => profile, :parent => forum) + post = TextArticle.create!(:name => 'post test', :profile => profile, :parent => forum) result = article_title(post) assert_tag_in_string result, :tag => 'span', :content => show_time(post.published_at) end should 'not display published-at for non-blog and non-forum posts' do - article = create(TextileArticle, :name => 'article for test', :profile => profile) + article = create(TextArticle, :name => 'article for test', :profile => profile) result = article_title(article) assert_no_match /#{show_date(article.published_at)}<\/span>, by .*#{profile.identifier}/, result end should 'create link on title of blog posts' do blog = fast_create(Blog, :name => 'Blog test', :profile_id => profile.id) - post = fast_create(TextileArticle, :name => 'post test', :profile_id => profile.id, :parent_id => blog.id) + post = fast_create(TextArticle, :name => 'post test', :profile_id => profile.id, :parent_id => blog.id) assert post.belongs_to_blog? result = article_title(post) assert_tag_in_string result, :tag => 'h1', :child => {:tag => 'a', :content => 'post test', :attributes => { :href => /my-article-\d+/ }} @@ -44,33 +44,33 @@ class ContentViewerHelperTest < ActionView::TestCase should 'not create link on title if pass no_link option' do blog = fast_create(Blog, :name => 'Blog test', :profile_id => profile.id) - post = fast_create(TextileArticle, :name => 'post test', :profile_id => profile.id, :parent_id => blog.id) + post = fast_create(TextArticle, :name => 'post test', :profile_id => profile.id, :parent_id => blog.id) result = article_title(post, :no_link => :true) assert_no_match /a href='#{url_for(post.url)}'>#{post.name} 'art test', :profile_id => profile.id) + article = fast_create(TextArticle, :name => 'art test', :profile_id => profile.id) result = article_title(article) assert_no_match /a href='#{url_for(article.url)}'>#{article.name} 'Blog test', :profile_id => profile.id) - article = fast_create(TextileArticle, :name => 'art test', :profile_id => profile.id, :parent_id => blog.id) + article = fast_create(TextArticle, :name => 'art test', :profile_id => profile.id, :parent_id => blog.id) result = article_title(article, :no_comments => true) assert_no_match(/a href='.*comments_list.*>No comments yet 'Blog test', :profile_id => profile.id) - article = fast_create(TextileArticle, :name => 'art test', :profile_id => profile.id, :parent_id => blog.id, :accept_comments => false) + article = fast_create(TextArticle, :name => 'art test', :profile_id => profile.id, :parent_id => blog.id, :accept_comments => false) result = article_title(article) assert_no_match(/a href='.*comments_list.*>No comments yet profile.id) + article = fast_create(TextArticle, :profile_id => profile.id) create(Comment, :article => article, :author => profile, :title => 'test', :body => 'test') article.reload result = link_to_comments(article) @@ -78,7 +78,7 @@ class ContentViewerHelperTest < ActionView::TestCase end should 'not display total of comments if the article doesn\'t allow comments' do - article = build(TextileArticle, :name => 'first post for test', :body => 'first post for test', :profile => profile, :accept_comments => false) + article = build(TextArticle, :name => 'first post for test', :body => 'first post for test', :profile => profile, :accept_comments => false) article.stubs(:url).returns({}) article.stubs(:comments).returns([build(Comment, :author => profile, :title => 'test', :body => 'test')]) result = link_to_comments(article) @@ -86,7 +86,7 @@ class ContentViewerHelperTest < ActionView::TestCase end should 'not crash if spam_comments_count is nil' do - article = TextileArticle.new(:name => 'post for test', :body => 'post for test', :profile => profile) + article = TextArticle.new(:name => 'post for test', :body => 'post for test', :profile => profile) article.stubs(:comments_count).returns(10) article.stubs(:spam_comments_count).returns(nil) result = number_of_comments(article) @@ -116,7 +116,7 @@ class ContentViewerHelperTest < ActionView::TestCase should 'show date with mm/dd/yyyy' do Environment.any_instance.stubs(:date_format).returns('numbers_with_year') - article = TextileArticle.new(:name => 'post for test', :body => 'post for test', :profile => profile) + article = TextArticle.new(:name => 'post for test', :body => 'post for test', :profile => profile) article.published_at = Time.zone.local(2007, 2, 1, 15, 30, 45) article.save! result = show_with_right_format_date article @@ -125,7 +125,7 @@ class ContentViewerHelperTest < ActionView::TestCase should 'show date with mm/dd' do Environment.any_instance.stubs(:date_format).returns('numbers') - article = TextileArticle.new(:name => 'post for test', :body => 'post for test', :profile => profile) + article = TextArticle.new(:name => 'post for test', :body => 'post for test', :profile => profile) article.published_at = Time.zone.local(2007, 2, 1, 15, 30, 45) article.save! result = show_with_right_format_date article @@ -134,7 +134,7 @@ class ContentViewerHelperTest < ActionView::TestCase should 'show date with month name' do Environment.any_instance.stubs(:date_format).returns('month_name') - article = TextileArticle.new(:name => 'post for test', :body => 'post for test', :profile => profile) + article = TextArticle.new(:name => 'post for test', :body => 'post for test', :profile => profile) article.published_at = Time.zone.local(2007, 2, 1, 15, 30, 45) article.save! result = show_with_right_format_date article @@ -143,7 +143,7 @@ class ContentViewerHelperTest < ActionView::TestCase should 'show date with month name and year' do Environment.any_instance.stubs(:date_format).returns('month_name_with_year') - article = TextileArticle.new(:name => 'post for test', :body => 'post for test', :profile => profile) + article = TextArticle.new(:name => 'post for test', :body => 'post for test', :profile => profile) article.published_at = Time.zone.local(2007, 2, 1, 15, 30, 45) article.save! result = show_with_right_format_date article diff --git a/test/unit/enterprise_test.rb b/test/unit/enterprise_test.rb index 6e2b7ad..a060ec7 100644 --- a/test/unit/enterprise_test.rb +++ b/test/unit/enterprise_test.rb @@ -414,7 +414,7 @@ class EnterpriseTest < ActiveSupport::TestCase enterprise = fast_create(Enterprise) User.current = person.user - article = create(TinyMceArticle, :profile => enterprise, :name => 'An article about free software') + article = create(TextArticle, :profile => enterprise, :name => 'An article about free software') assert_equal [article.activity], enterprise.activities.map(&:activity) end @@ -425,7 +425,7 @@ class EnterpriseTest < ActiveSupport::TestCase enterprise2 = fast_create(Enterprise) User.current = person.user - article = create(TinyMceArticle, :profile => enterprise2, :name => 'Another article about free software') + article = create(TextArticle, :profile => enterprise2, :name => 'Another article about free software') assert_not_includes enterprise.activities.map(&:activity), article.activity end diff --git a/test/unit/event_test.rb b/test/unit/event_test.rb index eb91810..c261bc8 100644 --- a/test/unit/event_test.rb +++ b/test/unit/event_test.rb @@ -285,10 +285,6 @@ class EventTest < ActiveSupport::TestCase assert_kind_of TranslatableContent, Event.new end - should 'tiny mce editor is enabled' do - assert Event.new.tiny_mce? - end - should 'be notifiable' do assert Event.new.notifiable? end diff --git a/test/unit/folder_test.rb b/test/unit/folder_test.rb index 6c6514b..a0b0b65 100644 --- a/test/unit/folder_test.rb +++ b/test/unit/folder_test.rb @@ -63,9 +63,9 @@ class FolderTest < ActiveSupport::TestCase folder = fast_create(Folder, :profile_id => c.id) f = fast_create(Folder, :name => 'folder', :profile_id => c.id, :parent_id => folder.id) u = create(UploadedFile, :profile => c, :uploaded_data => fixture_file_upload('/files/rails.png', 'image/png'), :parent => folder) - older_t = fast_create(TinyMceArticle, :name => 'old news', :profile_id => c.id, :parent_id => folder.id) - t = fast_create(TinyMceArticle, :name => 'news', :profile_id => c.id, :parent_id => folder.id) - t_in_f = fast_create(TinyMceArticle, :name => 'news', :profile_id => c.id, :parent_id => f.id) + older_t = fast_create(TextArticle, :name => 'old news', :profile_id => c.id, :parent_id => folder.id) + t = fast_create(TextArticle, :name => 'news', :profile_id => c.id, :parent_id => folder.id) + t_in_f = fast_create(TextArticle, :name => 'news', :profile_id => c.id, :parent_id => f.id) assert_equal [t], folder.news(1) end @@ -73,8 +73,8 @@ class FolderTest < ActiveSupport::TestCase should 'not return highlighted news when not asked' do c = fast_create(Community) folder = fast_create(Folder, :profile_id => c.id) - highlighted_t = fast_create(TinyMceArticle, :name => 'high news', :profile_id => c.id, :highlighted => true, :parent_id => folder.id) - t = fast_create(TinyMceArticle, :name => 'news', :profile_id => c.id, :parent_id => folder.id) + highlighted_t = fast_create(TextArticle, :name => 'high news', :profile_id => c.id, :highlighted => true, :parent_id => folder.id) + t = fast_create(TextArticle, :name => 'news', :profile_id => c.id, :parent_id => folder.id) assert_equal [t].map(&:slug), folder.news(2).map(&:slug) end @@ -82,8 +82,8 @@ class FolderTest < ActiveSupport::TestCase should 'return highlighted news when asked' do c = fast_create(Community) folder = fast_create(Folder, :profile_id => c.id) - highlighted_t = fast_create(TinyMceArticle, :name => 'high news', :profile_id => c.id, :highlighted => true, :parent_id => folder.id) - t = fast_create(TinyMceArticle, :name => 'news', :profile_id => c.id, :parent_id => folder.id) + highlighted_t = fast_create(TextArticle, :name => 'high news', :profile_id => c.id, :highlighted => true, :parent_id => folder.id) + t = fast_create(TextArticle, :name => 'news', :profile_id => c.id, :parent_id => folder.id) assert_equal [highlighted_t].map(&:slug), folder.news(2, true).map(&:slug) end diff --git a/test/unit/forum_helper_test.rb b/test/unit/forum_helper_test.rb index dd8b680..a344a5b 100644 --- a/test/unit/forum_helper_test.rb +++ b/test/unit/forum_helper_test.rb @@ -30,16 +30,16 @@ class ForumHelperTest < ActionView::TestCase end should 'list posts with different classes' do - forum.children << older_post = create(TextileArticle, :name => 'First post', :profile => profile, :parent => forum, :published => false, :author => profile) + forum.children << older_post = create(TextArticle, :name => 'First post', :profile => profile, :parent => forum, :published => false, :author => profile) one_month_later = Time.now + 1.month Time.stubs(:now).returns(one_month_later) - forum.children << newer_post = create(TextileArticle, :name => 'Second post', :profile => profile, :parent => forum, :published => true, :author => profile) + forum.children << newer_post = create(TextArticle, :name => 'Second post', :profile => profile, :parent => forum, :published => true, :author => profile) assert_match /forum-post position-1 first odd-post.*forum-post position-2 last not-published even-post/, list_forum_posts(forum.posts) end should 'return post update if it has no comments' do author = create_user('forum test author').person - some_post = create(TextileArticle, :name => 'First post', :profile => profile, :parent => forum, :published => true, :author => author) + some_post = create(TextArticle, :name => 'First post', :profile => profile, :parent => forum, :published => true, :author => author) assert some_post.comments.empty? out = last_topic_update(some_post) assert_match time_ago_in_words(some_post.updated_at), out @@ -47,7 +47,7 @@ class ForumHelperTest < ActionView::TestCase end should 'return last comment date if it has comments' do - some_post = create(TextileArticle, :name => 'First post', :profile => profile, :parent => forum, :published => true) + some_post = create(TextArticle, :name => 'First post', :profile => profile, :parent => forum, :published => true) a1, a2 = create_user('a1').person, create_user('a2').person some_post.comments << build(Comment, :title => 'test', :body => 'test', :author => a1, :created_at => Time.now - 1.day) some_post.comments << build(Comment, :title => 'test', :body => 'test', :author => a2, :created_at => Time.now) @@ -62,7 +62,7 @@ class ForumHelperTest < ActionView::TestCase end should "return last comment author's name from unauthenticated user" do - some_post = create(TextileArticle, :name => 'First post', :profile => profile, :parent => forum, :published => true) + some_post = create(TextArticle, :name => 'First post', :profile => profile, :parent => forum, :published => true) some_post.comments << build(Comment, :name => 'John', :email => 'lenon@example.com', :title => 'test', :body => 'test') c = Comment.last out = last_topic_update(some_post) diff --git a/test/unit/forum_test.rb b/test/unit/forum_test.rb index 913357e..47c7672 100644 --- a/test/unit/forum_test.rb +++ b/test/unit/forum_test.rb @@ -61,7 +61,7 @@ class ForumTest < ActiveSupport::TestCase should 'has posts' do p = create_user('testuser').person p.articles << forum = build(Forum, :profile => p, :name => 'Forum test', :body => 'Forum test') - post = fast_create(TextileArticle, :name => 'First post', :profile_id => p.id, :parent_id => forum.id) + post = fast_create(TextArticle, :name => 'First post', :profile_id => p.id, :parent_id => forum.id) forum.children << post assert_includes forum.posts, post end @@ -76,8 +76,8 @@ class ForumTest < ActiveSupport::TestCase should 'list posts ordered by updated at' do p = create_user('testuser').person forum = fast_create(Forum, :profile_id => p.id, :name => 'Forum test') - newer = create(TextileArticle, :name => 'Post 2', :parent => forum, :profile => p) - older = create(TextileArticle, :name => 'Post 1', :parent => forum, :profile => p) + newer = create(TextArticle, :name => 'Post 2', :parent => forum, :profile => p) + older = create(TextArticle, :name => 'Post 1', :parent => forum, :profile => p) older.updated_at = Time.now.in_time_zone - 1.month older.stubs(:record_timestamps).returns(false) older.save! diff --git a/test/unit/gallery_test.rb b/test/unit/gallery_test.rb index 5c18fde..3d755cd 100644 --- a/test/unit/gallery_test.rb +++ b/test/unit/gallery_test.rb @@ -71,9 +71,9 @@ class GalleryTest < ActiveSupport::TestCase gallery = fast_create(Gallery, :profile_id => c.id) f = fast_create(Gallery, :name => 'gallery', :profile_id => c.id, :parent_id => gallery.id) u = create(UploadedFile, :profile => c, :uploaded_data => fixture_file_upload('/files/rails.png', 'image/png'), :parent => gallery) - older_t = fast_create(TinyMceArticle, :name => 'old news', :profile_id => c.id, :parent_id => gallery.id) - t = fast_create(TinyMceArticle, :name => 'news', :profile_id => c.id, :parent_id => gallery.id) - t_in_f = fast_create(TinyMceArticle, :name => 'news', :profile_id => c.id, :parent_id => f.id) + older_t = fast_create(TextArticle, :name => 'old news', :profile_id => c.id, :parent_id => gallery.id) + t = fast_create(TextArticle, :name => 'news', :profile_id => c.id, :parent_id => gallery.id) + t_in_f = fast_create(TextArticle, :name => 'news', :profile_id => c.id, :parent_id => f.id) assert_equal [t], gallery.news(1) end @@ -81,8 +81,8 @@ class GalleryTest < ActiveSupport::TestCase should 'not return highlighted news when not asked' do c = fast_create(Community) gallery = fast_create(Gallery, :profile_id => c.id) - highlighted_t = fast_create(TinyMceArticle, :name => 'high news', :profile_id => c.id, :highlighted => true, :parent_id => gallery.id) - t = fast_create(TinyMceArticle, :name => 'news', :profile_id => c.id, :parent_id => gallery.id) + highlighted_t = fast_create(TextArticle, :name => 'high news', :profile_id => c.id, :highlighted => true, :parent_id => gallery.id) + t = fast_create(TextArticle, :name => 'news', :profile_id => c.id, :parent_id => gallery.id) assert_equal [t].map(&:slug), gallery.news(2).map(&:slug) end @@ -90,8 +90,8 @@ class GalleryTest < ActiveSupport::TestCase should 'return highlighted news when asked' do c = fast_create(Community) gallery = fast_create(Gallery, :profile_id => c.id) - highlighted_t = fast_create(TinyMceArticle, :name => 'high news', :profile_id => c.id, :highlighted => true, :parent_id => gallery.id) - t = fast_create(TinyMceArticle, :name => 'news', :profile_id => c.id, :parent_id => gallery.id) + highlighted_t = fast_create(TextArticle, :name => 'high news', :profile_id => c.id, :highlighted => true, :parent_id => gallery.id) + t = fast_create(TextArticle, :name => 'news', :profile_id => c.id, :parent_id => gallery.id) assert_equal [highlighted_t].map(&:slug), gallery.news(2, true).map(&:slug) end diff --git a/test/unit/layout_helper_test.rb b/test/unit/layout_helper_test.rb index 6286c1d..4d76908 100644 --- a/test/unit/layout_helper_test.rb +++ b/test/unit/layout_helper_test.rb @@ -21,8 +21,8 @@ class LayoutHelperTest < ActionView::TestCase @plugins = [] expects(:profile).returns(nil).at_least_once expects(:environment).returns(env).at_least_once + expects(:theme_option).with(:jquery_theme).returns(nil) expects(:theme_option).with(:icon_theme).returns(['my-icons']).at_least_once - expects(:jquery_theme).returns('jquery-nice').at_least_once global_css = Rails.root.join "public/designs/themes/#{env.theme}/global.css" File.stubs(:exists?).returns(false) File.expects(:exists?).with(global_css).returns(true).at_least_once diff --git a/test/unit/person_notifier_test.rb b/test/unit/person_notifier_test.rb index c97c506..9c1c6d4 100644 --- a/test/unit/person_notifier_test.rb +++ b/test/unit/person_notifier_test.rb @@ -18,7 +18,7 @@ class PersonNotifierTest < ActiveSupport::TestCase @member.save! @community = fast_create(Community) @community.add_member(@admin) - @article = fast_create(TextileArticle, :name => 'Article test', :profile_id => @community.id, :notify_comments => false) + @article = fast_create(TextArticle, :name => 'Article test', :profile_id => @community.id, :notify_comments => false) Delayed::Job.delete_all ActionMailer::Base.deliveries = [] end diff --git a/test/unit/person_test.rb b/test/unit/person_test.rb index ea94e2f..e55a7e0 100644 --- a/test/unit/person_test.rb +++ b/test/unit/person_test.rb @@ -1261,7 +1261,7 @@ class PersonTest < ActiveSupport::TestCase User.current = another_person.user scrap = create(Scrap, defaults_for_scrap(:sender => another_person, :receiver => person, :content => 'A scrap')) User.current = person.user - article = create(TinyMceArticle, :profile => person, :name => 'An article about free software') + article = create(TextArticle, :profile => person, :name => 'An article about free software') assert_equivalent [scrap,article.activity], person.activities.map { |a| a.activity } end @@ -1275,11 +1275,11 @@ class PersonTest < ActiveSupport::TestCase another_person_scrap = create(Scrap, defaults_for_scrap(:sender => another_person, :receiver => another_person, :content => 'A scrap from another person')) User.current = another_person.user - create(TinyMceArticle, :profile => another_person, :name => 'An article about free software from another person') + create(TextArticle, :profile => another_person, :name => 'An article about free software from another person') another_person_activity = ActionTracker::Record.last User.current = person.user - create(TinyMceArticle, :profile => person, :name => 'An article about free software') + create(TextArticle, :profile => person, :name => 'An article about free software') person_activity = ActionTracker::Record.last assert_equivalent [person_scrap,person_activity], person.activities.map { |a| a.activity } diff --git a/test/unit/profile_test.rb b/test/unit/profile_test.rb index d71d4c7..e684997 100644 --- a/test/unit/profile_test.rb +++ b/test/unit/profile_test.rb @@ -2113,7 +2113,7 @@ class ProfileTest < ActiveSupport::TestCase should 'not copy template welcome_page' do template = fast_create(Person, :is_template => true) - welcome_page = fast_create(TinyMceArticle, :slug => 'welcome-page', :profile_id => template.id) + welcome_page = fast_create(TextArticle, :slug => 'welcome-page', :profile_id => template.id) refute template.copy_article?(welcome_page) end @@ -2124,7 +2124,7 @@ class ProfileTest < ActiveSupport::TestCase should 'return nil on welcome_page_content if content is not published' do template = fast_create(Profile, :is_template => true) - welcome_page = fast_create(TinyMceArticle, :slug => 'welcome-page', :profile_id => template.id, :body => 'Template welcome page', :published => false) + welcome_page = fast_create(TextArticle, :slug => 'welcome-page', :profile_id => template.id, :body => 'Template welcome page', :published => false) template.welcome_page = welcome_page template.save! assert_nil template.welcome_page_content @@ -2133,7 +2133,7 @@ class ProfileTest < ActiveSupport::TestCase should 'return template welcome page content on welcome_page_content if content is published' do template = fast_create(Profile, :is_template => true) body = 'Template welcome page' - welcome_page = fast_create(TinyMceArticle, :slug => 'welcome-page', :profile_id => template.id, :body => body, :published => true) + welcome_page = fast_create(TextArticle, :slug => 'welcome-page', :profile_id => template.id, :body => body, :published => true) template.welcome_page = welcome_page template.save! assert_equal body, template.welcome_page_content diff --git a/test/unit/raw_html_article_test.rb b/test/unit/raw_html_article_test.rb index 2748849..7ac0998 100644 --- a/test/unit/raw_html_article_test.rb +++ b/test/unit/raw_html_article_test.rb @@ -7,7 +7,8 @@ class RawHTMLArticleTest < ActiveSupport::TestCase end should 'not filter HTML' do - article = RawHTMLArticle.create!( + article = TextArticle.create!( + :editor => Article::Editor::RAW_HTML, :name => 'Raw HTML', :body => 'HTML!
', :profile => @profile diff --git a/test/unit/rss_feed_test.rb b/test/unit/rss_feed_test.rb index a0df077..5168f5b 100644 --- a/test/unit/rss_feed_test.rb +++ b/test/unit/rss_feed_test.rb @@ -204,7 +204,7 @@ class RssFeedTest < ActiveSupport::TestCase end should 'display the referenced body of a article published' do - article = fast_create(TextileArticle, :body => 'This is the content of the Sample Article.', :profile_id => fast_create(Person).id) + article = fast_create(TextArticle, :body => 'This is the content of the Sample Article.', :profile_id => fast_create(Person).id) profile = fast_create(Profile) blog = fast_create(Blog, :profile_id => profile.id) a = create(ApproveArticle, :name => 'test name', :article => article, :target => profile, :requestor => fast_create(Person)) diff --git a/test/unit/suggest_article_test.rb b/test/unit/suggest_article_test.rb index 6572563..2e7fb47 100644 --- a/test/unit/suggest_article_test.rb +++ b/test/unit/suggest_article_test.rb @@ -54,9 +54,9 @@ class SuggestArticleTest < ActiveSupport::TestCase abstract = 'some abstract' t.article = {:name => name, :body => body, :abstract => abstract} t.target = @profile - count = TinyMceArticle.count + count = TextArticle.count t.perform - assert_equal count + 1, TinyMceArticle.count + assert_equal count + 1, TextArticle.count end should 'fill source name and URL into created article' do @@ -64,7 +64,7 @@ class SuggestArticleTest < ActiveSupport::TestCase t.article.merge!({:source_name => 'GNU project', :source => 'http://www.gnu.org/'}) t.perform - article = TinyMceArticle.last + article = TextArticle.last assert_equal 'GNU project', article.source_name assert_equal 'http://www.gnu.org/', article.source end @@ -81,7 +81,7 @@ class SuggestArticleTest < ActiveSupport::TestCase t.article[:highlighted] = true t.perform - article = TinyMceArticle.where(name: t.article_name).last # just to be sure + article = TextArticle.where(name: t.article_name).last # just to be sure assert article.highlighted end @@ -89,7 +89,7 @@ class SuggestArticleTest < ActiveSupport::TestCase t = build(SuggestArticle, :target => @profile) t.perform - article = TinyMceArticle.where(name: t.article_name).last + article = TextArticle.where(name: t.article_name).last assert_equal false, article.highlighted end @@ -110,7 +110,7 @@ class SuggestArticleTest < ActiveSupport::TestCase t.name = 'some name' t.perform - article = TinyMceArticle.last + article = TextArticle.last assert_equal 'some name', article.author_name end @@ -239,12 +239,12 @@ class SuggestArticleTest < ActiveSupport::TestCase should 'fallback to tinymce when type parameter is invalid' do t = SuggestArticle.new t.article = {:name => 'name', :body => 'body', :type => 'Comment'} - t.article_type == TinyMceArticle + t.article_type == TextArticle end should 'fallback to tinymce when type parameter is blank' do t = SuggestArticle.new t.article = {:name => 'name', :body => 'body', :type => ''} - t.article_type == TinyMceArticle + t.article_type == TextArticle end end diff --git a/test/unit/text_article_test.rb b/test/unit/text_article_test.rb index d397b2b..ef3fd90 100644 --- a/test/unit/text_article_test.rb +++ b/test/unit/text_article_test.rb @@ -8,12 +8,6 @@ class TextArticleTest < ActiveSupport::TestCase assert_kind_of Article, TextArticle.new end - should 'found TextileArticle by TextArticle class' do - person = create_user('testuser').person - article = fast_create(TextileArticle, :name => 'textile article test', :profile_id => person.id) - assert_includes TextArticle.all, article - end - should 'be translatable' do assert_kind_of TranslatableContent, TextArticle.new end @@ -119,4 +113,22 @@ class TextArticleTest < ActiveSupport::TestCase assert post.display_preview? end + should 'provide HTML version for textile editor' do + profile = create_user('testinguser').person + a = fast_create(TextArticle, :body => '*my text*', :profile_id => profile.id, :editor => Article::Editor::TEXTILE) + assert_equal '

my text

', a.to_html + end + + should 'provide HTML version for body lead textile editor' do + profile = create_user('testinguser').person + a = fast_create(TextArticle, :body => '*my text*', :profile_id => profile.id, :editor => Article::Editor::TEXTILE) + assert_equal '

my text

', a.lead + end + + should 'provide HTML version for abstract lead textile editor' do + profile = create_user('testinguser').person + a = fast_create(TextArticle, :abstract => '*my text*', :profile_id => profile.id, :editor => Article::Editor::TEXTILE) + assert_equal '

my text

', a.lead + end + end diff --git a/test/unit/textile_article_test.rb b/test/unit/textile_article_test.rb index 01a949d..e9442a3 100644 --- a/test/unit/textile_article_test.rb +++ b/test/unit/textile_article_test.rb @@ -1,6 +1,6 @@ require_relative "../test_helper" -class TextileArticleTest < ActiveSupport::TestCase +class TextArticleTest < ActiveSupport::TestCase def setup @user = User.current = create_user 'testing' @@ -8,20 +8,12 @@ class TextileArticleTest < ActiveSupport::TestCase end attr_reader :profile - should 'provide a proper short description' do - assert_kind_of String, TextileArticle.short_description - end - - should 'provide a proper description' do - assert_kind_of String, TextileArticle.description - end - should 'convert Textile to HTML' do - assert_equal '

my text

', build(TextileArticle, body: '*my text*').to_html + assert_equal '

my text

', build(TextArticle, body: '*my text*', :editor => Article::Editor::TEXTILE).to_html end should 'accept empty body' do - a = TextileArticle.new + a = TextArticle.new a.expects(:body).returns(nil) assert_nothing_raised do assert_equal '', a.to_html @@ -29,27 +21,27 @@ class TextileArticleTest < ActiveSupport::TestCase end should 'notifiable be true' do - a = fast_create(TextileArticle) + a = fast_create(TextArticle) assert a.notifiable? end should 'notify activity on create' do ActionTracker::Record.delete_all - create TextileArticle, name: 'test', profile_id: profile.id, published: true + create TextArticle, name: 'test', profile_id: profile.id, published: true assert_equal 1, ActionTracker::Record.count end should 'not group trackers activity of article\'s creation' do assert_difference 'ActionTracker::Record.count', 3 do - create TextileArticle, name: 'bar', profile_id: profile.id, published: true - create TextileArticle, name: 'another bar', profile_id: profile.id, published: true - create TextileArticle, name: 'another bar 2', profile_id: profile.id, published: true + create TextArticle, name: 'bar', profile_id: profile.id, published: true + create TextArticle, name: 'another bar', profile_id: profile.id, published: true + create TextArticle, name: 'another bar 2', profile_id: profile.id, published: true end end should 'not update activity on update of an article' do ActionTracker::Record.delete_all - article = create(TextileArticle, profile_id: profile.id) + article = create(TextArticle, profile_id: profile.id) time = article.activity.updated_at Time.stubs(:now).returns(time + 1.day) assert_no_difference 'ActionTracker::Record.count' do @@ -61,8 +53,8 @@ class TextileArticleTest < ActiveSupport::TestCase should 'not create trackers activity when updating articles' do ActionTracker::Record.delete_all - a1 = create TextileArticle, name: 'bar', profile_id: profile.id, published: true - a2 = create TextileArticle, name: 'another bar', profile_id: profile.id, published: true + a1 = create TextArticle, name: 'bar', profile_id: profile.id, published: true + a2 = create TextArticle, name: 'another bar', profile_id: profile.id, published: true assert_no_difference 'ActionTracker::Record.count' do a1.name = 'foo';a1.save! a2.name = 'another foo';a2.save! @@ -71,7 +63,7 @@ class TextileArticleTest < ActiveSupport::TestCase should 'remove activity after destroying article' do ActionTracker::Record.delete_all - a = create TextileArticle, name: 'bar', profile_id: profile.id, published: true + a = create TextArticle, name: 'bar', profile_id: profile.id, published: true assert_difference 'ActionTracker::Record.count', -1 do a.destroy end @@ -79,8 +71,8 @@ class TextileArticleTest < ActiveSupport::TestCase should 'remove activity after article is destroyed' do ActionTracker::Record.delete_all - a1 = create TextileArticle, name: 'bar', profile_id: profile.id, published: true - a2 = create TextileArticle, name: 'another bar', profile_id: profile.id, published: true + a1 = create TextArticle, name: 'bar', profile_id: profile.id, published: true + a2 = create TextArticle, name: 'another bar', profile_id: profile.id, published: true assert_equal 2, ActionTracker::Record.count assert_difference 'ActionTracker::Record.count', -2 do a1.destroy @@ -94,20 +86,20 @@ class TextileArticleTest < ActiveSupport::TestCase p1 = Person.first community.add_member(p1) assert p1.is_member_of?(community) - article = create TextileArticle, name: 'test', profile_id: community.id + article = create TextArticle, name: 'test', profile_id: community.id assert_equal article, ActionTracker::Record.last.target end should "the tracker action target be defined as the article on articles'creation in profile" do ActionTracker::Record.delete_all person = Person.first - article = create TextileArticle, name: 'test', profile_id: person.id + article = create TextArticle, name: 'test', profile_id: person.id assert_equal article, ActionTracker::Record.last.target end should 'not notify activity if the article is not advertise' do ActionTracker::Record.delete_all - a = create TextileArticle, name: 'bar', profile_id: profile.id, published: true, advertise: false + a = create TextArticle, name: 'bar', profile_id: profile.id, published: true, advertise: false assert_equal true, a.published? assert_equal true, a.notifiable? assert_equal false, a.image? @@ -116,11 +108,11 @@ class TextileArticleTest < ActiveSupport::TestCase end should "have defined the is_trackable method defined" do - assert TextileArticle.method_defined?(:is_trackable?) + assert TextArticle.method_defined?(:is_trackable?) end should "the common trackable conditions return the correct value" do - a = build(TextileArticle, profile: profile) + a = build(TextArticle, profile: profile) a.published = a.advertise = true assert_equal true, a.published? assert_equal true, a.notifiable? @@ -174,18 +166,18 @@ class TextileArticleTest < ActiveSupport::TestCase end should 'have can_display_media_panel with default true' do - a = TextileArticle.new + a = TextArticle.new assert a.can_display_media_panel? end should 'have can_display_blocks with default false' do - assert !TextileArticle.can_display_blocks? + assert !TextArticle.can_display_blocks? end protected def build_article(input = nil, options = {}) - article = build(TextileArticle, {body: input}.merge(options)) + article = build(TextArticle, {body: input, :editor => Article::Editor::TEXTILE}.merge(options)) article.valid? # trigger the xss terminate thingy article end diff --git a/test/unit/tiny_mce_article_test.rb b/test/unit/tiny_mce_article_test.rb index e924d64..024fa59 100644 --- a/test/unit/tiny_mce_article_test.rb +++ b/test/unit/tiny_mce_article_test.rb @@ -10,61 +10,48 @@ class TinyMceArticleTest < ActiveSupport::TestCase end attr_reader :profile - # this test can be removed when we get real tests for TinyMceArticle - should 'be an article' do - assert_kind_of TextArticle, TinyMceArticle.new - end - - should 'define description' do - assert_kind_of String, TinyMceArticle.description - end - - should 'define short description' do - assert_kind_of String, TinyMceArticle.short_description - end - should 'not sanitize target attribute' do - article = create(TinyMceArticle, :name => 'open link in new window', :body => "open link in new window", :profile => profile) + article = create(TextArticle, :name => 'open link in new window', :body => "open link in new window", :profile => profile) assert_tag_in_string article.body, :tag => 'a', :attributes => {:target => '_blank'} end should 'not translate & to amp; over times' do - article = create(TinyMceArticle, :name => 'link', :body => "link", :profile => profile) + article = create(TextArticle, :name => 'link', :body => "link", :profile => profile) assert article.save assert_no_match(/&amp;/, article.body) assert_match(/&/, article.body) end should 'not escape comments from tiny mce article body' do - article = create(TinyMceArticle, :profile => profile, :name => 'article', :abstract => 'abstract', :body => "the article ...") + article = create(TextArticle, :profile => profile, :name => 'article', :abstract => 'abstract', :body => "the article ...") assert_equal "the article ...", article.body end should 'convert entities characters to UTF-8 instead of ISO-8859-1' do - article = create(TinyMceArticle, :profile => profile, :name => 'teste ' + Time.now.to_s, :body => 'link') + article = create(TextArticle, :profile => profile, :name => 'teste ' + Time.now.to_s, :body => 'link') assert(article.body.is_utf8?, "%s expected to be valid UTF-8 content" % article.body.inspect) end should 'remove iframe if it is not from a trusted site' do - article = create(TinyMceArticle, :profile => profile, :name => 'article', :abstract => 'abstract', :body => "") + article = create(TextArticle, :profile => profile, :name => 'article', :abstract => 'abstract', :body => "") assert_equal "", article.body end should 'not mess with ") + article = create(TextArticle, :profile => profile, :name => 'article', :abstract => 'abstract', :body => "") assert_tag_in_string article.body, :tag => 'iframe', :attributes => { :src => "http://itheora.org/demo/index.php?v=example.ogv"} end should 'allow iframe if it is from stream.softwarelivre.org by default' do assert_includes Environment.default.trusted_sites_for_iframe, 'stream.softwarelivre.org' - article = create(TinyMceArticle, :profile => profile, :name => 'article', :abstract => 'abstract', :body => "") + article = create(TextArticle, :profile => profile, :name => 'article', :abstract => 'abstract', :body => "") assert_tag_in_string article.body, :tag => 'iframe', :attributes => { :src => "http://stream.softwarelivre.org/fisl10/sites/default/files/videos.ogg"} end should 'allow iframe if it is from tv.softwarelivre.org by default' do assert_includes Environment.default.trusted_sites_for_iframe, 'tv.softwarelivre.org' - article = create(TinyMceArticle, :profile => profile, :name => 'article', :abstract => 'abstract', :body => "") + article = create(TextArticle, :profile => profile, :name => 'article', :abstract => 'abstract', :body => "") assert_tag_in_string article.body, :tag => 'iframe', :attributes => { :src => "http://tv.softwarelivre.org/embed/1170", :width => "482", :height => "406", :align => "right", :frameborder => "0", :scrolling => "no"} end @@ -73,12 +60,12 @@ class TinyMceArticleTest < ActiveSupport::TestCase env.trusted_sites_for_iframe = ['avideosite.com'] env.save assert_includes Environment.default.trusted_sites_for_iframe, 'avideosite.com' - article = create(TinyMceArticle, :profile => profile, :name => 'article', :abstract => 'abstract', :body => "") + article = create(TextArticle, :profile => profile, :name => 'article', :abstract => 'abstract', :body => "") assert_tag_in_string article.body, :tag => 'iframe', :attributes => { :src => "http://avideosite.com/videos.ogg"} end should 'remove only the iframe from untrusted site' do - article = create(TinyMceArticle, :profile => profile, :name => 'article', :abstract => 'abstract', :body => "") + article = create(TextArticle, :profile => profile, :name => 'article', :abstract => 'abstract', :body => "") assert_tag_in_string article.body, :tag => 'iframe', :attributes => { :src => "http://stream.softwarelivre.org/videos.ogg"} assert_no_tag_in_string article.body, :tag => 'iframe', :attributes => { :src => "http://untrusted_site.com/videos.ogg"} end @@ -86,12 +73,12 @@ class TinyMceArticleTest < ActiveSupport::TestCase should 'consider first src if there is 2 or more src' do assert_includes Environment.default.trusted_sites_for_iframe, 'itheora.org' - article = create(TinyMceArticle, :profile => profile, :name => 'article', :abstract => 'abstract', :body => "") + article = create(TextArticle, :profile => profile, :name => 'article', :abstract => 'abstract', :body => "") assert_tag_in_string article.body, :tag => 'iframe', :attributes => { :src => "http://itheora.org/videos.ogg"} end should 'not sanitize html comments' do - article = TinyMceArticle.new + article = TextArticle.new article.body = '

Wellformed html code

' article.valid? @@ -99,38 +86,38 @@ class TinyMceArticleTest < ActiveSupport::TestCase end should 'not allow XSS on name' do - article = create(TinyMceArticle, :name => 'title with ', :profile => profile) + article = create(TextArticle, :name => 'title with ', :profile => profile) assert_no_match /script/, article.name end should 'not allow XSS on abstract' do - article = create(TinyMceArticle, :name => "test 123", :abstract => 'abstract with ', :profile => profile) + article = create(TextArticle, :name => "test 123", :abstract => 'abstract with ', :profile => profile) assert_no_match /script/, article.abstract end should 'notifiable be true' do - a = fast_create(TinyMceArticle) + a = fast_create(TextArticle) assert a.notifiable? end should 'notify activity on create' do ActionTracker::Record.delete_all - create TinyMceArticle, name: 'test', profile_id: profile.id, published: true + create TextArticle, name: 'test', profile_id: profile.id, published: true assert_equal 1, ActionTracker::Record.count end should 'not group trackers activity of article\'s creation' do ActionTracker::Record.delete_all - create TinyMceArticle, name: 'bar', profile_id: profile.id, published: true - create TinyMceArticle, name: 'another bar', profile_id: profile.id, published: true + create TextArticle, name: 'bar', profile_id: profile.id, published: true + create TextArticle, name: 'another bar', profile_id: profile.id, published: true assert_equal 2, ActionTracker::Record.count - create TinyMceArticle, name: 'another bar 2', profile_id: profile.id, published: true + create TextArticle, name: 'another bar 2', profile_id: profile.id, published: true assert_equal 3, ActionTracker::Record.count end should 'not update activity on update of an article' do ActionTracker::Record.delete_all - article = create TinyMceArticle, profile_id: profile.id + article = create TextArticle, profile_id: profile.id time = article.activity.updated_at Time.stubs(:now).returns(time + 1.day) assert_no_difference 'ActionTracker::Record.count' do @@ -142,8 +129,8 @@ class TinyMceArticleTest < ActiveSupport::TestCase should 'not create trackers activity when updating articles' do ActionTracker::Record.delete_all - a1 = create TinyMceArticle, name: 'bar', profile_id: profile.id, published: true - a2 = create TinyMceArticle, name: 'another bar', profile_id: profile.id, published: true + a1 = create TextArticle, name: 'bar', profile_id: profile.id, published: true + a2 = create TextArticle, name: 'another bar', profile_id: profile.id, published: true assert_no_difference 'ActionTracker::Record.count' do a1.name = 'foo';a1.save! a2.name = 'another foo';a2.save! @@ -152,8 +139,8 @@ class TinyMceArticleTest < ActiveSupport::TestCase should 'remove activity when an article is destroyed' do ActionTracker::Record.delete_all - a1 = create TinyMceArticle, name: 'bar', profile_id: profile.id, published: true - a2 = create TinyMceArticle, name: 'another bar', profile_id: profile.id, published: true + a1 = create TextArticle, name: 'bar', profile_id: profile.id, published: true + a2 = create TextArticle, name: 'another bar', profile_id: profile.id, published: true assert_difference 'ActionTracker::Record.count', -2 do a1.destroy a2.destroy @@ -165,19 +152,19 @@ class TinyMceArticleTest < ActiveSupport::TestCase community = fast_create(Community) community.add_member profile assert profile.is_member_of?(community) - article = create TinyMceArticle, name: 'test', profile_id: community.id + article = create TextArticle, name: 'test', profile_id: community.id assert_equal article, ActionTracker::Record.last.target end should "the tracker action target be defined as the article on articles'creation in profile" do ActionTracker::Record.delete_all - article = create TinyMceArticle, name: 'test', profile_id: profile.id + article = create TextArticle, name: 'test', profile_id: profile.id assert_equal article, ActionTracker::Record.last.target end should 'not notify activity if the article is not advertise' do ActionTracker::Record.delete_all - a = create TinyMceArticle, name: 'bar', profile_id: profile.id, published: true, advertise: false + a = create TextArticle, name: 'bar', profile_id: profile.id, published: true, advertise: false assert_equal true, a.published? assert_equal true, a.notifiable? assert_equal false, a.image? @@ -186,11 +173,11 @@ class TinyMceArticleTest < ActiveSupport::TestCase end should "have defined the is_trackable method defined" do - assert TinyMceArticle.method_defined?(:is_trackable?) + assert TextArticle.method_defined?(:is_trackable?) end should "the common trackable conditions return the correct value" do - a = build(TinyMceArticle, :profile => profile) + a = build(TextArticle, :profile => profile) a.published = a.advertise = true assert_equal true, a.published? assert_equal true, a.notifiable? @@ -207,24 +194,20 @@ class TinyMceArticleTest < ActiveSupport::TestCase assert_equal false, a.is_trackable? end - should 'tiny mce editor is enabled' do - assert TinyMceArticle.new.tiny_mce? - end - should 'not sanitize html5 audio tag on body' do - article = TinyMceArticle.create!(:name => 'html5 audio', :body => "Audio: ", :profile => profile) + article = TextArticle.create!(:name => 'html5 audio', :body => "Audio: ", :profile => profile) assert_tag_in_string article.body, :tag => 'audio', :attributes => {:controls => 'controls'} assert_tag_in_string article.body, :tag => 'source', :attributes => {:src => 'http://example.ogg', :type => 'audio/ogg'} end should 'not sanitize html5 video tag on body' do - article = TinyMceArticle.create!(:name => 'html5 video', :body => "Video: ", :profile => profile) + article = TextArticle.create!(:name => 'html5 video', :body => "Video: ", :profile => profile) assert_tag_in_string article.body, :tag => 'video', :attributes => {:controls => 'controls', :autoplay => 'autoplay'} assert_tag_in_string article.body, :tag => 'source', :attributes => {:src => 'http://example.ogv', :type => 'video/ogg'} end should 'not sanitize colspan and rowspan attributes' do - article = TinyMceArticle.create!(:name => 'table with colspan and rowspan', + article = TextArticle.create!(:name => 'table with colspan and rowspan', :body => "
", :profile => profile ) @@ -233,11 +216,11 @@ class TinyMceArticleTest < ActiveSupport::TestCase end should 'have can_display_media_panel with default true' do - a = TinyMceArticle.new + a = TextArticle.new assert a.can_display_media_panel? end should 'have can_display_blocks with default false' do - assert !TinyMceArticle.can_display_blocks? + assert !TextArticle.can_display_blocks? end end diff --git a/vendor/plugins/xss_terminate/lib/xss_terminate.rb b/vendor/plugins/xss_terminate/lib/xss_terminate.rb index 6356cd6..9d45663 100644 --- a/vendor/plugins/xss_terminate/lib/xss_terminate.rb +++ b/vendor/plugins/xss_terminate/lib/xss_terminate.rb @@ -27,11 +27,15 @@ module XssTerminate before_save filter_with end class_attribute "xss_terminate_#{options[:with]}_options".to_sym + + self.send("xss_terminate_#{options[:with]}_options=".to_sym, { :except => (options[:except] || []), + :if => (options[:if] || true), :only => (options[:only] || options[:sanitize] || []) - }) + }) if include XssTerminate::InstanceMethods + end end @@ -72,6 +76,9 @@ module XssTerminate unless except.empty? only.delete_if{ |i| except.include?( i.to_sym ) } end + if_condition = eval "xss_terminate_#{with}_options[:if]" + only = [] if !if_condition.nil? && if_condition.respond_to?(:call) && !if_condition.call(self) + return only, columns_serialized end -- libgit2 0.21.2