sunstone 6.0.0.4 → 6.1.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -107,7 +107,7 @@ class ActiveRecord::QueryTest < ActiveSupport::TestCase
107
107
  end
108
108
 
109
109
  test '#to_sql binds correctly when joining' do
110
- assert_equal 'SELECT ships.* FROM ships INNER JOIN ownerships ON ownerships.asset_id = ships.id AND ownerships.asset_type = \'ActiveRecord::QueryTest::Ship\' WHERE ownerships.id = 1', Ship.joins(:ownerships).where({ ownerships: { id: 1 } }).to_sql
110
+ assert_equal 'SELECT ships.* FROM ships INNER JOIN ownerships ON ownerships.asset_type = \'ActiveRecord::QueryTest::Ship\' AND ownerships.asset_id = ships.id WHERE ownerships.id = 1', Ship.joins(:ownerships).where({ ownerships: { id: 1 } }).to_sql
111
111
  end
112
112
 
113
113
  test '#to_sar' do
@@ -1,23 +1,23 @@
1
1
  class ActiveSupport::TestCase
2
2
  class Schema
3
-
3
+
4
4
  class Table
5
-
5
+
6
6
  class Column
7
-
7
+
8
8
  def initialize(name, type, options={})
9
9
  @name = name
10
10
  @type = type
11
11
  @options = options
12
12
  end
13
-
13
+
14
14
  def as_json
15
15
  {type: @type, primary_key: false, null: true, array: false}.merge(@options)
16
16
  end
17
17
  end
18
-
18
+
19
19
  attr_accessor :name, :options, :columns
20
-
20
+
21
21
  def initialize(name, options={}, &block)
22
22
  @name = name
23
23
  @options = options
@@ -30,36 +30,40 @@ class ActiveSupport::TestCase
30
30
 
31
31
  block.call(self)
32
32
  end
33
-
33
+
34
34
  def string(name, options={})
35
35
  @columns[name] = Column.new(name, :string, options)
36
36
  end
37
+
38
+ def text(name, options={})
39
+ @columns[name] = Column.new(name, :text, options)
40
+ end
37
41
 
38
42
  def datetime(name, options={})
39
43
  @columns[name] = Column.new(name, :datetime, options)
40
44
  end
41
-
45
+
42
46
  def integer(name, options={})
43
47
  @columns[name] = Column.new(name, :integer, options)
44
48
  end
45
-
49
+
46
50
  def to_json
47
51
  json = @options.slice(:limit)
48
- json[:columns] = {}
52
+ json[:attributes] = {}
49
53
  @columns.each do |name, column|
50
- json[:columns][name] = column.as_json
54
+ json[:attributes][name] = column.as_json
51
55
  end
52
56
  json.to_json
53
57
  end
54
-
58
+
55
59
  end
56
-
60
+
57
61
  attr_accessor :tables
58
-
62
+
59
63
  def initialize
60
64
  @tables = {}
61
65
  end
62
-
66
+
63
67
  def self.define(&block)
64
68
  i = new
65
69
  i.define(&block)
@@ -69,21 +73,21 @@ class ActiveSupport::TestCase
69
73
  def define(&block)
70
74
  instance_eval(&block)
71
75
  end
72
-
76
+
73
77
  def create_table(name, options={}, &block)
74
78
  @tables[name] = Table.new(name, options, &block)
75
79
  end
76
-
80
+
77
81
  end
78
-
82
+
79
83
  def self.schema(&block)
80
84
  self.class_variable_set(:@@schema, Schema.define(&block))
81
85
  end
82
-
86
+
83
87
  set_callback(:setup, :before) do
84
88
  if !instance_variable_defined?(:@suite_setup_run) && self.class.class_variable_defined?(:@@schema)
85
89
  ActiveRecord::Base.establish_connection(adapter: 'sunstone', url: 'http://example.com')
86
-
90
+
87
91
  req_stub = stub_request(:get, /^http:\/\/example.com/).with do |req|
88
92
  case req.uri.path
89
93
  when '/tables'
@@ -94,24 +98,24 @@ class ActiveSupport::TestCase
94
98
  false
95
99
  end
96
100
  end
97
-
101
+
98
102
  req_stub.to_return do |req|
99
103
  case req.uri.path
100
104
  when '/tables'
101
105
  {
102
106
  body: self.class.class_variable_get(:@@schema).tables.keys.to_json,
103
- headers: { 'StandardAPI-Version' => '5.0.0.5' }
107
+ headers: { 'StandardAPI-Version' => '6.0.0.29' }
104
108
  }
105
109
  when /^\/(\w+)\/schema$/i
106
110
  {
107
111
  body: self.class.class_variable_get(:@@schema).tables[$1].to_json,
108
- headers: { 'StandardAPI-Version' => '5.0.0.5' }
112
+ headers: { 'StandardAPI-Version' => '6.0.0.29' }
109
113
  }
110
114
  end
111
115
  end
112
-
116
+
113
117
  end
114
118
  @suite_setup_run = true
115
119
  end
116
-
117
- end
120
+
121
+ end
@@ -0,0 +1,30 @@
1
+ require 'test_helper'
2
+
3
+ class Sunstone::Connection::ColumnDefinitionTest < ActiveSupport::TestCase
4
+
5
+ schema do
6
+ create_table "ships", limit: 100 do |t|
7
+ t.string "name", limit: 255
8
+ t.integer "guns", limit: 8
9
+ t.integer "sailor_count"
10
+ end
11
+ end
12
+
13
+ class Ship < ActiveRecord::Base
14
+ end
15
+
16
+ test "default limit on column" do
17
+ assert_nil Ship.columns_hash['sailor_count'].limit
18
+ end
19
+
20
+ test "custom limit on column" do
21
+ assert_equal 8, Ship.columns_hash['guns'].limit
22
+ end
23
+
24
+ test "custom limit on string column" do
25
+ assert_equal 255, Ship.columns_hash['name'].limit
26
+ end
27
+
28
+ end
29
+
30
+
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sunstone
3
3
  version: !ruby/object:Gem::Version
