diff --git a/app/models/thumbnail.rb b/app/models/thumbnail.rb index 215c2e0..413b0f1 100644 --- a/app/models/thumbnail.rb +++ b/app/models/thumbnail.rb @@ -1,4 +1,9 @@ class Thumbnail < ActiveRecord::Base + + attr_accessible :uploaded_data + # mass assigned by attachment_fu + attr_accessible :content_type, :filename, :thumbnail_resize_options, :thumbnail, :parent_id + has_attachment :storage => :file_system, :content_type => :image, :max_size => 5.megabytes, processor: 'Rmagick' validates_as_attachment @@ -7,5 +12,4 @@ class Thumbnail < ActiveRecord::Base postgresql_attachment_fu - attr_accessible :uploaded_data end diff --git a/test/factories.rb b/test/factories.rb index 1a1e4c1..2970f1d 100644 --- a/test/factories.rb +++ b/test/factories.rb @@ -31,7 +31,8 @@ module Noosfero::Factory if respond_to?(target) send(target, attrs) else - obj = build(name, attrs) + obj = build name + attrs.each{ |a, v| obj.send "#{a}=", v } obj.save! obj end diff --git a/test/test_helper.rb b/test/test_helper.rb index 3562a60..b13a823 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -138,6 +138,7 @@ class ActiveSupport::TestCase def find_tag_in_string text, options doc = Nokogiri::HTML.fragment text tag = doc.css(options[:tag]).first + return unless tag content = tag.text.strip attributes = {}; tag.attributes.each do |a, v| @@ -146,7 +147,7 @@ class ActiveSupport::TestCase attributes[a] = v.value end - ret = tag.present? + ret = true ret &&= options[:attributes].blank? || attributes == options[:attributes] ret &&= options[:content].blank? || content == options[:content] ret diff --git a/test/unit/uploaded_file_test.rb b/test/unit/uploaded_file_test.rb index 8a5acfe..1bd58c6 100644 --- a/test/unit/uploaded_file_test.rb +++ b/test/unit/uploaded_file_test.rb @@ -347,13 +347,13 @@ class UploadedFileTest < ActiveSupport::TestCase 'INVALID' => 5.megabytes, # use default for invalid input '1ZYX' => 5.megabytes, # use default for invalid input }.each do |input,output| - test 'maximum upload size: convert %s into %s' % [input, output] do + should 'maximum upload size: convert %s into %s' % [input, output] do NOOSFERO_CONF.expects(:[]).with('max_upload_size').returns(input) assert_equal output, UploadedFile.max_size end end - test 'max_size should always return an integer' do - NOOSFERO_CONF.expects(:[]).with('max_upload_size').returns("0.5 GB") + should 'max_size should always return an integer' do + NOOSFERO_CONF.expects(:[]).with('max_upload_size').returns("0.5 GB").at_least_once assert_instance_of Fixnum, UploadedFile.max_size end -- libgit2 0.21.2