Commit 41536a311092210f90425418d70dadd5e2fb1373
Exists in
staging
and in
4 other branches
Merge branch 'master' into staging
Showing
9 changed files
with
75 additions
and
22 deletions
Show diff stats
app/controllers/my_profile/cms_controller.rb
... | ... | @@ -111,10 +111,7 @@ class CmsController < MyProfileController |
111 | 111 | end |
112 | 112 | end |
113 | 113 | |
114 | - unless @article.kind_of?(RssFeed) | |
115 | - @escaped_body = CGI::escapeHTML(@article.body || '') | |
116 | - @escaped_abstract = CGI::escapeHTML(@article.abstract || '') | |
117 | - end | |
114 | + escape_fields @article | |
118 | 115 | end |
119 | 116 | |
120 | 117 | def new |
... | ... | @@ -185,6 +182,8 @@ class CmsController < MyProfileController |
185 | 182 | end |
186 | 183 | end |
187 | 184 | |
185 | + escape_fields @article | |
186 | + | |
188 | 187 | render :action => 'edit' |
189 | 188 | end |
190 | 189 | |
... | ... | @@ -535,4 +534,10 @@ class CmsController < MyProfileController |
535 | 534 | end |
536 | 535 | end |
537 | 536 | |
537 | + def escape_fields article | |
538 | + unless article.kind_of?(RssFeed) | |
539 | + @escaped_body = CGI::escapeHTML(article.body || '') | |
540 | + @escaped_abstract = CGI::escapeHTML(article.abstract || '') | |
541 | + end | |
542 | + end | |
538 | 543 | end | ... | ... |
app/helpers/article_helper.rb
... | ... | @@ -88,7 +88,7 @@ module ArticleHelper |
88 | 88 | content_tag( 'small', _('Who will be able to create new topics on this forum?')) + |
89 | 89 | content_tag('div', '', slider_options) + |
90 | 90 | hidden_field_tag('article[topic_creation]', article.topic_creation) + |
91 | - javascript_include_tag('topic-creation-config') | |
91 | + javascript_include_tag("#{Noosfero.root}/assets/topic-creation-config.js") | |
92 | 92 | end |
93 | 93 | |
94 | 94 | def privacity_exceptions(article, tokenized_children) | ... | ... |
app/models/scrap.rb
... | ... | @@ -22,11 +22,11 @@ class Scrap < ActiveRecord::Base |
22 | 22 | |
23 | 23 | scope :not_replies, :conditions => {:scrap_id => nil} |
24 | 24 | |
25 | - track_actions :leave_scrap, :after_create, :keep_params => ['sender.name', 'content', 'receiver.name', 'receiver.url'], :if => Proc.new{|s| s.sender != s.receiver && s.sender != s.top_root.receiver}, :custom_target => :action_tracker_target | |
25 | + track_actions :leave_scrap, :after_create, :keep_params => ['sender.name', 'content', 'receiver.name', 'receiver.url'], :if => Proc.new{|s| s.sender != s.receiver && s.sender != s.top_root.receiver}, :custom_target => :action_tracker_target, :custom_user => :sender | |
26 | 26 | |
27 | - track_actions :leave_scrap_to_self, :after_create, :keep_params => ['sender.name', 'content'], :if => Proc.new{|s| s.sender == s.receiver} | |
27 | + track_actions :leave_scrap_to_self, :after_create, :keep_params => ['sender.name', 'content'], :if => Proc.new{|s| s.sender == s.receiver}, :custom_user => :sender | |
28 | 28 | |
29 | - track_actions :reply_scrap_on_self, :after_create, :keep_params => ['sender.name', 'content'], :if => Proc.new{|s| s.sender != s.receiver && s.sender == s.top_root.receiver} | |
29 | + track_actions :reply_scrap_on_self, :after_create, :keep_params => ['sender.name', 'content'], :if => Proc.new{|s| s.sender != s.receiver && s.sender == s.top_root.receiver}, :custom_user => :sender | |
30 | 30 | |
31 | 31 | after_create :send_notification |
32 | 32 | ... | ... |
app/views/cms/edit.html.erb
app/views/content_viewer/_article_toolbar.html.erb
... | ... | @@ -29,10 +29,10 @@ |
29 | 29 | <%= expirable_button @page, :locale, content, url %> |
30 | 30 | <% end %> |
31 | 31 | |
32 | - <%= modal_button(:new, label_for_new_article(@page), profile.admin_url.merge(:controller => 'cms', :action => 'new', :parent_id => (@page.folder? ? @page : (@page.parent.nil? ? nil : @page.parent)))) unless remove_content_button(:new, @page) %> | |
32 | + <%= modal_button(:new, label_for_new_article(@page), profile.admin_url.merge(:controller => 'cms', :action => 'new', :parent_id => (@page.folder? ? @page : @page.parent))) unless remove_content_button(:new, @page) %> | |
33 | 33 | |
34 | 34 | <% content = content_tag('span', label_for_clone_article(@page)) %> |
35 | - <% url = profile.admin_url.merge({ :controller => 'cms', :action => 'new', :id => @page.id, :clone => true, :type => @page.class }) %> | |
35 | + <% url = profile.admin_url.merge({ :controller => 'cms', :action => 'new', :id => @page.id, :clone => true, :parent_id => (@page.folder? ? @page : @page.parent), :type => @page.class}) %> | |
36 | 36 | <%= expirable_button @page, :clone, content, url %> |
37 | 37 | <% end %> |
38 | 38 | ... | ... |
test/functional/cms_controller_test.rb
... | ... | @@ -560,8 +560,17 @@ class CmsControllerTest < ActionController::TestCase |
560 | 560 | end |
561 | 561 | |
562 | 562 | should 'keep informed parent_id' do |
563 | + fast_create(:blog, :name=>"Sample blog", :profile_id=>@profile.id) | |
564 | + | |
565 | + profile.home_page = profile.blogs.find_by_name "Sample blog" | |
566 | + profile.save! | |
567 | + | |
563 | 568 | get :new, :profile => @profile.identifier, :parent_id => profile.home_page.id, :type => 'TextileArticle' |
564 | - assert_tag :tag => 'input', :attributes => { :name => 'parent_id', :value => profile.home_page.id } | |
569 | + assert_tag :tag => 'select', | |
570 | + :attributes => { :id => 'article_parent_id' }, | |
571 | + :child => { | |
572 | + :tag => "option", :attributes => {:value => profile.home_page.id, :selected => "selected"} | |
573 | + } | |
565 | 574 | end |
566 | 575 | |
567 | 576 | should 'list folders before others' do |
... | ... | @@ -1839,14 +1848,6 @@ class CmsControllerTest < ActionController::TestCase |
1839 | 1848 | assert_equal 'first version', assigns(:article).name |
1840 | 1849 | end |
1841 | 1850 | |
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 | 1851 | should 'save article with content from older version' do |
1851 | 1852 | article = profile.articles.create(:name => 'first version') |
1852 | 1853 | article.name = 'second version'; article.save |
... | ... | @@ -1897,6 +1898,33 @@ class CmsControllerTest < ActionController::TestCase |
1897 | 1898 | assert_equal '[{"label":"linux","value":"linux"}]', @response.body |
1898 | 1899 | end |
1899 | 1900 | |
1901 | + should 'clone an article with its parent' do | |
1902 | + login_as(profile.identifier) | |
1903 | + | |
1904 | + f = Folder.new(:name => 'f') | |
1905 | + profile.articles << f | |
1906 | + f.save! | |
1907 | + | |
1908 | + post :new, :type => 'TinyMceArticle', :profile => profile.identifier, :parent_id => f.id, | |
1909 | + :article => { :name => 'Main Article', :body => 'some content' } | |
1910 | + | |
1911 | + main_article = profile.articles.find_by_name('Main Article') | |
1912 | + assert_not_nil main_article | |
1913 | + | |
1914 | + post :new, :type => 'TinyMceArticle', :profile => profile.identifier, :parent_id => f.id, | |
1915 | + :id => main_article.id, :clone => true | |
1916 | + | |
1917 | + cloned_main_article = profile.articles.find_by_name('Main Article') | |
1918 | + assert_not_nil cloned_main_article | |
1919 | + | |
1920 | + assert_equal main_article.parent_id, cloned_main_article.parent_id | |
1921 | + | |
1922 | + get :new, :profile => profile.identifier, :id => cloned_main_article.id, | |
1923 | + :clone => true, :type => 'TinyMceArticle' | |
1924 | + | |
1925 | + assert_match main_article.body, @response.body | |
1926 | + end | |
1927 | + | |
1900 | 1928 | protected |
1901 | 1929 | |
1902 | 1930 | # FIXME this is to avoid adding an extra dependency for a proper JSON parser. | ... | ... |
test/functional/profile_controller_test.rb
... | ... | @@ -943,7 +943,7 @@ class ProfileControllerTest < ActionController::TestCase |
943 | 943 | @controller.stubs(:current_user).returns(user) |
944 | 944 | Person.any_instance.stubs(:follows?).returns(true) |
945 | 945 | get :index, :profile => p1.identifier |
946 | - assert_equal [s3,s2], assigns(:activities).map(&:activity) | |
946 | + assert_equal [s3,s2], assigns(:activities).map(&:activity).select {|a| a.kind_of?(Scrap)} | |
947 | 947 | end |
948 | 948 | |
949 | 949 | should 'the activities be the received scraps in community profile' do | ... | ... |
... | ... | @@ -0,0 +1,21 @@ |
1 | +require_relative "../test_helper" | |
2 | + | |
3 | +class CloneArticleTest < ActiveSupport::TestCase | |
4 | + | |
5 | + should 'cloned article have its source attributes' do | |
6 | + community = fast_create(Community) | |
7 | + folder = fast_create(Folder, :profile_id => community.id) | |
8 | + article = fast_create(TinyMceArticle, :profile_id => community.id) | |
9 | + article.parent_id = folder.id | |
10 | + article.save! | |
11 | + | |
12 | + article.reload | |
13 | + cloned_article = article.copy_without_save({:parent_id => article.parent_id}) | |
14 | + | |
15 | + assert_equal folder.id, cloned_article.parent_id | |
16 | + assert_equal article.body , cloned_article.body | |
17 | + assert_equal article.name, cloned_article.name | |
18 | + assert_equal article.setting, cloned_article.setting | |
19 | + end | |
20 | + | |
21 | +end | |
0 | 22 | \ No newline at end of file | ... | ... |