Skip to content

Embed URL

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
spec example for model which includes acts_as_paranoid
# for model which includes 'acts_as_paranoid'
# example (for User class):
# describe "acts_as_taggable" do
# let (:scope) { Question }
# it_behaves_like 'soft delete'
# it_behaves_like 'with_deleted scopes'
# end
shared_examples_for "soft delete" do
subject { create scope.to_s.downcase.to_sym }
it { expect { subject.destroy }.to_not change { scope.count } }
it "records when deleted at" do
subject.deleted_at.should_not be
subject.destroy
subject.deleted_at.should be
end
end
shared_examples_for "with_deleted scopes" do
before do
3.times{ create scope.to_s.downcase.to_sym }
scope.first.destroy
end
context "default scope" do
subject { scope }
it { should have(2).items }
end
context "with_deleted scope" do
subject { scope.with_deleted }
it { should have(3).items }
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.