Commit 6e53d8be9a1b6790ac4cf474d996556f279befd0

Authored by Rodrigo Souto
2 parents 5ceef49f 50e72f1d

Merge remote-tracking branch 'larissa/share' into stoa

app/controllers/my_profile/cms_controller.rb
@@ -238,25 +238,48 @@ class CmsController < MyProfileController @@ -238,25 +238,48 @@ class CmsController < MyProfileController
238 render :template => 'shared/update_categories', :locals => { :category => @current_category, :object_name => 'article' } 238 render :template => 'shared/update_categories', :locals => { :category => @current_category, :object_name => 'article' }
239 end 239 end
240 240
  241 + def search_communities_to_publish
  242 + 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
  243 + end
  244 +
241 def publish 245 def publish
242 @article = profile.articles.find(params[:id]) 246 @article = profile.articles.find(params[:id])
  247 + @portal_enabled = environment.portal_community && environment.enabled?('use_portal_community')
243 record_coming 248 record_coming
244 - @groups = profile.memberships - [profile]  
245 - @marked_groups = []  
246 - groups_ids = profile.memberships.map{|m|m.id.to_s}  
247 - @marked_groups = params[:marked_groups].map do |key, item|  
248 - if groups_ids.include?(item[:group_id])  
249 - item.merge :group => Profile.find(item.delete(:group_id)) 249 + @failed = {}
  250 + if request.post?
  251 + article_name = params[:name]
  252 + task = ApproveArticle.create!(:article => @article, :name => article_name, :target => user, :requestor => user)
  253 + begin
  254 + task.finish
  255 + rescue Exception => ex
  256 + @failed[ex.message] ? @failed[ex.message] << item.name : @failed[ex.message] = [item.name]
250 end 257 end
251 - end.compact unless params[:marked_groups].nil? 258 + if @failed.blank?
  259 + session[:notice] = _("Your publish request was sent successfully")
  260 + if @back_to
  261 + redirect_to @back_to
  262 + else
  263 + redirect_to @article.view_url
  264 + end
  265 + end
  266 + end
  267 + end
  268 +
  269 + def publish_on_communities
252 if request.post? 270 if request.post?
  271 + @back_to = params[:back_to]
  272 + @article = profile.articles.find(params[:id])
253 @failed = {} 273 @failed = {}
  274 + article_name = params[:name]
  275 + params_marked = params['q'].split(',').select { |marked| user.memberships.map(&:id).include? marked.to_i }
  276 + @marked_groups = Profile.find(params_marked)
254 @marked_groups.each do |item| 277 @marked_groups.each do |item|
255 - task = ApproveArticle.create!(:article => @article, :name => item[:name], :target => item[:group], :requestor => profile) 278 + task = ApproveArticle.create!(:article => @article, :name => article_name, :target => item, :requestor => user)
256 begin 279 begin
257 - task.finish unless item[:group].moderated_articles? 280 + task.finish unless item.moderated_articles?
258 rescue Exception => ex 281 rescue Exception => ex
259 - @failed[ex.message] ? @failed[ex.message] << item[:group].name : @failed[ex.message] = [item[:group].name] 282 + @failed[ex.message] ? @failed[ex.message] << item.name : @failed[ex.message] = [item.name]
260 end 283 end
261 end 284 end
262 if @failed.blank? 285 if @failed.blank?
@@ -271,9 +294,9 @@ class CmsController &lt; MyProfileController @@ -271,9 +294,9 @@ class CmsController &lt; MyProfileController
271 end 294 end
272 295
273 def publish_on_portal_community 296 def publish_on_portal_community
274 - @article = profile.articles.find(params[:id])  
275 if request.post? 297 if request.post?
276 - if environment.portal_community 298 + @article = profile.articles.find(params[:id])
  299 + if environment.portal_community && environment.enabled?('use_portal_community')
