forked from collectiveidea/audited
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstall_generator_test.rb
62 lines (48 loc) · 2.12 KB
/
install_generator_test.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
require "test_helper"
require "generators/audited/install_generator"
class InstallGeneratorTest < Rails::Generators::TestCase
destination File.expand_path("../../tmp", __FILE__)
setup :prepare_destination
tests Audited::Generators::InstallGenerator
test "generate migration with 'text' type for audited_changes column" do
run_generator
assert_migration "db/migrate/install_audited.rb" do |content|
assert_includes(content, "class InstallAudited")
assert_includes(content, "t.column :audited_changes, :text")
end
end
test "generate migration with 'jsonb' type for audited_changes column" do
run_generator %w[--audited-changes-column-type jsonb]
assert_migration "db/migrate/install_audited.rb" do |content|
assert_includes(content, "class InstallAudited")
assert_includes(content, "t.column :audited_changes, :jsonb")
end
end
test "generate migration with 'json' type for audited_changes column" do
run_generator %w[--audited-changes-column-type json]
assert_migration "db/migrate/install_audited.rb" do |content|
assert_includes(content, "class InstallAudited")
assert_includes(content, "t.column :audited_changes, :json")
end
end
test "generate migration with 'string' type for user_id column" do
run_generator %w[--audited-user-id-column-type string]
assert_migration "db/migrate/install_audited.rb" do |content|
assert_includes(content, "class InstallAudited")
assert_includes(content, "t.column :user_id, :string")
end
end
test "generate migration with 'uuid' type for user_id column" do
run_generator %w[--audited-user-id-column-type uuid]
assert_migration "db/migrate/install_audited.rb" do |content|
assert_includes(content, "class InstallAudited")
assert_includes(content, "t.column :user_id, :uuid")
end
end
test "generate migration with correct AR migration parent" do
run_generator
assert_migration "db/migrate/install_audited.rb" do |content|
assert_includes(content, "class InstallAudited < ActiveRecord::Migration[#{ActiveRecord::Migration.current_version}]\n")
end
end
end