Commit 50e72f1d66dda87ca0f064ae23dad937d763031e

Authored by Larissa Reis
1 parent deb07e92

spread: all public content can be reposted and portal community is free for all

app/controllers/my_profile/cms_controller.rb
@@ -235,25 +235,48 @@ class CmsController < MyProfileController @@ -235,25 +235,48 @@ class CmsController < MyProfileController
235 render :template => 'shared/update_categories', :locals => { :category => @current_category, :object_name => 'article' } 235 render :template => 'shared/update_categories', :locals => { :category => @current_category, :object_name => 'article' }
236 end 236 end
237 237
  238 + def search_communities_to_publish
  239 + render :text => find_by_contents(:profiles, user.memberships, params['q'], {:page => 1}, {:fields => ['name']})[:results].map {|community| {:id => community.id, :name => community.name} }.to_json
  240 + end
  241 +
238 def publish 242 def publish
239 @article = profile.articles.find(params[:id]) 243 @article = profile.articles.find(params[:id])
  244 + @portal_enabled = environment.portal_community && environment.enabled?('use_portal_community')
240 record_coming 245 record_coming
241 - @groups = profile.memberships - [profile]  
242 - @marked_groups = []  
243 - groups_ids = profile.memberships.map{|m|m.id.to_s}  
244 - @marked_groups = params[:marked_groups].map do |key, item|  
245 - if groups_ids.include?(item[:group_id])  
246 - item.merge :group => Profile.find(item.delete(:group_id)) 246 + @failed = {}
  247 + if request.post?
  248 + article_name = params[:name]
  249 + task = ApproveArticle.create!(:article => @article, :name => article_name, :target => user, :requestor => user)
  250 + begin
  251 + task.finish
  252 + rescue Exception => ex
  253 + @failed[ex.message] ? @failed[ex.message] << item.name : @failed[ex.message] = [item.name]
  254 + end
  255 + if @failed.blank?
  256 + session[:notice] = _("Your publish request was sent successfully")
  257 + if @back_to
  258 + redirect_to @back_to
  259 + else
  260 + redirect_to @article.view_url
  261 + end
247 end 262 end
248 - end.compact unless params[:marked_groups].nil? 263 + end
  264 + end
  265 +
  266 + def publish_on_communities
249 if request.post? 267 if request.post?
  268 + @back_to = params[:back_to]
  269 + @article = profile.articles.find(params[:id])
250 @failed = {} 270 @failed = {}
  271 + article_name = params[:name]
  272 + params_marked = params['q'].split(',').select { |marked| user.memberships.map(&:id).include? marked.to_i }
  273 + @marked_groups = Profile.find(params_marked)
251 @marked_groups.each do |item| 274 @marked_groups.each do |item|
252 - task = ApproveArticle.create!(:article => @article, :name => item[:name], :target => item[:group], :requestor => profile) 275 + task = ApproveArticle.create!(:article => @article, :name => article_name, :target => item, :requestor => user)
253 begin 276 begin
254 - task.finish unless item[:group].moderated_articles? 277 + task.finish unless item.moderated_articles?
255 rescue Exception => ex 278 rescue Exception => ex
256 - @failed[ex.message] ? @failed[ex.message] << item[:group].name : @failed[ex.message] = [item[:group].name] 279 + @failed[ex.message] ? @failed[ex.message] << item.name : @failed[ex.message] = [item.name]
257 end 280 end
258 end 281 end
259 if @failed.blank? 282 if @failed.blank?
@@ -268,9 +291,9 @@ class CmsController &lt; MyProfileController @@ -268,9 +291,9 @@ class CmsController &lt; MyProfileController
268 end 291 end
269 292
270 def publish_on_portal_community 293 def publish_on_portal_community
271 - @article = profile.articles.find(params[:id])  
272 if request.post? 294 if request.post?
273 - if environment.portal_community 295 + @article = profile.articles.find(params[:id])
  296 + if environment.portal_community && environment.enabled?('use_portal_community')
