Sha256: e2b51376b41eb6c3040e366c7045c0e73099dafe6d02bcc778514b7adfc52b05

Contents?: true

Size: 1.47 KB

Versions: 2

Compression:

Stored size: 1.47 KB

Contents

require File.dirname(__FILE__) + '/../spec_helper'

describe 'Core extensions' do

  describe 'ActiveRecord::Base' do

    let(:order) { Order.create }

    context "update_attribute_without_callbacks" do

      it "sets the attribute" do
        order.update_attribute_without_callbacks 'state', 'new_state'
        order.state.should == 'new_state'
      end

      it "updates the attribute in the database" do
        order.update_attribute_without_callbacks 'state', 'new_state'
        order.reload
        order.state.should == 'new_state'
      end

      it "doesn't call valid" do
        order.should_not_receive(:valid?)
        order.update_attribute_without_callbacks 'state', 'new_state'
      end

    end

    context "updte_attributes_without_callbacks" do

      it "sets the attributes" do
        order.update_attributes_without_callbacks :state => 'new_state', :email => 'spree@example.com'
        order.state.should == 'new_state'
        order.email.should == 'spree@example.com'
      end

      it "updates the attributes in the database" do
        order.update_attributes_without_callbacks :state => 'new_state', :email => 'spree@example.com'
        order.reload
        order.state.should == 'new_state'
        order.email.should == 'spree@example.com'
      end

      it "doesn't call valid" do
        order.should_not_receive(:valid?)
        order.update_attributes_without_callbacks :state => 'new_state', :email => 'spree@example.com'
      end

    end

  end

end

Version data entries

2 entries across 2 versions & 2 rubygems

Version Path
MyCommerceapi-1.0.0 core/spec/lib/ext_spec.rb
MyCommerce-0.0.3 core/spec/lib/ext_spec.rb