Sha256: f233e34e6eddca89cdd9dbdd3fbce299e7d10584bc8cd882d50c1a107ae824fe

Contents?: true

Size: 866 Bytes

Versions: 1

Compression:

Stored size: 866 Bytes

Contents

class Test::Unit::TestCase
  def self.should_act_as_paranoid
    klass = model_class

    context "A #{klass.name}" do
      should "be paranoid (it will not be deleted from the database)" do
        klass.paranoid?
      end

      should "not have a value for deleted_at" do
        assert object = klass.find(:first)
        assert_nil object.deleted_at
      end

      context "when destroyed" do
        setup do
          assert object = klass.find(:first)
          @deleted_id = object.id
          object.destroy
        end

        should "not be found" do
          assert_raise(ActiveRecord::RecordNotFound) { klass.find(@deleted_id) }
        end

        should "still exist in the database" do
          deleted_object = klass.find_with_deleted(@deleted_id)
          assert_not_nil deleted_object.deleted_at
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
seanhussey-woulda-0.1.0 shoulda_macros/should_act_as_paranoid.rb