This repository is private.
All pages are served over SSL and all pushing and pulling is done over SSH.
No one may fork, clone, or view it unless they are added as a member.
Every repository with this icon (
) is private.
Every repository with this icon (
This repository is public.
Anyone may fork, clone, or view it.
Every repository with this icon (
) is public.
Every repository with this icon (
has_digest / shoulda_macros / has_digest.rb
| 812e36da » | matthewtodd | 2008-11-07 | 1 | module HasDigest | |
| 2 | module Shoulda | ||||
| 4405ecbf » | matthewtodd | 2008-11-07 | 3 | # Asserts that the necessary database columns exist to support | |
| 4 | # <tt>has_digest :name</tt> and that the necessary callback methods have | ||||
| 5 | # been created. | ||||
| 695012b3 » | matthewtodd | 2008-11-07 | 6 | def should_have_digest(name, options = {}) | |
| f23993ec » | matthewtodd | 2008-11-07 | 7 | options.assert_valid_keys(:depends) | |
| 8 | |||||
| 5c5d75e0 » | matthewtodd | 2008-11-08 | 9 | context "#{model_class.name} with has_digest :#{name}" do | |
| f23993ec » | matthewtodd | 2008-11-07 | 10 | should_have_db_column name, :type => :string, :limit => 40 | |
| 5c5d75e0 » | matthewtodd | 2008-11-08 | 11 | ||
| 12 | should "generate digest for :#{name}" do | ||||
| 13 | assert_not_nil model_class.has_digest_attributes[name] | ||||
| 14 | end | ||||
| 695012b3 » | matthewtodd | 2008-11-07 | 15 | ||
| f23993ec » | matthewtodd | 2008-11-07 | 16 | if options[:depends] | |
| 17 | dependencies = options[:depends] | ||||
| 18 | dependencies = [dependencies] unless dependencies.respond_to?(:each) | ||||
| 5c5d75e0 » | matthewtodd | 2008-11-08 | 19 | dependencies.unshift(:salt) if model_class.column_names.include?('salt') | |
| 695012b3 » | matthewtodd | 2008-11-07 | 20 | ||
| 5c5d75e0 » | matthewtodd | 2008-11-08 | 21 | should "generate digest for :#{name} from #{dependencies.to_sentence}" do | |
| 22 | attributes = model_class.has_digest_attributes[name] || {} | ||||
| 23 | assert_equal dependencies, attributes[:dependencies] | ||||
| f23993ec » | matthewtodd | 2008-11-07 | 24 | end | |
| 695012b3 » | matthewtodd | 2008-11-07 | 25 | end | |
| 812e36da » | matthewtodd | 2008-11-07 | 26 | end | |
| 27 | end | ||||
| 28 | end | ||||
| 29 | end | ||||
| 30 | |||||
| 31 | Test::Unit::TestCase.extend(HasDigest::Shoulda) | ||||







