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,12 +163,12 @@ class AccountController < ApplicationController
163 render :action => 'password_recovery_sent' 163 render :action => 'password_recovery_sent'
164 rescue ActiveRecord::RecordNotFound 164 rescue ActiveRecord::RecordNotFound
165 if params[:value].blank? 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 else 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 end 169 end
170 rescue ActiveRecord::RecordInvald 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 end 172 end
173 end 173 end
174 end 174 end
app/helpers/application_helper.rb
@@ -277,7 +277,7 @@ module ApplicationHelper @@ -277,7 +277,7 @@ module ApplicationHelper
277 options[:class].nil? ? 277 options[:class].nil? ?
278 options[:class]='button-bar' : 278 options[:class]='button-bar' :
279 options[:class]+=' button-bar' 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 end 281 end
282 282
283 283
app/models/article.rb
@@ -2,7 +2,7 @@ require &#39;hpricot&#39; @@ -2,7 +2,7 @@ require &#39;hpricot&#39;
2 2
3 class Article < ActiveRecord::Base 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 acts_as_having_image 7 acts_as_having_image
8 8
app/models/profile.rb
@@ -3,7 +3,7 @@ @@ -3,7 +3,7 @@
3 # which by default is the one returned by Environment:default. 3 # which by default is the one returned by Environment:default.
4 class Profile < ActiveRecord::Base 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 # use for internationalizable human type names in search facets 8 # use for internationalizable human type names in search facets
9 # reimplement on subclasses 9 # reimplement on subclasses
app/models/user.rb
@@ -43,6 +43,7 @@ class User &lt; ActiveRecord::Base @@ -43,6 +43,7 @@ class User &lt; ActiveRecord::Base
43 p.environment = user.environment 43 p.environment = user.environment
44 p.name ||= user.name || user.login 44 p.name ||= user.name || user.login
45 p.visible = false unless user.activated? 45 p.visible = false unless user.activated?
  46 + p.save!
46 47
47 user.person = p 48 user.person = p
48 end 49 end
config/routes.rb
@@ -97,7 +97,7 @@ Noosfero::Application.routes.draw do @@ -97,7 +97,7 @@ Noosfero::Application.routes.draw do
97 ###################################################### 97 ######################################################
98 # profile customization - "My profile" 98 # profile customization - "My profile"
99 match 'myprofile/:profile', :controller => 'profile_editor', :action => 'index', :profile => /#{Noosfero.identifier_format}/ 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,7 +67,7 @@ class AccountControllerTest &lt; ActionController::TestCase
67 def test_should_require_login_on_signup 67 def test_should_require_login_on_signup
68 assert_no_difference 'User.count' do 68 assert_no_difference 'User.count' do
69 new_user(:login => nil) 69 new_user(:login => nil)
70 - assert assigns(:user).errors.on(:login) 70 + assert assigns(:user).errors[:login]
71 assert_response :success 71 assert_response :success
72 assert_nil assigns(:register_pending) 72 assert_nil assigns(:register_pending)
73 end 73 end
@@ -76,7 +76,7 @@ class AccountControllerTest &lt; ActionController::TestCase @@ -76,7 +76,7 @@ class AccountControllerTest &lt; ActionController::TestCase
76 def test_should_require_password_on_signup 76 def test_should_require_password_on_signup
77 assert_no_difference 'User.count' do 77 assert_no_difference 'User.count' do
78 new_user(:password => nil) 78 new_user(:password => nil)
79 - assert assigns(:user).errors.on(:password) 79 + assert assigns(:user).errors[:password]
80 assert_response :success 80 assert_response :success
81 assert_nil assigns(:register_pending) 81 assert_nil assigns(:register_pending)
82 end 82 end
@@ -85,7 +85,7 @@ class AccountControllerTest &lt; ActionController::TestCase @@ -85,7 +85,7 @@ class AccountControllerTest &lt; ActionController::TestCase
85 def test_should_require_password_confirmation_on_signup 85 def test_should_require_password_confirmation_on_signup
86 assert_no_difference 'User.count' do 86 assert_no_difference 'User.count' do
87 new_user(:password_confirmation => nil) 87 new_user(:password_confirmation => nil)
88 - assert assigns(:user).errors.on(:password_confirmation) 88 + assert assigns(:user).errors[:password_confirmation]
89 assert_response :success 89 assert_response :success
90 assert_nil assigns(:register_pending) 90 assert_nil assigns(:register_pending)
91 end 91 end
@@ -94,7 +94,7 @@ class AccountControllerTest &lt; ActionController::TestCase @@ -94,7 +94,7 @@ class AccountControllerTest &lt; ActionController::TestCase
94 def test_should_require_email_on_signup 94 def test_should_require_email_on_signup
95 assert_no_difference 'User.count' do 95 assert_no_difference 'User.count' do
96 new_user(:email => nil) 96 new_user(:email => nil)
97 - assert assigns(:user).errors.on(:email) 97 + assert assigns(:user).errors[:email]
98 assert_response :success 98 assert_response :success
99 assert_nil assigns(:register_pending) 99 assert_nil assigns(:register_pending)
100 end 100 end
@@ -300,7 +300,7 @@ class AccountControllerTest &lt; ActionController::TestCase @@ -300,7 +300,7 @@ class AccountControllerTest &lt; ActionController::TestCase
300 assert assigns(:user).valid? 300 assert assigns(:user).valid?
301 @controller.stubs(:logged_in?).returns(false) 301 @controller.stubs(:logged_in?).returns(false)
302 new_user(:login => 'user2', :email => 'user@example.com') 302 new_user(:login => 'user2', :email => 'user@example.com')
303 - assert assigns(:user).errors.on(:email) 303 + assert assigns(:user).errors[:email]
304 end 304 end
305 end 305 end
306 306
test/test_helper.rb
@@ -145,7 +145,7 @@ class ActiveSupport::TestCase @@ -145,7 +145,7 @@ class ActiveSupport::TestCase
145 patch ? patch[1] : nil 145 patch ? patch[1] : nil
146 end.compact 146 end.compact
147 s.each do |css_ref| 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 flunk 'CSS reference missed on HTML: "%s"' % css_ref 149 flunk 'CSS reference missed on HTML: "%s"' % css_ref
150 end 150 end
151 end 151 end
@@ -154,7 +154,7 @@ class ActiveSupport::TestCase @@ -154,7 +154,7 @@ class ActiveSupport::TestCase
154 # Test image references: 154 # Test image references:
155 (doc/'img').each do |img| 155 (doc/'img').each do |img|
156 src = img.get_attribute( 'src' ).gsub(/\?[0-9]+$/, '') 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 flunk 'Image reference missed on HTML: "%s"' % src 158 flunk 'Image reference missed on HTML: "%s"' % src
159 end 159 end
160 end 160 end