274 task = ApproveArticle.create!(:article => @article, :name => params[:name], :target => environment.portal_community, :requestor => user) 297 task = ApproveArticle.create!(:article => @article, :name => params[:name], :target => environment.portal_community, :requestor => user)
275 begin 298 begin
276 task.finish unless environment.portal_community.moderated_articles? 299 task.finish unless environment.portal_community.moderated_articles?
app/helpers/cms_helper.rb
@@ -40,11 +40,9 @@ module CmsHelper @@ -40,11 +40,9 @@ module CmsHelper
40 end 40 end
41 end 41 end
42 42
43 - def display_spread_button(profile, article)  
44 - if profile.person?  
45 - expirable_button article, :spread, _('Spread this'), :action => 'publish', :id => article.id  
46 - elsif profile.community? && environment.portal_community  
47 - expirable_button article, :spread, _('Spread this'), :action => 'publish_on_portal_community', :id => article.id 43 + def display_spread_button(article)
  44 + if article.public?
  45 + expirable_button article, :spread, _('Spread this'), {:action => 'publish', :id => article.id}, {:class => 'colorbox'}
48 end 46 end
49 end 47 end
50 48
app/helpers/token_helper.rb
@@ -12,6 +12,7 @@ module TokenHelper @@ -12,6 +12,7 @@ module TokenHelper
12 options[:search_delay] ||= 1000 12 options[:search_delay] ||= 1000
13 options[:prevent_duplicates] ||= true 13 options[:prevent_duplicates] ||= true
14 options[:backspace_delete_item] ||= false 14 options[:backspace_delete_item] ||= false
  15 + options[:zindex] ||= 999
15 options[:focus] ||= false 16 options[:focus] ||= false
16 options[:avoid_enter] ||= true 17 options[:avoid_enter] ||= true
17 options[:on_result] ||= 'null' 18 options[:on_result] ||= 'null'
@@ -30,6 +31,7 @@ module TokenHelper @@ -30,6 +31,7 @@ module TokenHelper
30 searchDelay: #{options[:search_delay].to_json}, 31 searchDelay: #{options[:search_delay].to_json},
31 preventDuplicates: #{options[:prevent_duplicates].to_json}, 32 preventDuplicates: #{options[:prevent_duplicates].to_json},
32 backspaceDeleteItem: #{options[:backspace_delete_item].to_json}, 33 backspaceDeleteItem: #{options[:backspace_delete_item].to_json},
  34 + zindex: #{options[:zindex].to_json},
33 queryParam: #{name.to_json}, 35 queryParam: #{name.to_json},
34 tokenLimit: #{options[:token_limit].to_json}, 36 tokenLimit: #{options[:token_limit].to_json},
35 onResult: #{options[:on_result]}, 37 onResult: #{options[:on_result]},
@@ -48,4 +50,4 @@ module TokenHelper @@ -48,4 +50,4 @@ module TokenHelper
48 result 50 result
49 end 51 end
50 52
51 -end  
52 \ No newline at end of file 53 \ No newline at end of file
  54 +end
app/views/cms/publish.html.erb
1 -<h1><%= _('Select the groups where you want to publish your article') %></h1> 1 +<script type="text/javascript" charset="utf-8">
  2 + jQuery(document).ready( function() {
  3 + jQuery('.publish-article-title').find('label')
  4 + .click( function(event) {
  5 + if (this == event.target) {
  6 + jQuery(this).toggleClass('expanded');
  7 + jQuery(this).next('input').slideToggle();
  8 + }
  9 + return false;
  10 + }).addClass('collapsed').next('input').hide();
  11 + });
  12 +
  13 +</script>
  14 +<div class="select-publish-target">
  15 +
  16 +<h2><%= _('Where do you want to publish this article?') %></h2>
