Commit 0be5d250 by jyurek

Added test cases to ensure it works with attr_protected

git-svn-id: https://svn.thoughtbot.com/plugins/paperclip/trunk@411 7bbfaf0e-4d1d-0410-9690-a8bb5f8ef2aa
parent 6c38225b
......@@ -22,6 +22,7 @@ ActiveRecord::Base.establish_connection(config[ENV['RAILS_ENV'] || 'test'])
def rebuild_model options = {}
ActiveRecord::Base.connection.create_table :dummies, :force => true do |table|
table.column :other, :string
table.column :avatar_file_name, :string
table.column :avatar_content_type, :string
table.column :avatar_file_size, :integer
......
......@@ -4,6 +4,36 @@ class PaperclipTest < Test::Unit::TestCase
context "An ActiveRecord model with an 'avatar' attachment" do
setup do
rebuild_model
@file = File.new(File.join(FIXTURES_DIR, "5k.png"))
end
context "that is attr_protected" do
setup do
Dummy.class_eval do
attr_protected :avatar
end
@dummy = Dummy.new
end
should "not assign the avatar on mass-set" do
@dummy.logger.expects(:debug)
@dummy.attributes = { :other => "I'm set!",
:avatar => @file }
assert_equal "I'm set!", @dummy.other
assert ! @dummy.avatar?
end
should "still allow assigment on normal set" do
@dummy.logger.expects(:debug).times(0)
@dummy.other = "I'm set!"
@dummy.avatar = @file
assert_equal "I'm set!", @dummy.other
assert @dummy.avatar?
end
end
should "have an #avatar method" do
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment