Sha256: 2e2c5ec8a5d11a6cb845e3df0cbd01fb23d998a145bb965b99fb4c457781dfa0

Contents?: true

Size: 1.38 KB

Versions: 23

Compression:

Stored size: 1.38 KB

Contents

require File.expand_path(File.dirname(__FILE__) + "/../../spec_helper")

describe ActsAsArchive::Base::Restore do
  
  before(:all) do
    establish_test_db
    Article.create_archive_table
  end
  
  describe 'restore_all' do
    
    before(:all) do
      @articles = create_records(Article::Archive)
    end
    
    describe 'with conditions' do
      
      before(:all) do
        # Mini restore parameter test
        Article.restore_all [ 'id = ?', @articles[0].id ]
        Article.restore_all "id = #{@articles[1].id}"
      end
      
      it "should move some records to the article table" do
        Article::Archive.count.should == 3
        Article.count.should == 2
      end
      
      it "should preserve record attributes" do
        2.times do |x|
          original = @articles[x]
          copy = Article.find(original.id)
          article_match?(original, copy)
        end
      end
    end
    
    describe 'without conditions' do
      
      before(:all) do
        Article.restore_all
      end
      
      it "should move all records to the archive table" do
        Article::Archive.count.should == 0
        Article.count.should == 5
      end
      
      it "should preserve record attributes" do
        5.times do |x|
          original = @articles[x]
          copy = Article.find(original.id)
          article_match?(original, copy)
        end
      end
    end
  end
end

Version data entries

23 entries across 23 versions & 7 rubygems

Version Path
winton-acts_as_archive-0.1.3 spec/acts_as_archive/base/restore_spec.rb
brianjlandau-acts_as_archive-0.2.8 spec/acts_as_archive/base/restore_spec.rb
brianjlandau-acts_as_archive-0.2.7 spec/acts_as_archive/base/restore_spec.rb
brianjlandau-acts_as_archive-0.2.6 spec/acts_as_archive/base/restore_spec.rb
micahwedemeyer-acts_as_archive-0.3.0 spec/acts_as_archive/base/restore_spec.rb
sideshowbandana-acts_as_archive-0.2.7 spec/acts_as_archive/base/restore_spec.rb
sideshowbandana-acts_as_archive-0.2.6 spec/acts_as_archive/base/restore_spec.rb
foolabs-acts_as_archive-0.2.12 spec/acts_as_archive/base/restore_spec.rb
gravis-acts_as_archive-0.2.11 spec/acts_as_archive/base/restore_spec.rb
gravis-acts_as_archive-0.2.10 spec/acts_as_archive/base/restore_spec.rb
gravis-acts_as_archive-0.2.7 spec/acts_as_archive/base/restore_spec.rb
gravis-acts_as_archive-0.2.9 spec/acts_as_archive/base/restore_spec.rb
gravis-acts_as_archive-0.2.8 spec/acts_as_archive/base/restore_spec.rb
gravis-acts_as_archive-0.2.6 spec/acts_as_archive/base/restore_spec.rb
acts_as_archive-0.2.5 spec/acts_as_archive/base/restore_spec.rb
acts_as_archive-0.2.4 spec/acts_as_archive/base/restore_spec.rb
acts_as_archive-0.2.3 spec/acts_as_archive/base/restore_spec.rb
acts_as_archive-0.2.2 spec/acts_as_archive/base/restore_spec.rb
acts_as_archive-0.2.1 spec/acts_as_archive/base/restore_spec.rb
acts_as_archive-0.2.0 spec/acts_as_archive/base/restore_spec.rb