2 17
3 <% if !@failed.blank? %> 18 <% if !@failed.blank? %>
4 <div class="errorExplanation" id="errorExplanation"> 19 <div class="errorExplanation" id="errorExplanation">
@@ -14,15 +29,57 @@ @@ -14,15 +29,57 @@
14 </div> 29 </div>
15 <% end %> 30 <% end %>
16 31
17 -<%= form_tag do%>  
18 - <%= hidden_field_tag :back_to, @back_to %>  
19 - <% @groups.each do |group| %>  
20 - <%= labelled_check_box group.name, "marked_groups[#{group.id}][group_id]", group.id, @marked_groups.include?(group) %><br />  
21 - <%= labelled_text_field _('Title') + ': ', "marked_groups[#{group.id}][name]", @article.name, :style => 'width: 100%' %>  
22 - <hr />  
23 - <% end %> 32 +<ul class='publish-targets'>
  33 + <li onmouseover="javascript: jQuery(this).addClass('mouseover')" onmouseout="jQuery(this).removeClass('mouseover')">
  34 + <strong><%= _("Publish this article on your profile") %></strong>
  35 + <div class='description'><%= _('You can publish this article on your profile where your friends and followers will see.') %></div>
  36 + <%= form_tag do %>
  37 + <%= hidden_field_tag :back_to, @back_to %>
  38 + <div class='publish-article-title'>
  39 + <%= labelled_text_field _('Title'), 'name', @article.name %>
  40 + </div>
24 41
25 - <% button_bar do %>  
26 - <%= submit_button 'spread', _('Spread this'), :cancel => @back_to %> 42 + <% button_bar do %>
  43 + <%= submit_button 'spread', _('Spread this') %>
  44 + <% end %>
  45 + <% end %>
  46 + </li>
  47 +
  48 + <li onmouseover="javascript: jQuery(this).addClass('mouseover')" onmouseout="jQuery(this).removeClass('mouseover')">
  49 + <strong><%= _("Publish this article on communities you are part of") %></strong>
  50 + <div class='description'><%= _('You can submit this article to one or more communities you are a member of, just search for the community below.') %></div>
  51 + <%= form_tag :action => 'publish_on_communities', :id => @article.id do %>
  52 + <%= hidden_field_tag :back_to, @back_to %>
  53 + <% search_action = url_for(:action => 'search_communities_to_publish') %>
  54 + <%= token_input_field_tag(:q, 'search-communities-to-publish', search_action, { :hint_text => _('Type in a search for your community'), :zindex => 10000, :focus => false }) %>
  55 +
  56 + <div class='publish-article-title'>
  57 + <%= labelled_text_field _('Title'), 'name', @article.name %>
  58 + </div>
  59 + <% button_bar do %>
  60 + <%= submit_button 'spread', _('Spread this') %>
  61 + <% end %>
  62 + <% end %>
  63 + </li>
  64 +
  65 +
  66 +<% if @portal_enabled %>
  67 + <li onmouseover="javascript: jQuery(this).addClass('mouseover')" onmouseout="jQuery(this).removeClass('mouseover')">
  68 + <strong><%= _("Publish your article on portal community") %></strong>
  69 + <div class='description'><%= _('You can suggest this article to the portal community, where it can show up on the homepage.') %></div>
  70 +
  71 + <%= form_tag :action => 'publish_on_portal_community', :id => @article.id do %>
  72 + <%= hidden_field_tag :back_to, @back_to %>
  73 + <div class='publish-article-title'>
  74 + <%= labelled_text_field _('Title'), :name, @article.name %>
  75 + </div>
  76 +
  77 + <% button_bar do %>
  78 + <%= submit_button 'spread', _('Spread this') %>
  79 + <% end %>
27 <% end %> 80 <% end %>
  81 + </li>
28 <% end %> 82 <% end %>
  83 +</ul>
  84 +
  85 +</div>
