spec/models/naf/machine_spec.rb in naf-2.1.9 vs spec/models/naf/machine_spec.rb in naf-2.1.10

- old
+ new

@@ -117,17 +117,30 @@ dying_machine.mark_machine_down(dying_machine) dying_machine.marked_down.should be_true end end + context "when updating the machine" do + it "should not save when enabled and deleted are true" do + bad_machine = FactoryGirl.build(:machine, enabled: true, deleted: true) + bad_machine.save.should_not be_true + bad_machine.errors.messages[:enabled].should_not be_nil + end + + it "should save when enabled is true and deleted is false" do + machine = FactoryGirl.build(:machine, enabled: true, deleted: false) + machine.save.should be_true + end + end + #---------------------- # *** Class Methods *** #++++++++++++++++++++++ describe "#enabled" do before do machine.update_attributes!(enabled: true) - FactoryGirl.create(:machine_two, enabled: false) + FactoryGirl.create(:machine_two, enabled: false, deleted: true) end it "return the correct machine" do ::Naf::Machine.enabled.all.should == [machine] end