Sha256: 00dbcf78f5284c225a16e48d25fabe68ead8792740dc71b26109e4c5d0bc7e27
Contents?: true
Size: 1.26 KB
Versions: 4
Compression:
Stored size: 1.26 KB
Contents
require 'spec_helper' describe Acfs::Model::Dirty do let(:model) { MyUser.new } before do stub_request(:get, "http://users.example.org/users/1").to_return( body: MessagePack.dump({ id: 1, name: 'Anon', age: 12 }), headers: {'Content-Type' => 'application/x-msgpack'}) stub_request(:post, 'http://users.example.org/users').to_return( body: MessagePack.dump({ id: 5, name: 'dhh', age: 12 }), headers: {'Content-Type' => 'application/x-msgpack'}) end it 'includes ActiveModel::Dirty' do model.is_a? ActiveModel::Dirty end describe '#changed?' do context 'after attribute change' do let(:user) { MyUser.new name: 'dhh' } it { expect(user).to be_changed } context 'and saving' do before { user.save } it { expect(user).to_not be_changed } end end context 'after model load' do let(:user) { MyUser.find 1 } before { user; Acfs.run} it { expect(user).to_not be_changed } end context 'after model new without attrs' do let(:user) { MyUser.new } it { expect(user).to_not be_changed } end context 'after model new with attrs' do let(:user) { MyUser.new name: "Uschi" } it { expect(user).to be_changed } end end end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
acfs-0.11.0 | spec/acfs/model/dirty_spec.rb |
acfs-0.10.0 | spec/acfs/model/dirty_spec.rb |
acfs-0.9.0 | spec/acfs/model/dirty_spec.rb |
acfs-0.8.0 | spec/acfs/model/dirty_spec.rb |