Sha256: 9c7a3db2fc072cab7e6505ffef9c9a05d1a856a9ea6344ec41b8585c6e517d93
Contents?: true
Size: 1.65 KB
Versions: 3
Compression:
Stored size: 1.65 KB
Contents
require "spec_helper" describe Mongoid::Persistence::Atomic::PushAll do describe "#persist" do context "when the field exists" do let(:person) do Person.create(aliases: [ "007" ]) end let!(:pushed) do person.push_all(:aliases, [ "Bond", "James" ]) end let(:reloaded) do person.reload end it "pushes the value onto the array" do person.aliases.should eq([ "007", "Bond", "James" ]) end it "persists the data" do reloaded.aliases.should eq([ "007", "Bond", "James" ]) end it "removes the field from the dirty attributes" do person.changes["aliases"].should be_nil end it "resets the document dirty flag" do person.should_not be_changed end it "returns the new array value" do pushed.should eq([ "007", "Bond", "James" ]) end end context "when the field does not exist" do let(:person) do Person.create end let!(:pushed) do person.push_all(:aliases, [ "Bond", "James" ]) end let(:reloaded) do person.reload end it "pushes the value onto the array" do person.aliases.should eq([ "Bond", "James" ]) end it "persists the data" do reloaded.aliases.should eq([ "Bond", "James" ]) end it "removes the field from the dirty attributes" do person.changes["aliases"].should be_nil end it "resets the document dirty flag" do person.should_not be_changed end it "returns the new array value" do pushed.should eq([ "Bond", "James" ]) end end end end
Version data entries
3 entries across 3 versions & 1 rubygems