Commit 68426a088554d39a7706db77d5478491b71b8544

Authored by Joenio Costa
2 parents 127a5cd0 67fdc2f1

Merge branch 'master' into AI2694-network_activity_email

app/controllers/my_profile/cms_controller.rb
@@ -24,10 +24,16 @@ class CmsController < MyProfileController @@ -24,10 +24,16 @@ class CmsController < MyProfileController
24 (user && (user.has_permission?('post_content', profile) || user.has_permission?('publish_content', profile))) 24 (user && (user.has_permission?('post_content', profile) || user.has_permission?('publish_content', profile)))
25 end 25 end
26 26
27 - protect_if :except => [:suggest_an_article, :set_home_page, :edit, :destroy, :publish, :upload_files] do |c, user, profile| 27 + protect_if :except => [:suggest_an_article, :set_home_page, :edit, :destroy, :publish, :upload_files, :new] do |c, user, profile|
28 user && (user.has_permission?('post_content', profile) || user.has_permission?('publish_content', profile)) 28 user && (user.has_permission?('post_content', profile) || user.has_permission?('publish_content', profile))
29 end 29 end
30 30
  31 + protect_if :only => :new do |c, user, profile|
  32 + article = profile.articles.find_by_id(c.params[:parent_id])
  33 + (!article.nil? && (article.allow_create?(user) || article.parent.allow_create?(user))) ||
  34 + (user && (user.has_permission?('post_content', profile) || user.has_permission?('publish_content', profile)))
  35 + end
  36 +
31 protect_if :only => [:destroy, :publish] do |c, user, profile| 37 protect_if :only => [:destroy, :publish] do |c, user, profile|
32 profile.articles.find(c.params[:id]).allow_post_content?(user) 38 profile.articles.find(c.params[:id]).allow_post_content?(user)
33 end 39 end
app/controllers/public/account_controller.rb
@@ -69,6 +69,8 @@ class AccountController < ApplicationController @@ -69,6 +69,8 @@ class AccountController < ApplicationController
69 session[:notice] = _("This environment doesn't allow user registration.") 69 session[:notice] = _("This environment doesn't allow user registration.")
70 end 70 end
71 71
  72 + store_location(request.referer) unless params[:return_to] or session[:return_to]
  73 +
72 @block_bot = !!session[:may_be_a_bot] 74 @block_bot = !!session[:may_be_a_bot]
73 @invitation_code = params[:invitation_code] 75 @invitation_code = params[:invitation_code]
74 begin 76 begin
@@ -77,6 +79,7 @@ class AccountController < ApplicationController @@ -77,6 +79,7 @@ class AccountController < ApplicationController
77 @user.environment = environment 79 @user.environment = environment
78 @terms_of_use = environment.terms_of_use 80 @terms_of_use = environment.terms_of_use
79 @user.person_data = params[:profile_data] 81 @user.person_data = params[:profile_data]
  82 + @user.return_to = session[:return_to]
80 @person = Person.new(params[:profile_data]) 83 @person = Person.new(params[:profile_data])
81 @person.environment = @user.environment 84 @person.environment = @user.environment
82 if request.post? 85 if request.post?
@@ -98,7 +101,7 @@ class AccountController < ApplicationController @@ -98,7 +101,7 @@ class AccountController < ApplicationController
98 end 101 end
99 if @user.activated? 102 if @user.activated?
100 self.current_user = @user 103 self.current_user = @user
101 - redirect_to '/' 104 + go_to_signup_initial_page
102 else 105 else
103 @register_pending = true 106 @register_pending = true
104 end 107 end
@@ -368,32 +371,29 @@ class AccountController < ApplicationController @@ -368,32 +371,29 @@ class AccountController < ApplicationController
368 end 371 end
369 372
370 def go_to_initial_page 373 def go_to_initial_page
  374 + if params[:redirection]
  375 + session[:return_to] = @user.return_to
  376 + @user.return_to = nil
  377 + @user.save
  378 + end
  379 +
371 if params[:return_to] 380 if params[:return_to]
372 redirect_to params[:return_to] 381 redirect_to params[:return_to]
373 elsif environment.enabled?('allow_change_of_redirection_after_login') 382 elsif environment.enabled?('allow_change_of_redirection_after_login')
374 - case user.preferred_login_redirection  
375 - when 'keep_on_same_page'  
376 - redirect_back_or_default(user.admin_url)  
377 - when 'site_homepage'  
378 - redirect_to :controller => :home  
379 - when 'user_profile_page'  
380 - redirect_to user.public_profile_url  
381 - when 'user_homepage'  
382 - redirect_to user.url  
383 - when 'user_control_panel'  
384 - redirect_to user.admin_url  
385 - else  
386 - redirect_back_or_default(user.admin_url)  
387 - end 383 + check_redirection_options(user, user.preferred_login_redirection, user.admin_url)
388 else 384 else
389 if environment == current_user.environment 385 if environment == current_user.environment
390 - redirect_back_or_default(user.admin_url) 386 + check_redirection_options(user, environment.redirection_after_login, user.admin_url)
391 else 387 else
392 redirect_back_or_default(:controller => 'home') 388 redirect_back_or_default(:controller => 'home')
393 end 389 end
394 end 390 end
395 end 391 end
396 392
  393 + def go_to_signup_initial_page
  394 + check_redirection_options(user, user.environment.redirection_after_signup, user.url)
  395 + end
  396 +
397 def redirect_if_logged_in 397 def redirect_if_logged_in
398 if logged_in? 398 if logged_in?
399 go_to_initial_page 399 go_to_initial_page
@@ -409,4 +409,22 @@ class AccountController < ApplicationController @@ -409,4 +409,22 @@ class AccountController < ApplicationController
409 user 409 user
410 end 410 end
411 411
  412 + protected
  413 +
  414 + def check_redirection_options(user, condition, default)
  415 + case condition
  416 + when 'keep_on_same_page'
  417 + redirect_back_or_default(user.admin_url)
  418 + when 'site_homepage'
  419 + redirect_to :controller => :home
  420 + when 'user_profile_page'
  421 + redirect_to user.public_profile_url
  422 + when 'user_homepage'
  423 + redirect_to user.url
  424 + when 'user_control_panel'
  425 + redirect_to user.admin_url
  426 + else
  427 + redirect_back_or_default(default)
  428 + end
  429 + end
