Commit 2b2ce9f85416fb7b46cbce2cdbc20c7a51655bfa

Authored by Fabio Teixeira
1 parent f1279433

Fix cloned article body bug

app/controllers/my_profile/cms_controller.rb
... ... @@ -118,10 +118,7 @@ class CmsController < MyProfileController
118 118 end
119 119 end
120 120  
121   - unless @article.kind_of?(RssFeed)
122   - @escaped_body = CGI::escapeHTML(@article.body || '')
123   - @escaped_abstract = CGI::escapeHTML(@article.abstract || '')
124   - end
  121 + escape_fields @article
125 122 end
126 123  
127 124 def new
... ... @@ -192,6 +189,8 @@ class CmsController < MyProfileController
192 189 end
193 190 end
194 191  
  192 + escape_fields @article
  193 +
195 194 render :action => 'edit'
196 195 end
197 196  
... ... @@ -541,4 +540,10 @@ class CmsController < MyProfileController
541 540 end
542 541 end
543 542  
  543 + def escape_fields article
  544 + unless article.kind_of?(RssFeed)
  545 + @escaped_body = CGI::escapeHTML(article.body || '')
  546 + @escaped_abstract = CGI::escapeHTML(article.abstract || '')
  547 + end
  548 + end
544 549 end
... ...
test/functional/cms_controller_test.rb
... ... @@ -1839,14 +1839,6 @@ class CmsControllerTest < ActionController::TestCase
1839 1839 assert_equal 'first version', assigns(:article).name
1840 1840 end
1841 1841  
1842   - should 'clone article with its content' do
1843   - article = profile.articles.create(:name => 'first version')
1844   -
1845   - get :new, :profile => profile.identifier, :id => article.id, :clone => true, :type => 'TinyMceArticle'
1846   -
1847   - assert_match article.name, @response.body
1848   - end
1849   -
1850 1842 should 'save article with content from older version' do
1851 1843 article = profile.articles.create(:name => 'first version')
1852 1844 article.name = 'second version'; article.save
... ... @@ -1918,6 +1910,10 @@ class CmsControllerTest < ActionController::TestCase
1918 1910  
1919 1911 assert_equal main_article.parent_id, cloned_main_article.parent_id
1920 1912  
  1913 + get :new, :profile => profile.identifier, :id => cloned_main_article.id,
  1914 + :clone => true, :type => 'TinyMceArticle'
  1915 +
  1916 + assert_match main_article.body, @response.body
1921 1917 end
1922 1918  
1923 1919 protected
... ...