Sha256: 7f6ce18157fd2bbc47b27b193aa783d822a46a12ff704138fe6e8de9dac607c6

Contents?: true

Size: 1.19 KB

Versions: 10

Compression:

Stored size: 1.19 KB

Contents

require 'spec_helper'

require 'factories/record_history_models'
require 'factories/users'
require 'factories/some_datas'
require 'shoulda-matchers'

describe RecordHistoryModel do
  context "validations" do
    before :each do
      @hist = Factory.create(:record_history_model)
    end
    it "presence" do
      [:item_type, :item_id, :old_value_dump, :new_value_dump].each do |attr|
        @hist.send("#{attr}=", nil)
        @hist.should_not be_valid
        @hist.errors.size.should == 1
        @hist.errors.get(attr).should == ["can't be blank"]
        @hist.send("#{attr}=", Factory.build(:record_history_model).send(attr ))
        @hist.should be_valid
      end
    end
  end

  context "associations" do
    before :each do
      @hist = Factory.create(:record_history_model)
    end

    it "item" do
      item = @hist.item
      item.class.name.should == @hist.item_type
      item.id.should == @hist.item.id

      item.record_history.first.should == @hist
    end

    it "author" do
      author = @hist.author
      author.class.name.should == @hist.author_type
      author.id.should == @hist.author_id

      author.written_history.first.class.name.should == "RecordHistoryModel"
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
record_history-0.9.1 spec/record_history_spec.rb
record_history-0.9.0 spec/record_history_spec.rb
record_history-0.8.9 spec/record_history_spec.rb
record_history-0.8.8 spec/record_history_spec.rb
record_history-0.8.7 spec/record_history_spec.rb
record_history-0.8.6 spec/record_history_spec.rb
record_history-0.8.5 spec/record_history_spec.rb
record_history-0.8.4 spec/record_history_spec.rb
record_history-0.8.3 spec/record_history_spec.rb
record_history-0.8.2 spec/record_history_spec.rb