Commit 6e53d8be9a1b6790ac4cf474d996556f279befd0
Exists in
master
and in
29 other branches
Merge remote-tracking branch 'larissa/share' into stoa
Showing
9 changed files
with
179 additions
and
77 deletions
Show diff stats
app/controllers/my_profile/cms_controller.rb
| ... | ... | @@ -238,25 +238,48 @@ class CmsController < MyProfileController |
| 238 | 238 | render :template => 'shared/update_categories', :locals => { :category => @current_category, :object_name => 'article' } |
| 239 | 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 | 245 | def publish |
| 242 | 246 | @article = profile.articles.find(params[:id]) |
| 247 | + @portal_enabled = environment.portal_community && environment.enabled?('use_portal_community') | |
| 243 | 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 | 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 | 270 | if request.post? |
| 271 | + @back_to = params[:back_to] | |
| 272 | + @article = profile.articles.find(params[:id]) | |
| 253 | 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 | 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 | 279 | begin |
| 257 | - task.finish unless item[:group].moderated_articles? | |
| 280 | + task.finish unless item.moderated_articles? | |
| 258 | 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 | 283 | end |
| 261 | 284 | end |
| 262 | 285 | if @failed.blank? |
| ... | ... | @@ -271,9 +294,9 @@ class CmsController < MyProfileController |
| 271 | 294 | end |
| 272 | 295 | |
| 273 | 296 | def publish_on_portal_community |
| 274 | - @article = profile.articles.find(params[:id]) | |
| 275 | 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 | 300 | task = ApproveArticle.create!(:article => @article, :name => params[:name], :target => environment.portal_community, :requestor => user) |
| 278 | 301 | begin |
| 279 | 302 | task.finish unless environment.portal_community.moderated_articles? | ... | ... |
app/helpers/cms_helper.rb
| ... | ... | @@ -40,11 +40,9 @@ module CmsHelper |
| 40 | 40 | end |
| 41 | 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 | 46 | end |
| 49 | 47 | end |
| 50 | 48 | ... | ... |
app/helpers/token_helper.rb
| ... | ... | @@ -12,6 +12,7 @@ module TokenHelper |
| 12 | 12 | options[:search_delay] ||= 1000 |
| 13 | 13 | options[:prevent_duplicates] ||= true |
| 14 | 14 | options[:backspace_delete_item] ||= false |
| 15 | + options[:zindex] ||= 999 | |
| 15 | 16 | options[:focus] ||= false |
| 16 | 17 | options[:avoid_enter] ||= true |
| 17 | 18 | options[:on_result] ||= 'null' |
| ... | ... | @@ -30,6 +31,7 @@ module TokenHelper |
| 30 | 31 | searchDelay: #{options[:search_delay].to_json}, |
| 31 | 32 | preventDuplicates: #{options[:prevent_duplicates].to_json}, |
| 32 | 33 | backspaceDeleteItem: #{options[:backspace_delete_item].to_json}, |
| 34 | + zindex: #{options[:zindex].to_json}, | |
| 33 | 35 | queryParam: #{name.to_json}, |
| 34 | 36 | tokenLimit: #{options[:token_limit].to_json}, |
| 35 | 37 | onResult: #{options[:on_result]}, |
| ... | ... | @@ -48,4 +50,4 @@ module TokenHelper |
| 48 | 50 | result |
| 49 | 51 | end |
| 50 | 52 | |
| 51 | -end | |
| 52 | 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 | 18 | <% if !@failed.blank? %> |
| 4 | 19 | <div class="errorExplanation" id="errorExplanation"> |
| ... | ... | @@ -14,15 +29,57 @@ |
| 14 | 29 | </div> |
| 15 | 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 | 80 | <% end %> |
| 81 | + </li> | |
| 28 | 82 | <% end %> |
| 83 | +</ul> | |
| 84 | + | |
| 85 | +</div> | ... | ... |
app/views/cms/view.html.erb
| ... | ... | @@ -66,7 +66,7 @@ |
| 66 | 66 | <td class="article-controls"> |
| 67 | 67 | <%= expirable_button article, :edit, _('Edit'), {:action => 'edit', :id => article.id} if !remove_content_button(:edit) %> |
| 68 | 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 | 70 | <% if !environment.enabled?('cant_change_homepage') && !remove_content_button(:home) %> |
| 71 | 71 | <% if profile.home_page != article %> |
| 72 | 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 | <%= expirable_button @page, :delete, content, url, options %> |
| 16 | 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 | 21 | <% end %> |
| 28 | 22 | |
| 29 | 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 | 35 | onAdd: null, |
| 36 | 36 | onDelete: null, |
| 37 | 37 | idPrefix: "token-input-", |
| 38 | + zindex: 999, | |
| 38 | 39 | backspaceDeleteItem: true |
| 39 | 40 | }; |
| 40 | 41 | |
| ... | ... | @@ -628,7 +629,7 @@ $.TokenList = function (input, url_or_data, options) { |
| 628 | 629 | position: "absolute", |
| 629 | 630 | top: $(token_list).offset().top + $(token_list).outerHeight(), |
| 630 | 631 | left: $(token_list).offset().left, |
| 631 | - zindex: 999 | |
| 632 | + 'z-index': settings.zindex | |
| 632 | 633 | }).show(); |
| 633 | 634 | else |
| 634 | 635 | dropdown.css({ | ... | ... |
public/stylesheets/application.css
| ... | ... | @@ -2159,7 +2159,7 @@ a.button.disabled, input.disabled { |
| 2159 | 2159 | .recent-documents-block .block-footer-content a:hover { |
| 2160 | 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 | 2165 | .disabled-enterprise-message-block { |
| ... | ... | @@ -2175,12 +2175,12 @@ a.button.disabled, input.disabled { |
| 2175 | 2175 | font-size: 80%; |
| 2176 | 2176 | background: #ffffa9; |
| 2177 | 2177 | } |
| 2178 | -/* ==> blocks/article-block.css <<= */ | |
| 2178 | +/* ==> blocks/article-block.css <<= */ | |
| 2179 | 2179 | |
| 2180 | 2180 | .article-block { |
| 2181 | 2181 | overflow: hidden; |
| 2182 | 2182 | } |
| 2183 | -/* ==> blocks/main-block.css <<= */ | |
| 2183 | +/* ==> blocks/main-block.css <<= */ | |
| 2184 | 2184 | |
| 2185 | 2185 | /* |
| 2186 | 2186 | Use article.css for article related css |
| ... | ... | @@ -2201,7 +2201,7 @@ div#activation_enterprise { |
| 2201 | 2201 | div#activation_enterprise label, div#activation_enterprise input, div#activation_enterprise div { |
| 2202 | 2202 | display: inline |
| 2203 | 2203 | } |
| 2204 | -/* ==> blocks/slideshow-block.css <<= */ | |
| 2204 | +/* ==> blocks/slideshow-block.css <<= */ | |
| 2205 | 2205 | |
| 2206 | 2206 | .slideshow-block .slideshow-container { |
| 2207 | 2207 | margin-bottom: 10px; |
| ... | ... | @@ -2266,7 +2266,7 @@ div#activation_enterprise label, div#activation_enterprise input, div#activation |
| 2266 | 2266 | display: inline-block; |
| 2267 | 2267 | width: 16px; |
| 2268 | 2268 | } |
| 2269 | -/* ==> blocks/products-block.css <<= */ | |
| 2269 | +/* ==> blocks/products-block.css <<= */ | |
| 2270 | 2270 | |
| 2271 | 2271 | .products-block ul { |
| 2272 | 2272 | margin: 0px; |
| ... | ... | @@ -2299,7 +2299,7 @@ div#activation_enterprise label, div#activation_enterprise input, div#activation |
| 2299 | 2299 | #content .products-block li a:hover { |
| 2300 | 2300 | color: #fff; |
| 2301 | 2301 | } |
| 2302 | -/* ==> blocks/blog-archives-block.css <<= */ | |
| 2302 | +/* ==> blocks/blog-archives-block.css <<= */ | |
| 2303 | 2303 | |
| 2304 | 2304 | #content .blog-archives-block { |
| 2305 | 2305 | padding: 10px 0px 10px 10px; |
| ... | ... | @@ -2319,7 +2319,7 @@ div#activation_enterprise label, div#activation_enterprise input, div#activation |
| 2319 | 2319 | padding: 5px 0px 10px 10px; |
| 2320 | 2320 | font-size: 12px; |
| 2321 | 2321 | } |
| 2322 | -/* ==> blocks/profile-info-block.css <<= */ | |
| 2322 | +/* ==> blocks/profile-info-block.css <<= */ | |
| 2323 | 2323 | |
| 2324 | 2324 | |
| 2325 | 2325 | .profile-info-block h2 { |
| ... | ... | @@ -2422,7 +2422,7 @@ div#activation_enterprise label, div#activation_enterprise input, div#activation |
| 2422 | 2422 | margin: 0px 0px 5px 0px; |
| 2423 | 2423 | padding: 2px; |
| 2424 | 2424 | } |
| 2425 | -/* ==> blocks/location-block.css <<= */ | |
| 2425 | +/* ==> blocks/location-block.css <<= */ | |
| 2426 | 2426 | |
| 2427 | 2427 | .location-block { |
| 2428 | 2428 | text-align: center; |
| ... | ... | @@ -2435,7 +2435,7 @@ div#activation_enterprise label, div#activation_enterprise input, div#activation |
| 2435 | 2435 | background: #FFF; |
| 2436 | 2436 | border: 1px solid #888; |
| 2437 | 2437 | } |
| 2438 | -/* ==> blocks/profile-image-block.css <<= */ | |
| 2438 | +/* ==> blocks/profile-image-block.css <<= */ | |
| 2439 | 2439 | |
| 2440 | 2440 | |
| 2441 | 2441 | .profile-image-block { |
| ... | ... | @@ -2470,7 +2470,7 @@ div#activation_enterprise label, div#activation_enterprise input, div#activation |
| 2470 | 2470 | list-style: none; |
| 2471 | 2471 | margin-bottom: 8px; |
| 2472 | 2472 | } |
| 2473 | -/* ==> blocks/sellers-search-block.css <<= */ | |
| 2473 | +/* ==> blocks/sellers-search-block.css <<= */ | |
| 2474 | 2474 | |
| 2475 | 2475 | |
| 2476 | 2476 | #content .sellers-search-block { |
| ... | ... | @@ -2529,7 +2529,7 @@ div#activation_enterprise label, div#activation_enterprise input, div#activation |
| 2529 | 2529 | margin: 0px; |
| 2530 | 2530 | float: none; |
| 2531 | 2531 | } |
| 2532 | -/* ==> blocks/feed-reader-block.css <<= */ | |
| 2532 | +/* ==> blocks/feed-reader-block.css <<= */ | |
| 2533 | 2533 | |
| 2534 | 2534 | #content .feed-reader-block { |
| 2535 | 2535 | padding: 10px 0px 10px 10px; |
| ... | ... | @@ -3288,6 +3288,52 @@ table.cms-articles .icon:hover { |
| 3288 | 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 | 3337 | .select-article-type { |
| 3292 | 3338 | padding: 5px 20px; |
| 3293 | 3339 | width: 455px; |
| ... | ... | @@ -6689,7 +6735,7 @@ li.profile-activity-item.upload_image .activity-gallery-images-count-1 img { |
| 6689 | 6735 | |
| 6690 | 6736 | /* AutoComplete*/ |
| 6691 | 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 | 6739 | .ui-autocomplete-category { |
| 6694 | 6740 | font-weight: bold; |
| 6695 | 6741 | padding: .2em .4em; | ... | ... |
test/unit/cms_helper_test.rb
| ... | ... | @@ -48,41 +48,22 @@ class CmsHelperTest < ActionView::TestCase |
| 48 | 48 | result = link_to_article(file) |
| 49 | 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 | 52 | plugins.stubs(:dispatch).returns([]) |
| 53 | 53 | profile = fast_create(Person) |
| 54 | 54 | article = fast_create(TinyMceArticle, :name => 'My article', :profile_id => profile.id) |
| 55 | 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 | 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 | 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 | 67 | end |
| 87 | 68 | |
| 88 | 69 | should 'display delete_button to folder' do | ... | ... |