sunstone 6.0.0.8 → 6.1.0.rc1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +26 -7
- data/ext/active_record/associations.rb +2 -2
- data/ext/active_record/attribute_methods.rb +2 -2
- data/ext/active_record/callbacks.rb +1 -1
- data/ext/active_record/finder_methods.rb +38 -23
- data/ext/active_record/persistence.rb +2 -0
- data/ext/active_record/relation/calculations.rb +12 -4
- data/ext/active_record/statement_cache.rb +7 -2
- data/ext/active_record/transactions.rb +8 -15
- data/ext/arel/attributes/empty_relation.rb +31 -31
- data/ext/arel/nodes/select_statement.rb +1 -1
- data/lib/active_record/connection_adapters/sunstone/column.rb +2 -2
- data/lib/active_record/connection_adapters/sunstone/schema_statements.rb +3 -1
- data/lib/active_record/connection_adapters/sunstone_adapter.rb +5 -5
- data/lib/arel/visitors/sunstone.rb +4 -10
- data/lib/sunstone/connection.rb +4 -4
- data/lib/sunstone/version.rb +1 -1
- data/sunstone.gemspec +1 -1
- data/test/active_record/persistance_test.rb +14 -1
- data/test/active_record/query_test.rb +1 -1
- data/test/schema_mock.rb +5 -1
- data/test/sunstone/connection/configuration_test.rb +13 -13
- data/test/sunstone/connection/cookie_store_test.rb +2 -2
- data/test/sunstone/connection/request_helper_test.rb +12 -12
- data/test/sunstone/connection/send_request_test.rb +12 -12
- data/test/sunstone/connection_test.rb +2 -2
- metadata +10 -10
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: afae21d218aa760e3a36c2db071a80f25f825fb618f56c9bc9cb25ddb628ee23
|
4
|
+
data.tar.gz: a1b4c27957ba0330a74bab059b5b352c56d74eeafd0d9e910845badae194a0e5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2bf28e210e209846f11c287b7153669721211b86e1e27de9388b52bbdeb37abe1ea53c8370abfc11ab50132275804796912eeeb67c0c4e83cd840f54be44634b
|
7
|
+
data.tar.gz: b0eb0399c0a7ff542d06b9b3b83a1dbc699d4de11b75e24813186fd6f6c6de375713903ecc4886efb6b78395bc44f77841238d365ec389ada64bfeca95449626
|
data/.travis.yml
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
dist:
|
1
|
+
dist: bionic
|
2
2
|
language: ruby
|
3
3
|
sudo: false
|
4
4
|
|
@@ -8,23 +8,42 @@ cache:
|
|
8
8
|
- /home/travis/.rvm/gems
|
9
9
|
|
10
10
|
rvm:
|
11
|
-
- 2.
|
11
|
+
- 2.7
|
12
12
|
|
13
13
|
env:
|
14
14
|
matrix:
|
15
|
-
- RAILS_VERSION=v6.
|
16
|
-
- RAILS_VERSION=v6.
|
17
|
-
- RAILS_VERSION=v6.
|
15
|
+
- RAILS_VERSION=v6.1.0 TASK='db:mysql:rebuild mysql2:test'
|
16
|
+
- RAILS_VERSION=v6.1.0 TASK='db:mysql:rebuild mysql2:isolated_test'
|
17
|
+
- RAILS_VERSION=v6.1.0 TASK='db:postgresql:rebuild postgresql:test'
|
18
|
+
- RAILS_VERSION=v6.1.0 TASK='db:postgresql:rebuild postgresql:isolated_test'
|
19
|
+
- RAILS_VERSION=v6.1.0 TASK='sqlite3:test'
|
20
|
+
- RAILS_VERSION=v6.1.0 TASK='sqlite3:isolated_test'
|
21
|
+
- RAILS_VERSION=v6.1.0 TASK='sqlite3_mem:test'
|
18
22
|
|
19
23
|
services:
|
20
24
|
- mysql
|
21
25
|
addons:
|
22
|
-
postgresql: "
|
26
|
+
postgresql: "13"
|
27
|
+
apt:
|
28
|
+
packages:
|
29
|
+
- postgresql-13
|
30
|
+
- postgresql-client-13
|
31
|
+
|
23
32
|
|
24
33
|
before_install:
|
34
|
+
- sudo sed -i 's/port = 5433/port = 5432/' /etc/postgresql/13/main/postgresql.conf
|
35
|
+
- sudo cp /etc/postgresql/{9.3,13}/main/pg_hba.conf
|
36
|
+
- sudo pg_ctlcluster 13 main restart
|
25
37
|
- unset BUNDLE_GEMFILE
|
26
38
|
- gem update --system
|
27
39
|
- gem update bundler
|
40
|
+
- gem install bundler --version 1.17.3
|
41
|
+
- mysql -e "create user rails@localhost;"
|
42
|
+
- mysql -e "grant all privileges on activerecord_unittest.* to rails@localhost;"
|
43
|
+
- mysql -e "grant all privileges on activerecord_unittest2.* to rails@localhost;"
|
44
|
+
- mysql -e "grant all privileges on inexistent_activerecord_unittest.* to rails@localhost;"
|
45
|
+
- mysql -e "create database activerecord_unittest default character set utf8mb4;"
|
46
|
+
- mysql -e "create database activerecord_unittest2 default character set utf8mb4;"
|
28
47
|
|
29
48
|
install:
|
30
49
|
- git clone --branch $RAILS_VERSION https://github.com/rails/rails.git ~/build/rails
|
@@ -46,4 +65,4 @@ before_script:
|
|
46
65
|
|
47
66
|
script:
|
48
67
|
- bundle exec rake test
|
49
|
-
- cd ~/build/rails &&
|
68
|
+
- cd ~/build/rails/activerecord && bundle exec rake $TASK
|
@@ -35,11 +35,11 @@ module ActiveRecord
|
|
35
35
|
hm_options[:through] = middle_reflection.name
|
36
36
|
hm_options[:source] = join_model.right_reflection.name
|
37
37
|
|
38
|
-
[:before_add, :after_add, :before_remove, :after_remove, :autosave, :validate, :join_table, :class_name, :extend].each do |k|
|
38
|
+
[:before_add, :after_add, :before_remove, :after_remove, :autosave, :validate, :join_table, :class_name, :extend, :strict_loading].each do |k|
|
39
39
|
hm_options[k] = options[k] if options.key? k
|
40
40
|
end
|
41
41
|
|
42
|
-
has_many name, scope, hm_options, &extension
|
42
|
+
has_many name, scope, **hm_options, &extension
|
43
43
|
_reflections[name.to_s].parent_reflection = habtm_reflection
|
44
44
|
end
|
45
45
|
end
|
@@ -6,8 +6,8 @@ module ActiveRecord
|
|
6
6
|
# Returns a Hash of the Arel::Attributes and attribute values that have been
|
7
7
|
# typecasted for use in an Arel insert/update method.
|
8
8
|
def attributes_with_values(attribute_names)
|
9
|
-
attrs = attribute_names.
|
10
|
-
|
9
|
+
attrs = attribute_names.index_with do |name|
|
10
|
+
_read_attribute(name)
|
11
11
|
end
|
12
12
|
|
13
13
|
if self.class.connection.is_a?(ActiveRecord::ConnectionAdapters::SunstoneAPIAdapter)
|
@@ -2,7 +2,7 @@ module ActiveRecord
|
|
2
2
|
module Callbacks
|
3
3
|
private
|
4
4
|
|
5
|
-
def create_or_update(
|
5
|
+
def create_or_update(**) #:nodoc:
|
6
6
|
if self.class.connection.is_a?(ActiveRecord::ConnectionAdapters::SunstoneAPIAdapter)
|
7
7
|
@_already_called ||= {}
|
8
8
|
self.class.reflect_on_all_associations.each do |r|
|
@@ -1,12 +1,12 @@
|
|
1
1
|
module ActiveRecord
|
2
2
|
class PredicateBuilder # :nodoc:
|
3
3
|
|
4
|
-
def expand_from_hash(attributes)
|
4
|
+
def expand_from_hash(attributes, &block)
|
5
5
|
return ["1=0"] if attributes.empty?
|
6
6
|
|
7
7
|
attributes.flat_map do |key, value|
|
8
8
|
if value.is_a?(Hash) && !table.has_column?(key)
|
9
|
-
ka =
|
9
|
+
ka = table.associated_table(key, &block).predicate_builder.expand_from_hash(value.stringify_keys)
|
10
10
|
if self.send(:table).instance_variable_get(:@klass).connection.is_a?(ActiveRecord::ConnectionAdapters::SunstoneAPIAdapter)
|
11
11
|
ka.each { |k|
|
12
12
|
if k.left.is_a?(Arel::Attributes::Attribute) || k.left.is_a?(Arel::Attributes::Relation)
|
@@ -28,13 +28,18 @@ module ActiveRecord
|
|
28
28
|
value = [value] unless value.is_a?(Array)
|
29
29
|
klass = PolymorphicArrayValue
|
30
30
|
end
|
31
|
+
elsif associated_table.through_association?
|
32
|
+
next associated_table.predicate_builder.expand_from_hash(
|
33
|
+
associated_table.primary_key => value
|
34
|
+
)
|
31
35
|
end
|
32
36
|
|
33
37
|
klass ||= AssociationQueryValue
|
34
|
-
queries = klass.new(associated_table, value).queries.map do |query|
|
35
|
-
expand_from_hash(query)
|
38
|
+
queries = klass.new(associated_table, value).queries.map! do |query|
|
39
|
+
expand_from_hash(query)
|
36
40
|
end
|
37
|
-
|
41
|
+
|
42
|
+
grouping_queries(queries)
|
38
43
|
elsif table.aggregated_with?(key)
|
39
44
|
mapping = table.reflect_on_aggregation(key).mapping
|
40
45
|
values = value.nil? ? [nil] : Array.wrap(value)
|
@@ -43,17 +48,18 @@ module ActiveRecord
|
|
43
48
|
values = values.map do |object|
|
44
49
|
object.respond_to?(aggr_attr) ? object.public_send(aggr_attr) : object
|
45
50
|
end
|
46
|
-
|
51
|
+
self[column_name, values]
|
47
52
|
else
|
48
53
|
queries = values.map do |object|
|
49
54
|
mapping.map do |field_attr, aggregate_attr|
|
50
|
-
|
51
|
-
end
|
55
|
+
self[field_attr, object.try!(aggregate_attr)]
|
56
|
+
end
|
52
57
|
end
|
53
|
-
|
58
|
+
|
59
|
+
grouping_queries(queries)
|
54
60
|
end
|
55
61
|
else
|
56
|
-
|
62
|
+
self[key, value]
|
57
63
|
end
|
58
64
|
end
|
59
65
|
end
|
@@ -77,7 +83,7 @@ module ActiveRecord
|
|
77
83
|
relation
|
78
84
|
end
|
79
85
|
|
80
|
-
def instantiate(result_set, &block)
|
86
|
+
def instantiate(result_set, strict_loading_value, &block)
|
81
87
|
seen = Hash.new { |i, object_id|
|
82
88
|
i[object_id] = Hash.new { |j, child_class|
|
83
89
|
j[child_class] = {}
|
@@ -98,14 +104,14 @@ module ActiveRecord
|
|
98
104
|
result_set.each { |row_hash|
|
99
105
|
parent_key = @klass.primary_key ? row_hash[@klass.primary_key] : row_hash
|
100
106
|
parent = parents[parent_key] ||= @klass.instantiate(row_hash.select{|k,v| @klass.column_names.include?(k.to_s) }, &block)
|
101
|
-
construct(parent, row_hash.select{|k,v| !@klass.column_names.include?(k.to_s) }, seen, model_cache)
|
107
|
+
construct(parent, row_hash.select{|k,v| !@klass.column_names.include?(k.to_s) }, seen, model_cache, strict_loading_value)
|
102
108
|
}
|
103
109
|
end
|
104
110
|
|
105
111
|
parents.values
|
106
112
|
end
|
107
113
|
|
108
|
-
def construct(parent, relations, seen, model_cache)
|
114
|
+
def construct(parent, relations, seen, model_cache, strict_loading_value)
|
109
115
|
relations.each do |key, attributes|
|
110
116
|
reflection = parent.class.reflect_on_association(key)
|
111
117
|
next unless reflection
|
@@ -116,22 +122,22 @@ module ActiveRecord
|
|
116
122
|
else
|
117
123
|
if parent.association_cached?(reflection.name)
|
118
124
|
model = parent.association(reflection.name).target
|
119
|
-
construct(model, attributes.select{|k,v| !model.class.column_names.include?(k.to_s) }, seen, model_cache)
|
125
|
+
construct(model, attributes.select{|k,v| !model.class.column_names.include?(k.to_s) }, seen, model_cache, strict_loading_value)
|
120
126
|
end
|
121
127
|
end
|
122
128
|
|
123
129
|
if !reflection.collection?
|
124
|
-
construct_association(parent, reflection, attributes, seen, model_cache)
|
130
|
+
construct_association(parent, reflection, attributes, seen, model_cache, strict_loading_value)
|
125
131
|
else
|
126
132
|
attributes.each do |row|
|
127
|
-
construct_association(parent, reflection, row, seen, model_cache)
|
133
|
+
construct_association(parent, reflection, row, seen, model_cache, strict_loading_value)
|
128
134
|
end
|
129
135
|
end
|
130
136
|
|
131
137
|
end
|
132
138
|
end
|
133
139
|
|
134
|
-
def construct_association(parent, reflection, attributes, seen, model_cache)
|
140
|
+
def construct_association(parent, reflection, attributes, seen, model_cache, strict_loading_value)
|
135
141
|
return if attributes.nil?
|
136
142
|
|
137
143
|
klass = if reflection.polymorphic?
|
@@ -143,7 +149,7 @@ module ActiveRecord
|
|
143
149
|
model = seen[parent.object_id][klass][id]
|
144
150
|
|
145
151
|
if model
|
146
|
-
construct(model, attributes.select{|k,v| !klass.column_names.include?(k.to_s) }, seen, model_cache)
|
152
|
+
construct(model, attributes.select{|k,v| !klass.column_names.include?(k.to_s) }, seen, model_cache, strict_loading_value)
|
147
153
|
|
148
154
|
other = parent.association(reflection.name)
|
149
155
|
|
@@ -155,14 +161,14 @@ module ActiveRecord
|
|
155
161
|
|
156
162
|
other.set_inverse_instance(model)
|
157
163
|
else
|
158
|
-
model = construct_model(parent, reflection, id, attributes.select{|k,v| klass.column_names.include?(k.to_s) }, seen, model_cache)
|
164
|
+
model = construct_model(parent, reflection, id, attributes.select{|k,v| klass.column_names.include?(k.to_s) }, seen, model_cache, strict_loading_value)
|
159
165
|
seen[parent.object_id][model.class.base_class][id] = model
|
160
|
-
construct(model, attributes.select{|k,v| !klass.column_names.include?(k.to_s) }, seen, model_cache)
|
166
|
+
construct(model, attributes.select{|k,v| !klass.column_names.include?(k.to_s) }, seen, model_cache, strict_loading_value)
|
161
167
|
end
|
162
168
|
end
|
163
169
|
|
164
170
|
|
165
|
-
def construct_model(record, reflection, id, attributes, seen, model_cache)
|
171
|
+
def construct_model(record, reflection, id, attributes, seen, model_cache, strict_loading_value)
|
166
172
|
klass = if reflection.polymorphic?
|
167
173
|
record.send(reflection.foreign_type).constantize
|
168
174
|
else
|
@@ -191,12 +197,21 @@ module ActiveRecord
|
|
191
197
|
relation.arel.eager_load = Arel::Nodes::EagerLoad.new(eager_load_values)
|
192
198
|
else
|
193
199
|
join_dependency = construct_join_dependency(
|
194
|
-
eager_load_values
|
200
|
+
eager_load_values | includes_values, Arel::Nodes::OuterJoin
|
195
201
|
)
|
196
202
|
relation = except(:includes, :eager_load, :preload).joins!(join_dependency)
|
197
203
|
end
|
198
204
|
|
199
|
-
if eager_loading && !
|
205
|
+
if eager_loading && !(
|
206
|
+
using_limitable_reflections?(join_dependency.reflections) &&
|
207
|
+
using_limitable_reflections?(
|
208
|
+
construct_join_dependency(
|
209
|
+
select_association_list(joins_values).concat(
|
210
|
+
select_association_list(left_outer_joins_values)
|
211
|
+
), nil
|
212
|
+
).reflections
|
213
|
+
)
|
214
|
+
)
|
200
215
|
if has_limit_or_offset?
|
201
216
|
limited_ids = limited_ids_for(relation)
|
202
217
|
limited_ids.empty? ? relation.none! : relation.where!(primary_key => limited_ids)
|
@@ -2,7 +2,7 @@ module ActiveRecord
|
|
2
2
|
module Calculations
|
3
3
|
|
4
4
|
def pluck(*column_names)
|
5
|
-
if loaded? && (column_names
|
5
|
+
if loaded? && all_attributes?(column_names)
|
6
6
|
return records.pluck(*column_names)
|
7
7
|
end
|
8
8
|
|
@@ -14,10 +14,18 @@ module ActiveRecord
|
|
14
14
|
return records.pluck(*column_names.map{|n| n.sub(/^#{klass.table_name}\./, "")})
|
15
15
|
else
|
16
16
|
klass.disallow_raw_sql!(column_names)
|
17
|
+
columns = arel_columns(column_names)
|
17
18
|
relation = spawn
|
18
|
-
relation.select_values =
|
19
|
-
|
20
|
-
result
|
19
|
+
relation.select_values = columns
|
20
|
+
|
21
|
+
result = skip_query_cache_if_necessary do
|
22
|
+
if where_clause.contradiction?
|
23
|
+
ActiveRecord::Result.new([], [])
|
24
|
+
else
|
25
|
+
klass.connection.select_all(relation.arel, nil)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
type_cast_pluck_values(result, columns)
|
21
29
|
end
|
22
30
|
end
|
23
31
|
|
@@ -18,8 +18,13 @@ module ActiveRecord
|
|
18
18
|
@values
|
19
19
|
else
|
20
20
|
val = @values.dup
|
21
|
-
|
22
|
-
|
21
|
+
@indexes.each do |i|
|
22
|
+
value = binds.shift
|
23
|
+
if ActiveModel::Attribute === value
|
24
|
+
value = value.value_for_database
|
25
|
+
end
|
26
|
+
val[i] = connection.quote(value)
|
27
|
+
end
|
23
28
|
val.join
|
24
29
|
end
|
25
30
|
end
|
@@ -20,7 +20,7 @@ module ActiveRecord
|
|
20
20
|
# end
|
21
21
|
# end
|
22
22
|
#
|
23
|
-
def save!(
|
23
|
+
def save!(**) #:nodoc:
|
24
24
|
if instance_variable_defined?(:@no_save_transaction) && @no_save_transaction
|
25
25
|
super
|
26
26
|
else
|
@@ -35,29 +35,22 @@ module ActiveRecord
|
|
35
35
|
|
36
36
|
def with_transaction_returning_status
|
37
37
|
status = nil
|
38
|
+
connection = self.class.connection
|
38
39
|
|
39
|
-
if
|
40
|
+
if connection.is_a?(ActiveRecord::ConnectionAdapters::SunstoneAPIAdapter) && instance_variable_defined?(:@updating) && @updating
|
40
41
|
status = yield
|
41
|
-
status
|
42
42
|
else
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
else
|
47
|
-
sync_with_transaction_state if @transaction_state&.finalized?
|
48
|
-
@transaction_state = self.class.connection.transaction_state
|
49
|
-
end
|
43
|
+
ensure_finalize = !connection.transaction_open?
|
44
|
+
connection.transaction do
|
45
|
+
add_to_transaction(ensure_finalize || has_transactional_callbacks?)
|
50
46
|
remember_transaction_record_state
|
51
47
|
|
52
48
|
status = yield
|
53
49
|
raise ActiveRecord::Rollback unless status
|
54
50
|
end
|
55
|
-
status
|
56
|
-
end
|
57
|
-
ensure
|
58
|
-
if @transaction_state && @transaction_state.committed?
|
59
|
-
clear_transaction_record_state
|
60
51
|
end
|
52
|
+
|
53
|
+
status
|
61
54
|
end
|
62
55
|
|
63
56
|
|
@@ -1,31 +1,31 @@
|
|
1
|
-
module Arel
|
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
|
-
end
|
1
|
+
# module Arel
|
2
|
+
# module Attributes
|
3
|
+
# class EmptyRelation < 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
|
@@ -2,8 +2,7 @@ module ActiveRecord
|
|
2
2
|
module ConnectionAdapters
|
3
3
|
# Sunstone-specific extensions to column definitions in a table.
|
4
4
|
class SunstoneColumn < Column #:nodoc:
|
5
|
-
|
6
|
-
alias :array? :array
|
5
|
+
attr_reader :array
|
7
6
|
|
8
7
|
def initialize(name, sql_type_metadata, options={})
|
9
8
|
@name = name.freeze
|
@@ -14,6 +13,7 @@ module ActiveRecord
|
|
14
13
|
@collation = nil
|
15
14
|
@table_name = nil
|
16
15
|
@primary_key = (options['primary_key'] == true)
|
16
|
+
@array = options['array']
|
17
17
|
end
|
18
18
|
|
19
19
|
def primary_key?
|
@@ -50,7 +50,9 @@ module ActiveRecord
|
|
50
50
|
# - format_type includes the column size constraint, e.g. varchar(50)
|
51
51
|
# - ::regclass is a function that gives the id for a table name
|
52
52
|
def column_definitions(table_name) # :nodoc:
|
53
|
-
|
53
|
+
# First check for attributes and then for the deprecated columns field
|
54
|
+
# TODO: Remove after 0.3
|
55
|
+
definition(table_name)['attributes'] || definition(table_name)['columns']
|
54
56
|
end
|
55
57
|
|
56
58
|
# Returns the limit definition of the table (the maximum limit that can
|
@@ -17,7 +17,7 @@ require 'active_record/connection_adapters/sunstone/type/json'
|
|
17
17
|
module ActiveRecord
|
18
18
|
module ConnectionHandling # :nodoc:
|
19
19
|
|
20
|
-
VALID_SUNSTONE_CONN_PARAMS = [:
|
20
|
+
VALID_SUNSTONE_CONN_PARAMS = [:endpoint, :host, :port, :api_key, :use_ssl, :user_agent, :ca_cert]
|
21
21
|
|
22
22
|
# Establishes a connection to the database that's used by all Active Record
|
23
23
|
# objects
|
@@ -25,8 +25,8 @@ module ActiveRecord
|
|
25
25
|
conn_params = config.symbolize_keys
|
26
26
|
conn_params.delete_if { |_, v| v.nil? }
|
27
27
|
|
28
|
-
if conn_params[:
|
29
|
-
uri = URI.parse(conn_params.delete(:
|
28
|
+
if conn_params[:endpoint]
|
29
|
+
uri = URI.parse(conn_params.delete(:endpoint))
|
30
30
|
conn_params[:api_key] ||= (uri.user ? CGI.unescape(uri.user) : nil)
|
31
31
|
conn_params[:host] ||= uri.host
|
32
32
|
conn_params[:port] ||= uri.port
|
@@ -212,8 +212,8 @@ module ActiveRecord
|
|
212
212
|
end
|
213
213
|
end
|
214
214
|
|
215
|
-
def create_table_definition(name,
|
216
|
-
SunstoneAPI::TableDefinition.new
|
215
|
+
def create_table_definition(name, **options)
|
216
|
+
SunstoneAPI::TableDefinition.new(self, name, **options)
|
217
217
|
end
|
218
218
|
|
219
219
|
ActiveRecord::Type.add_modifier({ array: true }, Sunstone::Type::Array, adapter: :sunstone)
|
@@ -1,10 +1,4 @@
|
|
1
1
|
require 'arel/visitors/visitor'
|
2
|
-
class Arel::Visitors::Dot
|
3
|
-
def visit_Arel_Nodes_Casted o
|
4
|
-
# collector << quoted(o.val, o.attribute).to_s
|
5
|
-
visit_String o.val
|
6
|
-
end
|
7
|
-
end
|
8
2
|
|
9
3
|
module Arel
|
10
4
|
module Visitors
|
@@ -233,7 +227,7 @@ module Arel
|
|
233
227
|
#
|
234
228
|
def visit_Arel_Nodes_Casted o, collector
|
235
229
|
# collector << quoted(o.val, o.attribute).to_s
|
236
|
-
o.
|
230
|
+
o.value
|
237
231
|
end
|
238
232
|
|
239
233
|
def visit_Arel_Nodes_Quoted o, collector
|
@@ -953,9 +947,9 @@ module Arel
|
|
953
947
|
end
|
954
948
|
end
|
955
949
|
|
956
|
-
def visit_Arel_Attributes_EmptyRelation o, collector, top=true
|
957
|
-
|
958
|
-
end
|
950
|
+
# def visit_Arel_Attributes_EmptyRelation o, collector, top=true
|
951
|
+
# o.for_write ? "#{o.name}_attributes" : o.name
|
952
|
+
# end
|
959
953
|
|
960
954
|
def visit_Arel_Attributes_Attribute o, collector
|
961
955
|
join_name = o.relation.table_alias || o.relation.name
|
data/lib/sunstone/connection.rb
CHANGED
@@ -10,7 +10,7 @@ module Sunstone
|
|
10
10
|
#
|
11
11
|
# Options:
|
12
12
|
#
|
13
|
-
# * <tt>:
|
13
|
+
# * <tt>:endpoint</tt> - An optional endpoint used to set the protocol, host, port,
|
14
14
|
# and api_key
|
15
15
|
# * <tt>:host</tt> - The default is to connect to 127.0.0.1.
|
16
16
|
# * <tt>:port</tt> - Defaults to 80.
|
@@ -19,8 +19,8 @@ module Sunstone
|
|
19
19
|
# * <tt>:user_agent</tt> - An optional string. Will be joined with other
|
20
20
|
# User-Agent info.
|
21
21
|
def initialize(config)
|
22
|
-
if config[:
|
23
|
-
uri = URI.parse(config.delete(:
|
22
|
+
if config[:endpoint]
|
23
|
+
uri = URI.parse(config.delete(:endpoint))
|
24
24
|
config[:api_key] ||= (uri.user ? CGI.unescape(uri.user) : nil)
|
25
25
|
config[:host] ||= uri.host
|
26
26
|
config[:port] ||= uri.port
|
@@ -348,7 +348,7 @@ module Sunstone
|
|
348
348
|
headers = Thread.current[:sunstone_headers]&.clone || {}
|
349
349
|
headers['Accept'] = 'application/json'
|
350
350
|
headers['User-Agent'] = user_agent
|
351
|
-
headers['Api-Version'] = '0.
|
351
|
+
headers['Api-Version'] = '0.2.0'
|
352
352
|
headers['Connection'] = 'keep-alive'
|
353
353
|
|
354
354
|
request_api_key = Thread.current[:sunstone_api_key] || api_key
|
data/lib/sunstone/version.rb
CHANGED
data/sunstone.gemspec
CHANGED
@@ -35,6 +35,6 @@ Gem::Specification.new do |s|
|
|
35
35
|
# Runtime
|
36
36
|
s.add_runtime_dependency 'msgpack'
|
37
37
|
s.add_runtime_dependency 'cookie_store'
|
38
|
-
s.add_runtime_dependency 'activerecord', '>= 6.
|
38
|
+
s.add_runtime_dependency 'activerecord', '>= 6.1.0'
|
39
39
|
s.add_runtime_dependency 'arel-extensions', '>= 6.0.0.5'
|
40
40
|
end
|
@@ -14,6 +14,7 @@ class ActiveRecord::PersistanceTest < ActiveSupport::TestCase
|
|
14
14
|
|
15
15
|
create_table "sailors" do |t|
|
16
16
|
t.string "name", limit: 255
|
17
|
+
t.text "assignment"
|
17
18
|
end
|
18
19
|
|
19
20
|
create_table "sailors_ships", id: false do |t|
|
@@ -74,7 +75,7 @@ class ActiveRecord::PersistanceTest < ActiveSupport::TestCase
|
|
74
75
|
assert_requested req_stub
|
75
76
|
end
|
76
77
|
|
77
|
-
test '#save w/o changes' do
|
78
|
+
test '#save w/o changes does not trigger a request' do
|
78
79
|
webmock(:get, '/fleets', where: {id: 1}, limit: 1).to_return(
|
79
80
|
body: [{id: 1, name: 'Armada Duo'}].to_json
|
80
81
|
)
|
@@ -85,6 +86,18 @@ class ActiveRecord::PersistanceTest < ActiveSupport::TestCase
|
|
85
86
|
assert fleet.save
|
86
87
|
assert_equal 1, fleet.id
|
87
88
|
assert_equal 'Armada Duo', fleet.name
|
89
|
+
|
90
|
+
|
91
|
+
webmock(:get, '/sailors', where: {id: 1}, limit: 1).to_return(
|
92
|
+
body: [{id: 1, name: 'Nandor', assignment: 'stay alert'}].to_json
|
93
|
+
)
|
94
|
+
|
95
|
+
fleet = Sailor.find(1)
|
96
|
+
fleet.save
|
97
|
+
|
98
|
+
assert fleet.save
|
99
|
+
assert_equal 1, fleet.id
|
100
|
+
assert_equal 'stay alert', fleet.assignment
|
88
101
|
end
|
89
102
|
|
90
103
|
test '#save attempts another request while in transaction' do
|
@@ -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.
|
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
|
data/test/schema_mock.rb
CHANGED
@@ -34,6 +34,10 @@ class ActiveSupport::TestCase
|
|
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)
|
@@ -82,7 +86,7 @@ class ActiveSupport::TestCase
|
|
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
|
-
ActiveRecord::Base.establish_connection(adapter: 'sunstone',
|
89
|
+
ActiveRecord::Base.establish_connection(adapter: 'sunstone', endpoint: 'http://example.com')
|
86
90
|
|
87
91
|
req_stub = stub_request(:get, /^http:\/\/example.com/).with do |req|
|
88
92
|
case req.uri.path
|
@@ -2,40 +2,40 @@ require 'test_helper'
|
|
2
2
|
|
3
3
|
class Sunstone::Connection::ConfigurationTest < ActiveSupport::TestCase
|
4
4
|
|
5
|
-
test "setting the
|
6
|
-
connection = Sunstone::Connection.new(
|
5
|
+
test "setting the endpoint sets the api_key" do
|
6
|
+
connection = Sunstone::Connection.new(endpoint: 'http://my_api_key@localhost')
|
7
7
|
assert_equal('my_api_key', connection.api_key)
|
8
8
|
end
|
9
9
|
|
10
|
-
test "setting the
|
11
|
-
connection = Sunstone::Connection.new(
|
10
|
+
test "setting the endpoint sets the host" do
|
11
|
+
connection = Sunstone::Connection.new(endpoint: 'https://example.com')
|
12
12
|
assert_equal('example.com', connection.host)
|
13
13
|
end
|
14
14
|
|
15
|
-
test "setting the
|
16
|
-
connection = Sunstone::Connection.new(
|
15
|
+
test "setting the endpoint sets the port" do
|
16
|
+
connection = Sunstone::Connection.new(endpoint: 'http://localhost')
|
17
17
|
assert_equal(80, connection.port)
|
18
18
|
|
19
|
-
connection = Sunstone::Connection.new(
|
19
|
+
connection = Sunstone::Connection.new(endpoint: 'https://localhost')
|
20
20
|
assert_equal(443, connection.port)
|
21
21
|
|
22
|
-
connection = Sunstone::Connection.new(
|
22
|
+
connection = Sunstone::Connection.new(endpoint: 'https://localhost:4321')
|
23
23
|
assert_equal(4321, connection.port)
|
24
24
|
end
|
25
25
|
|
26
|
-
test "setting the
|
27
|
-
connection = Sunstone::Connection.new(
|
26
|
+
test "setting the endpoint sets the use_ssl option" do
|
27
|
+
connection = Sunstone::Connection.new(endpoint: 'http://localhost')
|
28
28
|
assert_equal(false, connection.use_ssl)
|
29
29
|
|
30
|
-
connection = Sunstone::Connection.new(
|
30
|
+
connection = Sunstone::Connection.new(endpoint: 'https://localhost')
|
31
31
|
assert_equal(true, connection.use_ssl)
|
32
32
|
end
|
33
33
|
|
34
34
|
test "setting the user_agent appends it to the User-Agent" do
|
35
|
-
connection = Sunstone::Connection.new(
|
35
|
+
connection = Sunstone::Connection.new(endpoint: 'http://localhost')
|
36
36
|
assert_equal("Sunstone/#{Sunstone::VERSION} Ruby/#{RUBY_VERSION}-p#{RUBY_PATCHLEVEL} #{RUBY_PLATFORM}", connection.user_agent)
|
37
37
|
|
38
|
-
connection = Sunstone::Connection.new(
|
38
|
+
connection = Sunstone::Connection.new(endpoint: 'http://localhost', user_agent: "MyGem/3.14")
|
39
39
|
assert_equal("MyGem/3.14 Sunstone/#{Sunstone::VERSION} Ruby/#{RUBY_VERSION}-p#{RUBY_PATCHLEVEL} #{RUBY_PLATFORM}", connection.user_agent)
|
40
40
|
end
|
41
41
|
|
@@ -4,7 +4,7 @@ class Sunstone::Connection::CookieStoreTest < ActiveSupport::TestCase
|
|
4
4
|
|
5
5
|
test '#send_request(#<Net::HTTPRequest) adds cookies to the cookie store if present' do
|
6
6
|
store = CookieStore::HashStore.new
|
7
|
-
connection = Sunstone::Connection.new(
|
7
|
+
connection = Sunstone::Connection.new(endpoint: "http://testhost.com")
|
8
8
|
stub_request(:get, "http://testhost.com/test").to_return(:body => 'get', :headers => {'Set-Cookie' => 'foo=bar; Max-Age=3600'})
|
9
9
|
|
10
10
|
Sunstone::Connection.with_cookie_store(store) { connection.get('/test') }
|
@@ -17,7 +17,7 @@ class Sunstone::Connection::CookieStoreTest < ActiveSupport::TestCase
|
|
17
17
|
|
18
18
|
test '#send_request(#<Net::HTTPRequest) sends cookie header if cookie store is present' do
|
19
19
|
store = CookieStore::HashStore.new
|
20
|
-
connection = Sunstone::Connection.new(
|
20
|
+
connection = Sunstone::Connection.new(endpoint: "http://testhost.com")
|
21
21
|
stub_request(:get, "http://testhost.com/test").to_return(
|
22
22
|
headers: {
|
23
23
|
'Set-Cookie' => 'foo=bar; Path="/" Max-Age=3600'
|
@@ -5,28 +5,28 @@ class Sunstone::Connection::RequestHelpersTest < ActiveSupport::TestCase
|
|
5
5
|
# Sunstone.get ==============================================================
|
6
6
|
|
7
7
|
test '#get(path)' do
|
8
|
-
connection = Sunstone::Connection.new(
|
8
|
+
connection = Sunstone::Connection.new(endpoint: "http://testhost.com")
|
9
9
|
stub_request(:get, "http://testhost.com/test").to_return(:body => "get")
|
10
10
|
|
11
11
|
assert_equal('get', connection.get('/test').body)
|
12
12
|
end
|
13
13
|
|
14
14
|
test '#get(path, params) with params as string' do
|
15
|
-
connection = Sunstone::Connection.new(
|
15
|
+
connection = Sunstone::Connection.new(endpoint: "http://testhost.com")
|
16
16
|
stub_request(:get, "http://testhost.com/test").with(:query => {'key' => 'value'}).to_return(:body => "get")
|
17
17
|
|
18
18
|
assert_equal 'get', connection.get('/test', 'key=value').body
|
19
19
|
end
|
20
20
|
|
21
21
|
test '#get(path, params) with params as hash' do
|
22
|
-
connection = Sunstone::Connection.new(
|
22
|
+
connection = Sunstone::Connection.new(endpoint: "http://testhost.com")
|
23
23
|
stub_request(:get, "http://testhost.com/test").with(:query => {'key' => 'value'}).to_return(:body => "get")
|
24
24
|
|
25
25
|
assert_equal 'get', connection.get('/test', {:key => 'value'}).body
|
26
26
|
end
|
27
27
|
|
28
28
|
test '#get(path, &block)' do
|
29
|
-
connection = Sunstone::Connection.new(
|
29
|
+
connection = Sunstone::Connection.new(endpoint: "http://testhost.com")
|
30
30
|
stub_request(:get, "http://testhost.com/test").to_return(:body => 'get')
|
31
31
|
|
32
32
|
connection.get('/test') do |response|
|
@@ -37,21 +37,21 @@ class Sunstone::Connection::RequestHelpersTest < ActiveSupport::TestCase
|
|
37
37
|
# Sunstone.post =============================================================
|
38
38
|
|
39
39
|
test '#post(path)' do
|
40
|
-
connection = Sunstone::Connection.new(
|
40
|
+
connection = Sunstone::Connection.new(endpoint: "http://testhost.com")
|
41
41
|
stub_request(:post, "http://testhost.com/test").to_return(:body => "post")
|
42
42
|
|
43
43
|
assert_equal('post', connection.post('/test').body)
|
44
44
|
end
|
45
45
|
|
46
46
|
test '#post(path, body)' do
|
47
|
-
connection = Sunstone::Connection.new(
|
47
|
+
connection = Sunstone::Connection.new(endpoint: "http://testhost.com")
|
48
48
|
stub_request(:post, "http://testhost.com/test").with(:body => 'body').to_return(:body => "post")
|
49
49
|
|
50
50
|
assert_equal('post', connection.post('/test', 'body').body)
|
51
51
|
end
|
52
52
|
|
53
53
|
test '#post(path, &block)' do
|
54
|
-
connection = Sunstone::Connection.new(
|
54
|
+
connection = Sunstone::Connection.new(endpoint: "http://testhost.com")
|
55
55
|
stub_request(:post, "http://testhost.com/test").to_return(:body => 'post')
|
56
56
|
|
57
57
|
connection.post('/test') do |response|
|
@@ -62,21 +62,21 @@ class Sunstone::Connection::RequestHelpersTest < ActiveSupport::TestCase
|
|
62
62
|
# Sunstone.put ==============================================================
|
63
63
|
|
64
64
|
test '#put(path)' do
|
65
|
-
connection = Sunstone::Connection.new(
|
65
|
+
connection = Sunstone::Connection.new(endpoint: "http://testhost.com")
|
66
66
|
stub_request(:put, "http://testhost.com/test").to_return(:body => "put")
|
67
67
|
|
68
68
|
assert_equal('put', connection.put('/test').body)
|
69
69
|
end
|
70
70
|
|
71
71
|
test '#put(path, body)' do
|
72
|
-
connection = Sunstone::Connection.new(
|
72
|
+
connection = Sunstone::Connection.new(endpoint: "http://testhost.com")
|
73
73
|
stub_request(:put, "http://testhost.com/test").with(:body => 'body').to_return(:body => "put")
|
74
74
|
|
75
75
|
assert_equal('put', connection.put('/test', 'body').body)
|
76
76
|
end
|
77
77
|
|
78
78
|
test '#put(path, &block)' do
|
79
|
-
connection = Sunstone::Connection.new(
|
79
|
+
connection = Sunstone::Connection.new(endpoint: "http://testhost.com")
|
80
80
|
stub_request(:put, "http://testhost.com/test").to_return(:body => 'put')
|
81
81
|
|
82
82
|
connection.put('/test') do |response|
|
@@ -87,14 +87,14 @@ class Sunstone::Connection::RequestHelpersTest < ActiveSupport::TestCase
|
|
87
87
|
# Sunstone.delete ===========================================================
|
88
88
|
|
89
89
|
test '#delete' do
|
90
|
-
connection = Sunstone::Connection.new(
|
90
|
+
connection = Sunstone::Connection.new(endpoint: "http://testhost.com")
|
91
91
|
stub_request(:delete, "http://testhost.com/test").to_return(:body => "delete")
|
92
92
|
|
93
93
|
assert_equal('delete', connection.delete('/test').body)
|
94
94
|
end
|
95
95
|
|
96
96
|
test '#delete(path, &block)' do
|
97
|
-
connection = Sunstone::Connection.new(
|
97
|
+
connection = Sunstone::Connection.new(endpoint: "http://testhost.com")
|
98
98
|
stub_request(:delete, "http://testhost.com/test").to_return(:body => 'delete')
|
99
99
|
|
100
100
|
connection.delete('/test') do |response|
|
@@ -3,7 +3,7 @@ require 'test_helper'
|
|
3
3
|
class Sunstone::Connection::SendRequestTest < ActiveSupport::TestCase
|
4
4
|
|
5
5
|
test '#send_request(#<Net::HTTPRequest>) includes the api-key header when present' do
|
6
|
-
connection = Sunstone::Connection.new(
|
6
|
+
connection = Sunstone::Connection.new(endpoint: "http://my_api_key@example.com")
|
7
7
|
|
8
8
|
test_stub = stub_request(:get, "http://example.com/verify").with { |req|
|
9
9
|
req.headers['Api-Key'] == 'my_api_key'
|
@@ -13,7 +13,7 @@ class Sunstone::Connection::SendRequestTest < ActiveSupport::TestCase
|
|
13
13
|
end
|
14
14
|
|
15
15
|
test '#send_request(#<Net::HTTPRequest>) includes the user_agent' do
|
16
|
-
connection = Sunstone::Connection.new(
|
16
|
+
connection = Sunstone::Connection.new(endpoint: "http://example.com")
|
17
17
|
|
18
18
|
test_stub = stub_request(:get, "http://example.com/verify").with { |req|
|
19
19
|
req.headers['User-Agent'] =~ /Sunstone\/\S+ Ruby\/\S+ \S+/
|
@@ -22,7 +22,7 @@ class Sunstone::Connection::SendRequestTest < ActiveSupport::TestCase
|
|
22
22
|
assert_requested(test_stub)
|
23
23
|
|
24
24
|
# Custom Agent
|
25
|
-
connection = Sunstone::Connection.new(
|
25
|
+
connection = Sunstone::Connection.new(endpoint: "http://example.com", user_agent: "MyClient/2")
|
26
26
|
|
27
27
|
test_stub = stub_request(:get, "http://example.com/verify").with { |req|
|
28
28
|
req.headers['User-Agent'] =~ /MyClient\/2 Sunstone\/\S+ Ruby\/\S+ \S+/
|
@@ -34,7 +34,7 @@ class Sunstone::Connection::SendRequestTest < ActiveSupport::TestCase
|
|
34
34
|
test '#send_request(#<Net::HTTPRequest>)' do
|
35
35
|
stub_request(:get, "http://testhost.com/test").to_return(body: 'get')
|
36
36
|
|
37
|
-
connection = Sunstone::Connection.new(
|
37
|
+
connection = Sunstone::Connection.new(endpoint: "http://testhost.com")
|
38
38
|
assert_equal('get', connection.send_request(Net::HTTP::Get.new('/test')).body)
|
39
39
|
end
|
40
40
|
|
@@ -45,7 +45,7 @@ class Sunstone::Connection::SendRequestTest < ActiveSupport::TestCase
|
|
45
45
|
body: "post"
|
46
46
|
)
|
47
47
|
|
48
|
-
connection = Sunstone::Connection.new(
|
48
|
+
connection = Sunstone::Connection.new(endpoint: "http://testhost.com")
|
49
49
|
assert_equal('post', connection.send_request(Net::HTTP::Post.new('/test'), '{"key":"value"}').body)
|
50
50
|
end
|
51
51
|
|
@@ -58,14 +58,14 @@ class Sunstone::Connection::SendRequestTest < ActiveSupport::TestCase
|
|
58
58
|
wr.write('{"key":"value"}')
|
59
59
|
wr.close
|
60
60
|
|
61
|
-
connection = Sunstone::Connection.new(
|
61
|
+
connection = Sunstone::Connection.new(endpoint: "http://testhost.com")
|
62
62
|
assert_equal('post', connection.send_request(Net::HTTP::Post.new('/test'), rd).body)
|
63
63
|
end
|
64
64
|
|
65
65
|
test '#send_request(#<Net::HTTPRequest>, body) with Ruby Object body' do
|
66
66
|
stub_request(:post, "http://testhost.com/test").with(body: '{"key":"value"}').to_return(body: "post")
|
67
67
|
|
68
|
-
connection = Sunstone::Connection.new(
|
68
|
+
connection = Sunstone::Connection.new(endpoint: "http://testhost.com")
|
69
69
|
assert_equal('post', connection.send_request(Net::HTTP::Post.new('/test'), {:key => 'value'}).body)
|
70
70
|
end
|
71
71
|
|
@@ -80,7 +80,7 @@ class Sunstone::Connection::SendRequestTest < ActiveSupport::TestCase
|
|
80
80
|
stub_request(:get, "http://testhost.com/503").to_return(status: 503)
|
81
81
|
stub_request(:get, "http://testhost.com/550").to_return(status: 550)
|
82
82
|
|
83
|
-
connection = Sunstone::Connection.new(
|
83
|
+
connection = Sunstone::Connection.new(endpoint: "http://testhost.com")
|
84
84
|
assert_raises(Sunstone::Exception::BadRequest) { connection.send_request(Net::HTTP::Get.new('/400')) }
|
85
85
|
assert_raises(Sunstone::Exception::Unauthorized) { connection.send_request(Net::HTTP::Get.new('/401')) }
|
86
86
|
assert_raises(Sunstone::Exception::Forbidden) { connection.send_request(Net::HTTP::Get.new('/403')) }
|
@@ -95,7 +95,7 @@ class Sunstone::Connection::SendRequestTest < ActiveSupport::TestCase
|
|
95
95
|
test '#send_request(#<Net::HTTPRequest>, &block) returns value returned from &block' do
|
96
96
|
stub_request(:get, "http://testhost.com/test").to_return(body: 'get')
|
97
97
|
|
98
|
-
connection = Sunstone::Connection.new(
|
98
|
+
connection = Sunstone::Connection.new(endpoint: "http://testhost.com")
|
99
99
|
value = connection.send_request(Net::HTTP::Get.new('/test')) do |response|
|
100
100
|
3215
|
101
101
|
end
|
@@ -104,7 +104,7 @@ class Sunstone::Connection::SendRequestTest < ActiveSupport::TestCase
|
|
104
104
|
end
|
105
105
|
|
106
106
|
test '#send_request(#<Net::HTTPRequest>, &block)' do
|
107
|
-
connection = Sunstone::Connection.new(
|
107
|
+
connection = Sunstone::Connection.new(endpoint: "http://testhost.com")
|
108
108
|
stub_request(:get, "http://testhost.com/test").to_return(body: 'get')
|
109
109
|
|
110
110
|
connection.send_request(Net::HTTP::Get.new('/test')) do |response|
|
@@ -122,7 +122,7 @@ class Sunstone::Connection::SendRequestTest < ActiveSupport::TestCase
|
|
122
122
|
end
|
123
123
|
|
124
124
|
test '#send_request(#<Net::HTTPRequest>, &block) with block reading chunks' do
|
125
|
-
connection = Sunstone::Connection.new(
|
125
|
+
connection = Sunstone::Connection.new(endpoint: "http://testhost.com")
|
126
126
|
|
127
127
|
rd, wr = IO.pipe
|
128
128
|
rd = Net::BufferedIO.new(rd)
|
@@ -149,7 +149,7 @@ class Sunstone::Connection::SendRequestTest < ActiveSupport::TestCase
|
|
149
149
|
|
150
150
|
# TODO: support multple depreaction-notice headers
|
151
151
|
test 'deprecation warning printed when deprecation header returned' do
|
152
|
-
connection = Sunstone::Connection.new(
|
152
|
+
connection = Sunstone::Connection.new(endpoint: "http://testhost.com")
|
153
153
|
|
154
154
|
stub_request(:get, "http://testhost.com/test").to_return(
|
155
155
|
body: 'get',
|
@@ -5,7 +5,7 @@ class Sunstone::ConnectionTest < ActiveSupport::TestCase
|
|
5
5
|
# #ping =====================================================================
|
6
6
|
|
7
7
|
test '#ping' do
|
8
|
-
connection = Sunstone::Connection.new(
|
8
|
+
connection = Sunstone::Connection.new(endpoint: "http://testhost.com")
|
9
9
|
stub_request(:get, "http://testhost.com/ping").to_return(:body => 'pong')
|
10
10
|
|
11
11
|
assert_equal( 'pong', connection.ping )
|
@@ -14,7 +14,7 @@ class Sunstone::ConnectionTest < ActiveSupport::TestCase
|
|
14
14
|
# #server_config ===========================================================
|
15
15
|
|
16
16
|
test '#config' do
|
17
|
-
connection = Sunstone::Connection.new(
|
17
|
+
connection = Sunstone::Connection.new(endpoint: "http://testhost.com")
|
18
18
|
stub_request(:get, "http://testhost.com/config").to_return(:body => '{"server": "configs"}')
|
19
19
|
|
20
20
|
assert_equal( {:server => "configs"}, connection.server_config )
|
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.
|
4
|
+
version: 6.1.0.rc1
|
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:
|
11
|
+
date: 2020-12-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
@@ -226,14 +226,14 @@ dependencies:
|
|
226
226
|
requirements:
|
227
227
|
- - ">="
|
228
228
|
- !ruby/object:Gem::Version
|
229
|
-
version: 6.
|
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.
|
236
|
+
version: 6.1.0
|
237
237
|
- !ruby/object:Gem::Dependency
|
238
238
|
name: arel-extensions
|
239
239
|
requirement: !ruby/object:Gem::Requirement
|
@@ -325,7 +325,7 @@ files:
|
|
325
325
|
homepage: http://sunstonerb.com
|
326
326
|
licenses: []
|
327
327
|
metadata: {}
|
328
|
-
post_install_message:
|
328
|
+
post_install_message:
|
329
329
|
rdoc_options: []
|
330
330
|
require_paths:
|
331
331
|
- lib
|
@@ -336,12 +336,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
336
336
|
version: '2.6'
|
337
337
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
338
338
|
requirements:
|
339
|
-
- - "
|
339
|
+
- - ">"
|
340
340
|
- !ruby/object:Gem::Version
|
341
|
-
version:
|
341
|
+
version: 1.3.1
|
342
342
|
requirements: []
|
343
|
-
rubygems_version: 3.
|
344
|
-
signing_key:
|
343
|
+
rubygems_version: 3.1.4
|
344
|
+
signing_key:
|
345
345
|
specification_version: 4
|
346
346
|
summary: A library for interacting with REST APIs
|
347
347
|
test_files:
|