412 end 430 end
app/helpers/application_helper.rb
@@ -889,12 +889,11 @@ module ApplicationHelper @@ -889,12 +889,11 @@ module ApplicationHelper
889 889
890 def page_title 890 def page_title
891 (@page ? @page.title + ' - ' : '') + 891 (@page ? @page.title + ' - ' : '') +
892 - (profile ? profile.short_name + ' - ' : '') +  
893 (@topic ? @topic.title + ' - ' : '') + 892 (@topic ? @topic.title + ' - ' : '') +
894 (@section ? @section.title + ' - ' : '') + 893 (@section ? @section.title + ' - ' : '') +
895 (@toc ? _('Online Manual') + ' - ' : '') + 894 (@toc ? _('Online Manual') + ' - ' : '') +
896 (@controller.controller_name == 'chat' ? _('Chat') + ' - ' : '') + 895 (@controller.controller_name == 'chat' ? _('Chat') + ' - ' : '') +
897 - environment.name + 896 + (profile ? profile.short_name : environment.name) +
898 (@category ? " - #{@category.full_name}" : '') 897 (@category ? " - #{@category.full_name}" : '')
899 end 898 end
900 899
app/helpers/article_helper.rb
@@ -49,8 +49,14 @@ module ArticleHelper @@ -49,8 +49,14 @@ module ArticleHelper
49 'div', 49 'div',
50 check_box(:article, :display_versions) + 50 check_box(:article, :display_versions) +
51 content_tag('label', _('I want this article to display a link to older versions'), :for => 'article_display_versions') 51 content_tag('label', _('I want this article to display a link to older versions'), :for => 'article_display_versions')
52 - ) : '') 52 + ) : '') +
53 53
  54 + (article.forum? && article.profile.community? ?
  55 + content_tag(
  56 + 'div',
  57 + check_box(:article, :allows_members_to_create_topics) +
  58 + content_tag('label', _('Allow members to create topics'), :for => 'article_allows_members_to_create_topics')
  59 + ) : '')
54 ) 60 )
55 end 61 end
56 62
app/helpers/content_viewer_helper.rb
@@ -52,15 +52,6 @@ module ContentViewerHelper @@ -52,15 +52,6 @@ module ContentViewerHelper
52 end 52 end
53 end 53 end
54 54
55 - def addthis_facebook_url(article)  
56 - "http://www.facebook.com/sharer.php?s=100&p[title]=%{title}&p[summary]=%{summary}&p[url]=%{url}&p[images][0]=%{image}" % {  
57 - :title => CGI.escape(article.title),  
58 - :url => CGI.escape(url_for(article.url)),  
59 - :summary => CGI.escape(truncate(strip_tags(article.body.to_s), :length => 300)),  
60 - :image => CGI.escape(article.body_images_paths.first.to_s)  
61 - }  
62 - end  
63 -  
64 def addthis_image_tag 55 def addthis_image_tag
65 if File.exists?(File.join(Rails.root, 'public', theme_path, 'images', 'addthis.gif')) 56 if File.exists?(File.join(Rails.root, 'public', theme_path, 'images', 'addthis.gif'))
66 image_tag(File.join(theme_path, 'images', 'addthis.gif'), :border => 0, :alt => '') 57 image_tag(File.join(theme_path, 'images', 'addthis.gif'), :border => 0, :alt => '')
app/helpers/layout_helper.rb
@@ -90,5 +90,8 @@ module LayoutHelper @@ -90,5 +90,8 @@ module LayoutHelper
90 end 90 end
91 end 91 end
92 92
  93 + def meta_description_tag(article=nil)
  94 + article ? truncate(strip_tags(article.body.to_s), :length => 200) : environment.name
  95 + end
93 end 96 end
94 97
app/models/environment.rb
@@ -145,6 +145,18 @@ class Environment < ActiveRecord::Base @@ -145,6 +145,18 @@ class Environment < ActiveRecord::Base
145 end 145 end
146 validates_inclusion_of :redirection_after_login, :in => Environment.login_redirection_options.keys, :allow_nil => true 146 validates_inclusion_of :redirection_after_login, :in => Environment.login_redirection_options.keys, :allow_nil => true
147 147
  148 + def self.signup_redirection_options
  149 + {
  150 + 'keep_on_same_page' => _('Stays on the same page the user was before signup.'),
  151 + 'site_homepage' => _('Redirects the user to the environment homepage.'),
  152 + 'user_profile_page' => _('Redirects the user to his profile page.'),
  153 + 'user_homepage' => _('Redirects the user to his homepage.'),
  154 + 'user_control_panel' => _('Redirects the user to his control panel.')
  155 + }
  156 + end
  157 + validates_inclusion_of :redirection_after_signup, :in => Environment.signup_redirection_options.keys, :allow_nil => true
  158 +
  159 +
148 # ################################################# 160 # #################################################
149 # Relationships and applied behaviour 161 # Relationships and applied behaviour
150 # ################################################# 162 # #################################################
app/models/forum.rb
@@ -5,6 +5,7 @@ class Forum < Folder @@ -5,6 +5,7 @@ class Forum < Folder
5 5
6 settings_items :terms_of_use, :type => :string, :default => "" 6 settings_items :terms_of_use, :type => :string, :default => ""
7 settings_items :has_terms_of_use, :type => :boolean, :default => false 7 settings_items :has_terms_of_use, :type => :boolean, :default => false
  8 + settings_items :allows_members_to_create_topics, :type => :boolean, :default => false
8 has_and_belongs_to_many :users_with_agreement, :class_name => 'Person', :join_table => 'terms_forum_people' 9 has_and_belongs_to_many :users_with_agreement, :class_name => 'Person', :join_table => 'terms_forum_people'
9 10
10 before_save do |forum| 11 before_save do |forum|
@@ -66,4 +67,11 @@ class Forum < Folder @@ -66,4 +67,11 @@ class Forum < Folder
66 self.users_with_agreement.exists? user 67 self.users_with_agreement.exists? user
67 end 68 end
68 69
  70 + def can_create_topic?(user, profile)
  71 + return profile.community? && profile.members.include?(user) && self.allows_members_to_create_topics
  72 + end
  73 +
  74 + def allow_create?(user)
  75 + super || can_create_topic?(user, profile)
  76 + end
69 end 77 end
app/models/user.rb
@@ -71,7 +71,8 @@ class User < ActiveRecord::Base @@ -71,7 +71,8 @@ class User < ActiveRecord::Base
71 body :recipient => user.name, 71 body :recipient => user.name,
72 :activation_code => user.activation_code, 72 :activation_code => user.activation_code,
73 :environment => user.environment.name, 73 :environment => user.environment.name,
74 - :url => user.environment.top_url 74 + :url => user.environment.top_url,
  75 + :redirection => (true if user.return_to)
