Skip to content

Commit

Permalink
Test that we don't break the schema methods.
Browse files Browse the repository at this point in the history
  • Loading branch information
oggy committed Jun 27, 2012
1 parent 6a5781e commit c674666
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 0 deletions.
15 changes: 15 additions & 0 deletions test/unit/db_nazi/test_abstract_adapter.rb
Expand Up @@ -9,6 +9,11 @@
end

describe "#add_column" do
it "still adds the column if ok" do
connection.add_column 'test_table', 'test_column', :boolean, null: false, default: false
connection.column_exists?('test_table', 'test_column', :boolean, null: false, default: false).must_equal true
end

describe "when nullability is required" do
use_attribute_value DBNazi, :require_nullability, true

Expand Down Expand Up @@ -63,6 +68,11 @@
connection.add_column 'test_table', 'test_column', :boolean, null: false, default: false
end

it "still changes the column if ok" do
connection.change_column 'test_table', 'test_column', :integer, null: false
connection.column_exists?('test_table', 'test_column', :integer, null: false).must_equal true
end

describe "when nullability is required" do
use_attribute_value DBNazi, :require_nullability, true

Expand Down Expand Up @@ -117,6 +127,11 @@
connection.add_column 'test_table', 'test_column', :boolean, null: true
end

it "still adds the index if ok" do
connection.add_index 'test_table', 'test_column', unique: false
connection.index_exists?('test_table', 'test_column').must_equal true
end

describe "when index uniqueness is required" do
use_attribute_value DBNazi, :require_index_uniqueness, true

Expand Down
21 changes: 21 additions & 0 deletions test/unit/db_nazi/test_table.rb
Expand Up @@ -12,6 +12,13 @@
connection.create_table 'test_table'
end

it "still creates the column if ok" do
connection.change_table 'test_table', bulk: true do |t|
t.column 'test_column', :boolean, null: true
end
connection.column_exists?('test_table', 'test_column', :boolean, null: true).must_equal true
end

describe "when nullability is required" do
use_attribute_value DBNazi, :require_nullability, true

Expand Down Expand Up @@ -82,6 +89,13 @@
end
end

it "still creates the index if ok" do
connection.change_table 'test_table', bulk: true do |t|
t.index 'test_column', unique: false
end
connection.index_exists?('test_table', 'test_column', unique: false).must_equal true
end

describe "when index uniqueness is required" do
use_attribute_value DBNazi, :require_index_uniqueness, true

Expand Down Expand Up @@ -124,6 +138,13 @@
end
end

it "still changes the column if ok" do
connection.change_table 'test_table', bulk: true do |t|
t.change 'test_column', :integer, null: true
end
connection.column_exists?('test_table', 'test_column', :integer, null: true).must_equal true
end

describe "when nullability is required" do
use_attribute_value DBNazi, :require_nullability, true

Expand Down
7 changes: 7 additions & 0 deletions test/unit/db_nazi/test_table_definition.rb
Expand Up @@ -8,6 +8,13 @@
end

describe "#column" do
it "still creates the column if ok" do
connection.create_table 'test_table' do |t|
t.column 'test_column', :boolean, null: true
end
connection.column_exists?('test_table', 'test_column', :boolean, null: true).must_equal true
end

describe "when nullability is required" do
use_attribute_value DBNazi, :require_nullability, true

Expand Down

0 comments on commit c674666

Please sign in to comment.