Commit 844000a3ffac3bb12cc7407a1065426bdbf85075
1 parent
0ceb4036
Exists in
master
and in
22 other branches
rails3: avoiding mass-assignment on profile_list_block tests
Showing
1 changed file
with
6 additions
and
6 deletions
Show diff stats
test/unit/profile_list_block_test.rb
| @@ -149,9 +149,9 @@ class ProfileListBlockTest < ActiveSupport::TestCase | @@ -149,9 +149,9 @@ class ProfileListBlockTest < ActiveSupport::TestCase | ||
| 149 | 149 | ||
| 150 | should 'prioritize profiles with image if this option is turned on' do | 150 | should 'prioritize profiles with image if this option is turned on' do |
| 151 | env = fast_create(Environment) | 151 | env = fast_create(Environment) |
| 152 | - img1 = Image.create!(:uploaded_data => fixture_file_upload('/files/rails.png', 'image/png')) | 152 | + img1 = create(Image, :uploaded_data => fixture_file_upload('/files/rails.png', 'image/png')) |
| 153 | p1 = fast_create(Person, :environment_id => env.id, :image_id => img1.id) | 153 | p1 = fast_create(Person, :environment_id => env.id, :image_id => img1.id) |
| 154 | - img2 = Image.create!(:uploaded_data => fixture_file_upload('/files/rails.png', 'image/png')) | 154 | + img2 = create(Image, :uploaded_data => fixture_file_upload('/files/rails.png', 'image/png')) |
| 155 | p2 = fast_create(Person, :environment_id => env.id, :image_id => img2.id) | 155 | p2 = fast_create(Person, :environment_id => env.id, :image_id => img2.id) |
| 156 | 156 | ||
| 157 | p_without_image = fast_create(Person, :environment_id => env.id) | 157 | p_without_image = fast_create(Person, :environment_id => env.id) |
| @@ -165,9 +165,9 @@ class ProfileListBlockTest < ActiveSupport::TestCase | @@ -165,9 +165,9 @@ class ProfileListBlockTest < ActiveSupport::TestCase | ||
| 165 | 165 | ||
| 166 | should 'list profiles without image only if profiles with image arent enought' do | 166 | should 'list profiles without image only if profiles with image arent enought' do |
| 167 | env = fast_create(Environment) | 167 | env = fast_create(Environment) |
| 168 | - img1 = Image.create!(:uploaded_data => fixture_file_upload('/files/rails.png', 'image/png')) | 168 | + img1 = create(Image, :uploaded_data => fixture_file_upload('/files/rails.png', 'image/png')) |
| 169 | p1 = fast_create(Person, :environment_id => env.id, :image_id => img1.id) | 169 | p1 = fast_create(Person, :environment_id => env.id, :image_id => img1.id) |
| 170 | - img2 = Image.create!(:uploaded_data => fixture_file_upload('/files/rails.png', 'image/png')) | 170 | + img2 = create(Image, :uploaded_data => fixture_file_upload('/files/rails.png', 'image/png')) |
| 171 | p2 = fast_create(Person, :environment_id => env.id, :image_id => img2.id) | 171 | p2 = fast_create(Person, :environment_id => env.id, :image_id => img2.id) |
| 172 | p_without_image = fast_create(Person, :environment_id => env.id) | 172 | p_without_image = fast_create(Person, :environment_id => env.id) |
| 173 | block = ProfileListBlock.new | 173 | block = ProfileListBlock.new |
| @@ -186,7 +186,7 @@ class ProfileListBlockTest < ActiveSupport::TestCase | @@ -186,7 +186,7 @@ class ProfileListBlockTest < ActiveSupport::TestCase | ||
| 186 | 5.times do |n| | 186 | 5.times do |n| |
| 187 | fast_create(Person, :environment_id => env.id) | 187 | fast_create(Person, :environment_id => env.id) |
| 188 | end | 188 | end |
| 189 | - img = Image.create!(:uploaded_data => fixture_file_upload('/files/rails.png', 'image/png')) | 189 | + img = create(Image, :uploaded_data => fixture_file_upload('/files/rails.png', 'image/png')) |
| 190 | with_image = fast_create(Person, :environment_id => env.id, :image_id => img.id) | 190 | with_image = fast_create(Person, :environment_id => env.id, :image_id => img.id) |
| 191 | block = ProfileListBlock.new(:limit => 3) | 191 | block = ProfileListBlock.new(:limit => 3) |
| 192 | block.stubs(:prioritize_profiles_with_image).returns(true) | 192 | block.stubs(:prioritize_profiles_with_image).returns(true) |
| @@ -196,7 +196,7 @@ class ProfileListBlockTest < ActiveSupport::TestCase | @@ -196,7 +196,7 @@ class ProfileListBlockTest < ActiveSupport::TestCase | ||
| 196 | 196 | ||
| 197 | should 'not prioritize profiles with image if this option is turned off' do | 197 | should 'not prioritize profiles with image if this option is turned off' do |
| 198 | env = fast_create(Environment) | 198 | env = fast_create(Environment) |
| 199 | - img = Image.create!(:uploaded_data => fixture_file_upload('/files/rails.png', 'image/png')) | 199 | + img = create(Image, :uploaded_data => fixture_file_upload('/files/rails.png', 'image/png')) |
| 200 | with_image = fast_create(Person, :environment_id => env.id, :updated_at => DateTime.now, :image_id => img.id) | 200 | with_image = fast_create(Person, :environment_id => env.id, :updated_at => DateTime.now, :image_id => img.id) |
| 201 | 5.times do |n| | 201 | 5.times do |n| |
| 202 | fast_create(Person, :environment_id => env.id, :updated_at => DateTime.now + 1.day) | 202 | fast_create(Person, :environment_id => env.id, :updated_at => DateTime.now + 1.day) |