277 task = ApproveArticle.create!(:article => @article, :name => params[:name], :target => environment.portal_community, :requestor => user) 300 task = ApproveArticle.create!(:article => @article, :name => params[:name], :target => environment.portal_community, :requestor => user)
278 begin 301 begin
279 task.finish unless environment.portal_community.moderated_articles? 302 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
@@ -2159,7 +2159,7 @@ a.button.disabled, input.disabled { @@ -2159,7 +2159,7 @@ a.button.disabled, input.disabled {
2159 .recent-documents-block .block-footer-content a:hover { 2159 .recent-documents-block .block-footer-content a:hover {
2160 text-decoration: underline; 2160 text-decoration: underline;
2161 } 2161 }
2162 -/* ==> blocks/disabled-enterprise-message-block.css <<= */ 2162 +/* ==> blocks/disabled-enterprise-message-block.css <<= */
2163 2163
2164 2164
2165 .disabled-enterprise-message-block { 2165 .disabled-enterprise-message-block {
@@ -2175,12 +2175,12 @@ a.button.disabled, input.disabled { @@ -2175,12 +2175,12 @@ a.button.disabled, input.disabled {
2175 font-size: 80%; 2175 font-size: 80%;
2176 background: #ffffa9; 2176 background: #ffffa9;
2177 } 2177 }
2178 -/* ==> blocks/article-block.css <<= */ 2178 +/* ==> blocks/article-block.css <<= */
2179 2179
2180 .article-block { 2180 .article-block {
2181 overflow: hidden; 2181 overflow: hidden;
2182 } 2182 }
2183 -/* ==> blocks/main-block.css <<= */ 2183 +/* ==> blocks/main-block.css <<= */
2184 2184
2185 /* 2185 /*
2186 Use article.css for article related css 2186 Use article.css for article related css
@@ -2201,7 +2201,7 @@ div#activation_enterprise { @@ -2201,7 +2201,7 @@ div#activation_enterprise {
2201 div#activation_enterprise label, div#activation_enterprise input, div#activation_enterprise div { 2201 div#activation_enterprise label, div#activation_enterprise input, div#activation_enterprise div {
2202 display: inline 2202 display: inline
2203 } 2203 }
2204 -/* ==> blocks/slideshow-block.css <<= */ 2204 +/* ==> blocks/slideshow-block.css <<= */
2205 2205
2206 .slideshow-block .slideshow-container { 2206 .slideshow-block .slideshow-container {
2207 margin-bottom: 10px; 2207 margin-bottom: 10px;
@@ -2266,7 +2266,7 @@ div#activation_enterprise label, div#activation_enterprise input, div#activation @@ -2266,7 +2266,7 @@ div#activation_enterprise label, div#activation_enterprise input, div#activation
2266 display: inline-block; 2266 display: inline-block;
2267 width: 16px; 2267 width: 16px;
2268 } 2268 }
2269 -/* ==> blocks/products-block.css <<= */ 2269 +/* ==> blocks/products-block.css <<= */
2270 2270
2271 .products-block ul { 2271 .products-block ul {
2272 margin: 0px; 2272 margin: 0px;
@@ -2299,7 +2299,7 @@ div#activation_enterprise label, div#activation_enterprise input, div#activation @@ -2299,7 +2299,7 @@ div#activation_enterprise label, div#activation_enterprise input, div#activation
2299 #content .products-block li a:hover { 2299 #content .products-block li a:hover {
2300 color: #fff; 2300 color: #fff;
2301 } 2301 }
2302 -/* ==> blocks/blog-archives-block.css <<= */ 2302 +/* ==> blocks/blog-archives-block.css <<= */
2303 2303
2304 #content .blog-archives-block { 2304 #content .blog-archives-block {
2305 padding: 10px 0px 10px 10px; 2305 padding: 10px 0px 10px 10px;
@@ -2319,7 +2319,7 @@ div#activation_enterprise label, div#activation_enterprise input, div#activation @@ -2319,7 +2319,7 @@ div#activation_enterprise label, div#activation_enterprise input, div#activation
2319 padding: 5px 0px 10px 10px; 2319 padding: 5px 0px 10px 10px;
2320 font-size: 12px; 2320 font-size: 12px;
2321 } 2321 }
2322 -/* ==> blocks/profile-info-block.css <<= */ 2322 +/* ==> blocks/profile-info-block.css <<= */
2323 2323
2324 2324
2325 .profile-info-block h2 { 2325 .profile-info-block h2 {
@@ -2422,7 +2422,7 @@ div#activation_enterprise label, div#activation_enterprise input, div#activation @@ -2422,7 +2422,7 @@ div#activation_enterprise label, div#activation_enterprise input, div#activation
2422 margin: 0px 0px 5px 0px; 2422 margin: 0px 0px 5px 0px;
2423 padding: 2px; 2423 padding: 2px;
2424 } 2424 }
2425 -/* ==> blocks/location-block.css <<= */ 2425 +/* ==> blocks/location-block.css <<= */
2426 2426
2427 .location-block { 2427 .location-block {
2428 text-align: center; 2428 text-align: center;
@@ -2435,7 +2435,7 @@ div#activation_enterprise label, div#activation_enterprise input, div#activation @@ -2435,7 +2435,7 @@ div#activation_enterprise label, div#activation_enterprise input, div#activation
2435 background: #FFF; 2435 background: #FFF;
2436 border: 1px solid #888; 2436 border: 1px solid #888;
2437 } 2437 }
2438 -/* ==> blocks/profile-image-block.css <<= */ 2438 +/* ==> blocks/profile-image-block.css <<= */
2439 2439
2440 2440
2441 .profile-image-block { 2441 .profile-image-block {
@@ -2470,7 +2470,7 @@ div#activation_enterprise label, div#activation_enterprise input, div#activation @@ -2470,7 +2470,7 @@ div#activation_enterprise label, div#activation_enterprise input, div#activation
2470 list-style: none; 2470 list-style: none;
2471 margin-bottom: 8px; 2471 margin-bottom: 8px;
2472 } 2472 }
2473 -/* ==> blocks/sellers-search-block.css <<= */ 2473 +/* ==> blocks/sellers-search-block.css <<= */
2474 2474
2475 2475
2476 #content .sellers-search-block { 2476 #content .sellers-search-block {
@@ -2529,7 +2529,7 @@ div#activation_enterprise label, div#activation_enterprise input, div#activation @@ -2529,7 +2529,7 @@ div#activation_enterprise label, div#activation_enterprise input, div#activation
2529 margin: 0px; 2529 margin: 0px;
2530 float: none; 2530 float: none;
2531 } 2531 }
2532 -/* ==> blocks/feed-reader-block.css <<= */ 2532 +/* ==> blocks/feed-reader-block.css <<= */
2533 2533
2534 #content .feed-reader-block { 2534 #content .feed-reader-block {
2535 padding: 10px 0px 10px 10px; 2535 padding: 10px 0px 10px 10px;
@@ -3288,6 +3288,52 @@ table.cms-articles .icon:hover { @@ -3288,6 +3288,52 @@ table.cms-articles .icon:hover {
3288 background-color: transparent; 3288 background-color: transparent;
3289 } 3289 }
3290 3290
  3291 +.select-publish-target {
  3292 + margin: 10px 10px 0px 10px;
  3293 +}
  3294 +
  3295 +.publish-targets {
  3296 + padding: 10px;
  3297 + margin: 0px;
  3298 +}
  3299 +
  3300 +.publish-targets>li {
  3301 + list-style: none;
  3302 + padding: 10px 20px 5px 10px;
  3303 +}
  3304 +
  3305 +.publish-targets li.mouseover {
  3306 + background-color: #eeeeec;
  3307 +}
  3308 +
  3309 +.publish-targets div.publish-article-title, .publish-targets .description {
  3310 + width: 384px;
  3311 + margin-top: 2px;
  3312 +}
  3313 +
  3314 +.publish-targets div.publish-article-title .collapsed {
  3315 + background-image: url("../images/icons-task/closed-arrow-hover.png");
  3316 + background-repeat: no-repeat;
  3317 + background-position: 3px 0;
  3318 +}
  3319 +
  3320 +.publish-targets div.publish-article-title .expanded {
  3321 + background-image: url("../images/icons-task/opened-arrow-hover.png");
  3322 + background-repeat: no-repeat;
  3323 + background-position: 3px 0;
  3324 +}
  3325 +
  3326 +.publish-targets div.publish-article-title label {
  3327 + padding-left: 20px;
  3328 +}
  3329 +
  3330 +.publish-targets div.publish-article-title input {
  3331 + width: 100%;
  3332 + border: 1px solid #999;
  3333 + padding: 3px 8px;
  3334 + margin-bottom: 2px;
  3335 +}
  3336 +
3291 .select-article-type { 3337 .select-article-type {
3292 padding: 5px 20px; 3338 padding: 5px 20px;
3293 width: 455px; 3339 width: 455px;
@@ -6689,7 +6735,7 @@ li.profile-activity-item.upload_image .activity-gallery-images-count-1 img { @@ -6689,7 +6735,7 @@ li.profile-activity-item.upload_image .activity-gallery-images-count-1 img {
6689 6735
6690 /* AutoComplete*/ 6736 /* AutoComplete*/
6691 .formfield input.ui-autocomplete-loading { background: url('/images/loading-small.gif') right center no-repeat, url("../images/input-bg.gif") no-repeat left top; } 6737 .formfield input.ui-autocomplete-loading { background: url('/images/loading-small.gif') right center no-repeat, url("../images/input-bg.gif") no-repeat left top; }
6692 - 6738 +
6693 .ui-autocomplete-category { 6739 .ui-autocomplete-category {
6694 font-weight: bold; 6740 font-weight: bold;
6695 padding: .2em .4em; 6741 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