75 end 76 end
76 77
77 def signup_welcome_email(user) 78 def signup_welcome_email(user)
@@ -93,7 +94,7 @@ class User < ActiveRecord::Base @@ -93,7 +94,7 @@ class User < ActiveRecord::Base
93 self.person.save! 94 self.person.save!
94 end 95 end
95 end 96 end
96 - 97 +
97 has_one :person, :dependent => :destroy 98 has_one :person, :dependent => :destroy
98 belongs_to :environment 99 belongs_to :environment
99 100
@@ -183,7 +184,7 @@ class User < ActiveRecord::Base @@ -183,7 +184,7 @@ class User < ActiveRecord::Base
183 encryption_methods[sym] = block 184 encryption_methods[sym] = block
184 end 185 end
185 186
186 - # the encryption method used for this instance 187 + # the encryption method used for this instance
187 def encryption_method 188 def encryption_method
188 (password_type || User.system_encryption_method).to_sym 189 (password_type || User.system_encryption_method).to_sym
189 end 190 end
@@ -226,7 +227,7 @@ class User < ActiveRecord::Base @@ -226,7 +227,7 @@ class User < ActiveRecord::Base
226 end 227 end
227 228
228 def remember_token? 229 def remember_token?
229 - remember_token_expires_at && Time.now.utc < remember_token_expires_at 230 + remember_token_expires_at && Time.now.utc < remember_token_expires_at
230 end 231 end
231 232
232 # These create and unset the fields required for remembering users between browser closes 233 # These create and unset the fields required for remembering users between browser closes
@@ -255,7 +256,7 @@ class User &lt; ActiveRecord::Base @@ -255,7 +256,7 @@ class User &lt; ActiveRecord::Base
255 raise IncorrectPassword unless self.authenticated?(current) 256 raise IncorrectPassword unless self.authenticated?(current)
256 self.force_change_password!(new, confirmation) 257 self.force_change_password!(new, confirmation)
257 end 258 end
258 - 259 +
259 # Changes the password of a user without asking for the old password. This 260 # Changes the password of a user without asking for the old password. This
260 # method is intended to be used by the "I forgot my password", and must be 261 # method is intended to be used by the "I forgot my password", and must be
261 # used with care. 262 # used with care.
@@ -326,7 +327,7 @@ class User &lt; ActiveRecord::Base @@ -326,7 +327,7 @@ class User &lt; ActiveRecord::Base
326 end 327 end
327 328
328 protected 329 protected
329 - # before filter 330 + # before filter
330 def encrypt_password 331 def encrypt_password
331 return if password.blank? 332 return if password.blank?
332 self.salt ||= Digest::SHA1.hexdigest("--#{Time.now.to_s}--#{login}--") if new_record? 333 self.salt ||= Digest::SHA1.hexdigest("--#{Time.now.to_s}--#{login}--") if new_record?
app/views/content_viewer/_addthis.rhtml 0 → 100644
@@ -0,0 +1,8 @@ @@ -0,0 +1,8 @@
  1 +<div id="addThis">
  2 + <script type="text/javascript">
  3 + addthis_pub = '<%= escape_javascript( NOOSFERO_CONF['addthis_pub'] ) %>';
  4 + addthis_logo = '<%= escape_javascript( NOOSFERO_CONF['addthis_logo'] ) %>';
  5 + addthis_options = '<%= escape_javascript( NOOSFERO_CONF['addthis_options'] ) %>';
  6 + </script>
  7 + <a href="http://www.addthis.com/bookmark.php" id="bt_addThis" target="_blank" onmouseover="return addthis_open(this, '', '[URL]')" onmouseout="addthis_close()" onclick="return addthis_sendto()"><%= addthis_image_tag %></a>
  8 +</div>
app/views/content_viewer/_article_toolbar.rhtml
@@ -26,7 +26,7 @@ @@ -26,7 +26,7 @@
26 <%= expirable_button @page, :spread, content, url if url %> 26 <%= expirable_button @page, :spread, content, url if url %>
27 <% end %> 27 <% end %>
28 28
29 - <% if !@page.gallery? && @page.allow_create?(user) %> 29 + <% if !@page.gallery? && (@page.allow_create?(user) || (@page.parent && @page.parent.allow_create?(user))) %>
30 <% if @page.translatable? && !@page.native_translation.language.blank? && !remove_content_button(:locale) %> 30 <% if @page.translatable? && !@page.native_translation.language.blank? && !remove_content_button(:locale) %>
31 <% content = _('Add translation') %> 31 <% content = _('Add translation') %>
32 <% parent_id = (@page.folder? ? @page : (@page.parent.nil? ? nil : @page.parent)) %> 32 <% parent_id = (@page.folder? ? @page : (@page.parent.nil? ? nil : @page.parent)) %>
app/views/content_viewer/view_page.rhtml
@@ -43,21 +43,7 @@ @@ -43,21 +43,7 @@
43 <%= render :partial => 'shared/disabled_enterprise' %> 43 <%= render :partial => 'shared/disabled_enterprise' %>
44 44
45 <% if NOOSFERO_CONF['addthis_enabled'] %> 45 <% if NOOSFERO_CONF['addthis_enabled'] %>
46 -<div id="addThis">  
47 -<script type="text/javascript">  
48 - addthis_pub = '<%= escape_javascript( NOOSFERO_CONF['addthis_pub'] ) %>';  
49 - addthis_logo = '<%= escape_javascript( NOOSFERO_CONF['addthis_logo'] ) %>';  
50 - addthis_config = {  
51 - services_custom: {  
52 - name: 'Facebook',  
53 - url: '<%= addthis_facebook_url(@page) %>',  
54 - icon: 'http://cache.addthiscdn.com/icons/v1/thumbs/facebook.gif'  
55 - }  
56 - };  
57 - addthis_options = '<%= escape_javascript( NOOSFERO_CONF['addthis_options'] ) %>';  
58 -</script>  
59 -<a href="http://www.addthis.com/bookmark.php" id="bt_addThis" target="_blank" onmouseover="return addthis_open(this, '', '[URL]')" onmouseout="addthis_close()" onclick="return addthis_sendto()"><%= addthis_image_tag %></a>  
60 -</div> 46 + <%= render :partial => 'addthis' %>
61 <% end %> 47 <% end %>
62 48
63 <% cache(@page.cache_key(params, user, language)) do %> 49 <% cache(@page.cache_key(params, user, language)) do %>
app/views/features/index.rhtml
@@ -26,9 +26,13 @@ Check all the features you want to enable for your environment, uncheck all the @@ -26,9 +26,13 @@ Check all the features you want to enable for your environment, uncheck all the
26 26
27 <h2><%= _('Configure features') %></h2> 27 <h2><%= _('Configure features') %></h2>
28 28
  29 +<h3><%= _('Page to redirect after signup') %></h3>
  30 + <%= select 'environment', 'redirection_after_signup', Environment.signup_redirection_options.map{|key,value|[value,key]} %>
  31 +<hr/>
29 <h3><%= _('Page to redirect after login') %></h3> 32 <h3><%= _('Page to redirect after login') %></h3>
30 <%= select 'environment', 'redirection_after_login', Environment.login_redirection_options.map{|key,value|[value,key]} %> 33 <%= select 'environment', 'redirection_after_login', Environment.login_redirection_options.map{|key,value|[value,key]} %>
31 <hr/> 34 <hr/>
  35 +
