forked from thoughtbot/paperclip
-
Notifications
You must be signed in to change notification settings - Fork 0
/
attachment_options_test.rb
45 lines (37 loc) · 1.39 KB
/
attachment_options_test.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
require './test/helper'
class AttachmentOptionsTest < Test::Unit::TestCase
should "exist" do
Paperclip::AttachmentOptions
end
should "be a Hash" do
attachment_options = Paperclip::AttachmentOptions.new({})
assert attachment_options.is_a?(Hash), "attachment_options is not a Hash"
end
should "add a default empty validations" do
options = {:arbi => :trary}
expected = {:validations => []}.merge(options)
actual = Paperclip::AttachmentOptions.new(options).to_hash
assert_equal expected, actual
end
should "not override validations if passed to initializer" do
options = {:validations => "something"}
attachment_options = Paperclip::AttachmentOptions.new(options)
assert_equal "something", attachment_options[:validations]
end
should "respond to []" do
Paperclip::AttachmentOptions.new({})[:foo]
end
should "deliver the specified options through []" do
intended_options = {:specific_key => "specific value"}
attachment_options = Paperclip::AttachmentOptions.new(intended_options)
assert_equal "specific value", attachment_options[:specific_key]
end
should "respond to []=" do
Paperclip::AttachmentOptions.new({})[:foo] = "bar"
end
should "remember options set with []=" do
attachment_options = Paperclip::AttachmentOptions.new({})
attachment_options[:foo] = "bar"
assert_equal "bar", attachment_options[:foo]
end
end