Sha256: 6c101120d92c2c9d27f23f64292f2d09cdd993a03b53cdac4a0468fd7d1e72ec

Contents?: true

Size: 1.08 KB

Versions: 8

Compression:

Stored size: 1.08 KB

Contents

require 'test_helper'
require 'generators/slug_migration/slug_migration_generator'

module HumanUrls
  class SlugMigrationGeneratorTest < Rails::Generators::TestCase
    tests SlugMigrationGenerator
    destination Rails.root.join('tmp/generators')
    setup :prepare_destination

    test "generator creates proper migration" do
      run_generator ["posts"]
      assert_migration "db/migrate/add_slug_to_posts.rb" do |migration|
        assert_instance_method :change, migration do |change|
          assert_match(/add_column :posts, :slug, :string/, change)
          assert_match(/add_index :posts, :slug, unique: true/, change)
        end
      end
    end

    test "generator creates proper migration when using custom slug column" do
      run_generator ["posts", "--slug-name=url"]
      assert_migration "db/migrate/add_slug_to_posts.rb" do |migration|
        assert_instance_method :change, migration do |change|
          assert_match(/add_column :posts, :url, :string/, change)
          assert_match(/add_index :posts, :url, unique: true/, change)
        end
      end
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
human_urls-0.1.7.pre.alpha.0 test/lib/generators/human_urls/slug_migration_generator_test.rb
human_urls-0.1.6.pre.alpha.0 test/lib/generators/human_urls/slug_migration_generator_test.rb
human_urls-0.1.5.pre.alpha.0 test/lib/generators/human_urls/slug_migration_generator_test.rb
human_urls-0.1.4.pre.alpha.0 test/lib/generators/human_urls/slug_migration_generator_test.rb
human_urls-0.1.3.pre.alpha.0 test/lib/generators/human_urls/slug_migration_generator_test.rb
human_urls-0.1.2 test/lib/generators/human_urls/slug_migration_generator_test.rb
human_urls-0.1.1 test/lib/generators/human_urls/slug_migration_generator_test.rb
human_urls-0.1.0 test/lib/generators/human_urls/slug_migration_generator_test.rb