32 <h3><%= _('Organization Approval Method') %></h3> 36 <h3><%= _('Organization Approval Method') %></h3>
33 <%= select_organization_approval_method('environment', 'organization_approval_method') %> 37 <%= select_organization_approval_method('environment', 'organization_approval_method') %>
34 <hr/> 38 <hr/>
app/views/layouts/application-ng.rhtml
@@ -6,6 +6,27 @@ @@ -6,6 +6,27 @@
6 <!--<meta http-equiv="refresh" content="1"/>--> 6 <!--<meta http-equiv="refresh" content="1"/>-->
7 <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/> 7 <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
8 <meta name="description" content="<%= @environment.name %>" /> 8 <meta name="description" content="<%= @environment.name %>" />
  9 +
  10 + <!-- Twitter Card -->
  11 + <meta name="twitter:card" value="summary">
  12 + <meta name="twitter:title" content="<%= h page_title %>">
  13 + <meta name="twitter:description" content="<%= meta_description_tag(@page) %>">
  14 +
  15 + <!-- Open Graph -->
  16 + <meta property="og:type" content="<%= @page ? 'article' : 'website' %>">
  17 + <meta property="og:url" content="<%= @page ? url_for(@page.url) : @environment.top_url %>">
  18 + <meta property="og:title" content="<%= h page_title %>">
  19 + <meta property="og:site_name" content="<%= profile ? profile.name : @environment.name %>">
  20 + <meta property="og:description" content="<%= @page ? truncate(strip_tags(@page.body.to_s), :length => 200) : @environment.name %>">
  21 +
  22 + <% if @page %>
  23 + <meta property="article:published_time" content="<%= show_date(@page.published_at) %>">
  24 + <% @page.body_images_paths.each do |img| %>
  25 + <meta name="twitter:image" content="<%= img.to_s %>">
  26 + <meta property="og:image" content="<%= img.to_s %>">
  27 + <% end %>
  28 + <% end %>
  29 +
9 <link rel="shortcut icon" href="<%= image_path(theme_favicon) %>" type="image/x-icon" /> 30 <link rel="shortcut icon" href="<%= image_path(theme_favicon) %>" type="image/x-icon" />
10 <%= noosfero_javascript %> 31 <%= noosfero_javascript %>
11 <%= noosfero_stylesheets %> 32 <%= noosfero_stylesheets %>
app/views/user/mailer/activation_code.rhtml
1 <%= _('Hi, %{recipient}!') % { :recipient => @recipient } %> 1 <%= _('Hi, %{recipient}!') % { :recipient => @recipient } %>
2 2
3 -<%= word_wrap(_('Welcome to %{environment}! To activate your account, follow the link: %{activation_url}') % { :environment => @environment, :activation_url => @url + url_for(:controller => :account, :action => :activate, :activation_code => @activation_code) }) %> 3 +<%= word_wrap(_('Welcome to %{environment}! To activate your account, follow the link: %{activation_url}') % { :environment => @environment, :activation_url => @url + url_for(:controller => :account, :action => :activate, :activation_code => @activation_code, :redirection => @redirection) }) %>
4 4
5 <%= _("Greetings,") %> 5 <%= _("Greetings,") %>
6 6
db/migrate/20140205191914_add_redirection_after_signup_to_environment.rb 0 → 100644
@@ -0,0 +1,9 @@ @@ -0,0 +1,9 @@
  1 +class AddRedirectionAfterSignupToEnvironment < ActiveRecord::Migration
  2 + def self.up
  3 + add_column :environments, :redirection_after_signup, :string, :default => 'keep_on_same_page'
  4 + end
  5 +
  6 + def self.down
  7 + remove_column :environments, :redirection_after_signup
  8 + end
  9 +end
db/migrate/20140312184749_add_return_to_to_users.rb 0 → 100644
@@ -0,0 +1,9 @@ @@ -0,0 +1,9 @@
  1 +class AddReturnToToUsers < ActiveRecord::Migration
  2 + def self.up
  3 + add_column :users, :return_to, :string
  4 + end
  5 +
  6 + def self.down
  7 + remove_column :users, :return_to, :string
  8 + end
  9 +end
1 -# This file is auto-generated from the current state of the database. Instead of editing this file, 1 +# This file is auto-generated from the current state of the database. Instead of editing this file,
2 # please use the migrations feature of Active Record to incrementally modify your database, and 2 # please use the migrations feature of Active Record to incrementally modify your database, and
3 # then regenerate this schema definition. 3 # then regenerate this schema definition.
4 # 4 #
@@ -9,7 +9,7 @@ @@ -9,7 +9,7 @@
9 # 9 #
10 # It's strongly recommended to check this file into your version control system. 10 # It's strongly recommended to check this file into your version control system.
11 11
12 -ActiveRecord::Schema.define(:version => 20140108132730) do 12 +ActiveRecord::Schema.define(:version => 20140312184749) do
13 13
14 create_table "abuse_reports", :force => true do |t| 14 create_table "abuse_reports", :force => true do |t|
15 t.integer "reporter_id" 15 t.integer "reporter_id"
@@ -282,6 +282,7 @@ ActiveRecord::Schema.define(:version =&gt; 20140108132730) do @@ -282,6 +282,7 @@ ActiveRecord::Schema.define(:version =&gt; 20140108132730) do
282 t.text "signup_welcome_text" 282 t.text "signup_welcome_text"
283 t.string "languages" 283 t.string "languages"
284 t.string "default_language" 284 t.string "default_language"
  285 + t.string "redirection_after_signup", :default => "keep_on_same_page"
285 end 286 end
286 287
287 create_table "external_feeds", :force => true do |t| 288 create_table "external_feeds", :force => true do |t|
@@ -619,6 +620,7 @@ ActiveRecord::Schema.define(:version =&gt; 20140108132730) do @@ -619,6 +620,7 @@ ActiveRecord::Schema.define(:version =&gt; 20140108132730) do
619 t.datetime "chat_status_at" 620 t.datetime "chat_status_at"
620 t.string "activation_code", :limit => 40 621 t.string "activation_code", :limit => 40
621 t.datetime "activated_at" 622 t.datetime "activated_at"
  623 + t.string "return_to"
