Commit 2c109fdfc5198696c7c128eff5c7ee1e6856a76e

Authored by Victor Costa
1 parent 6ca74255

rails3: fix some functional tests

app/controllers/public/account_controller.rb
... ... @@ -163,12 +163,12 @@ class AccountController < ApplicationController
163 163 render :action => 'password_recovery_sent'
164 164 rescue ActiveRecord::RecordNotFound
165 165 if params[:value].blank?
166   - @change_password.errors.add_to_base(_('Can not recover user password with blank value.'))
  166 + @change_password.errors[:base] << _('Can not recover user password with blank value.')
167 167 else
168   - @change_password.errors.add_to_base(_('Could not find any user with %s equal to "%s".') % [fields_label, params[:value]])
  168 + @change_password.errors[:base] << _('Could not find any user with %s equal to "%s".') % [fields_label, params[:value]]
169 169 end
170 170 rescue ActiveRecord::RecordInvald
171   - @change_password.errors.add_to_base(_('Could not perform password recovery for the user.'))
  171 + @change_password.errors[:base] << _('Could not perform password recovery for the user.')
172 172 end
173 173 end
174 174 end
... ...
app/helpers/application_helper.rb
... ... @@ -277,7 +277,7 @@ module ApplicationHelper
277 277 options[:class].nil? ?
278 278 options[:class]='button-bar' :
279 279 options[:class]+=' button-bar'
280   - concat(content_tag('div', capture(&block) + tag('br', :style => 'clear: left;'), options))
  280 + concat(content_tag('div', capture(&block).to_s + tag('br', :style => 'clear: left;'), options))
281 281 end
282 282  
283 283  
... ...
app/models/article.rb
... ... @@ -2,7 +2,7 @@ require &#39;hpricot&#39;
2 2  
3 3 class Article < ActiveRecord::Base
4 4  
5   - attr_accessible :name, :body, :abstract, :profile, :tag_list, :parent, :allow_members_to_edit, :translation_of_id, :language, :license_id, :parent_id, :display_posts_in_current_language, :category_ids, :posts_per_page, :moderate_comments, :accept_comments, :feed, :published, :source, :highlighted
  5 + attr_accessible :name, :body, :abstract, :profile, :tag_list, :parent, :allow_members_to_edit, :translation_of_id, :language, :license_id, :parent_id, :display_posts_in_current_language, :category_ids, :posts_per_page, :moderate_comments, :accept_comments, :feed, :published, :source, :highlighted, :notify_comments, :display_hits
6 6  
7 7 acts_as_having_image
8 8  
... ...
app/models/profile.rb
... ... @@ -3,7 +3,7 @@
3 3 # which by default is the one returned by Environment:default.
4 4 class Profile < ActiveRecord::Base
5 5  
6   - attr_accessible :name, :identifier, :public_profile, :nickname, :custom_footer, :custom_header, :address, :zip_code, :contact_phone, :image_builder, :description, :closed
  6 + attr_accessible :name, :identifier, :public_profile, :nickname, :custom_footer, :custom_header, :address, :zip_code, :contact_phone, :image_builder, :description, :closed, :template_id
7 7  
8 8 # use for internationalizable human type names in search facets
9 9 # reimplement on subclasses
... ...
app/models/user.rb
... ... @@ -43,6 +43,7 @@ class User &lt; ActiveRecord::Base
43 43 p.environment = user.environment
44 44 p.name ||= user.name || user.login
45 45 p.visible = false unless user.activated?
  46 + p.save!
46 47  
47 48 user.person = p
48 49 end
... ...
config/routes.rb
... ... @@ -97,7 +97,7 @@ Noosfero::Application.routes.draw do
97 97 ######################################################
98 98 # profile customization - "My profile"
99 99 match 'myprofile/:profile', :controller => 'profile_editor', :action => 'index', :profile => /#{Noosfero.identifier_format}/
100   - match 'myprofile/:profile/:controller(/:action(/:id))', :controller => Noosfero.pattern_for_controllers_in_directory('my_profile'), :profile => /#{Noosfero.identifier_format}/
  100 + match 'myprofile/:profile/:controller(/:action(/:id))', :controller => Noosfero.pattern_for_controllers_in_directory('my_profile'), :profile => /#{Noosfero.identifier_format}/, :as => :myprofile
101 101  
102 102  
103 103 ######################################################
... ...
test/functional/account_controller_test.rb
... ... @@ -67,7 +67,7 @@ class AccountControllerTest &lt; ActionController::TestCase
67 67 def test_should_require_login_on_signup
68 68 assert_no_difference 'User.count' do
69 69 new_user(:login => nil)
70   - assert assigns(:user).errors.on(:login)
  70 + assert assigns(:user).errors[:login]
71 71 assert_response :success
72 72 assert_nil assigns(:register_pending)
73 73 end
... ... @@ -76,7 +76,7 @@ class AccountControllerTest &lt; ActionController::TestCase
76 76 def test_should_require_password_on_signup
77 77 assert_no_difference 'User.count' do
78 78 new_user(:password => nil)
79   - assert assigns(:user).errors.on(:password)
  79 + assert assigns(:user).errors[:password]
80 80 assert_response :success
81 81 assert_nil assigns(:register_pending)
82 82 end
... ... @@ -85,7 +85,7 @@ class AccountControllerTest &lt; ActionController::TestCase
85 85 def test_should_require_password_confirmation_on_signup
86 86 assert_no_difference 'User.count' do
87 87 new_user(:password_confirmation => nil)
88   - assert assigns(:user).errors.on(:password_confirmation)
  88 + assert assigns(:user).errors[:password_confirmation]
89 89 assert_response :success
90 90 assert_nil assigns(:register_pending)
91 91 end
... ... @@ -94,7 +94,7 @@ class AccountControllerTest &lt; ActionController::TestCase
94 94 def test_should_require_email_on_signup
95 95 assert_no_difference 'User.count' do
96 96 new_user(:email => nil)
97   - assert assigns(:user).errors.on(:email)
  97 + assert assigns(:user).errors[:email]
98 98 assert_response :success
99 99 assert_nil assigns(:register_pending)
100 100 end
... ... @@ -300,7 +300,7 @@ class AccountControllerTest &lt; ActionController::TestCase
300 300 assert assigns(:user).valid?
301 301 @controller.stubs(:logged_in?).returns(false)
302 302 new_user(:login => 'user2', :email => 'user@example.com')
303   - assert assigns(:user).errors.on(:email)
  303 + assert assigns(:user).errors[:email]
304 304 end
305 305 end
306 306  
... ...
test/test_helper.rb
... ... @@ -145,7 +145,7 @@ class ActiveSupport::TestCase
145 145 patch ? patch[1] : nil
146 146 end.compact
147 147 s.each do |css_ref|
148   - if ! File.exists?(Rails.root.join('public', css_ref ))
  148 + if ! File.exists?(File.join(Rails.root, 'public', css_ref))
149 149 flunk 'CSS reference missed on HTML: "%s"' % css_ref
150 150 end
151 151 end
... ... @@ -154,7 +154,7 @@ class ActiveSupport::TestCase
154 154 # Test image references:
155 155 (doc/'img').each do |img|
156 156 src = img.get_attribute( 'src' ).gsub(/\?[0-9]+$/, '')
157   - if ! File.exists?(Rails.root.join('public', src))
  157 + if ! File.exists?(File.join(Rails.root, 'public', src))
158 158 flunk 'Image reference missed on HTML: "%s"' % src
159 159 end
160 160 end
... ...