Commit 6d4cd4e6fb80bf498eb643fac0aa23efa483718d

Authored by Rodrigo Souto
1 parent 207dbaca

rails3: fix block tests

Showing 1 changed file with 10 additions and 10 deletions   Show diff stats
test/unit/block_test.rb
@@ -63,15 +63,15 @@ class BlockTest < ActiveSupport::TestCase @@ -63,15 +63,15 @@ class BlockTest < ActiveSupport::TestCase
63 end 63 end
64 64
65 should 'not display when set to hidden' do 65 should 'not display when set to hidden' do
66 - assert_equal false, Block.new(:display => 'never').visible?  
67 - assert_equal false, Block.new(:display => 'never').visible?(:article => Article.new) 66 + assert_equal false, build(Block, :display => 'never').visible?
  67 + assert_equal false, build(Block, :display => 'never').visible?(:article => Article.new)
68 end 68 end
69 69
70 should 'be able to be displayed only in the homepage' do 70 should 'be able to be displayed only in the homepage' do
71 profile = Profile.new 71 profile = Profile.new
72 home_page = Article.new 72 home_page = Article.new
73 profile.home_page = home_page 73 profile.home_page = home_page
74 - block = Block.new(:display => 'home_page_only') 74 + block = build(Block, :display => 'home_page_only')
75 block.stubs(:owner).returns(profile) 75 block.stubs(:owner).returns(profile)
76 76
77 assert_equal true, block.visible?(:article => home_page) 77 assert_equal true, block.visible?(:article => home_page)
@@ -79,7 +79,7 @@ class BlockTest < ActiveSupport::TestCase @@ -79,7 +79,7 @@ class BlockTest < ActiveSupport::TestCase
79 end 79 end
80 80
81 should 'be able to be displayed only in the homepage (index) of the environment' do 81 should 'be able to be displayed only in the homepage (index) of the environment' do
82 - block = Block.new(:display => 'home_page_only') 82 + block = build(Block, :display => 'home_page_only')
83 83
84 assert_equal true, block.visible?(:article => nil, :request_path => '/') 84 assert_equal true, block.visible?(:article => nil, :request_path => '/')
85 assert_equal false, block.visible?(:article => nil) 85 assert_equal false, block.visible?(:article => nil)
@@ -89,7 +89,7 @@ class BlockTest < ActiveSupport::TestCase @@ -89,7 +89,7 @@ class BlockTest < ActiveSupport::TestCase
89 profile = Profile.new 89 profile = Profile.new
90 home_page = Article.new 90 home_page = Article.new
91 profile.home_page = home_page 91 profile.home_page = home_page
92 - block = Block.new(:display => 'except_home_page') 92 + block = build(Block, :display => 'except_home_page')
93 block.stubs(:owner).returns(profile) 93 block.stubs(:owner).returns(profile)
94 94
95 assert_equal false, block.visible?(:article => home_page) 95 assert_equal false, block.visible?(:article => home_page)
@@ -97,8 +97,8 @@ class BlockTest < ActiveSupport::TestCase @@ -97,8 +97,8 @@ class BlockTest < ActiveSupport::TestCase
97 end 97 end
98 98
99 should 'be able to be displayed everywhere except on profile index' do 99 should 'be able to be displayed everywhere except on profile index' do
100 - profile = Profile.new(:identifier => 'testinguser')  
101 - block = Block.new(:display => 'except_home_page') 100 + profile = build(Profile, :identifier => 'testinguser')
  101 + block = build(Block, :display => 'except_home_page')
102 block.stubs(:owner).returns(profile) 102 block.stubs(:owner).returns(profile)
103 103
104 assert_equal false, block.visible?(:article => nil, :request_path => '/testinguser') 104 assert_equal false, block.visible?(:article => nil, :request_path => '/testinguser')
@@ -132,7 +132,7 @@ class BlockTest < ActiveSupport::TestCase @@ -132,7 +132,7 @@ class BlockTest < ActiveSupport::TestCase
132 132
133 should 'be able to be displayed in all languages' do 133 should 'be able to be displayed in all languages' do
134 profile = Profile.new 134 profile = Profile.new
135 - block = Block.new(:language => 'all') 135 + block = build(Block, :language => 'all')
136 block.stubs(:owner).returns(profile) 136 block.stubs(:owner).returns(profile)
137 137
138 assert_equal true, block.visible?(:locale => 'pt') 138 assert_equal true, block.visible?(:locale => 'pt')
@@ -141,7 +141,7 @@ class BlockTest < ActiveSupport::TestCase @@ -141,7 +141,7 @@ class BlockTest < ActiveSupport::TestCase
141 141
142 should 'be able to be displayed only in the selected language' do 142 should 'be able to be displayed only in the selected language' do
143 profile = Profile.new 143 profile = Profile.new
144 - block = Block.new(:language => 'pt') 144 + block = build(Block, :language => 'pt')
145 block.stubs(:owner).returns(profile) 145 block.stubs(:owner).returns(profile)
146 146
147 assert_equal true, block.visible?(:locale => 'pt') 147 assert_equal true, block.visible?(:locale => 'pt')
@@ -150,7 +150,7 @@ class BlockTest < ActiveSupport::TestCase @@ -150,7 +150,7 @@ class BlockTest < ActiveSupport::TestCase
150 150
151 should 'delegate environment to box' do 151 should 'delegate environment to box' do
152 box = fast_create(Box, :owner_id => fast_create(Profile).id) 152 box = fast_create(Box, :owner_id => fast_create(Profile).id)
153 - block = Block.new(:box => box) 153 + block = build(Block, :box => box)
154 box.stubs(:environment).returns(Environment.default) 154 box.stubs(:environment).returns(Environment.default)
155 155
156 assert_equal box.environment, block.environment 156 assert_equal box.environment, block.environment