622 end 624 end
623 625
624 create_table "validation_infos", :force => true do |t| 626 create_table "validation_infos", :force => true do |t|
features/forum.feature
@@ -166,3 +166,121 @@ Feature: forum @@ -166,3 +166,121 @@ Feature: forum
166 | Post one | joaosilva | Hi all | Hi all | 166 | Post one | joaosilva | Hi all | Hi all |
167 When I go to /joaosilva/forum 167 When I go to /joaosilva/forum
168 Then I should see "Joao" linking to "http://localhost/joaosilva" 168 Then I should see "Joao" linking to "http://localhost/joaosilva"
  169 +
  170 + @selenium
  171 + Scenario: community member should be able to see the discussion topic button
  172 + Given the following community
  173 + | identifier | name | owner |
  174 + | sample-community | Sample Community | joaosilva |
  175 + And the following forums
  176 + | owner | name |
  177 + | sample-community | Forum |
  178 + And the following users
  179 + | login | name |
  180 + | mariasilva | Maria Silva|
  181 + And "Maria Silva" is a member of "Sample Community"
  182 + And I am logged in as "joaosilva"
  183 + When I go to /sample-community/forum
  184 + And I follow "Configure forum"
  185 + And I check "Allow member to create topics"
  186 + And I press "Save"
  187 + And I am logged in as "mariasilva"
  188 + And I go to /sample-community/forum
  189 + Then I should see "New discussion topic"
  190 +
  191 + @selenium
  192 + Scenario: a non community member should not be able to see the discussion topic button
  193 + Given the following community
  194 + | identifier | name | owner |
  195 + | sample-community | Sample Community | joaosilva |
  196 + And the following forums
  197 + | owner | name |
  198 + | sample-community | Forum |
  199 + And the following users
  200 + | login | name |
  201 + | mariasilva | Maria Silva|
  202 + And I am logged in as "joaosilva"
  203 + When I go to /sample-community/forum
  204 + And I follow "Configure forum"
  205 + And I check "Allow member to create topics"
  206 + And I press "Save"
  207 + And I am logged in as "mariasilva"
  208 + And I go to /sample-community/forum
  209 + Then I should not see "New discussion topic"
  210 +
  211 + @selenium
  212 + Scenario: community member should not be able to see the discussion topic button
  213 + Given the following community
  214 + | identifier | name | owner |
  215 + | sample-community | Sample Community | joaosilva |
  216 + And the following forums
  217 + | owner | name |
  218 + | sample-community | Forum |
  219 + And the following users
  220 + | login | name |
  221 + | mariasilva | Maria Silva|
  222 + And "Maria Silva" is a member of "Sample Community"
  223 + And I am logged in as "joaosilva"
  224 + When I go to /sample-community/forum
  225 + And I follow "Configure forum"
  226 + And I uncheck "Allow member to create topics"
  227 + And I press "Save"
  228 + And I am logged in as "mariasilva"
  229 + And I go to /sample-community/forum
  230 + Then I should not see "New discussion topic"
  231 +
  232 + @selenium
  233 + Scenario: community member should be able to create a topic with the discussion topic button
  234 + Given the following community
  235 + | identifier | name | owner |
  236 + | sample-community | Sample Community | joaosilva |
  237 + And the following forums
  238 + | owner | name |
  239 + | sample-community | Forum |
  240 + And the following users
  241 + | login | name |
  242 + | mariasilva | Maria Silva|
  243 + And "Maria Silva" is a member of "Sample Community"
  244 + And I am logged in as "joaosilva"
  245 + When I go to /sample-community/forum
  246 + And I follow "Configure forum"
  247 + And I check "Allow member to create topics"
  248 + And I press "Save"
  249 + And I am logged in as "mariasilva"
  250 + And I go to /sample-community/forum
  251 + And I follow "New discussion topic"
  252 + And I follow "Text article with visual editor"
  253 + And I fill in "Title" with "Test"
  254 + And I press "Save"
  255 + Then I should see "Test"
  256 +
  257 + @selenium
  258 + Scenario: community member should be able to create a topic on a topic page
  259 + Given the following community
  260 + | identifier | name | owner |
  261 + | sample-community | Sample Community | joaosilva |
  262 + And the following forums
  263 + | owner | name |
  264 + | sample-community | Forum |
  265 + And the following users
  266 + | login | name |
  267 + | mariasilva | Maria Silva|
  268 + And "Maria Silva" is a member of "Sample Community"
  269 + And I am logged in as "joaosilva"
  270 + When I go to /sample-community/forum
  271 + And I follow "Configure forum"
  272 + And I check "Allow member to create topics"
  273 + And I press "Save"
  274 + And I am logged in as "mariasilva"
  275 + And I go to /sample-community/forum
  276 + And I follow "New discussion topic"
  277 + And I follow "Text article with visual editor"
  278 + And I fill in "Title" with "Test"
  279 + And I press "Save"
  280 + And I go to /sample-community/forum/test
  281 + And I follow "New discussion topic"
  282 + And I follow "Text article with visual editor"
  283 + And I fill in "Title" with "Test inside the topic page"
  284 + And I press "Save"
  285 + And I go to /sample-community/forum
  286 + Then I should see "Test inside the topic page"
