Commit b361aebc6cc4e4054bc85148e22d0b5f896da203

Authored by Joenio Costa
2 parents 381cca8f 1a7d1285

Merge branch 'stable' into master

Conflicts:
	app/models/environment.rb
	features/publish_article.feature
	test/unit/application_helper_test.rb
	test/unit/blog_test.rb
	test/unit/environment_test.rb
Showing 44 changed files with 491 additions and 254 deletions   Show diff stats
app/controllers/public/content_viewer_controller.rb
... ... @@ -81,7 +81,13 @@ class ContentViewerController < ApplicationController
81 81 end
82 82  
83 83 if @page.blog?
84   - @page.filter = {:year => params[:year], :month => params[:month]}
  84 + posts = if params[:year] and params[:month]
  85 + filter_date = DateTime.parse("#{params[:year]}-#{params[:month]}-01")
  86 + @page.posts.by_range(filter_date..Article.last_day_of_month(filter_date))
  87 + else
  88 + @page.posts
  89 + end
  90 + @posts = available_articles(posts, user).paginate :page => params[:npage], :per_page => @page.posts_per_page
85 91 end
86 92  
87 93 if @page.folder? && @page.view_as == 'image_gallery'
... ...
app/helpers/application_helper.rb
... ... @@ -11,7 +11,7 @@ module ApplicationHelper
11 11 include BoxesHelper
12 12  
13 13 include FormsHelper
14   -
  14 +
15 15 include AssetsHelper
16 16  
17 17 include BlockHelper
... ... @@ -94,7 +94,7 @@ module ApplicationHelper
94 94 if options[:type] == :textile
95 95 content = RedCloth.new(content).to_html
96 96 end
97   -
  97 +
98 98 options[:class] = '' if ! options[:class]
99 99 options[:class] += ' button icon-help' # with-text
100 100  
... ... @@ -269,7 +269,7 @@ module ApplicationHelper
269 269 if klass.nil?
270 270 raise ArgumentError, 'No partial for object. Is there a partial for any class in the inheritance hierarchy?'
271 271 end
272   -
  272 +
273 273 name = klass.name.underscore
274 274 if File.exists?(File.join(RAILS_ROOT, 'app', 'views', params[:controller], "_#{name}.rhtml"))
275 275 name
... ... @@ -285,7 +285,7 @@ module ApplicationHelper
285 285 # DEPRECATED. Do not use this.
286 286 def stylesheet_import(*sources)
287 287 options = sources.last.is_a?(Hash) ? sources.pop : { }
288   - themed_source = options.delete(:themed_source)
  288 + themed_source = options.delete(:themed_source)
289 289 content_tag(
290 290 'style',
291 291 "\n" +
... ... @@ -299,7 +299,7 @@ module ApplicationHelper
299 299 end.join(),
300 300 { "type" => "text/css" }.merge(options)
301 301 )
302   - end
  302 + end
303 303  
304 304 # DEPRECATED. Do not use this.
305 305 def filename_for_stylesheet(name, in_theme)
... ... @@ -391,7 +391,7 @@ module ApplicationHelper
391 391 Theme.find(current_theme).owner.identifier
392 392 end
393 393  
394   - # generates a image tag for the profile.
  394 + # generates a image tag for the profile.
395 395 #
396 396 # If the profile has no image set yet, then a default image is used.
397 397 def profile_image(profile, size=:portrait, opt={})
... ... @@ -787,8 +787,9 @@ module ApplicationHelper
787 787 field_html ||= ''
788 788 field_html += capture(&block)
789 789 end
790   - if (controller.action_name == 'signup')
791   - if profile.signup_fields.include?(name) || profile.required_fields.include?(name)
  790 +
  791 + if controller.action_name == 'signup' || controller.action_name == 'new_community' || (controller.controller_name == "enterprise_registration" && controller.action_name == 'index')
  792 + if profile.signup_fields.include?(name)
792 793 result = field_html
793 794 end
794 795 else
... ... @@ -796,6 +797,7 @@ module ApplicationHelper
796 797 result = field_html
797 798 end
798 799 end
  800 +
799 801 if is_required
800 802 result = required(result)
801 803 end
... ... @@ -943,8 +945,9 @@ module ApplicationHelper
943 945 content_for(:head) { stylesheet_link_tag(*args) }
944 946 end
945 947  
946   - def article_to_html(article)
947   - content = article.to_html(:page => params[:npage])
  948 + def article_to_html(article, options = {})
  949 + options.merge(:page => params[:npage])
  950 + content = article.to_html(options)
948 951 return self.instance_eval(&content) if content.kind_of?(Proc)
949 952 content
950 953 end
... ...
app/helpers/blog_helper.rb
... ... @@ -14,7 +14,7 @@ module BlogHelper
14 14 _('Edit blog')
15 15 end
16 16  
17   - def list_posts(user, articles, format = 'full')
  17 + def list_posts(articles, format = 'full')
