Sha256: 844fd4870aee04742125d9435c82824782fd997cb3f8bb4348e6843e45ed35a5

Contents?: true

Size: 1.09 KB

Versions: 116

Compression:

Stored size: 1.09 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 response({ id: 1, name: 'Anon', age: 12 })
    stub_request(:post, 'http://users.example.org/users').to_return response({ id: 5, name: 'dhh', age: 12 })
  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

116 entries across 116 versions & 1 rubygems

Version Path
acfs-0.30.0.1.b260 spec/acfs/model/dirty_spec.rb
acfs-0.30.0 spec/acfs/model/dirty_spec.rb
acfs-0.29.1.1.b259 spec/acfs/model/dirty_spec.rb
acfs-0.29.1.1.b257 spec/acfs/model/dirty_spec.rb
acfs-0.29.1 spec/acfs/model/dirty_spec.rb
acfs-0.29.0.1.b256 spec/acfs/model/dirty_spec.rb
acfs-0.29.0.1.b254 spec/acfs/model/dirty_spec.rb
acfs-0.29.0 spec/acfs/model/dirty_spec.rb
acfs-0.28.0.1.b253 spec/acfs/model/dirty_spec.rb
acfs-0.28.0.1.b249 spec/acfs/model/dirty_spec.rb
acfs-0.28.0 spec/acfs/model/dirty_spec.rb
acfs-0.27.0.1.b248 spec/acfs/model/dirty_spec.rb
acfs-0.27.0.1.b244 spec/acfs/model/dirty_spec.rb
acfs-0.27.0 spec/acfs/model/dirty_spec.rb
acfs-0.26.0.1.b243 spec/acfs/model/dirty_spec.rb
acfs-0.26.0.1.b242 spec/acfs/model/dirty_spec.rb
acfs-0.26.0 spec/acfs/model/dirty_spec.rb
acfs-0.25.0.1.b232 spec/acfs/model/dirty_spec.rb
acfs-0.25.0.1.b229 spec/acfs/model/dirty_spec.rb
acfs-0.25.0.1.b228 spec/acfs/model/dirty_spec.rb