Skip to content

Commit

Permalink
Added test
Browse files Browse the repository at this point in the history
  • Loading branch information
aidanharan committed Jul 18, 2024
1 parent b0f64ef commit 6ce7a13
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 2 deletions.
16 changes: 14 additions & 2 deletions test/cases/adapter_test_sqlserver.rb
Original file line number Diff line number Diff line change
Expand Up @@ -550,11 +550,23 @@ def test_doesnt_error_when_a_select_query_is_called_while_preventing_writes

describe 'table is in non-dbo schema' do
it "records can be created successfully" do
Alien.create!(name: 'Trisolarans')
assert_difference("Alien.count", 1) do
Alien.create!(name: 'Trisolarans')
end
end

it 'records can be inserted using SQL' do
Alien.connection.exec_insert("insert into [test].[aliens] (id, name) VALUES(1, 'Trisolarans'), (2, 'Xenomorph')")
assert_difference("Alien.count", 2) do
Alien.connection.exec_insert("insert into [test].[aliens] (id, name) VALUES(1, 'Trisolarans'), (2, 'Xenomorph')")
end
end
end

describe 'table names contains spaces' do
it 'records can be created successfully' do
assert_difference("TableWithSpaces.count", 1) do
TableWithSpaces.create!(name: 'Bob')
end
end
end

Expand Down
5 changes: 5 additions & 0 deletions test/models/sqlserver/table_with_spaces.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# frozen_string_literal: true

class TableWithSpaces < ActiveRecord::Base
self.table_name = "A Table With Spaces"
end
4 changes: 4 additions & 0 deletions test/schema/sqlserver_specific_schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,10 @@
SELECT GETUTCDATE() utcdate
SQL

create_table 'A Table With Spaces', force: true do |t|
t.string :name
end

# Constraints

create_table(:sst_has_fks, force: true) do |t|
Expand Down

0 comments on commit 6ce7a13

Please sign in to comment.