Sha256: 76514cf38efd2688d0ad37afa9f814d498aca971f19cf9f83ab7e58c1ad33a3c

Contents?: true

Size: 1.56 KB

Versions: 3

Compression:

Stored size: 1.56 KB

Contents

require 'test_helper'

require 'generators/acts_as_audited/upgrade_generator'

class UpgradeGeneratorTest < Rails::Generators::TestCase
  destination File.expand_path('../../tmp', __FILE__)
  setup :prepare_destination
  tests ActsAsAudited::Generators::UpgradeGenerator

  test "should add 'comment' to audits table" do
    load_schema 1

    run_generator %w(upgrade)

    assert_migration "db/migrate/add_comment_to_audits.rb" do |content|
      assert_match /add_column :audits, :comment, :string/, content
    end

    assert_migration "db/migrate/rename_changes_to_audited_changes.rb"
  end

  test "should rename 'changes' to 'audited_changes'" do
    load_schema 2

    run_generator %w(upgrade)

    assert_no_migration "db/migrate/add_comment_to_audits.rb"

    assert_migration "db/migrate/rename_changes_to_audited_changes.rb" do |content|
      assert_match /rename_column :audits, :changes, :audited_changes/, content
    end
  end

  test "should add a 'remote_address' to audits table" do
    load_schema 3

    run_generator %w(upgrade)

    assert_migration "db/migrate/add_remote_address_to_audits.rb" do |content|
      assert_match /add_column :audits, :remote_address, :string/, content
    end
  end

  test "should add 'associated_id' and 'associated_type' to audits table" do
    load_schema 4

    run_generator %w(upgrade)

    assert_migration "db/migrate/add_association_to_audits.rb" do |content|
      assert_match /add_column :audits, :association_id, :integer/, content
      assert_match /add_column :audits, :association_type, :string/, content
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
acts_as_audited-2.0.0.rc7 test/upgrade_generator_test.rb
acts_as_audited-2.0.0.rc6 test/upgrade_generator_test.rb
acts_as_audited-2.0.0.rc5 test/upgrade_generator_test.rb