169 \ No newline at end of file 287 \ No newline at end of file
features/signup.feature
@@ -3,7 +3,7 @@ Feature: signup @@ -3,7 +3,7 @@ Feature: signup
3 I want to sign up to the site 3 I want to sign up to the site
4 So I can have fun using its features 4 So I can have fun using its features
5 5
6 -@selenium 6 + @selenium
7 Scenario: successfull registration 7 Scenario: successfull registration
8 Given I am on the homepage 8 Given I am on the homepage
9 When I follow "Login" 9 When I follow "Login"
@@ -60,3 +60,183 @@ Feature: signup @@ -60,3 +60,183 @@ Feature: signup
60 And I fill in "Name" with "" 60 And I fill in "Name" with ""
61 When I press "Save" 61 When I press "Save"
62 Then I should see "Name can't be blank" 62 Then I should see "Name can't be blank"
  63 +
  64 + @selenium
  65 + Scenario: user should stay on same page after signup
  66 + Given the environment is configured to stay on the same page after signup
  67 + And feature "skip_new_user_email_confirmation" is enabled on environment
  68 + And I am on /search/people
  69 + When I follow "Sign up"
  70 + And I fill in the following within ".no-boxes":
  71 + | e-Mail | josesilva@example.com |
  72 + | Username | josesilva |
  73 + | Password | secret |
  74 + | Password confirmation | secret |
  75 + | Full name | José da Silva |
  76 + And wait for the captcha signup time
  77 + And I press "Create my account"
  78 + Then I should be on /search/people
  79 +
  80 + @selenium
  81 + Scenario: user should go to his homepage after signup
  82 + Given the environment is configured to redirect to profile homepage after signup
  83 + And feature "skip_new_user_email_confirmation" is enabled on environment
  84 + And I am on /search/people
  85 + When I follow "Sign up"
  86 + And I fill in the following within ".no-boxes":
  87 + | e-Mail | josesilva@example.com |
  88 + | Username | josesilva |
  89 + | Password | secret |
  90 + | Password confirmation | secret |
  91 + | Full name | José da Silva |
  92 + And wait for the captcha signup time
  93 + And I press "Create my account"
  94 + Then I should be on josesilva's profile
  95 +
  96 + @selenium
  97 + Scenario: user should go to his control panel after signup
  98 + Given the environment is configured to redirect to profile control panel after signup
  99 + And feature "skip_new_user_email_confirmation" is enabled on environment
  100 + And I am on /search/people
  101 + When I follow "Sign up"
  102 + And I fill in the following within ".no-boxes":
  103 + | e-Mail | josesilva@example.com |
  104 + | Username | josesilva |
  105 + | Password | secret |
  106 + | Password confirmation | secret |
  107 + | Full name | José da Silva |
  108 + And wait for the captcha signup time
  109 + And I press "Create my account"
  110 + Then I should be on josesilva's control panel
  111 +
  112 + @selenium
  113 + Scenario: user should go to his profile page after signup
  114 + Given the environment is configured to redirect to user profile page after signup
  115 + And feature "skip_new_user_email_confirmation" is enabled on environment
  116 + And I am on /search/people
  117 + When I follow "Sign up"
  118 + And I fill in the following within ".no-boxes":
  119 + | e-Mail | josesilva@example.com |
  120 + | Username | josesilva |
  121 + | Password | secret |
  122 + | Password confirmation | secret |
  123 + | Full name | José da Silva |
  124 + And wait for the captcha signup time
  125 + And I press "Create my account"
  126 + Then I should be on josesilva's profile
  127 +
  128 + @selenium
  129 + Scenario: user should go to the environment's homepage after signup
  130 + Given the environment is configured to redirect to site homepage after signup
  131 + And feature "skip_new_user_email_confirmation" is enabled on environment
  132 + And I am on /search/people
  133 + When I follow "Sign up"
  134 + And I fill in the following within ".no-boxes":
  135 + | e-Mail | josesilva@example.com |
  136 + | Username | josesilva |
  137 + | Password | secret |
  138 + | Password confirmation | secret |
  139 + | Full name | José da Silva |
  140 + And wait for the captcha signup time
  141 + And I press "Create my account"
  142 + Then I should be on the homepage
  143 +
  144 + @selenium
  145 + Scenario: user should stay on same page after following confirmation link
  146 + Given the environment is configured to stay on the same page after login
  147 + And feature "skip_new_user_email_confirmation" is disabled on environment
  148 + And I am on /search/people
  149 + When I follow "Sign up"
  150 + And I fill in the following within ".no-boxes":
  151 + | e-Mail | josesilva@example.com |
  152 + | Username | josesilva |
  153 + | Password | secret |
  154 + | Password confirmation | secret |
  155 + | Full name | José da Silva |
  156 + And wait for the captcha signup time
  157 + And I press "Create my account"
  158 + And I go to josesilva's confirmation URL
  159 + And I fill in "Username" with "josesilva"
  160 + And I fill in "Password" with "secret"
  161 + And I press "Log in"
  162 + Then I should be on /search/people
  163 +
  164 + @selenium
  165 + Scenario: user should go to his homepage after following confirmation link
  166 + Given the environment is configured to redirect to profile homepage after login
  167 + And feature "skip_new_user_email_confirmation" is disabled on environment
  168 + And I am on /search/people
  169 + When I follow "Sign up"
  170 + And I fill in the following within ".no-boxes":
  171 + | e-Mail | josesilva@example.com |
  172 + | Username | josesilva |
  173 + | Password | secret |
  174 + | Password confirmation | secret |
  175 + | Full name | José da Silva |
  176 + And wait for the captcha signup time
  177 + And I press "Create my account"
  178 + And I go to josesilva's confirmation URL
  179 + And I fill in "Username" with "josesilva"
  180 + And I fill in "Password" with "secret"
  181 + And I press "Log in"
  182 + Then I should be on /profile/josesilva
  183 +
  184 + @selenium
  185 + Scenario: user should go to his control panel after following confirmation link
  186 + Given the environment is configured to redirect to profile control panel after login
  187 + And feature "skip_new_user_email_confirmation" is disabled on environment
  188 + And I am on /search/people
  189 + When I follow "Sign up"
  190 + And I fill in the following within ".no-boxes":
  191 + | e-Mail | josesilva@example.com |
  192 + | Username | josesilva |
  193 + | Password | secret |
  194 + | Password confirmation | secret |
  195 + | Full name | José da Silva |
  196 + And wait for the captcha signup time
  197 + And I press "Create my account"
  198 + And I go to josesilva's confirmation URL
  199 + And I fill in "Username" with "josesilva"
  200 + And I fill in "Password" with "secret"
  201 + And I press "Log in"
  202 + Then I should be on /myprofile/josesilva
  203 +
  204 + @selenium
  205 + Scenario: user should go to his profile page after following confirmation link
  206 + Given the environment is configured to redirect to user profile page after login
  207 + And feature "skip_new_user_email_confirmation" is disabled on environment
  208 + And I am on /search/people
  209 + When I follow "Sign up"
  210 + And I fill in the following within ".no-boxes":
  211 + | e-Mail | josesilva@example.com |
  212 + | Username | josesilva |
  213 + | Password | secret |
  214 + | Password confirmation | secret |
  215 + | Full name | José da Silva |
  216 + And wait for the captcha signup time
  217 + And I press "Create my account"
  218 + And I go to josesilva's confirmation URL
  219 + And I fill in "Username" with "josesilva"
  220 + And I fill in "Password" with "secret"
  221 + And I press "Log in"
  222 + Then I should be on /profile/josesilva
  223 +
  224 + @selenium
  225 + Scenario: user should go to the environment homepage after following confirmation link
  226 + Given the environment is configured to redirect to site homepage after login
  227 + And feature "skip_new_user_email_confirmation" is disabled on environment
  228 + And I am on /search/people
  229 + When I follow "Sign up"
  230 + And I fill in the following within ".no-boxes":
  231 + | e-Mail | josesilva@example.com |
  232 + | Username | josesilva |
  233 + | Password | secret |
  234 + | Password confirmation | secret |
  235 + | Full name | José da Silva |
  236 + And wait for the captcha signup time
  237 + And I press "Create my account"
  238 + And I go to josesilva's confirmation URL
  239 + And I fill in "Username" with "josesilva"
  240 + And I fill in "Password" with "secret"
  241 + And I press "Log in"
  242 + Then I should be on the homepage
features/step_definitions/noosfero_steps.rb
@@ -738,6 +738,24 @@ Given /^the profile (.*) is configured to (.*) after login$/ do |profile, option @@ -738,6 +738,24 @@ Given /^the profile (.*) is configured to (.*) after login$/ do |profile, option
738 profile.save 738 profile.save
739 end 739 end
740 740
  741 +Given /^the environment is configured to (.*) after signup$/ do |option|
  742 + redirection = case option
  743 + when 'stay on the same page'
  744 + 'keep_on_same_page'
  745 + when 'redirect to site homepage'
  746 + 'site_homepage'
  747 + when 'redirect to user profile page'
  748 + 'user_profile_page'
  749 + when 'redirect to profile homepage'
  750 + 'user_homepage'
  751 + when 'redirect to profile control panel'
  752 + 'user_control_panel'
  753 + end
  754 + environment = Environment.default
  755 + environment.redirection_after_signup = redirection
  756 + environment.save
  757 +end
  758 +
741 When /^wait for the captcha signup time$/ do 759 When /^wait for the captcha signup time$/ do
742 environment = Environment.default 760 environment = Environment.default
743 sleep environment.min_signup_delay + 1 761 sleep environment.min_signup_delay + 1
features/support/paths.rb
@@ -111,6 +111,10 @@ module NavigationHelpers @@ -111,6 +111,10 @@ module NavigationHelpers
111 when /the user data path/ 111 when /the user data path/
112 '/account/user_data' 112 '/account/user_data'
113 113
  114 + when /^(.+)'s confirmation URL/
  115 + user = User[$1]
  116 + "/account/activate?activation_code=#{user.activation_code}&redirection=" + (user.return_to.nil? ? 'false' : 'true')
  117 +
