Commit a3c6b6027928fffe73e8a91dd4ec09a9f0e5de6b
1 parent
2f568c12
Exists in
master
and in
20 other branches
rails4: fix uploaded file tests
Showing
4 changed files
with
12 additions
and
6 deletions
Show diff stats
app/models/thumbnail.rb
1 | 1 | class Thumbnail < ActiveRecord::Base |
2 | + | |
3 | + attr_accessible :uploaded_data | |
4 | + # mass assigned by attachment_fu | |
5 | + attr_accessible :content_type, :filename, :thumbnail_resize_options, :thumbnail, :parent_id | |
6 | + | |
2 | 7 | has_attachment :storage => :file_system, |
3 | 8 | :content_type => :image, :max_size => 5.megabytes, processor: 'Rmagick' |
4 | 9 | validates_as_attachment |
... | ... | @@ -7,5 +12,4 @@ class Thumbnail < ActiveRecord::Base |
7 | 12 | |
8 | 13 | postgresql_attachment_fu |
9 | 14 | |
10 | - attr_accessible :uploaded_data | |
11 | 15 | end | ... | ... |
test/factories.rb
test/test_helper.rb
... | ... | @@ -138,6 +138,7 @@ class ActiveSupport::TestCase |
138 | 138 | def find_tag_in_string text, options |
139 | 139 | doc = Nokogiri::HTML.fragment text |
140 | 140 | tag = doc.css(options[:tag]).first |
141 | + return unless tag | |
141 | 142 | content = tag.text.strip |
142 | 143 | |
143 | 144 | attributes = {}; tag.attributes.each do |a, v| |
... | ... | @@ -146,7 +147,7 @@ class ActiveSupport::TestCase |
146 | 147 | attributes[a] = v.value |
147 | 148 | end |
148 | 149 | |
149 | - ret = tag.present? | |
150 | + ret = true | |
150 | 151 | ret &&= options[:attributes].blank? || attributes == options[:attributes] |
151 | 152 | ret &&= options[:content].blank? || content == options[:content] |
152 | 153 | ret | ... | ... |
test/unit/uploaded_file_test.rb
... | ... | @@ -347,13 +347,13 @@ class UploadedFileTest < ActiveSupport::TestCase |
347 | 347 | 'INVALID' => 5.megabytes, # use default for invalid input |
348 | 348 | '1ZYX' => 5.megabytes, # use default for invalid input |
349 | 349 | }.each do |input,output| |
350 | - test 'maximum upload size: convert %s into %s' % [input, output] do | |
350 | + should 'maximum upload size: convert %s into %s' % [input, output] do | |
351 | 351 | NOOSFERO_CONF.expects(:[]).with('max_upload_size').returns(input) |
352 | 352 | assert_equal output, UploadedFile.max_size |
353 | 353 | end |
354 | 354 | end |
355 | - test 'max_size should always return an integer' do | |
356 | - NOOSFERO_CONF.expects(:[]).with('max_upload_size').returns("0.5 GB") | |
355 | + should 'max_size should always return an integer' do | |
356 | + NOOSFERO_CONF.expects(:[]).with('max_upload_size').returns("0.5 GB").at_least_once | |
357 | 357 | assert_instance_of Fixnum, UploadedFile.max_size |
358 | 358 | end |
359 | 359 | ... | ... |