Commit b5ca63ab9c95720fe44ed7cddf0d4ef85ad8c9c3

Authored by Braulio Bhavamitra
1 parent d1246cba

rails4: fix profile tests

lib/noosfero/core_ext/active_record.rb
@@ -9,10 +9,10 @@ class ActiveRecord::Base @@ -9,10 +9,10 @@ class ActiveRecord::Base
9 # an ActionView instance for rendering views on models 9 # an ActionView instance for rendering views on models
10 def self.action_view 10 def self.action_view
11 @action_view ||= begin 11 @action_view ||= begin
12 - view_paths = ActionController::Base.view_paths  
13 - action_view = ActionView::Base.new view_paths 12 + view_paths = ::ActionController::Base.view_paths
  13 + action_view = ::ActionView::Base.new view_paths
14 # for using Noosfero helpers inside render calls 14 # for using Noosfero helpers inside render calls
15 - action_view.extend ApplicationHelper 15 + action_view.extend ::ApplicationHelper
16 action_view 16 action_view
17 end 17 end
18 end 18 end
test/factories.rb
@@ -89,7 +89,7 @@ module Noosfero::Factory @@ -89,7 +89,7 @@ module Noosfero::Factory
89 :password_confirmation => name.underscore 89 :password_confirmation => name.underscore
90 }.merge(options) 90 }.merge(options)
91 user = build(User, data) 91 user = build(User, data)
92 - user.person = build(Person, person_options) 92 + user.person_data = person_options
93 user.save! 93 user.save!
94 user 94 user
95 end 95 end
test/unit/enterprise_test.rb
@@ -38,7 +38,7 @@ class EnterpriseTest < ActiveSupport::TestCase @@ -38,7 +38,7 @@ class EnterpriseTest < ActiveSupport::TestCase
38 38
39 def test_has_domains 39 def test_has_domains
40 p = Enterprise.new 40 p = Enterprise.new
41 - assert_kind_of Array, p.domains 41 + assert p.domains.empty?
42 end 42 end
43 43
44 def test_belongs_to_environment_and_has_default 44 def test_belongs_to_environment_and_has_default
test/unit/environment_test.rb
@@ -173,7 +173,7 @@ class EnvironmentTest < ActiveSupport::TestCase @@ -173,7 +173,7 @@ class EnvironmentTest < ActiveSupport::TestCase
173 173
174 should 'have regions' do 174 should 'have regions' do
175 env = fast_create(Environment) 175 env = fast_create(Environment)
176 - assert_kind_of Array, env.regions 176 + assert env.regions.empty?
177 assert_raise ActiveRecord::AssociationTypeMismatch do 177 assert_raise ActiveRecord::AssociationTypeMismatch do
178 env.regions << 1 178 env.regions << 1
179 end 179 end
test/unit/profile_test.rb
@@ -36,7 +36,7 @@ class ProfileTest &lt; ActiveSupport::TestCase @@ -36,7 +36,7 @@ class ProfileTest &lt; ActiveSupport::TestCase
36 36
37 def test_has_domains 37 def test_has_domains
38 p = Profile.new 38 p = Profile.new
39 - assert_kind_of Array, p.domains 39 + assert p.domains.empty?
40 end 40 end
41 41
42 should 'be assigned to default environment if no environment is informed' do 42 should 'be assigned to default environment if no environment is informed' do
@@ -771,7 +771,7 @@ class ProfileTest &lt; ActiveSupport::TestCase @@ -771,7 +771,7 @@ class ProfileTest &lt; ActiveSupport::TestCase
771 should 'nickname be able to be nil' do 771 should 'nickname be able to be nil' do
772 p = Profile.new() 772 p = Profile.new()
773 p.valid? 773 p.valid?
774 - assert_blank p.errors[:nickname] 774 + assert p.errors[:nickname].blank?
775 end 775 end
776 776
777 should 'filter html from nickname' do 777 should 'filter html from nickname' do
@@ -1382,13 +1382,13 @@ class ProfileTest &lt; ActiveSupport::TestCase @@ -1382,13 +1382,13 @@ class ProfileTest &lt; ActiveSupport::TestCase
1382 should 'profile be valid when image is empty' do 1382 should 'profile be valid when image is empty' do
1383 profile = build(Profile, :image_builder => {:uploaded_data => ""}) 1383 profile = build(Profile, :image_builder => {:uploaded_data => ""})
1384 profile.valid? 1384 profile.valid?
1385 - assert_blank profile.errors[:image] 1385 + assert profile.errors[:image].blank?
1386 end 1386 end
1387 1387
1388 should 'profile be valid when has no image' do 1388 should 'profile be valid when has no image' do
1389 profile = Profile.new 1389 profile = Profile.new
1390 profile.valid? 1390 profile.valid?
1391 - assert_blank profile.errors[:image] 1391 + assert profile.errors[:image].blank?
1392 end 1392 end
1393 1393
1394 should 'copy header and footer after create a person' do 1394 should 'copy header and footer after create a person' do
@@ -1398,6 +1398,7 @@ class ProfileTest &lt; ActiveSupport::TestCase @@ -1398,6 +1398,7 @@ class ProfileTest &lt; ActiveSupport::TestCase
1398 Environment.any_instance.stubs(:person_default_template).returns(template) 1398 Environment.any_instance.stubs(:person_default_template).returns(template)
1399 1399
1400 person = create_user_full('mytestuser').person 1400 person = create_user_full('mytestuser').person
  1401 + assert_equal person.environment.person_default_template, person.template
1401 assert_equal "footer customized", person.custom_footer 1402 assert_equal "footer customized", person.custom_footer
1402 assert_equal "header customized", person.custom_header 1403 assert_equal "header customized", person.custom_header
1403 end 1404 end
test/unit/uploaded_file_test.rb
@@ -147,7 +147,7 @@ class UploadedFileTest &lt; ActiveSupport::TestCase @@ -147,7 +147,7 @@ class UploadedFileTest &lt; ActiveSupport::TestCase
147 should 'use name as title by default but cut down the title' do 147 should 'use name as title by default but cut down the title' do
148 upload = build(UploadedFile, :uploaded_data => fixture_file_upload('/files/AGENDA_CULTURA_-_FESTA_DE_VAQUEIROS_PONTO_DE_SERRA_PRETA_BAIXA.txt')) 148 upload = build(UploadedFile, :uploaded_data => fixture_file_upload('/files/AGENDA_CULTURA_-_FESTA_DE_VAQUEIROS_PONTO_DE_SERRA_PRETA_BAIXA.txt'))
149 upload.valid? 149 upload.valid?
150 - assert_blank upload.errors[:title] 150 + assert upload.errors[:title].blank?
151 end 151 end
152 152
153 should 'create thumbnails after processing jobs' do 153 should 'create thumbnails after processing jobs' do