app/views/cms/view.html.erb
@@ -66,7 +66,7 @@ @@ -66,7 +66,7 @@
66 <td class="article-controls"> 66 <td class="article-controls">
67 <%= expirable_button article, :edit, _('Edit'), {:action => 'edit', :id => article.id} if !remove_content_button(:edit) %> 67 <%= expirable_button article, :edit, _('Edit'), {:action => 'edit', :id => article.id} if !remove_content_button(:edit) %>
68 <%= button_without_text :eyes, _('Public view'), article.view_url %> 68 <%= button_without_text :eyes, _('Public view'), article.view_url %>
69 - <%= display_spread_button(profile, article) unless article.folder? || remove_content_button(:spread)%> 69 + <%= display_spread_button(article) unless article.folder? || remove_content_button(:spread)%>
70 <% if !environment.enabled?('cant_change_homepage') && !remove_content_button(:home) %> 70 <% if !environment.enabled?('cant_change_homepage') && !remove_content_button(:home) %>
71 <% if profile.home_page != article %> 71 <% if profile.home_page != article %>
72 <%= expirable_button article, :home, _('Use as homepage'), { :action => 'set_home_page', :id => article.id }, :method => :post %> 72 <%= expirable_button article, :home, _('Use as homepage'), { :action => 'set_home_page', :id => article.id }, :method => :post %>
app/views/content_viewer/_article_toolbar.html.erb
@@ -15,15 +15,9 @@ @@ -15,15 +15,9 @@
15 <%= expirable_button @page, :delete, content, url, options %> 15 <%= expirable_button @page, :delete, content, url, options %>
16 <% end %> 16 <% end %>
17 17
18 - <% if !@page.folder? && @page.allow_spread?(user) && !remove_content_button(:spread) %>  
19 - <% content = content_tag( 'span', _('Spread this') ) %>  
20 - <% url = nil %>  
21 - <% if profile.kind_of?(Person) %>  
22 - <% url = profile.admin_url.merge({ :controller => 'cms', :action => 'publish', :id => @page.id }) %>  
23 - <% elsif profile.kind_of?(Community) && environment.portal_community %>  
24 - <% url = profile.admin_url.merge({ :controller => 'cms', :action => 'publish_on_portal_community', :id => @page.id }) %>  
25 - <% end %>  
26 - <%= expirable_button @page, :spread, content, url if url %> 18 + <% if !@page.folder? && @page.public? && !remove_content_button(:spread) %>
  19 + <% url = profile.admin_url.merge({ :controller => 'cms', :action => 'publish', :id => @page.id }) %>
  20 + <%= expirable_button @page, :spread, content_tag( 'span', _('Spread this') ), url, {:class => 'colorbox'} if url %>