114 when /^(.+)'s members page/ 118 when /^(.+)'s members page/
115 '/profile/%s/members' % profile_identifier($1) 119 '/profile/%s/members' % profile_identifier($1)
116 120
test/functional/application_controller_test.rb
@@ -263,7 +263,7 @@ class ApplicationControllerTest &lt; ActionController::TestCase @@ -263,7 +263,7 @@ class ApplicationControllerTest &lt; ActionController::TestCase
263 assert_no_tag :tag => 'a', :content => /Category 2/ 263 assert_no_tag :tag => 'a', :content => /Category 2/
264 end 264 end
265 265
266 - should 'show name of article as title of page' do 266 + should 'show name of article as title of page without environment' do
267 p = create_user('test_user').person 267 p = create_user('test_user').person
268 a = p.articles.create!(:name => 'test article') 268 a = p.articles.create!(:name => 'test article')
269 269
@@ -271,17 +271,22 @@ class ApplicationControllerTest &lt; ActionController::TestCase @@ -271,17 +271,22 @@ class ApplicationControllerTest &lt; ActionController::TestCase
271 @controller.instance_variable_set('@page', a) 271 @controller.instance_variable_set('@page', a)
272 272
273 get :index 273 get :index
274 - assert_tag 'title', :content => 'test article - ' + p.name + ' - ' + p.environment.name 274 + assert_tag 'title', :content => 'test article - ' + p.name
275 end 275 end
276 276
277 - should 'diplay name of profile in the title' do 277 + should 'diplay name of profile in the title without environment' do
278 p = create_user('test_user').person 278 p = create_user('test_user').person
279 p.name = 'Some Test User' 279 p.name = 'Some Test User'
280 p.save! 280 p.save!
281 @controller.instance_variable_set('@profile', p) 281 @controller.instance_variable_set('@profile', p)
282 282
283 get :index, :profile => p.identifier 283 get :index, :profile => p.identifier
284 - assert_tag 'title', :content => p.name + ' - ' + p.environment.name 284 + assert_tag 'title', :content => p.name
  285 + end
  286 +
  287 + should 'display environment name in title when profile and page are not defined' do
  288 + get :index
  289 + assert_tag 'title', :content => assigns(:environment).name
285 end 290 end
286 291
287 should 'display menu links for my environment when logged in other environment' do 292 should 'display menu links for my environment when logged in other environment' do
@@ -324,7 +329,8 @@ class ApplicationControllerTest &lt; ActionController::TestCase @@ -324,7 +329,8 @@ class ApplicationControllerTest &lt; ActionController::TestCase
324 end 329 end
325 330
326 should 'set html lang as the article language if an article is present and has a language' do 331 should 'set html lang as the article language if an article is present and has a language' do
327 - a = fast_create(Article, :name => 'test article', :language => 'fr') 332 + p = create_user('test_user').person
  333 + a = fast_create(Article, :name => 'test article', :language => 'fr', :profile_id => p.id )
328 @controller.instance_variable_set('@page', a) 334 @controller.instance_variable_set('@page', a)
329 FastGettext.stubs(:locale).returns('es') 335 FastGettext.stubs(:locale).returns('es')
330 get :index 336 get :index
@@ -338,7 +344,9 @@ class ApplicationControllerTest &lt; ActionController::TestCase @@ -338,7 +344,9 @@ class ApplicationControllerTest &lt; ActionController::TestCase
338 end 344 end
339 345
340 should 'set html lang as locale if page has no language' do 346 should 'set html lang as locale if page has no language' do
341 - a = fast_create(Article, :name => 'test article', :language => nil) 347 + p = create_user('test_user').person
  348 + a = fast_create(Article, :name => 'test article', :language => nil, :profile_id => p.id )
  349 +
342 @controller.instance_variable_set('@page', a) 350 @controller.instance_variable_set('@page', a)
343 FastGettext.stubs(:locale).returns('es') 351 FastGettext.stubs(:locale).returns('es')
344 get :index 352 get :index
@@ -542,4 +550,18 @@ class ApplicationControllerTest &lt; ActionController::TestCase @@ -542,4 +550,18 @@ class ApplicationControllerTest &lt; ActionController::TestCase
542 assert_equal nil, @controller.application_controller_test_other_filter_plugin_filter_plugin 550 assert_equal nil, @controller.application_controller_test_other_filter_plugin_filter_plugin
543 end 551 end
544 552
  553 + should 'display meta tags for social media' do
  554 + get :index
  555 + assert_tag :tag => 'meta', :attributes => { :name => 'twitter:card', :value => 'summary' }
  556 + assert_tag :tag => 'meta', :attributes => { :name => 'twitter:title', :content => assigns(:environment).name }
  557 + assert_tag :tag => 'meta', :attributes => { :name => 'twitter:description', :content => assigns(:environment).name }
  558 + assert_no_tag :tag => 'meta', :attributes => { :name => 'twitter:image' }
  559 + assert_tag :tag => 'meta', :attributes => { :property => 'og:type', :content => 'website' }
  560 + assert_tag :tag => 'meta', :attributes => { :property => 'og:url', :content => assigns(:environment).top_url }
  561 + assert_tag :tag => 'meta', :attributes => { :property => 'og:title', :content => assigns(:environment).name }
  562 + assert_tag :tag => 'meta', :attributes => { :property => 'og:site_name', :content => assigns(:environment).name }
  563 + assert_tag :tag => 'meta', :attributes => { :property => 'og:description', :content => assigns(:environment).name }
  564 + assert_no_tag :tag => 'meta', :attributes => { :property => 'article:published_time' }
  565 + assert_no_tag :tag => 'meta', :attributes => { :property => 'og:image' }
  566 + end
