Sha256: a2e18b5e18286990a4fb89845be88640942b18a41042fe8f5d8c2304ee11a17d
Contents?: true
Size: 1.5 KB
Versions: 2
Compression:
Stored size: 1.5 KB
Contents
require 'spec_helper' module Pose describe Assignment do describe :delete_class_index do before :each do FactoryGirl.create :assignment, posable_id: 1, posable_type: 'PosableOne' FactoryGirl.create :assignment, posable_id: 2, posable_type: 'PosableTwo' Assignment.delete_class_index PosableOne end it "deletes all Assignments for the given class" do expect(Assignment.where(posable_type: 'PosableOne')).to have(0).items end it "doesn't delete Assignments for other classes" do expect(Assignment.where(posable_type: 'PosableTwo')).to have(1).items end end describe :cleanup_orphaned_pose_assignments do it "deletes the assignment if the posable object doesn't exist" do FactoryGirl.create :assignment, posable_id: 2, posable_type: 'PosableOne' expect(Assignment.count).to be > 0 Assignment.cleanup_orphaned_pose_assignments expect(Assignment.count).to eql 0 end it "deletes the assignment if the word doesn't exist" do assignment = FactoryGirl.create :assignment, word: nil, word_id: 27 Assignment.cleanup_orphaned_pose_assignments expect(Assignment.find_by_id(assignment.id)).to be_nil end it "doesn't delete the assignment if it is still used" do assignment = FactoryGirl.create :assignment Assignment.cleanup_orphaned_pose_assignments expect(Assignment.find_by_id(assignment.id)).to_not be_nil end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
pose-3.0.0 | spec/models/assignment_spec.rb |
pose-2.1.0 | spec/models/assignment_spec.rb |