27 <% end %> 21 <% end %>
28 22
29 <% if !@page.gallery? && (@page.allow_create?(user) || (@page.parent && @page.parent.allow_create?(user))) %> 23 <% if !@page.gallery? && (@page.allow_create?(user) || (@page.parent && @page.parent.allow_create?(user))) %>
public/javascripts/jquery.tokeninput.js
@@ -35,6 +35,7 @@ var DEFAULT_SETTINGS = { @@ -35,6 +35,7 @@ var DEFAULT_SETTINGS = {
35 onAdd: null, 35 onAdd: null,
36 onDelete: null, 36 onDelete: null,
37 idPrefix: "token-input-", 37 idPrefix: "token-input-",
  38 + zindex: 999,
38 backspaceDeleteItem: true 39 backspaceDeleteItem: true
39 }; 40 };
40 41
@@ -628,7 +629,7 @@ $.TokenList = function (input, url_or_data, options) { @@ -628,7 +629,7 @@ $.TokenList = function (input, url_or_data, options) {
628 position: "absolute", 629 position: "absolute",
629 top: $(token_list).offset().top + $(token_list).outerHeight(), 630 top: $(token_list).offset().top + $(token_list).outerHeight(),
630 left: $(token_list).offset().left, 631 left: $(token_list).offset().left,
631 - zindex: 999 632 + 'z-index': settings.zindex
632 }).show(); 633 }).show();
633 else 634 else
634 dropdown.css({ 635 dropdown.css({
public/stylesheets/application.css
@@ -2137,7 +2137,7 @@ a.button.disabled, input.disabled { @@ -2137,7 +2137,7 @@ a.button.disabled, input.disabled {
2137 .recent-documents-block .block-footer-content a:hover { 2137 .recent-documents-block .block-footer-content a:hover {
2138 text-decoration: underline; 2138 text-decoration: underline;
2139 } 2139 }
2140 -/* ==> blocks/disabled-enterprise-message-block.css <<= */ 2140 +/* ==> blocks/disabled-enterprise-message-block.css <<= */
2141 2141
2142 2142
2143 .disabled-enterprise-message-block { 2143 .disabled-enterprise-message-block {
@@ -2153,12 +2153,12 @@ a.button.disabled, input.disabled { @@ -2153,12 +2153,12 @@ a.button.disabled, input.disabled {
2153 font-size: 80%; 2153 font-size: 80%;
2154 background: #ffffa9; 2154 background: #ffffa9;
2155 } 2155 }
2156 -/* ==> blocks/article-block.css <<= */ 2156 +/* ==> blocks/article-block.css <<= */
2157 2157
2158 .article-block { 2158 .article-block {
2159 overflow: hidden; 2159 overflow: hidden;
2160 } 2160 }
2161 -/* ==> blocks/main-block.css <<= */ 2161 +/* ==> blocks/main-block.css <<= */
2162 2162
2163 /* 2163 /*
2164 Use article.css for article related css 2164 Use article.css for article related css
@@ -2179,7 +2179,7 @@ div#activation_enterprise { @@ -2179,7 +2179,7 @@ div#activation_enterprise {
2179 div#activation_enterprise label, div#activation_enterprise input, div#activation_enterprise div { 2179 div#activation_enterprise label, div#activation_enterprise input, div#activation_enterprise div {
2180 display: inline 2180 display: inline
2181 } 2181 }
2182 -/* ==> blocks/slideshow-block.css <<= */ 2182 +/* ==> blocks/slideshow-block.css <<= */
2183 2183
2184 .slideshow-block .slideshow-container { 2184 .slideshow-block .slideshow-container {
2185 margin-bottom: 10px; 2185 margin-bottom: 10px;
@@ -2244,7 +2244,7 @@ div#activation_enterprise label, div#activation_enterprise input, div#activation @@ -2244,7 +2244,7 @@ div#activation_enterprise label, div#activation_enterprise input, div#activation
2244 display: inline-block; 2244 display: inline-block;
2245 width: 16px; 2245 width: 16px;
2246 } 2246 }
2247 -/* ==> blocks/products-block.css <<= */ 2247 +/* ==> blocks/products-block.css <<= */
2248 2248
2249 .products-block ul { 2249 .products-block ul {
2250 margin: 0px; 2250 margin: 0px;
@@ -2277,7 +2277,7 @@ div#activation_enterprise label, div#activation_enterprise input, div#activation @@ -2277,7 +2277,7 @@ div#activation_enterprise label, div#activation_enterprise input, div#activation
2277 #content .products-block li a:hover { 2277 #content .products-block li a:hover {
2278 color: #fff; 2278 color: #fff;
2279 } 2279 }
2280 -/* ==> blocks/blog-archives-block.css <<= */ 2280 +/* ==> blocks/blog-archives-block.css <<= */
2281 2281
2282 #content .blog-archives-block { 2282 #content .blog-archives-block {
2283 padding: 10px 0px 10px 10px; 2283 padding: 10px 0px 10px 10px;
@@ -2297,7 +2297,7 @@ div#activation_enterprise label, div#activation_enterprise input, div#activation @@ -2297,7 +2297,7 @@ div#activation_enterprise label, div#activation_enterprise input, div#activation
2297 padding: 5px 0px 10px 10px; 2297 padding: 5px 0px 10px 10px;
2298 font-size: 12px; 2298 font-size: 12px;
2299 } 2299 }
2300 -/* ==> blocks/profile-info-block.css <<= */ 2300 +/* ==> blocks/profile-info-block.css <<= */
2301 2301
2302 2302
2303 .profile-info-block h2 { 2303 .profile-info-block h2 {
@@ -2400,7 +2400,7 @@ div#activation_enterprise label, div#activation_enterprise input, div#activation @@ -2400,7 +2400,7 @@ div#activation_enterprise label, div#activation_enterprise input, div#activation
2400 margin: 0px 0px 5px 0px; 2400 margin: 0px 0px 5px 0px;
2401 padding: 2px; 2401 padding: 2px;
2402 } 2402 }
2403 -/* ==> blocks/location-block.css <<= */ 2403 +/* ==> blocks/location-block.css <<= */
2404 2404
2405 .location-block { 2405 .location-block {
2406 text-align: center; 2406 text-align: center;
@@ -2413,7 +2413,7 @@ div#activation_enterprise label, div#activation_enterprise input, div#activation @@ -2413,7 +2413,7 @@ div#activation_enterprise label, div#activation_enterprise input, div#activation
2413 background: #FFF; 2413 background: #FFF;
2414 border: 1px solid #888; 2414 border: 1px solid #888;
2415 } 2415 }
2416 -/* ==> blocks/profile-image-block.css <<= */ 2416 +/* ==> blocks/profile-image-block.css <<= */
2417 2417
2418 2418
2419 .profile-image-block { 2419 .profile-image-block {
@@ -2448,7 +2448,7 @@ div#activation_enterprise label, div#activation_enterprise input, div#activation @@ -2448,7 +2448,7 @@ div#activation_enterprise label, div#activation_enterprise input, div#activation
2448 list-style: none; 2448 list-style: none;
2449 margin-bottom: 8px; 2449 margin-bottom: 8px;
2450 } 2450 }
2451 -/* ==> blocks/sellers-search-block.css <<= */ 2451 +/* ==> blocks/sellers-search-block.css <<= */
2452 2452
2453 2453
2454 #content .sellers-search-block { 2454 #content .sellers-search-block {
@@ -2507,7 +2507,7 @@ div#activation_enterprise label, div#activation_enterprise input, div#activation @@ -2507,7 +2507,7 @@ div#activation_enterprise label, div#activation_enterprise input, div#activation
2507 margin: 0px; 2507 margin: 0px;
2508 float: none; 2508 float: none;
2509 } 2509 }
2510 -/* ==> blocks/feed-reader-block.css <<= */ 2510 +/* ==> blocks/feed-reader-block.css <<= */
2511 2511
2512 #content .feed-reader-block { 2512 #content .feed-reader-block {
2513 padding: 10px 0px 10px 10px; 2513 padding: 10px 0px 10px 10px;
@@ -3266,6 +3266,52 @@ table.cms-articles .icon:hover { @@ -3266,6 +3266,52 @@ table.cms-articles .icon:hover {
3266 background-color: transparent; 3266 background-color: transparent;
3267 } 3267 }
3268 3268
  3269 +.select-publish-target {
  3270 + margin: 10px 10px 0px 10px;
  3271 +}
  3272 +
  3273 +.publish-targets {
  3274 + padding: 10px;
  3275 + margin: 0px;
  3276 +}
  3277 +
  3278 +.publish-targets>li {
  3279 + list-style: none;
  3280 + padding: 10px 20px 5px 10px;
  3281 +}
  3282 +
  3283 +.publish-targets li.mouseover {
  3284 + background-color: #eeeeec;
  3285 +}
  3286 +
  3287 +.publish-targets div.publish-article-title, .publish-targets .description {
  3288 + width: 384px;
  3289 + margin-top: 2px;
  3290 +}
  3291 +
  3292 +.publish-targets div.publish-article-title .collapsed {
  3293 + background-image: url("../images/icons-task/closed-arrow-hover.png");
  3294 + background-repeat: no-repeat;
  3295 + background-position: 3px 0;
  3296 +}
  3297 +
  3298 +.publish-targets div.publish-article-title .expanded {
  3299 + background-image: url("../images/icons-task/opened-arrow-hover.png");
  3300 + background-repeat: no-repeat;
  3301 + background-position: 3px 0;
  3302 +}
  3303 +
  3304 +.publish-targets div.publish-article-title label {
  3305 + padding-left: 20px;
  3306 +}
  3307 +
  3308 +.publish-targets div.publish-article-title input {
  3309 + width: 100%;
  3310 + border: 1px solid #999;
  3311 + padding: 3px 8px;
  3312 + margin-bottom: 2px;
  3313 +}
  3314 +
3269 .select-article-type { 3315 .select-article-type {
3270 padding: 5px 20px; 3316 padding: 5px 20px;
3271 width: 455px; 3317 width: 455px;
@@ -6514,7 +6560,7 @@ li.profile-activity-item.upload_image .activity-gallery-images-count-1 img { @@ -6514,7 +6560,7 @@ li.profile-activity-item.upload_image .activity-gallery-images-count-1 img {
6514 6560
6515 /* AutoComplete*/ 6561 /* AutoComplete*/
6516 .formfield input.ui-autocomplete-loading { background: url('/images/loading-small.gif') right center no-repeat, url("../images/input-bg.gif") no-repeat left top; } 6562 .formfield input.ui-autocomplete-loading { background: url('/images/loading-small.gif') right center no-repeat, url("../images/input-bg.gif") no-repeat left top; }
6517 - 6563 +
6518 .ui-autocomplete-category { 6564 .ui-autocomplete-category {
6519 font-weight: bold; 6565 font-weight: bold;
6520 padding: .2em .4em; 6566 padding: .2em .4em;
test/unit/cms_helper_test.rb
@@ -48,41 +48,22 @@ class CmsHelperTest &lt; ActionView::TestCase @@ -48,41 +48,22 @@ class CmsHelperTest &lt; ActionView::TestCase
48 result = link_to_article(file) 48 result = link_to_article(file)
49 end 49 end
50 50
51 - should 'display spread button when profile is a person' do 51 + should 'display spread button when content is public' do
52 plugins.stubs(:dispatch).returns([]) 52 plugins.stubs(:dispatch).returns([])
53 profile = fast_create(Person) 53 profile = fast_create(Person)
54 article = fast_create(TinyMceArticle, :name => 'My article', :profile_id => profile.id) 54 article = fast_create(TinyMceArticle, :name => 'My article', :profile_id => profile.id)
55 expects(:link_to).with('Spread this', {:action => 'publish', :id => article.id}, :class => 'button with-text icon-spread', :title => nil) 55 expects(:link_to).with('Spread this', {:action => 'publish', :id => article.id}, :class => 'button with-text icon-spread', :title => nil)
56 56
57 - result = display_spread_button(profile, article) 57 + result = display_spread_button(article)
58 end 58 end
59 59
60 - should 'display spread button when profile is a community and env has portal_community' do 60 + should 'not display spread button when content is not public' do
61 plugins.stubs(:dispatch).returns([]) 61 plugins.stubs(:dispatch).returns([])
62 - env = fast_create(Environment)  
63 - env.expects(:portal_community).returns(true)  
64 - profile = fast_create(Community, :environment_id => env.id)  
65 - expects(:environment).returns(env)  
66 -  
67 - article = fast_create(TinyMceArticle, :name => 'My article', :profile_id => profile.id)  
68 -  
69 - expects(:link_to).with('Spread this', {:action => 'publish_on_portal_community', :id => article.id}, :class => 'button with-text icon-spread', :title => nil)  
70 -  
71 - result = display_spread_button(profile, article)  
72 - end  
73 -  
74 - should 'not display spread button when profile is a community and env has not portal_community' do  
75 - plugins.stubs(:dispatch).returns([])  
76 - env = fast_create(Environment)  
77 - env.expects(:portal_community).returns(nil)  
78 - profile = fast_create(Community, :environment_id => env.id)  
79 - expects(:environment).returns(env)  
80 -  
81 - article = fast_create(TinyMceArticle, :name => 'My article', :profile_id => profile.id)  
82 -  
83 - expects(:link_to).with('Spread this', {:action => 'publish_on_portal_community', :id => article.id}, :class => 'button with-text icon-spread', :title => nil).never 62 + profile = fast_create(Person)
  63 + article = fast_create(TinyMceArticle, :name => 'My article', :profile_id => profile.id, :published => false)
  64 + expects(:link_to).with('Spread this', {:action => 'publish', :id => article.id}, :class => 'button with-text icon-spread', :title => nil).never
84 65
85 - result = display_spread_button(profile, article) 66 + result = display_spread_button(article)
86 end 67 end
87 68
88 should 'display delete_button to folder' do 69 should 'display delete_button to folder' do