From 2c109fdfc5198696c7c128eff5c7ee1e6856a76e Mon Sep 17 00:00:00 2001 From: Victor Costa Date: Tue, 28 Jan 2014 12:41:06 -0300 Subject: [PATCH] rails3: fix some functional tests --- app/controllers/public/account_controller.rb | 6 +++--- app/helpers/application_helper.rb | 2 +- app/models/article.rb | 2 +- app/models/profile.rb | 2 +- app/models/user.rb | 1 + config/routes.rb | 2 +- test/functional/account_controller_test.rb | 10 +++++----- test/test_helper.rb | 4 ++-- 8 files changed, 15 insertions(+), 14 deletions(-) diff --git a/app/controllers/public/account_controller.rb b/app/controllers/public/account_controller.rb index ad603e1..e0df528 100644 --- a/app/controllers/public/account_controller.rb +++ b/app/controllers/public/account_controller.rb @@ -163,12 +163,12 @@ class AccountController < ApplicationController render :action => 'password_recovery_sent' rescue ActiveRecord::RecordNotFound if params[:value].blank? - @change_password.errors.add_to_base(_('Can not recover user password with blank value.')) + @change_password.errors[:base] << _('Can not recover user password with blank value.') else - @change_password.errors.add_to_base(_('Could not find any user with %s equal to "%s".') % [fields_label, params[:value]]) + @change_password.errors[:base] << _('Could not find any user with %s equal to "%s".') % [fields_label, params[:value]] end rescue ActiveRecord::RecordInvald - @change_password.errors.add_to_base(_('Could not perform password recovery for the user.')) + @change_password.errors[:base] << _('Could not perform password recovery for the user.') end end end diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 6022d2f..b9b9e7f 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -277,7 +277,7 @@ module ApplicationHelper options[:class].nil? ? options[:class]='button-bar' : options[:class]+=' button-bar' - concat(content_tag('div', capture(&block) + tag('br', :style => 'clear: left;'), options)) + concat(content_tag('div', capture(&block).to_s + tag('br', :style => 'clear: left;'), options)) end diff --git a/app/models/article.rb b/app/models/article.rb index 1bb9672..c2edf39 100644 --- a/app/models/article.rb +++ b/app/models/article.rb @@ -2,7 +2,7 @@ require 'hpricot' class Article < ActiveRecord::Base - 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 + 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 acts_as_having_image diff --git a/app/models/profile.rb b/app/models/profile.rb index 00afc92..5d2f03a 100644 --- a/app/models/profile.rb +++ b/app/models/profile.rb @@ -3,7 +3,7 @@ # which by default is the one returned by Environment:default. class Profile < ActiveRecord::Base - attr_accessible :name, :identifier, :public_profile, :nickname, :custom_footer, :custom_header, :address, :zip_code, :contact_phone, :image_builder, :description, :closed + attr_accessible :name, :identifier, :public_profile, :nickname, :custom_footer, :custom_header, :address, :zip_code, :contact_phone, :image_builder, :description, :closed, :template_id # use for internationalizable human type names in search facets # reimplement on subclasses diff --git a/app/models/user.rb b/app/models/user.rb index c60e30a..8f7cc7f 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -43,6 +43,7 @@ class User < ActiveRecord::Base p.environment = user.environment p.name ||= user.name || user.login p.visible = false unless user.activated? + p.save! user.person = p end diff --git a/config/routes.rb b/config/routes.rb index 463de8d..60eb8ea 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -97,7 +97,7 @@ Noosfero::Application.routes.draw do ###################################################### # profile customization - "My profile" match 'myprofile/:profile', :controller => 'profile_editor', :action => 'index', :profile => /#{Noosfero.identifier_format}/ - match 'myprofile/:profile/:controller(/:action(/:id))', :controller => Noosfero.pattern_for_controllers_in_directory('my_profile'), :profile => /#{Noosfero.identifier_format}/ + match 'myprofile/:profile/:controller(/:action(/:id))', :controller => Noosfero.pattern_for_controllers_in_directory('my_profile'), :profile => /#{Noosfero.identifier_format}/, :as => :myprofile ###################################################### diff --git a/test/functional/account_controller_test.rb b/test/functional/account_controller_test.rb index 23ad38e..808379d 100644 --- a/test/functional/account_controller_test.rb +++ b/test/functional/account_controller_test.rb @@ -67,7 +67,7 @@ class AccountControllerTest < ActionController::TestCase def test_should_require_login_on_signup assert_no_difference 'User.count' do new_user(:login => nil) - assert assigns(:user).errors.on(:login) + assert assigns(:user).errors[:login] assert_response :success assert_nil assigns(:register_pending) end @@ -76,7 +76,7 @@ class AccountControllerTest < ActionController::TestCase def test_should_require_password_on_signup assert_no_difference 'User.count' do new_user(:password => nil) - assert assigns(:user).errors.on(:password) + assert assigns(:user).errors[:password] assert_response :success assert_nil assigns(:register_pending) end @@ -85,7 +85,7 @@ class AccountControllerTest < ActionController::TestCase def test_should_require_password_confirmation_on_signup assert_no_difference 'User.count' do new_user(:password_confirmation => nil) - assert assigns(:user).errors.on(:password_confirmation) + assert assigns(:user).errors[:password_confirmation] assert_response :success assert_nil assigns(:register_pending) end @@ -94,7 +94,7 @@ class AccountControllerTest < ActionController::TestCase def test_should_require_email_on_signup assert_no_difference 'User.count' do new_user(:email => nil) - assert assigns(:user).errors.on(:email) + assert assigns(:user).errors[:email] assert_response :success assert_nil assigns(:register_pending) end @@ -300,7 +300,7 @@ class AccountControllerTest < ActionController::TestCase assert assigns(:user).valid? @controller.stubs(:logged_in?).returns(false) new_user(:login => 'user2', :email => 'user@example.com') - assert assigns(:user).errors.on(:email) + assert assigns(:user).errors[:email] end end diff --git a/test/test_helper.rb b/test/test_helper.rb index c650dbb..fb74911 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -145,7 +145,7 @@ class ActiveSupport::TestCase patch ? patch[1] : nil end.compact s.each do |css_ref| - if ! File.exists?(Rails.root.join('public', css_ref )) + if ! File.exists?(File.join(Rails.root, 'public', css_ref)) flunk 'CSS reference missed on HTML: "%s"' % css_ref end end @@ -154,7 +154,7 @@ class ActiveSupport::TestCase # Test image references: (doc/'img').each do |img| src = img.get_attribute( 'src' ).gsub(/\?[0-9]+$/, '') - if ! File.exists?(Rails.root.join('public', src)) + if ! File.exists?(File.join(Rails.root, 'public', src)) flunk 'Image reference missed on HTML: "%s"' % src end end -- libgit2 0.21.2