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 63 end
64 64  
65 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 68 end
69 69  
70 70 should 'be able to be displayed only in the homepage' do
71 71 profile = Profile.new
72 72 home_page = Article.new
73 73 profile.home_page = home_page
74   - block = Block.new(:display => 'home_page_only')
  74 + block = build(Block, :display => 'home_page_only')
75 75 block.stubs(:owner).returns(profile)
76 76  
77 77 assert_equal true, block.visible?(:article => home_page)
... ... @@ -79,7 +79,7 @@ class BlockTest < ActiveSupport::TestCase
79 79 end
80 80  
81 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 84 assert_equal true, block.visible?(:article => nil, :request_path => '/')
85 85 assert_equal false, block.visible?(:article => nil)
... ... @@ -89,7 +89,7 @@ class BlockTest < ActiveSupport::TestCase
89 89 profile = Profile.new
90 90 home_page = Article.new
91 91 profile.home_page = home_page
92   - block = Block.new(:display => 'except_home_page')
  92 + block = build(Block, :display => 'except_home_page')
93 93 block.stubs(:owner).returns(profile)
94 94  
95 95 assert_equal false, block.visible?(:article => home_page)
... ... @@ -97,8 +97,8 @@ class BlockTest < ActiveSupport::TestCase
97 97 end
98 98  
99 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 102 block.stubs(:owner).returns(profile)
103 103  
104 104 assert_equal false, block.visible?(:article => nil, :request_path => '/testinguser')
... ... @@ -132,7 +132,7 @@ class BlockTest < ActiveSupport::TestCase
132 132  
133 133 should 'be able to be displayed in all languages' do
134 134 profile = Profile.new
135   - block = Block.new(:language => 'all')
  135 + block = build(Block, :language => 'all')
136 136 block.stubs(:owner).returns(profile)
137 137  
138 138 assert_equal true, block.visible?(:locale => 'pt')
... ... @@ -141,7 +141,7 @@ class BlockTest < ActiveSupport::TestCase
141 141  
142 142 should 'be able to be displayed only in the selected language' do
143 143 profile = Profile.new
144   - block = Block.new(:language => 'pt')
  144 + block = build(Block, :language => 'pt')
145 145 block.stubs(:owner).returns(profile)
146 146  
147 147 assert_equal true, block.visible?(:locale => 'pt')
... ... @@ -150,7 +150,7 @@ class BlockTest < ActiveSupport::TestCase
150 150  
151 151 should 'delegate environment to box' do
152 152 box = fast_create(Box, :owner_id => fast_create(Profile).id)
153   - block = Block.new(:box => box)
  153 + block = build(Block, :box => box)
154 154 box.stubs(:environment).returns(Environment.default)
155 155  
156 156 assert_equal box.environment, block.environment
... ...