4
- version: 6.0.0.4
4
+ version: 6.1.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jon Bracy
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-07-25 00:00:00.000000000 Z
11
+ date: 2021-01-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
@@ -184,14 +184,14 @@ dependencies:
184
184
  requirements:
185
185
  - - ">="
186
186
  - !ruby/object:Gem::Version
187
- version: 6.0.0.rc1
187
+ version: 6.1.0
188
188
  type: :development
189
189
  prerelease: false
190
190
  version_requirements: !ruby/object:Gem::Requirement
191
191
  requirements:
192
192
  - - ">="
193
193
  - !ruby/object:Gem::Version
194
- version: 6.0.0.rc1
194
+ version: 6.1.0
195
195
  - !ruby/object:Gem::Dependency
196
196
  name: msgpack
197
197
  requirement: !ruby/object:Gem::Requirement
@@ -226,14 +226,28 @@ dependencies:
226
226
  requirements:
227
227
  - - ">="
228
228
  - !ruby/object:Gem::Version
229
- version: 6.0.0.rc1
229
+ version: 6.1.0
230
230
  type: :runtime
231
231
  prerelease: false
232
232
  version_requirements: !ruby/object:Gem::Requirement
233
233
  requirements:
234
234
  - - ">="
235
235
  - !ruby/object:Gem::Version
236
- version: 6.0.0.rc1
236
+ version: 6.1.0
237
+ - !ruby/object:Gem::Dependency
238
+ name: arel-extensions
239
+ requirement: !ruby/object:Gem::Requirement
240
+ requirements:
241
+ - - ">="
242
+ - !ruby/object:Gem::Version
243
+ version: 6.1.0
244
+ type: :runtime
245
+ prerelease: false
246
+ version_requirements: !ruby/object:Gem::Requirement
247
+ requirements:
248
+ - - ">="
249
+ - !ruby/object:Gem::Version
250
+ version: 6.1.0
237
251
  description: A library for interacting with REST APIs. Similar to ActiveResource
238
252
  email:
239
253
  - jonbracy@gmail.com
@@ -262,7 +276,6 @@ files:
262
276
  - ext/active_record/transactions.rb
263
277
  - ext/active_support/core_ext/object/to_query.rb
264
278
  - ext/arel/attributes/empty_relation.rb
265
- - ext/arel/attributes/relation.rb
266
279
  - ext/arel/nodes/eager_load.rb
267
280
  - ext/arel/nodes/select_statement.rb
268
281
  - ext/arel/select_manager.rb
@@ -271,6 +284,7 @@ files:
271
284
  - lib/active_record/connection_adapters/sunstone/schema_dumper.rb
272
285
  - lib/active_record/connection_adapters/sunstone/schema_statements.rb
273
286
  - lib/active_record/connection_adapters/sunstone/type/array.rb
287
+ - lib/active_record/connection_adapters/sunstone/type/binary.rb
274
288
  - lib/active_record/connection_adapters/sunstone/type/date_time.rb
275
289
  - lib/active_record/connection_adapters/sunstone/type/ewkb.rb
276
290
  - lib/active_record/connection_adapters/sunstone/type/json.rb
@@ -301,6 +315,7 @@ files:
301
315
  - test/active_record/query_test.rb
302
316
  - test/active_record/rpc_test.rb
303
317
  - test/schema_mock.rb
318
+ - test/sunstone/connection/column_definition_test.rb
304
319
  - test/sunstone/connection/configuration_test.rb
305
320
  - test/sunstone/connection/cookie_store_test.rb
306
321
  - test/sunstone/connection/request_helper_test.rb
@@ -310,7 +325,7 @@ files:
310
325
  homepage: http://sunstonerb.com
311
326
  licenses: []
312
327
  metadata: {}
313
- post_install_message:
328
+ post_install_message:
314
329
  rdoc_options: []
315
330
  require_paths:
316
331
  - lib
@@ -325,8 +340,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
325
340
  - !ruby/object:Gem::Version
326
341
  version: '0'
327
342
  requirements: []
328
- rubygems_version: 3.0.3
329
- signing_key:
343
+ rubygems_version: 3.2.3
344
+ signing_key:
330
345
  specification_version: 4
331
346
  summary: A library for interacting with REST APIs
332
347
  test_files:
@@ -346,6 +361,7 @@ test_files:
346
361
  - test/active_record/query_test.rb
347
362
  - test/active_record/rpc_test.rb
348
363
  - test/schema_mock.rb
364
+ - test/sunstone/connection/column_definition_test.rb
349
365
  - test/sunstone/connection/configuration_test.rb
350
366
  - test/sunstone/connection/cookie_store_test.rb
351
367
  - test/sunstone/connection/request_helper_test.rb
@@ -1,31 +0,0 @@
1
- module Arel
2
- module Attributes
3
- class Relation < Attribute
4
-
5
- attr_accessor :collection, :for_write
6
-
7
- def initialize(relation, name, collection = false, for_write=false)
8
- self[:relation] = relation
9
- self[:name] = name
10
- @collection = collection
11
- @for_write = for_write
12
- end
13
-
14
- def able_to_type_cast?
15
- false
16
- end
17
-
18
- def table_name
19
- nil
20
- end
21
-
22
- def eql? other
23
- self.class == other.class &&
24
- self.relation == other.relation &&
25
- self.name == other.name &&
26
- self.collection == other.collection
27
- end
28
-
29
- end
30
- end
31
- end