545 end 567 end
test/functional/content_viewer_controller_test.rb
@@ -1369,4 +1369,28 @@ class ContentViewerControllerTest &lt; ActionController::TestCase @@ -1369,4 +1369,28 @@ class ContentViewerControllerTest &lt; ActionController::TestCase
1369 assert_match /this is a sample text file/, @response.body 1369 assert_match /this is a sample text file/, @response.body
1370 end 1370 end
1371 1371
  1372 + should 'add meta tags with article info' do
  1373 + a = TinyMceArticle.create(:name => 'Article to be shared', :body => 'This article should be shared with all social networks', :profile => profile)
  1374 +
  1375 + get :view_page, :profile => profile.identifier, :page => [ a.name.to_slug ]
  1376 +
  1377 + assert_tag :tag => 'meta', :attributes => { :name => 'twitter:title', :content => /#{a.name} - #{a.profile.name}/ }
  1378 + assert_tag :tag => 'meta', :attributes => { :name => 'twitter:description', :content => a.body }
  1379 + assert_no_tag :tag => 'meta', :attributes => { :name => 'twitter:image' }
  1380 + assert_tag :tag => 'meta', :attributes => { :property => 'og:type', :content => 'article' }
  1381 + assert_tag :tag => 'meta', :attributes => { :property => 'og:url', :content => /\/#{profile.identifier}\/#{a.name.to_slug}/ }
  1382 + assert_tag :tag => 'meta', :attributes => { :property => 'og:title', :content => /#{a.name} - #{a.profile.name}/ }
  1383 + assert_tag :tag => 'meta', :attributes => { :property => 'og:site_name', :content => a.profile.name }
  1384 + assert_tag :tag => 'meta', :attributes => { :property => 'og:description', :content => a.body }
  1385 + assert_no_tag :tag => 'meta', :attributes => { :property => 'og:image' }
  1386 + end
  1387 +
  1388 + should 'add meta tags with article images' do
  1389 + a = TinyMceArticle.create(:name => 'Article to be shared with images', :body => 'This article should be shared with all social networks <img src="/images/x.png" />', :profile => profile)
  1390 +
  1391 + get :view_page, :profile => profile.identifier, :page => [ a.name.to_slug ]
  1392 + assert_tag :tag => 'meta', :attributes => { :name => 'twitter:image', :content => /\/images\/x.png/ }
  1393 + assert_tag :tag => 'meta', :attributes => { :property => 'og:image', :content => /\/images\/x.png/ }
  1394 + end
  1395 +
1372 end 1396 end
test/unit/application_helper_test.rb
@@ -466,6 +466,22 @@ class ApplicationHelperTest &lt; ActiveSupport::TestCase @@ -466,6 +466,22 @@ class ApplicationHelperTest &lt; ActiveSupport::TestCase
466 assert_match(/Community nick/, page_title) 466 assert_match(/Community nick/, page_title)
467 end 467 end
468 468
  469 + should 'not display environment name if is a profile' do
  470 + stubs(:environment).returns(Environment.default)
  471 + @controller = ApplicationController.new
  472 +
  473 + c = fast_create(Community, :name => 'Community for tests', :nickname => 'Community nick', :identifier => 'test_comm')
  474 + stubs(:profile).returns(c)
  475 + assert_equal c.short_name, page_title
  476 + end
  477 +
  478 + should 'display only environment if no profile and page' do
  479 + stubs(:environment).returns(Environment.default)
  480 + @controller = ApplicationController.new
  481 +
  482 + assert_equal Environment.default.name, page_title
  483 + end
  484 +
469 should 'gravatar default parameter' do 485 should 'gravatar default parameter' do
470 profile = mock 486 profile = mock
471 profile.stubs(:theme).returns('some-theme') 487 profile.stubs(:theme).returns('some-theme')
test/unit/content_viewer_helper_test.rb
@@ -89,38 +89,6 @@ class ContentViewerHelperTest &lt; ActiveSupport::TestCase @@ -89,38 +89,6 @@ class ContentViewerHelperTest &lt; ActiveSupport::TestCase
89 assert_no_match /feed/, result 89 assert_no_match /feed/, result
90 end 90 end
91 91
92 - should 'generate facebook addthis url for article' do  
93 - Environment.any_instance.stubs(:default_hostname).returns('noosfero.org')  
94 - [TextileArticle, Blog, Folder, Gallery, UploadedFile, Forum, Event, TextArticle, TinyMceArticle].each do |model|  
95 - a = model.new(:name => 'Some title', :body => 'Some text here.', :profile => profile)  
96 - assert_equal "http://www.facebook.com/sharer.php?s=100&p[title]=Some+title&p[summary]=Some+text+here.&p[url]=http%3A%2F%2Fnoosfero.org%2Fblog_helper_test%2Fsome-title&p[images][0]=", addthis_facebook_url(a)  
97 - end  
98 - end  
99 -  
100 - should 'generate facebook addthis url without body' do  
101 - Environment.any_instance.stubs(:default_hostname).returns('noosfero.org')  
102 - a = TinyMceArticle.new(:name => 'Test', :body => nil, :profile => profile)  
103 - assert_equal "http://www.facebook.com/sharer.php?s=100&p[title]=Test&p[summary]=&p[url]=http%3A%2F%2Fnoosfero.org%2Fblog_helper_test%2Ftest&p[images][0]=", addthis_facebook_url(a)  
104 - end  
105 -  
106 - should 'generate facebook addthis url without tags in body' do  
107 - Environment.any_instance.stubs(:default_hostname).returns('noosfero.org')  
108 - a = TinyMceArticle.new(:name => 'Some title', :body => '<p>This <b class="bold">is</b> a test</p>', :profile => profile)  
109 - assert_equal "http://www.facebook.com/sharer.php?s=100&p[title]=Some+title&p[summary]=This+is+a+test&p[url]=http%3A%2F%2Fnoosfero.org%2Fblog_helper_test%2Fsome-title&p[images][0]=", addthis_facebook_url(a)  
110 - end  
111 -  
112 - should 'generate facebook addthis url with truncated body' do  
113 - Environment.any_instance.stubs(:default_hostname).returns('noosfero.org')  
114 - a = TinyMceArticle.new(:name => 'Some title', :body => 'test' * 76, :profile => profile)  
115 - assert_equal "http://www.facebook.com/sharer.php?s=100&p[title]=Some+title&p[summary]=#{'test' * 74}t...&p[url]=http%3A%2F%2Fnoosfero.org%2Fblog_helper_test%2Fsome-title&p[images][0]=", addthis_facebook_url(a)  
116 - end  
117 -  
118 - should 'generate facebook addthis url for tinymce article with images' do  
119 - Environment.any_instance.stubs(:default_hostname).returns('noosfero.org')  
120 - a = TinyMceArticle.new(:name => 'Some title', :body => '<p>This <b class="bold">is</b> a <img src="/images/x.png" />test</p>', :profile => profile)  
121 - assert_equal "http://www.facebook.com/sharer.php?s=100&p[title]=Some+title&p[summary]=This+is+a+test&p[url]=http%3A%2F%2Fnoosfero.org%2Fblog_helper_test%2Fsome-title&p[images][0]=http%3A%2F%2Fnoosfero.org%2Fimages%2Fx.png", addthis_facebook_url(a)  
122 - end  
123 -  
124 should 'theme provides addthis custom icon' do 92 should 'theme provides addthis custom icon' do
125 stubs(:session).returns({:theme => 'base'}) 93 stubs(:session).returns({:theme => 'base'})
126 File.expects(:exists?).with(anything).returns(true) 94 File.expects(:exists?).with(anything).returns(true)
test/unit/environment_test.rb
@@ -1220,6 +1220,27 @@ class EnvironmentTest &lt; ActiveSupport::TestCase @@ -1220,6 +1220,27 @@ class EnvironmentTest &lt; ActiveSupport::TestCase
1220 end 1220 end
1221 end 1221 end
1222 1222
  1223 + should 'return a Hash on signup redirection options' do
  1224 + assert_kind_of Hash, Environment.signup_redirection_options
  1225 + end
  1226 +
  1227 + should 'respond to redirection after signup' do
  1228 + assert_respond_to Environment.new, :redirection_after_signup
  1229 + end
  1230 +
  1231 + should 'allow only environment signup redirection options' do
  1232 + environment = fast_create(Environment)
  1233 + environment.redirection_after_signup = 'invalid_option'
  1234 + environment.save
  1235 + assert environment.errors.invalid?(:redirection_after_signup)
  1236 +
  1237 + Environment.signup_redirection_options.keys.each do |redirection|
  1238 + environment.redirection_after_signup = redirection
  1239 + environment.save
  1240 + assert !environment.errors.invalid?(:redirection_after_signup)
  1241 + end
  1242 + end
  1243 +
1223 should 'respond to signup_welcome_text' do 1244 should 'respond to signup_welcome_text' do
1224 assert_respond_to Environment.new, :signup_welcome_text 1245 assert_respond_to Environment.new, :signup_welcome_text
1225 end 1246 end