activerecord-jdbcteradata-adapter 0.3.7 → 0.3.8
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile.lock +2 -2
- data/activerecord-jdbcteradata-adapter.gemspec +1 -1
- data/lib/arjdbc/teradata/adapter.rb +1 -7
- data/spec/associations_spec.rb +22 -0
- data/spec/models/purchase_orders.rb +23 -0
- metadata +1 -1
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
activerecord-jdbcteradata-adapter (0.3.
|
4
|
+
activerecord-jdbcteradata-adapter (0.3.7)
|
5
5
|
activerecord
|
6
6
|
activerecord-jdbc-adapter
|
7
7
|
jdbc-teradata
|
@@ -26,7 +26,7 @@ GEM
|
|
26
26
|
diff-lcs (1.2.2)
|
27
27
|
i18n (0.6.1)
|
28
28
|
jdbc-teradata (0.2.0)
|
29
|
-
multi_json (1.7.
|
29
|
+
multi_json (1.7.3)
|
30
30
|
rake (10.0.4)
|
31
31
|
rspec (2.13.0)
|
32
32
|
rspec-core (~> 2.13.0)
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
2
|
s.name = "activerecord-jdbcteradata-adapter"
|
3
|
-
s.version = "0.3.
|
3
|
+
s.version = "0.3.8"
|
4
4
|
s.authors = ["Chris Parker"]
|
5
5
|
s.email = [ "mrcsparker@gmail.com"]
|
6
6
|
s.homepage = "https://github.com/mrcsparker/activerecord-jdbcteradata-adapter"
|
@@ -145,13 +145,7 @@ module ::ArJdbc
|
|
145
145
|
|
146
146
|
#- tables
|
147
147
|
def tables
|
148
|
-
|
149
|
-
schema, table = extract_schema_and_table(table_name.to_s)
|
150
|
-
return false unless table
|
151
|
-
|
152
|
-
schema = database_name unless schema
|
153
|
-
|
154
|
-
@connection.tables(nil, schema, nil, %w(TABLE))
|
148
|
+
@connection.tables(nil, database_name, nil, %w(TABLE))
|
155
149
|
end
|
156
150
|
|
157
151
|
#- table_exists?
|
data/spec/associations_spec.rb
CHANGED
@@ -7,6 +7,7 @@ describe 'AssociationsSpec' do
|
|
7
7
|
CreateVendors.up
|
8
8
|
CreateProducts.up
|
9
9
|
CreatePurchaseOrders.up
|
10
|
+
CreateOrderLineItems.up
|
10
11
|
end
|
11
12
|
|
12
13
|
it 'should create all of the tables' do
|
@@ -26,9 +27,30 @@ describe 'AssociationsSpec' do
|
|
26
27
|
vendor.purchase_orders.count.should == 1
|
27
28
|
end
|
28
29
|
|
30
|
+
describe '#accepts_nested_attibutes_for' do
|
31
|
+
it 'should be able to create a purchase_order with line_items' do
|
32
|
+
vendor = Vendor.new(:name => 'Test vendor', :catch_phrase => 'Hello, world')
|
33
|
+
vendor.products.build(:name => 'Test product', :price => 100.00)
|
34
|
+
vendor.save
|
35
|
+
|
36
|
+
params = { :purchase_order => {
|
37
|
+
:product_id => vendor.products.first.id,
|
38
|
+
:code => 'Order 2',
|
39
|
+
:quantity => 1,
|
40
|
+
:order_line_items_attributes => [
|
41
|
+
{ :item_name => 'Test item' }
|
42
|
+
]
|
43
|
+
} }
|
44
|
+
|
45
|
+
purchase_order = PurchaseOrder.create(params[:purchase_order])
|
46
|
+
purchase_order.order_line_items.size.should == 1
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
29
50
|
after(:all) do
|
30
51
|
CreateVendors.down
|
31
52
|
CreateProducts.down
|
32
53
|
CreatePurchaseOrders.down
|
54
|
+
CreateOrderLineItems.down
|
33
55
|
end
|
34
56
|
end
|
@@ -44,6 +44,22 @@ class CreatePurchaseOrders < ActiveRecord::Migration
|
|
44
44
|
end
|
45
45
|
end
|
46
46
|
|
47
|
+
class CreateOrderLineItems < ActiveRecord::Migration
|
48
|
+
def self.up
|
49
|
+
create_table :order_line_items do |t|
|
50
|
+
t.integer :purchase_order_id, :null => false
|
51
|
+
t.string :item_name, :null => false
|
52
|
+
end
|
53
|
+
|
54
|
+
add_index :order_line_items, :purchase_order_id, :name => 'idx_line_items_po_id'
|
55
|
+
end
|
56
|
+
|
57
|
+
def self.down
|
58
|
+
drop_table :order_line_items
|
59
|
+
end
|
60
|
+
|
61
|
+
end
|
62
|
+
|
47
63
|
class Vendor < ActiveRecord::Base
|
48
64
|
has_many :products
|
49
65
|
has_many :purchase_orders, :through => :products
|
@@ -54,6 +70,13 @@ class Product < ActiveRecord::Base
|
|
54
70
|
has_many :purchase_orders
|
55
71
|
end
|
56
72
|
|
73
|
+
class OrderLineItem < ActiveRecord::Base
|
74
|
+
belongs_to :purchase_order
|
75
|
+
end
|
76
|
+
|
57
77
|
class PurchaseOrder < ActiveRecord::Base
|
58
78
|
belongs_to :product
|
79
|
+
has_many :order_line_items, :dependent => :destroy
|
80
|
+
accepts_nested_attributes_for :order_line_items, :allow_destroy => true
|
59
81
|
end
|
82
|
+
|