From 799845ec1cf35c92405633cd7402e98d2414ece0 Mon Sep 17 00:00:00 2001 From: Tute Costa Date: Tue, 22 Mar 2016 22:38:44 -0400 Subject: [PATCH] Fix spec While working on this branch, Kito found that this test fails due to: https://github.com/rails/rails/commit/6ec8ba16d85d5feaccb993c9756c1edcbbf0ba13#diff-fdcf8b65b5fb954372c6fe1ddf284c78R76 We are not yet sure if it's a bug in paperclip or in Rails itself. With current `ActiveModel::Errors` implementation the following happens: ``` record.errors # => @messages = {} record.errors.include?(:foo) # => false record.errors # => @messages = { :foo => [] } ``` Which bit us in: https://github.com/thoughtbot/paperclip/blob/69f18375333234b6f395300266e2612936bd242e/lib/paperclip/validators/attachment_file_name_validator.rb#L23 Another related Rails commit: https://github.com/rails/rails/commit/b97035df64f5b2f912425c4a7fcb6e6bb3ddab8d I worked around the issue by changing what we assert in this spec. I am still not sure that this is a bug in current Rails master. cc @kitop for review --- spec/paperclip/validators_spec.rb | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/spec/paperclip/validators_spec.rb b/spec/paperclip/validators_spec.rb index 398948d83..93a57e26b 100644 --- a/spec/paperclip/validators_spec.rb +++ b/spec/paperclip/validators_spec.rb @@ -64,12 +64,11 @@ assert_raises(RuntimeError){ dummy.valid? } end - it 'allows you to attach a file that does not violates these validations' do + it 'allows you to attach a file that does not violate these validations' do dummy = Dummy.new(avatar: File.new(fixture_file('rotated.jpg'))) - expect(dummy.errors.keys).to match_array [] + expect(dummy.errors.full_messages).to be_empty assert dummy.valid? end - end context "using the helper with a conditional" do