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 @@
<%= 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| %>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 networksContent 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.
Content to be displayed.
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 = 'NoosferoFooBar
FooBar