18 18 pagination = will_paginate(articles, {
19 19 :param_name => 'npage',
20 20 :prev_label => _('« Newer posts'),
... ... @@ -25,18 +25,16 @@ module BlogHelper
25 25 articles.each_with_index{ |art,i|
26 26 css_add = [ 'position-'+(i+1).to_s() ]
27 27 position = (i%2 == 0) ? 'odd-post' : 'even-post'
28   - if art.published? || (user==art.profile)
29   - css_add << 'first' if i == 0
30   - css_add << 'last' if i == (artic_len-1)
31   - css_add << 'not-published' if !art.published?
32   - css_add << position + '-inner'
33   - content << content_tag('div',
34   - content_tag('div',
35   - display_post(art, format) + '<br style="clear:both"/>',
36   - :class => 'blog-post ' + css_add.join(' '),
37   - :id => "post-#{art.id}"), :class => position
38   - )
39   - end
  28 + css_add << 'first' if i == 0
  29 + css_add << 'last' if i == (artic_len-1)
  30 + css_add << 'not-published' if !art.published?
  31 + css_add << position + '-inner'
  32 + content << content_tag('div',
  33 + content_tag('div',
  34 + display_post(art, format) + '<br style="clear:both"/>',
  35 + :class => 'blog-post ' + css_add.join(' '),
  36 + :id => "post-#{art.id}"), :class => position
  37 + )
40 38 }
41 39 content.join("\n<hr class='sep-posts'/>\n") + (pagination or '')
42 40 end
... ...
app/models/article.rb
... ... @@ -32,6 +32,23 @@ class Article &lt; ActiveRecord::Base
32 32 {:include => 'categories', :conditions => { 'categories.id' => category.id }}
33 33 }
34 34  
  35 + named_scope :by_range, lambda { |range| {
  36 + :conditions => [
  37 + 'published_at BETWEEN :start_date AND :end_date', { :start_date => range.first, :end_date => range.last }
  38 + ]
  39 + }}
  40 +
  41 + def self.first_day_of_month(date)
  42 + date ||= Date.today
  43 + Date.new(date.year, date.month, 1)
  44 + end
  45 +
  46 + def self.last_day_of_month(date)
  47 + date ||= Date.today
  48 + date >>= 1
  49 + Date.new(date.year, date.month, 1) - 1.day
  50 + end
  51 +
35 52 URL_FORMAT = /\A(http|https):\/\/[a-z0-9]+([\-\.]{1}[a-z0-9]+)*\.[a-z]{2,5}(([0-9]{1,5})?\/.*)?\Z/ix
36 53  
37 54 validates_format_of :external_link, :with => URL_FORMAT, :if => lambda { |article| !article.external_link.blank? }
... ...
app/models/article_block.rb
... ... @@ -12,7 +12,7 @@ class ArticleBlock &lt; Block
12 12 block = self
13 13 lambda do
14 14 block_title(block.title) +
15   - (block.article ? article_to_html(block.article) : _('Article not selected yet.'))
  15 + (block.article ? article_to_html(block.article, :gallery_view => false) : _('Article not selected yet.'))
16 16 end
17 17 end
18 18  
... ...
app/models/blog.rb
... ... @@ -3,7 +3,6 @@ class Blog &lt; Folder
3 3 has_many :posts, :class_name => 'Article', :foreign_key => 'parent_id', :source => :children, :conditions => [ 'type != ?', 'RssFeed' ], :order => 'published_at DESC, id DESC'
4 4  
5 5 attr_accessor :feed_attrs
6   - attr_accessor :filter
7 6  
8 7 after_create do |blog|
9 8 blog.children << RssFeed.new(:name => 'feed', :profile => blog.profile)
... ... @@ -23,7 +22,9 @@ class Blog &lt; Folder
23 22 # FIXME isn't this too much including just to be able to generate some HTML?
24 23 include ActionView::Helpers::TagHelper
25 24 def to_html(options = {})
26   - posts_list(options[:page])
  25 + lambda do
  26 + render :file => 'content_viewer/blog_page'
  27 + end
27 28 end
28 29  
29 30 def folder?
... ... @@ -49,19 +50,6 @@ class Blog &lt; Folder
49 50 self.feed
50 51 end
51 52  
52   - def posts_list(npage)
53   - article = self
54   - children = if filter and filter[:year] and filter[:month]
55   - filter_date = DateTime.parse("#{filter[:year]}-#{filter[:month]}-01")
56   - posts.paginate :page => npage, :per_page => posts_per_page, :conditions => [ 'published_at between ? and ?', filter_date, filter_date + 1.month - 1.day ]
57   - else
58   - posts.paginate :page => npage, :per_page => posts_per_page
59   - end
60   - lambda do
61   - render :file => 'content_viewer/blog_page', :locals => {:article => article, :children => children}
62   - end
63   - end
64   -
65 53 has_one :external_feed, :foreign_key => 'blog_id', :dependent => :destroy
66 54  
67 55 attr_accessor :external_feed_data
... ...
app/models/change_password.rb
... ... @@ -5,7 +5,7 @@ class ChangePassword &lt; Task
5 5 self[:data] ||= {}
6 6 end
7 7  
8   - attr_accessor :login, :email, :password, :password_confirmation
  8 + attr_accessor :login, :email, :password, :password_confirmation, :environment_id
9 9  
10 10 def self.human_attribute_name(attrib)
11 11 case attrib.to_sym
... ... @@ -25,15 +25,15 @@ class ChangePassword &lt; Task
25 25 ###################################################
26 26 # validations for creating a ChangePassword task
27 27  
28   - validates_presence_of :login, :email, :on => :create
  28 + validates_presence_of :login, :email, :environment_id, :on => :create
29 29  
30 30 validates_presence_of :requestor_id
31 31  
32 32 validates_format_of :email, :on => :create, :with => Noosfero::Constants::EMAIL_FORMAT, :if => (lambda { |obj| !obj.email.blank? })
33 33  
34 34 validates_each :login, :on => :create do |data,attr,value|
35   - unless data.login.blank?
36   - user = User.find_by_login(data.login)
  35 + unless data.login.blank? || data.email.blank?
  36 + user = User.find_by_login_and_environment_id(data.login, data.environment_id)
37 37 if user.nil?
38 38 data.errors.add(:login, _('%{fn} is not a valid username.'))
39 39 else
... ...
app/models/community.rb
... ... @@ -23,10 +23,6 @@ class Community &lt; Organization
23 23 xss_terminate :only => [ :name, :address, :contact_phone, :description ], :on => 'validation'
24 24  
25 25 FIELDS = %w[
26   - city
27   - state
28   - country
29   - zip_code
30 26 language
31 27 ]
32 28  
... ... @@ -38,7 +34,7 @@ class Community &lt; Organization
38 34 super
39 35 self.required_fields.each do |field|
40 36 if self.send(field).blank?
41   - self.errors.add(field, _('%{fn} is mandatory'))
  37 + self.errors.add(field, _('%{fn} can\'t be blank'))
42 38 end
43 39 end
44 40 end
... ... @@ -51,6 +47,10 @@ class Community &lt; Organization
51 47 environment ? environment.required_community_fields : []
52 48 end
53 49  
  50 + def signup_fields
  51 + environment ? environment.signup_community_fields : []
  52 + end
  53 +
54 54 def name=(value)
55 55 super(value)
56 56 self.identifier = value.to_slug
... ...
app/models/create_community.rb
... ... @@ -14,7 +14,7 @@ class CreateCommunity &lt; Task
14 14  
15 15 acts_as_having_image
16 16  
17   - DATA_FIELDS = Community.fields + ['name', 'closed', 'tag_list']
  17 + DATA_FIELDS = Community.fields + ['name', 'closed']
18 18  
19 19 DATA_FIELDS.each do |field|
20 20 # getter
... ... @@ -30,7 +30,7 @@ class CreateCommunity &lt; Task
30 30 def validate
31 31 self.environment.required_community_fields.each do |field|
32 32 if self.send(field).blank?
33   - self.errors.add(field, _('%{fn} is mandatory'))
  33 + self.errors.add(field, _('%{fn} can\'t be blank'))
34 34 end
35 35 end
36 36 end
... ...
app/models/create_enterprise.rb
... ... @@ -106,6 +106,10 @@ class CreateEnterprise &lt; Task
106 106 environment ? environment.required_enterprise_fields : []
107 107 end
108 108  
  109 + def signup_fields
  110 + environment ? environment.signup_enterprise_fields : []
  111 + end
  112 +
109 113 def community?
110 114 false
111 115 end
... ...
app/models/enterprise.rb
... ... @@ -27,10 +27,6 @@ class Enterprise &lt; Organization
27 27  
28 28 FIELDS = %w[
29 29 business_name
30   - zip_code
31   - city
32   - state
33   - country
34 30 organization_website
35 31 historic_and_current_context
36 32 activities_short_description
... ... @@ -59,6 +55,10 @@ class Enterprise &lt; Organization
59 55 environment ? environment.required_enterprise_fields : []
60 56 end
61 57  
  58 + def signup_fields
  59 + environment ? environment.signup_enterprise_fields : []
  60 + end
  61 +
62 62 def product_categories
63 63 products.map{|p| p.category_full_name}.compact
64 64 end
... ...
app/models/environment.rb
... ... @@ -304,14 +304,25 @@ class Environment &lt; ActiveRecord::Base
304 304 if values['schooling'] && values['schooling']['active'] == 'true'
305 305 schooling_status = values['schooling']
306 306 end
  307 +
307 308 self.settings[:custom_person_fields] = values.delete_if { |key, value| ! Person.fields.include?(key)}
  309 + self.settings[:custom_person_fields].each_pair do |key, value|
  310 + if value['required'] == 'true'
  311 + self.settings[:custom_person_fields][key]['active'] = 'true'
  312 + self.settings[:custom_person_fields][key]['signup'] = 'true'
  313 + end
  314 + if value['signup'] == 'true'
  315 + self.settings[:custom_person_fields][key]['active'] = 'true'
  316 + end
  317 + end
  318 +
308 319 if schooling_status
309 320 self.settings[:custom_person_fields]['schooling_status'] = schooling_status
310 321 end
311 322 end
312 323  
313 324 def custom_person_field(field, status)
314   - if (custom_person_fields[field] && custom_person_fields[field][status] == 'true')
  325 + if (custom_person_fields[field] && custom_person_fields[field][status] == 'true')
315 326 return true
316 327 end
317 328 false
... ... @@ -351,10 +362,19 @@ class Environment &lt; ActiveRecord::Base
351 362  
352 363 def custom_enterprise_fields=(values)
353 364 self.settings[:custom_enterprise_fields] = values.delete_if { |key, value| ! Enterprise.fields.include?(key)}
  365 + self.settings[:custom_enterprise_fields].each_pair do |key, value|
  366 + if value['required'] == 'true'
  367 + self.settings[:custom_enterprise_fields][key]['active'] = 'true'
  368 + self.settings[:custom_enterprise_fields][key]['signup'] = 'true'
  369 + end
  370 + if value['signup'] == 'true'
  371 + self.settings[:custom_enterprise_fields][key]['active'] = 'true'
  372 + end
  373 + end
354 374 end
355 375  
356 376 def custom_enterprise_field(field, status)
357   - if (custom_enterprise_fields[field] && custom_enterprise_fields[field][status] == 'true')
  377 + if (custom_enterprise_fields[field] && custom_enterprise_fields[field][status] == 'true')
358 378 return true
359 379 end
360 380 false
... ... @@ -372,16 +392,32 @@ class Environment &lt; ActiveRecord::Base
372 392 required_fields
373 393 end
374 394  
  395 + def signup_enterprise_fields
  396 + signup_fields = []
  397 + active_enterprise_fields.each do |field|
  398 + signup_fields << field if custom_enterprise_fields[field]['signup'] == 'true'
  399 + end
  400 + signup_fields
  401 + end
  402 +
375 403 def custom_community_fields
376 404 self.settings[:custom_community_fields].nil? ? {} : self.settings[:custom_community_fields]
377 405 end
378   -
379 406 def custom_community_fields=(values)
380 407 self.settings[:custom_community_fields] = values.delete_if { |key, value| ! Community.fields.include?(key) }
  408 + self.settings[:custom_community_fields].each_pair do |key, value|
  409 + if value['required'] == 'true'
  410 + self.settings[:custom_community_fields][key]['active'] = 'true'
  411 + self.settings[:custom_community_fields][key]['signup'] = 'true'
  412 + end
  413 + if value['signup'] == 'true'
  414 + self.settings[:custom_community_fields][key]['active'] = 'true'
  415 + end
  416 + end
381 417 end
382 418  
383 419 def custom_community_field(field, status)
384   - if (custom_community_fields[field] && custom_community_fields[field][status] == 'true')
  420 + if (custom_community_fields[field] && custom_community_fields[field][status] == 'true')
385 421 return true
386 422 end
387 423 false
... ... @@ -399,6 +435,14 @@ class Environment &lt; ActiveRecord::Base
399 435 required_fields
400 436 end
401 437  
  438 + def signup_community_fields
  439 + signup_fields = []
  440 + active_community_fields.each do |field|
  441 + signup_fields << field if custom_community_fields[field]['signup'] == 'true'
  442 + end
  443 + signup_fields
  444 + end
  445 +
402 446 # #################################################
403 447 # Validations
404 448 # #################################################
... ... @@ -423,7 +467,7 @@ class Environment &lt; ActiveRecord::Base
423 467 self.find(:first, :conditions => [ 'is_default = ?', true ] )
424 468 end
425 469  
426   - # returns an array with the top level categories for this environment.
  470 + # returns an array with the top level categories for this environment.
427 471 def top_level_categories
428 472 Category.top_level_for(self)
429 473 end
... ... @@ -459,7 +503,7 @@ class Environment &lt; ActiveRecord::Base
459 503 self.articles.recent(limit)
460 504 end
461 505  
462   - has_many :events, :through => :profiles, :source => :articles, :class_name => 'Event'
  506 + has_many :events, :through => :profiles, :source => :articles, :class_name => 'Event'
463 507  
464 508 has_many :tags, :through => :articles
465 509  
... ... @@ -491,7 +535,7 @@ class Environment &lt; ActiveRecord::Base
491 535 def community_template=(value)
492 536 settings[:community_template_id] = value.id
493 537 end
494   -
  538 +
495 539 def person_template
496 540 Person.find_by_id settings[:person_template_id]
497 541 end
... ...
app/models/event.rb
... ... @@ -56,17 +56,6 @@ class Event &lt; Article
56 56 first_day..last_day
57 57 end
58 58  
59   - def self.first_day_of_month(date)
60   - date ||= Date.today
61   - Date.new(date.year, date.month, 1)
62   - end
63   -
64   - def self.last_day_of_month(date)
65   - date ||= Date.today
66   - date >>= 1
67   - Date.new(date.year, date.month, 1) - 1.day
68   - end
69   -
70 59 def date_range
71 60 start_date..(end_date||start_date)
72 61 end
... ...
app/models/organization.rb
... ... @@ -48,14 +48,20 @@ class Organization &lt; Profile
48 48 end
49 49  
50 50 FIELDS = %w[
  51 + display_name
  52 + description
51 53 contact_person
52   - contact_phone
53 54 contact_email
54   - description
  55 + contact_phone
55 56 legal_form
56 57 economic_activity
57 58 management_information
58 59 address
  60 + zip_code
  61 + city
  62 + state
  63 + country
  64 + tag_list
59 65 ]
60 66  
61 67 def self.fields
... ... @@ -70,8 +76,12 @@ class Organization &lt; Profile
70 76 []
71 77 end
72 78  
73   - N_('Contact person'); N_('Contact email'); N_('Acronym'); N_('Foundation year'); N_('Legal form'); N_('Economic activity'); N_('Management information'); N_('Validated')
74   - settings_items :contact_person, :contact_email, :acronym, :foundation_year, :legal_form, :economic_activity, :management_information, :validated, :cnpj
  79 + def signup_fields
  80 + []
  81 + end
  82 +
  83 + N_('Display name'); N_('Description'); N_('Contact person'); N_('Contact email'); N_('Acronym'); N_('Foundation year'); N_('Legal form'); N_('Economic activity'); N_('Management information'); N_('Validated'); N_('Tag list')
  84 + settings_items :display_name, :description, :contact_person, :contact_email, :acronym, :foundation_year, :legal_form, :economic_activity, :management_information, :validated, :cnpj
75 85  
76 86 validates_format_of :foundation_year, :with => Noosfero::Constants::INTEGER_FORMAT
77 87  
... ...
app/models/uploaded_file.rb
... ... @@ -58,7 +58,7 @@ class UploadedFile &lt; Article
58 58 article = self
59 59 if image?
60 60 lambda do
61   - if article.display_as_gallery?
  61 + if article.display_as_gallery? && options[:gallery_view]
62 62 images = article.parent.images
63 63 current_index = images.index(article)
64 64 total_of_images = images.count
... ...
app/views/account/forgot_password.rhtml
... ... @@ -9,6 +9,8 @@
9 9  
10 10 <%= f.text_field :email %>
11 11  
  12 + <%= f.hidden_field :environment_id, :value => environment.id %>
  13 +
12 14 <div>
13 15 <% button_bar do %>
14 16 <%= submit_button('send', _('Send instructions')) %>
... ...
app/views/cms/edit.rhtml
... ... @@ -28,9 +28,6 @@
28 28  
29 29 <%= select_categories(:article, _('Categorize your article')) %>
30 30  
31   - <%= f.text_field('tag_list', :size => 64) %>
32   - <%= content_tag( 'small', _('Separate tags with commas') ) %>
33   -
34 31 <div id='edit-article-options'>
35 32 <%= options_for_article(@article) %>
36 33 </div>
... ...
app/views/content_viewer/blog_page.rhtml
1   -<% add_rss_feed_to_head(article.name, article.feed.url) if article.blog? && article.feed %>
  1 +<% add_rss_feed_to_head(@page.name, @page.feed.url) if @page.blog? && @page.feed %>
2 2  
3   -<%= content_tag('em', _('(external feed was not loaded yet)'), :id => 'external-feed-info', :class => 'metadata') if article.blog? && article.external_feed && article.external_feed.enabled && article.external_feed.fetched_at.nil? %>
  3 +<%= content_tag('em', _('(external feed was not loaded yet)'), :id => 'external-feed-info', :class => 'metadata') if @page.blog? && @page.external_feed && @page.external_feed.enabled && @page.external_feed.fetched_at.nil? %>
4 4  
5 5 <div>
6   - <%= link_to(image_tag('icons-mime/rss-feed.png'), article.feed.url, :class => 'blog-feed-link') if article.blog? && article.feed %>
  6 + <%= link_to(image_tag('icons-mime/rss-feed.png'), @page.feed.url, :class => 'blog-feed-link') if @page.blog? && @page.feed %>
7 7 <div class='blog-description'>
8   - <%= article.body %>
  8 + <%= @page.body %>
9 9 </div>
10 10 </div>
11 11 <hr class="pre-posts"/>
12 12 <div class="blog-posts">
13   - <%= (children.compact.empty? ? content_tag('em', _('(no posts)')) : list_posts(user, children, article.visualization_format)) %>
  13 + <%= (@posts.compact.empty? ? content_tag('em', _('(no posts)')) : list_posts(@posts, @page.visualization_format)) %>
14 14 </div>
... ...
app/views/content_viewer/view_page.rhtml
... ... @@ -86,7 +86,8 @@
86 86  
87 87 <% cache(@page.cache_key(params, user)) do %>
88 88 <div class="<%="article-body article-body-" + @page.css_class_name %>">
89   - <%= article_to_html(@page) %>
  89 + <% options = @page.image? ? {:gallery_view => true} : {} %>
  90 + <%= article_to_html(@page, options) %>
90 91 <br style="clear:both" />
91 92 </div> <!-- end class="article-body" -->
92 93 <% end %>
... ...
app/views/enterprise_registration/basic_information.rhtml
... ... @@ -20,8 +20,8 @@
20 20  
21 21 <% labelled_form_for(:create_enterprise, @create_enterprise) do |f| %>
22 22 <%= required f.text_field 'name', :onchange => "updateUrlField(this, 'create_enterprise_identifier')", :size => 40 %>
23   - <%= required labelled_form_field(_('Address'), content_tag('code', environment.top_url + "/" + text_field(:create_enterprise, 'identifier', :size => 25))) %>
24   - <%= render :partial => 'shared/custom_fields', :locals => { :f => f, :object_name => :create_enterprise, :profile => @create_enterprise, :only_required => false } %>
  23 + <%= required labelled_form_field(_('Address'), content_tag('code', environment.top_url + "/" + text_field(:create_enterprise, 'identifier', :size => 26))) %>
  24 + <%= render :partial => 'shared/organization_custom_fields', :locals => { :f => f, :object_name => :create_enterprise, :profile => @create_enterprise } %>
25 25 <%= required labelled_form_field(_('Region'), f.select('region_id', @regions)) if @validation == :region %>
26 26  
27 27 <% if @validation == :admin %>
... ...
app/views/features/_manage_community_fields.rhtml
... ... @@ -7,18 +7,25 @@
7 7 <th><%= _('Field') %></th>
8 8 <th><%= _('Active') %></th>
9 9 <th><%= _('Required') %></th>
  10 + <th><%= _('Display on creation?') %></th>
10 11 </tr>
11 12 <% @community_fields.each do |field| %>
12 13 <tr>
13 14 <td><label for="community_fields[<%= field %>][active]"><%= _(field.humanize) %></label></td>
  15 +
14 16 <td>
15   - <%= check_box_tag "community_fields[#{field}][active]", true, environment.custom_community_field(field, 'active'), :onclick => "$('community_fields[#{field}][required]').disabled=!this.checked" %>
  17 + <%= check_box_tag "community_fields[#{field}][active]", true, environment.custom_community_field(field, 'active'), :onclick => "$('community_fields[#{field}][required]').disabled=$('community_fields[#{field}][signup]').disabled=!this.checked;" %>
16 18 <%= hidden_field_tag "community_fields[#{field}][active]", false %>
17 19 </td>
18 20 <td>
19   - <%= check_box_tag "community_fields[#{field}][required]", true, environment.custom_community_field(field, 'required') %>
  21 + <%= check_box_tag "community_fields[#{field}][required]", true, environment.custom_community_field(field, 'required'), :onclick => "if(this.checked) $('community_fields[#{field}][signup]').checked = true;" %>
20 22 <%= hidden_field_tag "community_fields[#{field}][required]", false %>
21 23 </td>
  24 + <td>
  25 + <%= check_box_tag "community_fields[#{field}][signup]", true, environment.custom_community_field(field, 'signup'), :onclick => "if(!this.checked) $('community_fields[#{field}][required]').checked = false;" %>
  26 + <%= hidden_field_tag "community_fields[#{field}][signup]", false %>
  27 + </td>
  28 +
22 29 </tr>
23 30 <% end %>
24 31 </table>
... ...
app/views/features/_manage_enterprise_fields.rhtml
... ... @@ -7,18 +7,25 @@
7 7 <th><%= _('Field') %></th>
8 8 <th><%= _('Active') %></th>
9 9 <th><%= _('Required') %></th>
  10 + <th><%= _('Display on registration?') %></th>
10 11 </tr>
11 12 <% @enterprise_fields.each do |field| %>
12 13 <tr>
  14 +
13 15 <td><label for="enterprise_fields[<%= field %>][active]"><%= _(field.humanize) %></label></td>
14 16 <td>
15   - <%= check_box_tag "enterprise_fields[#{field}][active]", true, environment.custom_enterprise_field(field, 'active'), :onclick => "$('enterprise_fields[#{field}][required]').disabled=!this.checked" %>
  17 + <%= check_box_tag "enterprise_fields[#{field}][active]", true, environment.custom_enterprise_field(field, 'active'), :onclick => "$('enterprise_fields[#{field}][required]').disabled=$('enterprise_fields[#{field}][signup]').disabled=!this.checked;" %>
16 18 <%= hidden_field_tag "enterprise_fields[#{field}][active]", false %>
17 19 </td>
18 20 <td>
19   - <%= check_box_tag "enterprise_fields[#{field}][required]", true, environment.custom_enterprise_field(field, 'required') %>
  21 + <%= check_box_tag "enterprise_fields[#{field}][required]", true, environment.custom_enterprise_field(field, 'required'), :onclick => "if(this.checked) $('enterprise_fields[#{field}][signup]').checked = true;" %>
20 22 <%= hidden_field_tag "enterprise_fields[#{field}][required]", false %>
21 23 </td>
  24 + <td>
  25 + <%= check_box_tag "enterprise_fields[#{field}][signup]", true, environment.custom_enterprise_field(field, 'signup'), :onclick => "if(!this.checked) $('enterprise_fields[#{field}][required]').checked = false;" %>
  26 + <%= hidden_field_tag "enterprise_fields[#{field}][signup]", false %>
  27 + </td>
  28 +
22 29 </tr>
23 30 <% end %>
24 31 </table>
... ...
app/views/features/_manage_person_fields.rhtml
... ... @@ -13,15 +13,15 @@
13 13 <tr>
14 14 <td><label for="person_fields[<%= field %>][active]"><%= _(field.humanize) %></label></td>
15 15 <td>
16   - <%= check_box_tag "person_fields[#{field}][active]", true, environment.custom_person_field(field, 'active'), :onclick => "$('person_fields[#{field}][required]').disabled=$('person_fields[#{field}][signup]').disabled=!this.checked" %>
  16 + <%= check_box_tag "person_fields[#{field}][active]", true, environment.custom_person_field(field, 'active'), :onclick => "$('person_fields[#{field}][required]').disabled=$('person_fields[#{field}][signup]').disabled=!this.checked;" %>
17 17 <%= hidden_field_tag "person_fields[#{field}][active]", false %>
18 18 </td>
19 19 <td>
20   - <%= check_box_tag "person_fields[#{field}][required]", true, environment.custom_person_field(field, 'required') %>
  20 + <%= check_box_tag "person_fields[#{field}][required]", true, environment.custom_person_field(field, 'required'), :onclick => "if(this.checked) $('person_fields[#{field}][signup]').checked = true;" %>
21 21 <%= hidden_field_tag "person_fields[#{field}][required]", false %>
22 22 </td>
23 23 <td>
24   - <%= check_box_tag "person_fields[#{field}][signup]", true, environment.custom_person_field(field, 'signup') %>
  24 + <%= check_box_tag "person_fields[#{field}][signup]", true, environment.custom_person_field(field, 'signup'), :onclick => "if(!this.checked) $('person_fields[#{field}][required]').checked = false;" %>
25 25 <%= hidden_field_tag "person_fields[#{field}][signup]", false %>
26 26 </td>
27 27 </tr>
... ...
app/views/memberships/new_community.rhtml
... ... @@ -22,10 +22,7 @@
22 22  
23 23 <%= hidden_field_tag :wizard, params[:wizard] %>
24 24  
25   - <%= render :partial => 'shared/custom_fields', :locals => { :f => f, :object_name => 'community', :profile => @community, :only_required => true } %>
26   -
27   - <%= f.text_field('tag_list', :size => 64) %>
28   - <%= content_tag( 'small', _('Separate tags with commas.') + '<br/>' + __("Tags are important to new users, they'll be able to find your new community more easily.") ) %>
  25 + <%= render :partial => 'shared/organization_custom_fields', :locals => { :f => f, :object_name => 'community', :profile => @community } %>
29 26  
30 27 <% f.fields_for :image_builder, @community.image do |i| %>
31 28 <%= file_field_or_thumbnail(_('Image:'), @community.image, i) %>
... ...
app/views/profile_editor/_organization.rhtml
... ... @@ -14,14 +14,6 @@
14 14 </script>
15 15 <% end %>
16 16  
17   -<div class="formfieldline">
18   - <label class="formlabel" for="profile_data_nickname"><%= _('Display name') %></label>
19   - <div class="formfield type-text">
20   - <%= text_field_tag 'profile_data[nickname]', @profile_data.nickname, :id => 'profile_data_nickname', :size => 30, :maxlength => 16, :onchange => (@environment.enabled?('enable_organization_url_change') ? "updateUrlField(this, 'profile_data_identifier')" : "") %>
21   - <em><%= _('A short name by which the organization is know.')%></em>
22   - </div>
23   -</div>
24   -
25 17 <% if @environment.enabled?('enable_organization_url_change') %>
26 18 <script type="text/javascript">
27 19 function submit_button() {
... ... @@ -45,7 +37,7 @@
45 37  
46 38 <%= hidden_field_tag 'old_profile_identifier', @profile.identifier %>
47 39 <div id="profile-identifier-formitem">
48   - <%= labelled_form_field( _('Address'),
  40 + <%= required labelled_form_field( _('Address'),
49 41 content_tag('code',
50 42 url_for(profile.url).gsub(/#{profile.identifier}$/, '') +
51 43 text_field(:profile_data, :identifier, :onchange => "warn_value_change()", :size => 25)
... ... @@ -66,7 +58,7 @@
66 58 </div>
67 59 <% end %>
68 60  
69   - <%= render :partial => 'shared/custom_fields', :locals => { :f => f, :object_name => 'profile_data', :profile => @profile, :only_required => false } %>
  61 + <%= render :partial => 'shared/organization_custom_fields', :locals => { :f => f, :object_name => 'profile_data', :profile => @profile } %>
70 62  
71 63 <%= labelled_check_box(_('Enable "contact us"'), 'profile_data[enable_contact_us]', "1", @profile.enable_contact_us) if @profile.enterprise? %>
72 64  
... ...
app/views/shared/_custom_fields.rhtml
... ... @@ -1,25 +0,0 @@
1   -<% if profile.community? %>
2   - <%= optional_field(profile, 'language', f.text_field(:language), only_required) %>
3   -<% end %>
4   -
5   -<%= optional_field(profile, 'description', f.text_area(:description, :rows => 5)) %> <!-- , :maxlength => 10 -->
6   -<%= optional_field(profile, 'contact_person', f.text_field(:contact_person), only_required) %>
7   -<%= optional_field(profile, 'contact_email', f.text_field(:contact_email), only_required) %>
8   -<%= optional_field(profile, 'contact_phone', f.text_field(:contact_phone), only_required) %>
9   -<%= optional_field(profile, 'legal_form', f.text_field(:legal_form), only_required) %>
10   -<%= optional_field(profile, 'economic_activity', f.text_field(:economic_activity), only_required) %>
11   -<%= optional_field(profile, 'management_information', f.text_area(:management_information, :rows => 5), only_required) %>
12   -<%= optional_field(profile, 'address', labelled_form_field(_('Address (street and number)'), text_field(object_name, :address)), only_required) %>
13   -
14   -<% if profile.enterprise? %>
15   - <%= optional_field(profile, 'business_name', f.text_field(:business_name), only_required) %>
16   - <%= optional_field(profile, 'zip_code', labelled_form_field(_('ZIP code'), text_field(object_name, :zip_code)), only_required) %>
17   - <%= optional_field(profile, 'city', f.text_field(:city), only_required) %>
18   - <%= optional_field(profile, 'state', f.text_field(:state), only_required) %>
19   - <%= optional_field(profile, 'country', select_country(_('Country'), object_name, 'country', {:class => 'type-select'}), only_required) %>
20   - <%= optional_field(profile, 'organization_website', f.text_field(:organization_website), only_required) %>
21   - <%= optional_field(profile, 'historic_and_current_context', f.text_area(:historic_and_current_context, :rows => 5), only_required) %>
22   - <%= optional_field(profile, 'activities_short_description', f.text_area(:activities_short_description, :rows => 5), only_required) %>
23   - <%= optional_field(profile, 'acronym', f.text_field(:acronym), only_required) %>
24   - <%= optional_field(profile, 'foundation_year', f.text_field(:foundation_year), only_required) %>
25   -<% end %>
app/views/shared/_organization_custom_fields.rhtml 0 → 100644
... ... @@ -0,0 +1,27 @@
  1 +<%= optional_field(profile, 'display_name', f.text_field(:display_name)) %>
  2 +<%= optional_field(profile, 'description', f.text_area(:description, :rows => 5)) %> <!-- , :maxlength => 10 -->
  3 +<%= optional_field(profile, 'contact_person', f.text_field(:contact_person)) %>
  4 +<%= optional_field(profile, 'contact_email', f.text_field(:contact_email)) %>
  5 +<%= optional_field(profile, 'contact_phone', f.text_field(:contact_phone)) %>
  6 +<%= optional_field(profile, 'legal_form', f.text_field(:legal_form)) %>
  7 +<%= optional_field(profile, 'economic_activity', f.text_field(:economic_activity)) %>
  8 +<%= optional_field(profile, 'management_information', f.text_area(:management_information, :rows => 5)) %>
  9 +<%= optional_field(profile, 'address', labelled_form_field(_('Address (street and number)'), text_field(object_name, :address))) %>
  10 +<%= optional_field(profile, 'zip_code', labelled_form_field(_('ZIP code'), text_field(object_name, :zip_code))) %>
  11 +<%= optional_field(profile, 'city', f.text_field(:city)) %>
  12 +<%= optional_field(profile, 'state', f.text_field(:state)) %>
  13 +<%= optional_field(profile, 'country', select_country(_('Country'), object_name, 'country', {:class => 'type-select'})) %>
  14 +<%= optional_field(profile, 'tag_list', f.text_field(:tag_list)) %>
  15 +
  16 +<% if profile.community? %>
  17 + <%= optional_field(profile, 'language', f.text_field(:language)) %>
  18 +<% end %>
  19 +
  20 +<% if profile.enterprise? %>
  21 + <%= optional_field(profile, 'business_name', f.text_field(:business_name)) %>
  22 + <%= optional_field(profile, 'organization_website', f.text_field(:organization_website)) %>
  23 + <%= optional_field(profile, 'historic_and_current_context', f.text_area(:historic_and_current_context, :rows => 5)) %>
  24 + <%= optional_field(profile, 'activities_short_description', f.text_area(:activities_short_description, :rows => 5)) %>
  25 + <%= optional_field(profile, 'acronym', f.text_field(:acronym)) %>
  26 + <%= optional_field(profile, 'foundation_year', f.text_field(:foundation_year)) %>
  27 +<% end %>
... ...
features/location.feature
... ... @@ -10,7 +10,7 @@ Feature: Location
10 10 And I am logged in as "zezinho"
11 11  
12 12 Scenario: editing my address
13   - Given the following Person fields are active
  13 + Given the following Person fields are active fields
14 14 | address |
15 15 | country |
16 16 | state |
... ... @@ -29,7 +29,7 @@ Feature: Location
29 29 | Rua Marechal Floriano, 28 | BR | Bahia | Salvador | 40110010 |
30 30  
31 31 Scenario Outline: editing address of collectives
32   - Given the following <class> fields are active
  32 + Given the following <class> fields are active fields
33 33 | address |
34 34 | country |
35 35 | state |
... ...
features/organization_custom_fields.feature 0 → 100644
... ... @@ -0,0 +1,101 @@
  1 +Feature: organization custom fields
  2 + As a noosfero admin
  3 + I want to choose what fields are active or required for organizations
  4 + In order to have more consistency in the system
  5 +
  6 + Background:
  7 + Given the following users
  8 + | login | name |
  9 + | joaosilva | Joao Silva |
  10 + And I am logged in as "joaosilva"
  11 + And feature "enterprise_registration" is enabled on environment
  12 + And I follow "Control panel"
  13 +
  14 + Scenario Outline: organization active fields are not displayed on creation
  15 + Given the following <organization> fields are active fields
  16 + | display_name |
  17 + | contact_email |
  18 + | city |
  19 + And I follow "Manage my groups"
  20 + When I follow <creation_button>
  21 + Then I should not see "Display name"
  22 + Then I should not see "Contact email"
  23 + Then I should not see "City"
  24 + Examples:
  25 + | organization | creation_button |
  26 + | community | "Create a new community" |
  27 + | enterprise | "Register a new enterprise" |
  28 +
  29 + Scenario Outline: organization active fields are displayed on edition
  30 + Given the following <organization> fields are active fields
  31 + | display_name |
  32 + | contact_email |
  33 + | city |
  34 + And the following <organization>
  35 + | name | identifier |
  36 + | Organization | organization |
  37 + And "Joao Silva" is admin of "Organization"
  38 + And I am on Organization's control panel
  39 + And I follow <information>
  40 + Then I should see "Display name"
  41 + Then I should see "Contact email"
  42 + Then I should see "City"
  43 + Examples:
  44 + | organization | information |
  45 + | community | "Community Info and settings" |
  46 + | enterprise | "Enterprise Info and settings" |
  47 +
  48 + Scenario Outline: organization required fields are displayed on creation
  49 + Given the following <organization> fields are required fields
  50 + | display_name |
  51 + | contact_email |
  52 + | city |
  53 + And I follow "Manage my groups"
  54 + And I follow <creation_button>
  55 + When I press <confirmation_button>
  56 + Then I should see "Display name can't be blank"
  57 + Then I should see "Contact email can't be blank"
  58 + Then I should see "City can't be blank"
  59 + Examples:
  60 + | organization | creation_button | confirmation_button |
  61 + | community | "Create a new community" | "Create" |
  62 + | enterprise | "Register a new enterprise" | "Next" |
  63 +
  64 + Scenario Outline: organization required fields are displayed on edition
  65 + Given the following <organization> fields are required fields
  66 + | display_name |
  67 + | contact_email |
  68 + | city |
  69 + And the following <organization>
  70 + | name | identifier | display_name | contact_email | city |
  71 + | Organization | organization | organization | bla@bleee.com | city |
  72 + And "Joao Silva" is admin of "Organization"
  73 + And I am on Organization's control panel
  74 + And I follow <information>
  75 + And I fill in the following:
  76 + | Display name | |
  77 + | Contact email | |
  78 + | City | |
  79 + When I press "Save"
  80 + Then I should see "Display name can't be blank"
  81 + Then I should see "Contact email can't be blank"
  82 + Then I should see "City can't be blank"
  83 + Examples:
  84 + | organization | information |
  85 + | community | "Community Info and settings" |
  86 + | enterprise | "Enterprise Info and settings" |
  87 +
  88 + Scenario Outline: organization signup fields are displayed on creation
  89 + Given the following <organization> fields are signup fields
  90 + | display_name |
  91 + | contact_email |
  92 + | city |
  93 + And I follow "Manage my groups"
  94 + When I follow <creation_button>
  95 + Then I should see "Display name"
  96 + Then I should see "Contact email"
  97 + Then I should see "City"
  98 + Examples:
  99 + | organization | creation_button |
  100 + | community | "Create a new community" |
  101 + | enterprise | "Register a new enterprise" |
... ...
features/publish_article.feature
... ... @@ -54,7 +54,7 @@ Feature: publish article
54 54 And I follow "Spread"
55 55 And I check "Sample Community"
56 56 When I press "Publish"
57   - Then I should see "Validation failed: The title (article name) is already being used by another article, please use another title.:"
  57 + Then I should see "The title (article name) is already being used by another article, please use another title."
58 58  
59 59 Scenario: publishing an article in many communities and listing the communities that couldn't publish the article again,
60 60 stills publishing the article in the other communities.
... ... @@ -79,7 +79,7 @@ Feature: publish article
79 79 And I check "Another Community1"
80 80 And I check "Another Community2"
81 81 When I press "Publish"
82   - Then I should see "Validation failed: The title (article name) is already being used by another article, please use another title.:"
  82 + Then I should see "The title (article name) is already being used by another article, please use another title."
83 83 And I am on Another Community1's homepage
84 84 And I follow "View profile"
85 85 When I go to Another Community1's sitemap
... ... @@ -110,9 +110,9 @@ Feature: publish article
110 110 And I am on Sample Community's control panel
111 111 And I follow "Tasks"
112 112 And I press "Ok!"
113   - And I should not see "Validation failed: The title (article name) is already being used by another article, please use another title.:"
  113 + And I should not see "The title (article name) is already being used by another article, please use another title."
114 114 When I press "Ok!"
115   - Then I should see "Validation failed: The title (article name) is already being used by another article, please use another title."
  115 + Then I should see "The title (article name) is already being used by another article, please use another title."
116 116  
117 117 Scenario: ask to publish an article that was deleted before approval
118 118 Given I am logged in as "joaosilva"
... ...
features/register_enterprise.feature
... ... @@ -44,8 +44,8 @@ Feature: register enterprise
44 44 When I follow "Register a new enterprise"
45 45 Then I should see "There are no validators to validate the registration of this new enterprise. Contact your administrator for instructions."
46 46  
47   - Scenario: some active fields
48   - Given the following enterprise fields are active
  47 + Scenario: some signup fields
  48 + Given the following enterprise fields are signup fields
49 49 | foundation_year |
50 50 | contact_person |
51 51 | contact_email |
... ... @@ -61,7 +61,7 @@ Feature: register enterprise
61 61 And the following states
62 62 | name |
63 63 | Sample State |
64   - And the following enterprise fields are required
  64 + And the following enterprise fields are required fields
65 65 | foundation_year |
66 66 | contact_person |
67 67 | contact_email |
... ...
features/step_definitions/noosfero_steps.rb
... ... @@ -144,18 +144,21 @@ Given /^&quot;([^\&quot;]*)&quot; has no articles$/ do |profile|
144 144 (Profile[profile] || Profile.find_by_name(profile)).articles.delete_all
145 145 end
146 146  
147   -Given /^the following (\w+) fields are (\w+)$/ do |klass, status, table|
  147 +Given /^the following (\w+) fields are (\w+) fields$/ do |klass, status, table|
148 148 env = Environment.default
149 149 fields = table.raw.inject({}) do |hash, line|
150   - hash[line.first] = { "active" => 'true' }
151   - hash[line.first].merge!({ "required" => 'true'}) if status == "required"
  150 + hash[line.first] = {}
  151 + hash[line.first].merge!({ "active" => 'true' }) if status == "active"
  152 + hash[line.first].merge!({ "required" => 'true'}) if status == "required"
  153 + hash[line.first].merge!({ "signup" => 'true'}) if status == "signup"
152 154 hash
153 155 end
154 156  
155 157 env.send("custom_#{klass.downcase}_fields=", fields)
156 158 env.save!
  159 +
157 160 if fields.keys != env.send("#{status}_#{klass.downcase}_fields")
158   - raise "Not all fields #{status}! Requested: %s; #{status.camelcase}: %s" % [fields.keys.inspect, env.send("#{status}_#{klass.downcase}_fields").inspect]
  161 + raise "Not all fields #{status}! Requested: %s; #{status.camelcase}: %s" % [fields.keys.inspect, env.send("#{status}_#{klass.downcase}_fields").inspect]
159 162 end
160 163 end
161 164  
... ...
lib/noosfero.rb
1 1 module Noosfero
2 2 PROJECT = 'noosfero'
3   - VERSION = '0.24.1'
  3 + VERSION = '0.24.2'
4 4  
5 5 def self.pattern_for_controllers_in_directory(dir)
6 6 disjunction = controllers_in_directory(dir).join('|')
... ...
test/functional/account_controller_test.rb
... ... @@ -265,7 +265,7 @@ class AccountControllerTest &lt; Test::Unit::TestCase
265 265  
266 266 should 'require password confirmation correctly to enter new pasword' do
267 267 user = create_user('testuser', :email => 'testuser@example.com', :password => 'test', :password_confirmation => 'test')
268   - change = ChangePassword.create!(:login => 'testuser', :email => 'testuser@example.com')
  268 + change = ChangePassword.create!(:login => 'testuser', :email => 'testuser@example.com', :environment_id => Environment.default.id)
269 269  
270 270 post :new_password, :code => change.code, :change_password => { :password => 'onepass', :password_confirmation => 'another_pass' }
271 271 assert_response :success
... ...
test/functional/content_viewer_controller_test.rb
... ... @@ -603,10 +603,27 @@ class ContentViewerControllerTest &lt; Test::Unit::TestCase
603 603 assert_response :missing
604 604 end
605 605  
  606 + should 'list unpublished posts to owner with a different class' do
  607 + login_as('testinguser')
  608 + blog = Blog.create!(:name => 'A blog test', :profile => profile)
  609 + blog.posts << TextileArticle.create!(:name => 'Post', :profile => profile, :parent => blog, :published => false)
  610 +
  611 + get :view_page, :profile => profile.identifier, :page => [blog.path]
  612 + assert_tag :tag => 'div', :attributes => {:class => /not-published/}
  613 + end
  614 +
  615 + should 'not list unpublished posts to a not logged person' do
  616 + blog = Blog.create!(:name => 'A blog test', :profile => profile)
  617 + blog.posts << TextileArticle.create!(:name => 'Post', :profile => profile, :parent => blog, :published => false)
  618 +
  619 + get :view_page, :profile => profile.identifier, :page => [blog.path]
  620 + assert_no_tag :tag => 'a', :content => "Post"
  621 + end
  622 +
606 623 should 'display pagination links of blog' do
607 624 blog = Blog.create!(:name => 'A blog test', :profile => profile, :posts_per_page => 5)
608 625 for n in 1..10
609   - blog.children << TextileArticle.create!(:name => "Post #{n}", :profile => profile, :parent => blog)
  626 + blog.posts << TextileArticle.create!(:name => "Post #{n}", :profile => profile, :parent => blog)
610 627 end
611 628 assert_equal 10, blog.posts.size
612 629  
... ... @@ -614,11 +631,17 @@ class ContentViewerControllerTest &lt; Test::Unit::TestCase
614 631 assert_tag :tag => 'a', :attributes => { :href => "/#{profile.identifier}/#{blog.path}?npage=2", :rel => 'next' }
615 632 end
616 633  
617   - should 'set year and month filter from URL params' do
618   - profile.articles << Blog.new(:name => 'A blog test', :profile => profile)
619   - year, month = profile.blog.created_at.year.to_s, '%02d' % profile.blog.created_at.month
620   - get :view_page, :profile => profile.identifier, :page => [profile.blog.path], :year => year, :month => month
621   - assert_equal({ :year => year.to_s, :month => month.to_s }, assigns(:page).filter)
  634 + should 'display filtered posts' do
  635 + blog = Blog.create!(:name => 'A blog test', :profile => profile)
  636 + not_display_post = TextileArticle.new(:name => "Post 1", :profile => profile, :parent => blog)
  637 + display_post = TextileArticle.new(:name => "Post 2", :profile => profile, :parent => blog)
  638 +
  639 + not_display_post.update_attribute(:published_at, DateTime.parse('2009-09-10'))
  640 + display_post.update_attribute(:published_at, DateTime.parse('2010-09-10'))
  641 +
  642 + get :view_page, :profile => profile.identifier, :page => [blog.path], :year => 2010, :month => 9
  643 + assert_no_tag :tag => 'a', :content => "Post 1"
  644 + assert_tag :tag => 'a', :content => "Post 2"
622 645 end
623 646  
624 647 should 'give link to create new article inside folder when view child of folder' do
... ...
test/integration/forgot_password_test.rb
... ... @@ -19,7 +19,7 @@ class ForgotPasswordTest &lt; ActionController::IntegrationTest
19 19 assert_response :success
20 20 assert_tag :tag => 'form', :attributes => { :action => '/account/forgot_password', :method => 'post' }
21 21  
22   - post '/account/forgot_password', :change_password => { :login => 'forgotten', :email => 'forgotten@localhost.localdomain' }
  22 + post '/account/forgot_password', :change_password => { :login => 'forgotten', :email => 'forgotten@localhost.localdomain', :environment_id => Environment.default.id }
23 23  
24 24 assert_response :success
25 25 assert_template 'password_recovery_sent'
... ...
test/unit/application_helper_test.rb
... ... @@ -244,17 +244,44 @@ class ApplicationHelperTest &lt; Test::Unit::TestCase
244 244 assert_equal '', profile_sex_icon(Person.new(:sex => 'male'))
245 245 end
246 246  
247   - should 'display field on signup' do
248   - env = fast_create(Environment, :name => 'env test')
  247 + should 'display field on person signup' do
  248 + env = Environment.create!(:name => 'env test')
249 249 stubs(:environment).returns(env)
250 250  
251 251 controller = mock
252 252 stubs(:controller).returns(controller)
253 253 controller.expects(:action_name).returns('signup')
254 254  
255   - profile = Person.new
256   - profile.expects(:signup_fields).returns(['field'])
257   - assert_equal 'SIGNUP_FIELD', optional_field(profile, 'field', 'SIGNUP_FIELD')
  255 + person = Person.new
  256 + person.expects(:signup_fields).returns(['field'])
  257 + assert_equal 'SIGNUP_FIELD', optional_field(person, 'field', 'SIGNUP_FIELD')
  258 + end
  259 +
  260 + should 'display field on enterprise registration' do
  261 + env = Environment.create!(:name => 'env test')
  262 + stubs(:environment).returns(env)
  263 +
  264 + controller = mock
  265 + stubs(:controller).returns(controller)
  266 + controller.stubs(:controller_name).returns('enterprise_registration')
  267 + controller.stubs(:action_name).returns('index')
  268 +
  269 + enterprise = Enterprise.new
  270 + enterprise.expects(:signup_fields).returns(['field'])
  271 + assert_equal 'SIGNUP_FIELD', optional_field(enterprise, 'field', 'SIGNUP_FIELD')
  272 + end
  273 +
  274 + should 'display field on community creation' do
  275 + env = Environment.create!(:name => 'env test')
  276 + stubs(:environment).returns(env)
  277 +
  278 + controller = mock
  279 + stubs(:controller).returns(controller)
  280 + controller.stubs(:action_name).returns('new_community')
  281 +
  282 + community = Community.new
  283 + community.expects(:signup_fields).returns(['field'])
  284 + assert_equal 'SIGNUP_FIELD', optional_field(community, 'field', 'SIGNUP_FIELD')
258 285 end
259 286  
260 287 should 'not display field on signup' do
... ... @@ -265,9 +292,36 @@ class ApplicationHelperTest &lt; Test::Unit::TestCase
265 292 stubs(:controller).returns(controller)
266 293 controller.expects(:action_name).returns('signup')
267 294  
268   - profile = Person.new
269   - profile.expects(:signup_fields).returns([])
270   - assert_equal '', optional_field(profile, 'field', 'SIGNUP_FIELD')
  295 + person = Person.new
  296 + person.expects(:signup_fields).returns([])
  297 + assert_equal '', optional_field(person, 'field', 'SIGNUP_FIELD')
  298 + end
  299 +
  300 + should 'not display field on enterprise registration' do
  301 + env = Environment.create!(:name => 'env test')
  302 + stubs(:environment).returns(env)
  303 +
  304 + controller = mock
  305 + stubs(:controller).returns(controller)
  306 + controller.stubs(:controller_name).returns('enterprise_registration')
  307 + controller.stubs(:action_name).returns('index')
  308 +
  309 + enterprise = Enterprise.new
  310 + enterprise.expects(:signup_fields).returns([])
  311 + assert_equal '', optional_field(enterprise, 'field', 'SIGNUP_FIELD')
  312 + end
  313 +
  314 + should 'not display field on community creation' do
  315 + env = Environment.create!(:name => 'env test')
  316 + stubs(:environment).returns(env)
  317 +
  318 + controller = mock
  319 + stubs(:controller).returns(controller)
  320 + controller.stubs(:action_name).returns('new_community')
  321 +
  322 + community = Community.new
  323 + community.stubs(:signup_fields).returns([])
  324 + assert_equal '', optional_field(community, 'field', 'SIGNUP_FIELD')
271 325 end
272 326  
273 327 should 'display active fields' do
... ... @@ -276,7 +330,8 @@ class ApplicationHelperTest &lt; Test::Unit::TestCase
276 330  
277 331 controller = mock
278 332 stubs(:controller).returns(controller)
279   - controller.expects(:action_name).returns('edit')
  333 + controller.stubs(:controller_name).returns('')
  334 + controller.stubs(:action_name).returns('edit')
280 335  
281 336 profile = Person.new
282 337 profile.expects(:active_fields).returns(['field'])
... ... @@ -289,7 +344,8 @@ class ApplicationHelperTest &lt; Test::Unit::TestCase
289 344  
290 345 controller = mock
291 346 stubs(:controller).returns(controller)
292   - controller.expects(:action_name).returns('edit')
  347 + controller.stubs(:action_name).returns('edit')
  348 + controller.stubs(:controller_name).returns('')
293 349  
294 350 profile = Person.new
295 351 profile.expects(:active_fields).returns([])
... ... @@ -302,7 +358,8 @@ class ApplicationHelperTest &lt; Test::Unit::TestCase
302 358  
303 359 controller = mock
304 360 stubs(:controller).returns(controller)
305   - controller.expects(:action_name).returns('edit')
  361 + controller.stubs(:controller_name).returns('')
  362 + controller.stubs(:action_name).returns('edit')
306 363  
307 364 stubs(:required).with('SIGNUP_FIELD').returns('<span>SIGNUP_FIELD</span>')
308 365 profile = Person.new
... ... @@ -311,21 +368,6 @@ class ApplicationHelperTest &lt; Test::Unit::TestCase
311 368 assert_equal '<span>SIGNUP_FIELD</span>', optional_field(profile, 'field', 'SIGNUP_FIELD')
312 369 end
313 370  
314   - should 'display required fields on signup even if admin did not marked field to show up in signup' do
315   - env = Environment.create!(:name => 'env test')
316   - stubs(:environment).returns(env)
317   -
318   - controller = mock
319   - stubs(:controller).returns(controller)
320   - controller.expects(:action_name).returns('signup')
321   -
322   - stubs(:required).with('SIGNUP_FIELD').returns('<span>SIGNUP_FIELD</span>')
323   - profile = Person.new
324   - profile.stubs(:required_fields).returns(['field'])
325   - profile.stubs(:signup_fields).returns([])
326   - assert_equal '<span>SIGNUP_FIELD</span>', optional_field(profile, 'field', 'SIGNUP_FIELD')
327   - end
328   -
329 371 should 'not ask_to_join unless profile defined' do
330 372 stubs(:params).returns({})
331 373  
... ...
test/unit/article_block_test.rb
... ... @@ -115,6 +115,21 @@ class ArticleBlockTest &lt; Test::Unit::TestCase
115 115 assert_match(/image/, instance_eval(&block.content))
116 116 end
117 117  
  118 + should 'not display gallery pages navigation in content' do
  119 + profile = create_user('testuser').person
  120 + block = ArticleBlock.new
  121 + gallery = fast_create(Folder, :profile_id => profile.id)
  122 + gallery.view_as = 'image_gallery'
  123 + gallery.save!
  124 + image = UploadedFile.create!(:profile => profile, :uploaded_data => fixture_file_upload('/files/rails.png', 'image/png'), :parent => gallery)
  125 + block.article = image
  126 + block.save!
  127 +
  128 + expects(:image_tag).with(image.public_filename(:display), :class => image.css_class_name, :style => 'max-width: 100%').returns('image')
  129 +
  130 + assert_no_match(/Previous/, instance_eval(&block.content))
  131 + end
  132 +
118 133 should 'display link to archive if article is an archive' do
119 134 profile = create_user('testuser').person
120 135 block = ArticleBlock.new
... ...
test/unit/article_test.rb
... ... @@ -873,4 +873,22 @@ class ArticleTest &lt; Test::Unit::TestCase
873 873 assert_no_match /[<>]/, article.name
874 874 end
875 875  
  876 + should 'found articles with published date between a range' do
  877 + start_date = DateTime.parse('2010-07-06')
  878 + end_date = DateTime.parse('2010-08-02')
  879 +
  880 + article_found1 = fast_create(Article, :published_at => start_date)
  881 + article_found2 = fast_create(Article, :published_at => end_date)
  882 + article_not_found = fast_create(Article, :published_at => end_date + 1.month)
  883 +
  884 + assert_includes Article.by_range(start_date..end_date), article_found1
  885 + assert_includes Article.by_range(start_date..end_date), article_found2
  886 + assert_not_includes Article.by_range(start_date..end_date), article_not_found
  887 + end
  888 +
  889 + should 'calculate first/end day of a month' do
  890 + assert_equal 1, Article.first_day_of_month(DateTime.parse('2010-07-06')).day
  891 + assert_equal 31, Article.last_day_of_month(DateTime.parse('2010-07-06')).day
  892 + end
  893 +
876 894 end
... ...
test/unit/blog_helper_test.rb
... ... @@ -27,28 +27,7 @@ class BlogHelperTest &lt; Test::Unit::TestCase
27 27 expects(:content_tag).with('div', "POST<br style=\"clear:both\"/>", :class => 'blog-post position-1 first last odd-post-inner', :id => "post-#{published_post.id}").returns('POST')
28 28 expects(:content_tag).with('div', 'POST', {:class => 'odd-post'}).returns('RESULT')
29 29  
30   - assert_equal 'RESULT', list_posts(profile, blog.posts)
31   - end
32   -
33   - should 'list unpublished posts to owner with a different class' do
34   - blog.children << unpublished_post = TextileArticle.create!(:name => 'Post', :profile => profile, :parent => blog, :published => false)
35   -
36   - expects(:display_post).with(anything, anything).returns('POST')
37   - expects(:content_tag).with('div', "POST<br style=\"clear:both\"/>", :class => 'blog-post position-1 first last not-published odd-post-inner', :id => "post-#{unpublished_post.id}").returns('POST')
38   - expects(:content_tag).with('div', 'POST', {:class => 'odd-post'}).returns('RESULT')
39   - assert_equal 'RESULT', list_posts(profile, blog.posts)
40   - end
41   -
42   - should 'not list unpublished posts to not owner' do
43   - blog.children << unpublished_post = TextileArticle.create!(:name => 'First post', :profile => profile, :parent => blog, :published => false)
44   -
45   - blog.children << published_post = TextileArticle.create!(:name => 'Second post', :profile => profile, :parent => blog, :published => true)
46   -
47   - expects(:display_post).with(anything, anything).returns('POST')
48   - expects(:content_tag).with('div', "POST<br style=\"clear:both\"/>", has_entries(:id => "post-#{unpublished_post.id}")).never
49   - expects(:content_tag).with('div', "POST<br style=\"clear:both\"/>", has_entries(:id => "post-#{published_post.id}")).returns('POST')
50   - expects(:content_tag).with('div', 'POST', {:class => 'odd-post'}).returns('RESULT')
51   - assert_equal 'RESULT', list_posts(nil, blog.posts)
  30 + assert_equal 'RESULT', list_posts(blog.posts)
52 31 end
53 32  
54 33 should 'list even/odd posts with a different class' do
... ... @@ -64,7 +43,7 @@ class BlogHelperTest &lt; Test::Unit::TestCase
64 43 expects(:content_tag).with('div', "POST<br style=\"clear:both\"/>", :class => 'blog-post position-2 last even-post-inner', :id => "post-#{older_post.id}").returns('POST 2')
65 44 expects(:content_tag).with('div', "POST 2", :class => 'even-post').returns('EVEN-POST')
66 45  
67   - assert_equal "ODD-POST\n<hr class='sep-posts'/>\nEVEN-POST", list_posts(nil, blog.posts)
  46 + assert_equal "ODD-POST\n<hr class='sep-posts'/>\nEVEN-POST", list_posts(blog.posts)
68 47 end
69 48  
70 49  
... ...
test/unit/blog_test.rb
... ... @@ -82,13 +82,6 @@ class BlogTest &lt; ActiveSupport::TestCase
82 82 assert_equal [newer, older], blog.posts
83 83 end
84 84  
85   - should 'has filter' do
86   - p = create_user('testuser').person
87   - blog = fast_create(Blog, :profile_id => p.id, :name => 'Blog test')
88   - blog.filter = {:param => 'value'}
89   - assert_equal 'value', blog.filter[:param]
90   - end
91   -
92 85 should 'has one external feed' do
93 86 p = create_user('testuser').person
94 87 blog = fast_create(Blog, :profile_id => p.id, :name => 'Blog test')
... ...
test/unit/change_password_test.rb
... ... @@ -14,6 +14,8 @@ class ChangePasswordTest &lt; Test::Unit::TestCase
14 14  
15 15 data = ChangePassword.new
16 16 data.login = 'unexisting'
  17 + data.email = 'example@example.com'
  18 + data.environment_id = Environment.default.id
17 19 data.valid?
18 20 assert data.errors.invalid?(:login)
19 21 end
... ... @@ -35,6 +37,7 @@ class ChangePasswordTest &lt; Test::Unit::TestCase
35 37 data = ChangePassword.new
36 38 data.login = 'testuser'
37 39 data.email = 'wrong@example.com'
  40 + data.environment_id = Environment.default.id
38 41  
39 42 data.valid?
40 43 assert !data.errors.invalid?(:login)
... ... @@ -48,6 +51,7 @@ class ChangePasswordTest &lt; Test::Unit::TestCase
48 51 data = ChangePassword.new
49 52 data.login = 'testuser'
50 53 data.email = 'test@example.com'
  54 + data.environment_id = Environment.default.id
51 55  
52 56 data.valid?
53 57 assert !data.errors.invalid?(:login)
... ... @@ -60,6 +64,7 @@ class ChangePasswordTest &lt; Test::Unit::TestCase
60 64 change = ChangePassword.new
61 65 change.login = 'testuser'
62 66 change.email = 'test@example.com'
  67 + change.environment_id = Environment.default.id
63 68 change.save!
64 69  
65 70 change.status = Task::Status::FINISHED
... ... @@ -80,6 +85,7 @@ class ChangePasswordTest &lt; Test::Unit::TestCase
80 85 change = ChangePassword.new
81 86 change.login = 'testuser'
82 87 change.email = 'test@example.com'
  88 + change.environment_id = Environment.default.id
83 89 change.save!
84 90  
85 91 change.expects(:requestor).returns(person).at_least_once
... ... @@ -98,6 +104,7 @@ class ChangePasswordTest &lt; Test::Unit::TestCase
98 104 change = ChangePassword.new
99 105 change.login = 'testuser'
100 106 change.email = 'test@example.com'
  107 + change.environment_id = Environment.default.id
101 108 change.save!
102 109  
103 110 assert_nothing_raised do
... ... @@ -111,4 +118,18 @@ class ChangePasswordTest &lt; Test::Unit::TestCase
111 118 assert_equal t1.permission, t2.permission
112 119 end
113 120  
  121 + should 'search for user in the correct environment' do
  122 + e1 = Environment.create!(:id => 1, :name => "environment1")
  123 + e2 = Environment.create!(:id => 2, :name => "environment2")
  124 + p1 = create_user('sample-user', :password => 'test', :password_confirmation => 'test', :email => 'sample-user@e1.com', :environment => e1).person
  125 + p2 = create_user('sample-user', :password => 'test', :password_confirmation => 'test', :email => 'sample-user@e2.com', :environment => e2).person
  126 +
  127 + change = ChangePassword.new
  128 + change.login = 'sample-user'
  129 + change.email = 'sample-user@e2.com'
  130 + change.environment_id = e2.id
  131 +
  132 + assert change.valid?
  133 + end
  134 +
114 135 end
... ...
test/unit/content_viewer_helper_test.rb
... ... @@ -57,32 +57,10 @@ class ContentViewerHelperTest &lt; Test::Unit::TestCase
57 57 should 'not list feed article' do
58 58 profile.articles << Blog.new(:name => 'Blog test', :profile => profile)
59 59 assert_includes profile.blog.children.map{|i| i.class}, RssFeed
60   - result = list_posts(nil, profile.blog.posts)
  60 + result = list_posts(profile.blog.posts)
61 61 assert_no_match /feed/, result
62 62 end
63 63  
64   - should 'filter blog posts by date' do
65   - blog = Blog.create!(:name => 'Blog test', :profile => profile)
66   -
67   - nov = TextileArticle.create!(:name => 'November post', :parent => blog, :profile => profile)
68   - nov.update_attributes!(:published_at => DateTime.parse('2008-11-15'))
69   -
70   - sep = TextileArticle.create!(:name => 'September post', :parent => blog, :profile => profile)
71   - sep.update_attribute(:published_at, DateTime.parse('2008-09-10'))
72   -
73   - blog.reload
74   - blog.filter = {:year => 2008, :month => 11}
75   - assert blog.save!
76   -
77   - self.stubs(:params).returns({:npage => nil})
78   -
79   - expects(:render).with(:file => 'content_viewer/blog_page', :locals => {:article => blog, :children => [nov]}).returns("BLI")
80   -
81   - result = article_to_html(blog)
82   -
83   - assert_equal 'BLI', result
84   - end
85   -
86 64 end
87 65  
88 66 def show_date(date)
... ...
test/unit/environment_test.rb
... ... @@ -253,7 +253,7 @@ class EnvironmentTest &lt; Test::Unit::TestCase
253 253 assert_raise ArgumentError do
254 254 env.organization_approval_method = :lalala
255 255 end
256   -
  256 +
257 257 end
258 258  
259 259 should 'provide environment name in to_s' do
... ... @@ -373,7 +373,7 @@ class EnvironmentTest &lt; Test::Unit::TestCase
373 373  
374 374 assert_includes env.products, p1
375 375 end
376   -
  376 +
377 377 should 'not have person through communities' do
378 378 env = Environment.default
379 379 com = fast_create(Community)
... ... @@ -472,15 +472,15 @@ class EnvironmentTest &lt; Test::Unit::TestCase
472 472  
473 473 comm = fast_create(Community)
474 474 e.community_template = comm
475   - assert_equal comm, e.community_template
  475 + assert_equal comm, e.community_template
476 476  
477 477 person = fast_create(Person)
478 478 e.person_template = person
479   - assert_equal person, e.person_template
  479 + assert_equal person, e.person_template
480 480  
481 481 enterprise = fast_create(Enterprise)
482 482 e.enterprise_template = enterprise
483   - assert_equal enterprise, e.enterprise_template
  483 + assert_equal enterprise, e.enterprise_template
484 484 end
485 485  
486 486 should 'not enable ssl by default' do
... ... @@ -523,11 +523,11 @@ class EnvironmentTest &lt; Test::Unit::TestCase
523 523 assert_equal false, Environment.new.replace_enterprise_template_when_enable
524 524 end
525 525  
526   - should 'set custom_person_fields' do
  526 + should 'set custom_person_fields with its dependecies' do
527 527 env = Environment.new
528   - env.custom_person_fields = {'cell_phone' => {'required' => 'true', 'active' => 'true'},'comercial_phone'=> {'required' => 'true', 'active' => 'true'}}
  528 + env.custom_person_fields = {'cell_phone' => {'required' => 'true', 'active' => '', 'signup' => ''}, 'comercial_phone'=> {'required' => '', 'active' => 'true', 'signup' => '' }, 'description' => {'required' => '', 'active' => '', 'signup' => 'true'}}
529 529  
530   - assert_equal({'cell_phone' => {'required' => 'true', 'active' => 'true'},'comercial_phone'=> {'required' => 'true', 'active' => 'true'}}, env.custom_person_fields)
  530 + assert_equal({'cell_phone' => {'required' => 'true', 'active' => 'true', 'signup' => 'true'}, 'comercial_phone'=> {'required' => '', 'active' => 'true', 'signup' => '' }, 'description' => {'required' => '', 'active' => 'true', 'signup' => 'true'}}, env.custom_person_fields)
531 531 end
532 532  
533 533 should 'have no custom_person_fields by default' do
... ... @@ -539,7 +539,7 @@ class EnvironmentTest &lt; Test::Unit::TestCase
539 539 Person.stubs(:fields).returns(['cell_phone', 'comercial_phone'])
540 540  
541 541 env.custom_person_fields = { 'birth_date' => {'required' => 'true', 'active' => 'true'}, 'cell_phone' => {'required' => 'true', 'active' => 'true'}}
542   - assert_equal({'cell_phone' => {'required' => 'true', 'active' => 'true'}}, env.custom_person_fields)
  542 + assert_equal({'cell_phone' => {'required' => 'true','signup' => 'true', 'active' => 'true'}}, env.custom_person_fields)
543 543 assert ! env.custom_person_fields.keys.include?('birth_date')
544 544 end
545 545  
... ... @@ -548,7 +548,7 @@ class EnvironmentTest &lt; Test::Unit::TestCase
548 548 Person.stubs(:fields).returns(['cell_phone', 'schooling'])
549 549  
550 550 env.custom_person_fields = { 'schooling' => {'required' => 'true', 'active' => 'true'}}
551   - assert_equal({'schooling' => {'required' => 'true', 'active' => 'true'}, 'schooling_status' => {'required' => 'true', 'active' => 'true'}}, env.custom_person_fields)
  551 + assert_equal({'schooling' => {'required' => 'true', 'signup' => 'true', 'active' => 'true'}, 'schooling_status' => {'required' => 'true', 'signup' => 'true', 'active' => 'true'}}, env.custom_person_fields)
552 552 assert ! env.custom_person_fields.keys.include?('birth_date')
553 553 end
554 554  
... ... @@ -596,11 +596,11 @@ class EnvironmentTest &lt; Test::Unit::TestCase
596 596 end
597 597 end
598 598  
599   - should 'set custom_enterprises_fields' do
  599 + should 'set custom_enterprise_fields with its dependencies' do
600 600 env = Environment.new
601   - env.custom_enterprise_fields = {'contact_person' => {'required' => 'true', 'active' => 'true'},'contact_email'=> {'required' => 'true', 'active' => 'true'}}
  601 + env.custom_enterprise_fields = {'contact_person' => {'required' => 'true', 'active' => '', 'signup' => ''}, 'contact_email'=> {'required' => '', 'active' => 'true', 'signup' => '' }, 'description' => {'required' => '', 'active' => '', 'signup' => 'true'}}
602 602  
603   - assert_equal({'contact_person' => {'required' => 'true', 'active' => 'true'},'contact_email'=> {'required' => 'true', 'active' => 'true'}}, env.custom_enterprise_fields)
  603 + assert_equal({'contact_person' => {'required' => 'true', 'active' => 'true', 'signup' => 'true'}, 'contact_email'=> {'required' => '', 'active' => 'true', 'signup' => '' }, 'description' => {'required' => '', 'active' => 'true', 'signup' => 'true'}} , env.custom_enterprise_fields)
604 604 end
605 605  
606 606 should 'have no custom_enterprise_fields by default' do
... ... @@ -612,7 +612,7 @@ class EnvironmentTest &lt; Test::Unit::TestCase
612 612 Enterprise.stubs(:fields).returns(['contact_person', 'comercial_phone'])
613 613  
614 614 env.custom_enterprise_fields = { 'contact_email' => {'required' => 'true', 'active' => 'true'}, 'contact_person' => {'required' => 'true', 'active' => 'true'}}
615   - assert_equal({'contact_person' => {'required' => 'true', 'active' => 'true'}}, env.custom_enterprise_fields)
  615 + assert_equal({'contact_person' => {'required' => 'true', 'signup' => 'true', 'active' => 'true'}}, env.custom_enterprise_fields)
616 616 assert ! env.custom_enterprise_fields.keys.include?('contact_email')
617 617 end
618 618  
... ... @@ -639,11 +639,11 @@ class EnvironmentTest &lt; Test::Unit::TestCase
639 639 assert_equal ['contact_email'], env.required_enterprise_fields
640 640 end
641 641  
642   - should 'set custom_communitys_fields' do
  642 + should 'set custom_community_fields with its dependencies' do
643 643 env = Environment.new
644   - env.custom_community_fields = {'contact_person' => {'required' => 'true', 'active' => 'true'},'contact_email'=> {'required' => 'true', 'active' => 'true'}}
  644 + env.custom_community_fields = {'contact_person' => {'required' => 'true', 'active' => '', 'signup' => ''}, 'contact_email'=> {'required' => '', 'active' => 'true', 'signup' => '' }, 'description' => {'required' => '', 'active' => '', 'signup' => 'true'}}
645 645  
646   - assert_equal({'contact_person' => {'required' => 'true', 'active' => 'true'},'contact_email'=> {'required' => 'true', 'active' => 'true'}}, env.custom_community_fields)
  646 + assert_equal({'contact_person' => {'required' => 'true', 'active' => 'true', 'signup' => 'true'}, 'contact_email'=> {'required' => '', 'active' => 'true', 'signup' => '' }, 'description' => {'required' => '', 'active' => 'true', 'signup' => 'true'}} , env.custom_community_fields)
647 647 end
648 648  
649 649 should 'have no custom_community_fields by default' do
... ... @@ -655,7 +655,7 @@ class EnvironmentTest &lt; Test::Unit::TestCase
655 655 Community.stubs(:fields).returns(['contact_person', 'comercial_phone'])
656 656  
657 657 env.custom_community_fields = { 'contact_email' => {'required' => 'true', 'active' => 'true'}, 'contact_person' => {'required' => 'true', 'active' => 'true'}}
658   - assert_equal({'contact_person' => {'required' => 'true', 'active' => 'true'}}, env.custom_community_fields)
  658 + assert_equal({'contact_person' => {'required' => 'true', 'signup' => 'true', 'active' => 'true'}}, env.custom_community_fields)
659 659 assert ! env.custom_community_fields.keys.include?('contact_email')
660 660 end
661 661  
... ...