Created
August 17, 2009 14:14
-
-
Save boone/169143 to your computer and use it in GitHub Desktop.
Shoulda macro for file_column plugin
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# file_column Shoulda macro, based off the Paperclip method given here: | |
# http://giantrobots.thoughtbot.com/2008/3/18/for-attaching-files-use-paperclip#comment--614050918 | |
# pass the extra option :magick => true to test the extra method for the columns that use RMagick | |
def self.should_have_file_column(attachment, options = {}) | |
klass = described_type | |
fields = ["#{attachment}", "#{attachment}=", "#{attachment}_temp", "#{attachment}_temp=", | |
"#{attachment}_dir", "#{attachment}_just_uploaded?", "#{attachment}_options", | |
"#{attachment}_relative_dir", "#{attachment}_relative_path"] | |
fields << "#{attachment}_magick_after_assign" if options[:magick] | |
should "have_file_column #{attachment}" do | |
fields.each do |method_name| | |
assert klass.instance_methods.include?(method_name), "#{klass.name} does not have a #{method_name} instance method." | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment