Commit f9b47d6f877b1085574ef06c22b454010adc5b2f
Committed by
Antonio Terceiro
1 parent
5534d8f9
Exists in
master
and in
28 other branches
Communities can publish article in the portal community
(ActionItem1628)
Showing
5 changed files
with
122 additions
and
24 deletions
Show diff stats
app/controllers/my_profile/cms_controller.rb
| @@ -242,6 +242,29 @@ class CmsController < MyProfileController | @@ -242,6 +242,29 @@ class CmsController < MyProfileController | ||
| 242 | end | 242 | end |
| 243 | end | 243 | end |
| 244 | 244 | ||
| 245 | + def publish_on_portal_community | ||
| 246 | + @article = profile.articles.find(params[:id]) | ||
| 247 | + if request.post? | ||
| 248 | + if environment.portal_community | ||
| 249 | + task = ApproveArticle.create!(:article => @article, :name => params[:name], :target => environment.portal_community, :requestor => user) | ||
| 250 | + begin | ||
| 251 | + task.finish unless environment.portal_community.moderated_articles? | ||
| 252 | + flash[:notice] = _("Your publish request was sent successfully") | ||
| 253 | + rescue | ||
| 254 | + flash[:error] = _("Your publish request couldn't be sent.") | ||
| 255 | + end | ||
| 256 | + else | ||
| 257 | + flash[:notice] = _("There is no portal community to publish your article.") | ||
| 258 | + end | ||
| 259 | + | ||
| 260 | + if @back_to | ||
| 261 | + redirect_to @back_to | ||
| 262 | + else | ||
| 263 | + redirect_to @article.view_url | ||
| 264 | + end | ||
| 265 | + end | ||
| 266 | + end | ||
| 267 | + | ||
| 245 | def media_listing | 268 | def media_listing |
| 246 | if params[:image_folder_id] | 269 | if params[:image_folder_id] |
| 247 | folder = profile.articles.find(params[:image_folder_id]) if !params[:image_folder_id].blank? | 270 | folder = profile.articles.find(params[:image_folder_id]) if !params[:image_folder_id].blank? |
| @@ -0,0 +1,21 @@ | @@ -0,0 +1,21 @@ | ||
| 1 | +<% if environment.portal_community %> | ||
| 2 | + <h1><%= _("Publish your article on portal community") %></h1> | ||
| 3 | + | ||
| 4 | + <% form_tag do%> | ||
| 5 | + <%= hidden_field_tag :back_to, @back_to %> | ||
| 6 | + <%= labelled_text_field _('Title') + ': ', :name, @article.name, :style => 'width: 100%' %> | ||
| 7 | + | ||
| 8 | + <% button_bar do %> | ||
| 9 | + <%= submit_button 'spread', _('Spread this'), :cancel => @back_to %> | ||
| 10 | + <% end %> | ||
| 11 | + <% end %> | ||
| 12 | +<% else %> | ||
| 13 | + <div class='atention'> | ||
| 14 | + <%= _("There is no portal community in this environment.") %> | ||
| 15 | + </div> | ||
| 16 | + | ||
| 17 | + <% button_bar do %> | ||
| 18 | + <%= button :back, _('Back'), :controller => 'cms' %> | ||
| 19 | + <% end %> | ||
| 20 | +<% end %> | ||
| 21 | + |
app/views/cms/view.rhtml
| @@ -82,6 +82,8 @@ | @@ -82,6 +82,8 @@ | ||
| 82 | <%= button_without_text :eyes, _('Public view'), item.url %> | 82 | <%= button_without_text :eyes, _('Public view'), item.url %> |
| 83 | <% if profile.person? %> | 83 | <% if profile.person? %> |
| 84 | <%= button_without_text :spread, _('Spread this'), :action => 'publish', :id => item.id %> | 84 | <%= button_without_text :spread, _('Spread this'), :action => 'publish', :id => item.id %> |
| 85 | + <% elsif profile.community? && environment.portal_community %> | ||
| 86 | + <%= button_without_text :spread, _('Spread this'), :action => 'publish_on_portal_community', :id => item.id %> | ||
| 85 | <% end %> | 87 | <% end %> |
| 86 | <% if !environment.enabled?('cant_change_homepage') %> | 88 | <% if !environment.enabled?('cant_change_homepage') %> |
| 87 | <%= button_without_text :home, _('Use as homepage'), { :action => 'set_home_page', :id => item.id }, :method => :post %> | 89 | <%= button_without_text :home, _('Use as homepage'), { :action => 'set_home_page', :id => item.id }, :method => :post %> |
app/views/content_viewer/view_page.rhtml
| @@ -40,10 +40,16 @@ | @@ -40,10 +40,16 @@ | ||
| 40 | profile.admin_url.merge({ :controller => 'cms', :action => 'destroy', :id => @page }), | 40 | profile.admin_url.merge({ :controller => 'cms', :action => 'destroy', :id => @page }), |
| 41 | :class => 'button with-text icon-delete' %> | 41 | :class => 'button with-text icon-delete' %> |
| 42 | <% end %> | 42 | <% end %> |
| 43 | - <% if profile.kind_of?(Person) && !environment.enabled?('disable_cms') && !@page.folder? %> | ||
| 44 | - <%= link_to content_tag( 'span', _('Spread this') ), | ||
| 45 | - profile.admin_url.merge({ :controller => 'cms', :action => 'publish', :id => @page }), | ||
| 46 | - :class => 'button with-text icon-spread' %> | 43 | + <% if !environment.enabled?('disable_cms') && !@page.folder? %> |
| 44 | + <% if profile.kind_of?(Person) %> | ||
| 45 | + <%= link_to content_tag( 'span', _('Spread this') ), | ||
| 46 | + profile.admin_url.merge({ :controller => 'cms', :action => 'publish', :id => @page }), | ||
| 47 | + :class => 'button with-text icon-spread' %> | ||
| 48 | + <% elsif profile.kind_of?(Community) && environment.portal_community %> | ||
| 49 | + <%= link_to content_tag( 'span', _('Spread this') ), | ||
| 50 | + profile.admin_url.merge({ :controller => 'cms', :action => 'publish_on_portal_community', :id => @page }), | ||
| 51 | + :class => 'button with-text icon-spread' %> | ||
| 52 | + <% end %> | ||
| 47 | <% end %> | 53 | <% end %> |
| 48 | <% end %> | 54 | <% end %> |
| 49 | <% end %> | 55 | <% end %> |
test/functional/cms_controller_test.rb
| @@ -23,11 +23,11 @@ class CmsControllerTest < Test::Unit::TestCase | @@ -23,11 +23,11 @@ class CmsControllerTest < Test::Unit::TestCase | ||
| 23 | def test_local_files_reference | 23 | def test_local_files_reference |
| 24 | assert_local_files_reference :get, :index, :profile => profile.identifier | 24 | assert_local_files_reference :get, :index, :profile => profile.identifier |
| 25 | end | 25 | end |
| 26 | - | 26 | + |
| 27 | def test_valid_xhtml | 27 | def test_valid_xhtml |
| 28 | assert_valid_xhtml | 28 | assert_valid_xhtml |
| 29 | end | 29 | end |
| 30 | - | 30 | + |
| 31 | should 'list top level documents on index' do | 31 | should 'list top level documents on index' do |
| 32 | get :index, :profile => profile.identifier | 32 | get :index, :profile => profile.identifier |
| 33 | 33 | ||
| @@ -41,7 +41,7 @@ class CmsControllerTest < Test::Unit::TestCase | @@ -41,7 +41,7 @@ class CmsControllerTest < Test::Unit::TestCase | ||
| 41 | 41 | ||
| 42 | a = profile.articles.build(:name => 'blablabla') | 42 | a = profile.articles.build(:name => 'blablabla') |
| 43 | a.save! | 43 | a.save! |
| 44 | - | 44 | + |
| 45 | get :view, :profile => profile.identifier, :id => a.id | 45 | get :view, :profile => profile.identifier, :id => a.id |
| 46 | 46 | ||
| 47 | assert_template 'view' | 47 | assert_template 'view' |
| @@ -110,7 +110,7 @@ class CmsControllerTest < Test::Unit::TestCase | @@ -110,7 +110,7 @@ class CmsControllerTest < Test::Unit::TestCase | ||
| 110 | should 'be able to set home page' do | 110 | should 'be able to set home page' do |
| 111 | a = profile.articles.build(:name => 'my new home page') | 111 | a = profile.articles.build(:name => 'my new home page') |
| 112 | a.save! | 112 | a.save! |
| 113 | - | 113 | + |
| 114 | assert_not_equal a, profile.home_page | 114 | assert_not_equal a, profile.home_page |
| 115 | 115 | ||
| 116 | post :set_home_page, :profile => profile.identifier, :id => a.id | 116 | post :set_home_page, :profile => profile.identifier, :id => a.id |
| @@ -156,7 +156,7 @@ class CmsControllerTest < Test::Unit::TestCase | @@ -156,7 +156,7 @@ class CmsControllerTest < Test::Unit::TestCase | ||
| 156 | a = profile.articles.build(:name => 'my article') | 156 | a = profile.articles.build(:name => 'my article') |
| 157 | a.last_changed_by = other_person | 157 | a.last_changed_by = other_person |
| 158 | a.save! | 158 | a.save! |
| 159 | - | 159 | + |
| 160 | login_as(profile.identifier) | 160 | login_as(profile.identifier) |
| 161 | post :edit, :profile => profile.identifier, :id => a.id, :article => { :body => 'new content for this article' } | 161 | post :edit, :profile => profile.identifier, :id => a.id, :article => { :body => 'new content for this article' } |
| 162 | 162 | ||
| @@ -384,7 +384,7 @@ class CmsControllerTest < Test::Unit::TestCase | @@ -384,7 +384,7 @@ class CmsControllerTest < Test::Unit::TestCase | ||
| 384 | c1 = env.categories.build(:name => "Test category 1"); c1.save! | 384 | c1 = env.categories.build(:name => "Test category 1"); c1.save! |
| 385 | c2 = env.categories.build(:name => "Test category 2"); c2.save! | 385 | c2 = env.categories.build(:name => "Test category 2"); c2.save! |
| 386 | c3 = env.categories.build(:name => "Test Category 3"); c3.save! | 386 | c3 = env.categories.build(:name => "Test Category 3"); c3.save! |
| 387 | - | 387 | + |
| 388 | # post is in c1 and c3 | 388 | # post is in c1 and c3 |
| 389 | post :new, :type => TextileArticle.name, :profile => profile.identifier, :article => { :name => 'adding-categories-test', :category_ids => [ c1.id, c3.id] } | 389 | post :new, :type => TextileArticle.name, :profile => profile.identifier, :article => { :name => 'adding-categories-test', :category_ids => [ c1.id, c3.id] } |
| 390 | 390 | ||
| @@ -399,44 +399,44 @@ class CmsControllerTest < Test::Unit::TestCase | @@ -399,44 +399,44 @@ class CmsControllerTest < Test::Unit::TestCase | ||
| 399 | c1 = env.categories.build(:name => "Test category 1"); c1.save! | 399 | c1 = env.categories.build(:name => "Test category 1"); c1.save! |
| 400 | c2 = env.categories.build(:name => "Test category 2"); c2.save! | 400 | c2 = env.categories.build(:name => "Test category 2"); c2.save! |
| 401 | c3 = env.categories.build(:name => "Test Category 3"); c3.save! | 401 | c3 = env.categories.build(:name => "Test Category 3"); c3.save! |
| 402 | - | 402 | + |
| 403 | # post is in c1, c3 and c3 | 403 | # post is in c1, c3 and c3 |
| 404 | post :new, :type => TextileArticle.name, :profile => profile.identifier, :article => { :name => 'adding-categories-test', :category_ids => [ c1.id, c3.id, c3.id ] } | 404 | post :new, :type => TextileArticle.name, :profile => profile.identifier, :article => { :name => 'adding-categories-test', :category_ids => [ c1.id, c3.id, c3.id ] } |
| 405 | 405 | ||
| 406 | saved = profile.articles.find_by_name('adding-categories-test') | 406 | saved = profile.articles.find_by_name('adding-categories-test') |
| 407 | assert_equal [c1, c3], saved.categories | 407 | assert_equal [c1, c3], saved.categories |
| 408 | end | 408 | end |
| 409 | - | 409 | + |
| 410 | should 'filter html from textile article name' do | 410 | should 'filter html from textile article name' do |
| 411 | post :new, :type => 'TextileArticle', :profile => profile.identifier, :article => { :name => 'a <strong>test</strong> article', :body => 'the text of the article ...' } | 411 | post :new, :type => 'TextileArticle', :profile => profile.identifier, :article => { :name => 'a <strong>test</strong> article', :body => 'the text of the article ...' } |
| 412 | assert_sanitized assigns(:article).name | 412 | assert_sanitized assigns(:article).name |
| 413 | end | 413 | end |
| 414 | - | 414 | + |
| 415 | should 'filter html from textile article abstract' do | 415 | should 'filter html from textile article abstract' do |
| 416 | post :new, :type => 'TextileArticle', :profile => profile.identifier, :article => { :name => 'article', :abstract => '<strong>abstract</strong>', :body => 'the text of the article ...' } | 416 | post :new, :type => 'TextileArticle', :profile => profile.identifier, :article => { :name => 'article', :abstract => '<strong>abstract</strong>', :body => 'the text of the article ...' } |
| 417 | assert_sanitized assigns(:article).abstract | 417 | assert_sanitized assigns(:article).abstract |
| 418 | end | 418 | end |
| 419 | - | 419 | + |
| 420 | should 'filter html from textile article body' do | 420 | should 'filter html from textile article body' do |
| 421 | post :new, :type => 'TextileArticle', :profile => profile.identifier, :article => { :name => 'article', :abstract => 'abstract', :body => 'the <b>text</b> of <a href=#>the</a> article ...' } | 421 | post :new, :type => 'TextileArticle', :profile => profile.identifier, :article => { :name => 'article', :abstract => 'abstract', :body => 'the <b>text</b> of <a href=#>the</a> article ...' } |
| 422 | assert_sanitized assigns(:article).body | 422 | assert_sanitized assigns(:article).body |
| 423 | end | 423 | end |
| 424 | - | 424 | + |
| 425 | should 'filter html with white_list from tiny mce article name' do | 425 | should 'filter html with white_list from tiny mce article name' do |
| 426 | post :new, :type => 'TinyMceArticle', :profile => profile.identifier, :article => { :name => "<strong>test</strong>", :body => 'the text of the article ...' } | 426 | post :new, :type => 'TinyMceArticle', :profile => profile.identifier, :article => { :name => "<strong>test</strong>", :body => 'the text of the article ...' } |
| 427 | assert_equal "<strong>test</strong>", assigns(:article).name | 427 | assert_equal "<strong>test</strong>", assigns(:article).name |
| 428 | end | 428 | end |
| 429 | - | 429 | + |
| 430 | should 'filter html with white_list from tiny mce article abstract' do | 430 | should 'filter html with white_list from tiny mce article abstract' do |
| 431 | post :new, :type => 'TinyMceArticle', :profile => profile.identifier, :article => { :name => 'article', :abstract => "<script>alert('test')</script> article", :body => 'the text of the article ...' } | 431 | post :new, :type => 'TinyMceArticle', :profile => profile.identifier, :article => { :name => 'article', :abstract => "<script>alert('test')</script> article", :body => 'the text of the article ...' } |
| 432 | assert_equal " article", assigns(:article).abstract | 432 | assert_equal " article", assigns(:article).abstract |
| 433 | end | 433 | end |
| 434 | - | 434 | + |
| 435 | should 'filter html with white_list from tiny mce article body' do | 435 | should 'filter html with white_list from tiny mce article body' do |
| 436 | post :new, :type => 'TinyMceArticle', :profile => profile.identifier, :article => { :name => 'article', :abstract => 'abstract', :body => "the <script>alert('text')</script> of article ..." } | 436 | post :new, :type => 'TinyMceArticle', :profile => profile.identifier, :article => { :name => 'article', :abstract => 'abstract', :body => "the <script>alert('text')</script> of article ..." } |
| 437 | assert_equal "the of article ...", assigns(:article).body | 437 | assert_equal "the of article ...", assigns(:article).body |
| 438 | end | 438 | end |
| 439 | - | 439 | + |
| 440 | should 'not filter html tags permitted from tiny mce article body' do | 440 | should 'not filter html tags permitted from tiny mce article body' do |
| 441 | post :new, :type => 'TinyMceArticle', :profile => profile.identifier, :article => { :name => 'article', :abstract => 'abstract', :body => "<b>the</b> <script>alert('text')</script> <strong>of</strong> article ..." } | 441 | post :new, :type => 'TinyMceArticle', :profile => profile.identifier, :article => { :name => 'article', :abstract => 'abstract', :body => "<b>the</b> <script>alert('text')</script> <strong>of</strong> article ..." } |
| 442 | assert_equal "<b>the</b> <strong>of</strong> article ...", assigns(:article).body | 442 | assert_equal "<b>the</b> <strong>of</strong> article ...", assigns(:article).body |
| @@ -653,7 +653,7 @@ class CmsControllerTest < Test::Unit::TestCase | @@ -653,7 +653,7 @@ class CmsControllerTest < Test::Unit::TestCase | ||
| 653 | 653 | ||
| 654 | should 'create a private article child of private folder' do | 654 | should 'create a private article child of private folder' do |
| 655 | folder = Folder.new(:name => 'my intranet', :published => false); profile.articles << folder; folder.save! | 655 | folder = Folder.new(:name => 'my intranet', :published => false); profile.articles << folder; folder.save! |
| 656 | - | 656 | + |
| 657 | post :new, :profile => profile.identifier, :type => 'TextileArticle', :parent_id => folder.id, :article => { :name => 'new-private-article'} | 657 | post :new, :profile => profile.identifier, :type => 'TextileArticle', :parent_id => folder.id, :article => { :name => 'new-private-article'} |
| 658 | folder.reload | 658 | folder.reload |
| 659 | 659 | ||
| @@ -666,7 +666,7 @@ class CmsControllerTest < Test::Unit::TestCase | @@ -666,7 +666,7 @@ class CmsControllerTest < Test::Unit::TestCase | ||
| 666 | c = Community.create!(:name => 'test comm', :identifier => 'test_comm') | 666 | c = Community.create!(:name => 'test comm', :identifier => 'test_comm') |
| 667 | c.affiliate(profile, Profile::Roles.all_roles(c.environment.id)) | 667 | c.affiliate(profile, Profile::Roles.all_roles(c.environment.id)) |
| 668 | a = profile.articles.create!(:name => 'something intresting', :body => 'ruby on rails') | 668 | a = profile.articles.create!(:name => 'something intresting', :body => 'ruby on rails') |
| 669 | - | 669 | + |
| 670 | get :publish, :profile => profile.identifier, :id => a.id | 670 | get :publish, :profile => profile.identifier, :id => a.id |
| 671 | 671 | ||
| 672 | assert_equal [c], assigns(:groups) | 672 | assert_equal [c], assigns(:groups) |
| @@ -677,18 +677,38 @@ class CmsControllerTest < Test::Unit::TestCase | @@ -677,18 +677,38 @@ class CmsControllerTest < Test::Unit::TestCase | ||
| 677 | c = Community.create!(:name => 'test comm', :identifier => 'test_comm', :moderated_articles => false) | 677 | c = Community.create!(:name => 'test comm', :identifier => 'test_comm', :moderated_articles => false) |
| 678 | c.affiliate(profile, Profile::Roles.all_roles(c.environment.id)) | 678 | c.affiliate(profile, Profile::Roles.all_roles(c.environment.id)) |
| 679 | a = profile.articles.create!(:name => 'something intresting', :body => 'ruby on rails') | 679 | a = profile.articles.create!(:name => 'something intresting', :body => 'ruby on rails') |
| 680 | - | 680 | + |
| 681 | assert_difference PublishedArticle, :count do | 681 | assert_difference PublishedArticle, :count do |
| 682 | post :publish, :profile => profile.identifier, :id => a.id, :marked_groups => [{:name => 'bli', :group_id => c.id.to_s}] | 682 | post :publish, :profile => profile.identifier, :id => a.id, :marked_groups => [{:name => 'bli', :group_id => c.id.to_s}] |
| 683 | assert_equal [{'group' => c, 'name' => 'bli'}], assigns(:marked_groups) | 683 | assert_equal [{'group' => c, 'name' => 'bli'}], assigns(:marked_groups) |
| 684 | end | 684 | end |
| 685 | end | 685 | end |
| 686 | - | 686 | + |
| 687 | + should "not crash if there is a post and no portal community defined" do | ||
| 688 | + Environment.any_instance.stubs(:portal_community).returns(nil) | ||
| 689 | + article = profile.articles.create!(:name => 'something intresting', :body => 'ruby on rails') | ||
| 690 | + assert_nothing_raised do | ||
| 691 | + post :publish_on_portal_community, :profile => profile.identifier, :id => article.id, :name => article.name | ||
| 692 | + end | ||
| 693 | + end | ||
| 694 | + | ||
| 695 | + should 'publish the article on portal community if it is not moderated' do | ||
| 696 | + portal_community = fast_create(Community) | ||
| 697 | + portal_community.moderated_articles = false | ||
| 698 | + portal_community.save | ||
| 699 | + Environment.any_instance.stubs(:portal_community).returns(portal_community) | ||
| 700 | + article = profile.articles.create!(:name => 'something intresting', :body => 'ruby on rails') | ||
| 701 | + | ||
| 702 | + assert_difference PublishedArticle, :count do | ||
| 703 | + post :publish_on_portal_community, :profile => profile.identifier, :id => article.id, :name => article.name | ||
| 704 | + end | ||
| 705 | + end | ||
| 706 | + | ||
| 687 | should 'create a task for article approval if community is moderated' do | 707 | should 'create a task for article approval if community is moderated' do |
| 688 | c = Community.create!(:name => 'test comm', :identifier => 'test_comm', :moderated_articles => true) | 708 | c = Community.create!(:name => 'test comm', :identifier => 'test_comm', :moderated_articles => true) |
| 689 | c.affiliate(profile, Profile::Roles.all_roles(c.environment.id)) | 709 | c.affiliate(profile, Profile::Roles.all_roles(c.environment.id)) |
| 690 | a = profile.articles.create!(:name => 'something intresting', :body => 'ruby on rails') | 710 | a = profile.articles.create!(:name => 'something intresting', :body => 'ruby on rails') |
| 691 | - | 711 | + |
| 692 | assert_no_difference PublishedArticle, :count do | 712 | assert_no_difference PublishedArticle, :count do |
| 693 | assert_difference ApproveArticle, :count do | 713 | assert_difference ApproveArticle, :count do |
| 694 | assert_difference c.tasks, :count do | 714 | assert_difference c.tasks, :count do |
| @@ -699,6 +719,22 @@ class CmsControllerTest < Test::Unit::TestCase | @@ -699,6 +719,22 @@ class CmsControllerTest < Test::Unit::TestCase | ||
| 699 | end | 719 | end |
| 700 | end | 720 | end |
| 701 | 721 | ||
| 722 | + should 'create a task for article approval if portal community is moderated' do | ||
| 723 | + portal_community = fast_create(Community) | ||
| 724 | + portal_community.moderated_articles = true | ||
| 725 | + portal_community.save | ||
| 726 | + Environment.any_instance.stubs(:portal_community).returns(portal_community) | ||
| 727 | + article = profile.articles.create!(:name => 'something intresting', :body => 'ruby on rails') | ||
| 728 | + | ||
| 729 | + assert_no_difference PublishedArticle, :count do | ||
| 730 | + assert_difference ApproveArticle, :count do | ||
| 731 | + assert_difference portal_community.tasks, :count do | ||
| 732 | + post :publish_on_portal_community, :profile => profile.identifier, :id => article.id, :name => article.name | ||
| 733 | + end | ||
| 734 | + end | ||
| 735 | + end | ||
| 736 | + end | ||
| 737 | + | ||
| 702 | should 'require ssl in general' do | 738 | should 'require ssl in general' do |
| 703 | Environment.default.update_attribute(:enable_ssl, true) | 739 | Environment.default.update_attribute(:enable_ssl, true) |
| 704 | @request.expects(:ssl?).returns(false).at_least_once | 740 | @request.expects(:ssl?).returns(false).at_least_once |
| @@ -1136,7 +1172,17 @@ class CmsControllerTest < Test::Unit::TestCase | @@ -1136,7 +1172,17 @@ class CmsControllerTest < Test::Unit::TestCase | ||
| 1136 | assert_tag :tag => 'a', :attributes => {:href => "/myprofile/#{profile.identifier}/cms/publish/#{a.id}"} | 1172 | assert_tag :tag => 'a', :attributes => {:href => "/myprofile/#{profile.identifier}/cms/publish/#{a.id}"} |
| 1137 | end | 1173 | end |
| 1138 | 1174 | ||
| 1139 | - should "not display 'Publish' when profile is not a person" do | 1175 | + should "display 'Publish' when profile is a community" do |
| 1176 | + community = fast_create(Community) | ||
| 1177 | + community.add_member(profile) | ||
| 1178 | + Environment.any_instance.stubs(:portal_community).returns(community) | ||
| 1179 | + a = community.articles.create!(:name => 'my new home page') | ||
| 1180 | + Article.stubs(:short_description).returns('bli') | ||
| 1181 | + get :index, :profile => community.identifier | ||
| 1182 | + assert_tag :tag => 'a', :attributes => {:href => "/myprofile/#{community.identifier}/cms/publish_on_portal_community/#{a.id}"} | ||
| 1183 | + end | ||
| 1184 | + | ||
| 1185 | + should "not display 'Publish' when profile is not a person nor a community" do | ||
| 1140 | p = Community.create!(:name => 'community-test') | 1186 | p = Community.create!(:name => 'community-test') |
| 1141 | p.add_admin(profile) | 1187 | p.add_admin(profile) |
| 1142 | a = p.articles.create!(:name => 'my new home page') | 1188 | a = p.articles.create!(:name => 'my new home page') |