rom-repository 1.3.0 → 1.3.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +1 -0
- data/CHANGELOG.md +12 -0
- data/lib/rom/repository.rb +3 -3
- data/lib/rom/repository/changeset.rb +3 -3
- data/lib/rom/repository/changeset/associated.rb +3 -3
- data/lib/rom/repository/changeset/stateful.rb +2 -4
- data/lib/rom/repository/class_interface.rb +5 -12
- data/lib/rom/repository/relation_proxy.rb +6 -6
- data/lib/rom/repository/version.rb +1 -1
- data/rom-repository.gemspec +1 -3
- data/spec/integration/multi_adapter_spec.rb +4 -6
- data/spec/integration/repository_spec.rb +24 -2
- data/spec/shared/database.rb +1 -9
- data/spec/shared/mappers.rb +3 -3
- data/spec/shared/structs.rb +0 -2
- data/spec/spec_helper.rb +31 -10
- data/spec/unit/relation_proxy_spec.rb +35 -35
- metadata +5 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c74e20a5f12fce2888ae33bfeba0f4ff2baa9546
|
4
|
+
data.tar.gz: 816d5902836dfe8ab67f785c448c7e1b33b42853
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9b8dac9fd33b64b269353b52dc6d01a5f2d65a6f97376d2df322ea9bb64fa1a31850100b2080e8b69b89c15a84227cb6e6f02913fcfda673554f1cbb2f0f8539
|
7
|
+
data.tar.gz: a8355e2936bf75d78ce989337815b0a5446aa532e2fa5e93e359cc87bb920db82afecd3f6a899306d3994e0aab75956a17adda086bb8909075849911eea11da5
|
data/.travis.yml
CHANGED
@@ -5,6 +5,7 @@ cache: bundler
|
|
5
5
|
bundler_args: --without yard guard benchmarks tools
|
6
6
|
before_script:
|
7
7
|
- psql -c 'create database rom_repository' -U postgres
|
8
|
+
- rvm get master
|
8
9
|
script: "bundle exec rake ci"
|
9
10
|
after_success:
|
10
11
|
- '[ "${TRAVIS_JOB_NUMBER#*.}" = "1" ] && [ "$TRAVIS_BRANCH" = "master" ] && bundle exec codeclimate-test-reporter'
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,15 @@
|
|
1
|
+
# v1.3.1 2017-03-25
|
2
|
+
|
3
|
+
### Fixed
|
4
|
+
|
5
|
+
* Support for using custom mappers inside `#node` (flash-gordon)
|
6
|
+
|
7
|
+
### Changed
|
8
|
+
|
9
|
+
* Updated `dry-initializer` (flash-gordon)
|
10
|
+
|
11
|
+
[Compare v1.3.0...v1.3.1](https://github.com/rom-rb/rom-repository/compare/v1.3.0...v1.3.1)
|
12
|
+
|
1
13
|
# v1.3.0 2017-03-07
|
2
14
|
|
3
15
|
### Added
|
data/lib/rom/repository.rb
CHANGED
@@ -86,9 +86,9 @@ module ROM
|
|
86
86
|
# @return [ROM::Container] The container used to set up a repo
|
87
87
|
param :container, allow: ROM::Container
|
88
88
|
|
89
|
-
# @!attribute [r]
|
90
|
-
# @return [
|
91
|
-
option :auto_struct,
|
89
|
+
# @!attribute [r] auto_struct
|
90
|
+
# @return [Boolean] The container used to set up a repo
|
91
|
+
option :auto_struct, default: -> { self.class.auto_struct }
|
92
92
|
|
93
93
|
# @!attribute [r] relations
|
94
94
|
# @return [RelationRegistry] The relation proxy registry used by a repo
|
@@ -53,11 +53,11 @@ module ROM
|
|
53
53
|
|
54
54
|
# @!attribute [r] command_compiler
|
55
55
|
# @return [Proc] a proc that can compile a command (typically provided by a repo)
|
56
|
-
option :command_compiler,
|
56
|
+
option :command_compiler, optional: true
|
57
57
|
|
58
58
|
# @!attribute [r] command_type
|
59
59
|
# @return [Symbol] a custom command identifier
|
60
|
-
option :command_type,
|
60
|
+
option :command_type, default: -> { self.class.command_type }
|
61
61
|
|
62
62
|
# Create a changeset class preconfigured for a specific relation
|
63
63
|
#
|
@@ -78,7 +78,7 @@ module ROM
|
|
78
78
|
#
|
79
79
|
# @example
|
80
80
|
# class NewUser < ROM::Changeset::Create[:users]
|
81
|
-
# option :token_generator
|
81
|
+
# option :token_generator
|
82
82
|
# end
|
83
83
|
#
|
84
84
|
# changeset = user_repo.changeset(NewUser).with(token_generator: my_token_gen)
|
@@ -12,9 +12,9 @@ module ROM
|
|
12
12
|
# @return [Changeset::Create] Child changeset
|
13
13
|
param :left
|
14
14
|
|
15
|
-
# @!attribute [r]
|
16
|
-
# @return [
|
17
|
-
option :associations
|
15
|
+
# @!attribute [r] associations
|
16
|
+
# @return [Array] List of association identifiers from relation schema
|
17
|
+
option :associations
|
18
18
|
|
19
19
|
# Infer association name from an object with a schema
|
20
20
|
#
|
@@ -13,14 +13,12 @@ module ROM
|
|
13
13
|
# @!attribute [r] __data__
|
14
14
|
# @return [Hash] The relation data
|
15
15
|
# @api private
|
16
|
-
option :__data__,
|
16
|
+
option :__data__, optional: true
|
17
17
|
|
18
18
|
# @!attribute [r] pipe
|
19
19
|
# @return [Changeset::Pipe] data transformation pipe
|
20
20
|
# @api private
|
21
|
-
option :pipe,
|
22
|
-
changeset.class.default_pipe(changeset)
|
23
|
-
}
|
21
|
+
option :pipe, accept: [Proc, Pipe], default: -> { self.class.default_pipe(self) }
|
24
22
|
|
25
23
|
# Define a changeset mapping
|
26
24
|
#
|
@@ -51,18 +51,11 @@ module ROM
|
|
51
51
|
#
|
52
52
|
# @api public
|
53
53
|
def relations(*names)
|
54
|
-
if names.
|
55
|
-
|
56
|
-
|
57
|
-
if defined?(@relations)
|
58
|
-
@relations.concat(names).uniq!
|
59
|
-
else
|
60
|
-
@relations = names
|
61
|
-
end
|
62
|
-
|
63
|
-
@relations
|
54
|
+
if names.empty?
|
55
|
+
@relations ||= []
|
64
56
|
else
|
65
|
-
|
57
|
+
attr_reader(*(names - relations))
|
58
|
+
@relations = relations | names
|
66
59
|
end
|
67
60
|
end
|
68
61
|
|
@@ -104,7 +97,7 @@ module ROM
|
|
104
97
|
end
|
105
98
|
end
|
106
99
|
else
|
107
|
-
@commands
|
100
|
+
@commands ||= []
|
108
101
|
end
|
109
102
|
end
|
110
103
|
|
@@ -27,10 +27,10 @@ module ROM
|
|
27
27
|
param :relation
|
28
28
|
|
29
29
|
option :name, type: Types::Strict::Symbol
|
30
|
-
option :mappers,
|
31
|
-
option :meta,
|
32
|
-
option :registry, type: RelationRegistryType, default:
|
33
|
-
option :auto_struct,
|
30
|
+
option :mappers, default: -> { MapperBuilder.new }
|
31
|
+
option :meta, default: -> { EMPTY_HASH }
|
32
|
+
option :registry, type: RelationRegistryType, default: -> { RelationRegistry.new }
|
33
|
+
option :auto_struct, default: -> { true }
|
34
34
|
|
35
35
|
# Relation name
|
36
36
|
#
|
@@ -38,7 +38,7 @@ module ROM
|
|
38
38
|
#
|
39
39
|
# @api public
|
40
40
|
def name
|
41
|
-
@name
|
41
|
+
@name ? relation.name.with(@name) : relation.name
|
42
42
|
end
|
43
43
|
|
44
44
|
# Materializes wrapped relation and sends it through a mapper
|
@@ -91,7 +91,7 @@ module ROM
|
|
91
91
|
elsif names.size > 1 && names.any? { |name| name.is_a?(Class) }
|
92
92
|
raise ArgumentError, 'using custom mappers and a model is not supported'
|
93
93
|
else
|
94
|
-
if opts[:auto_map]
|
94
|
+
if opts[:auto_map] && !meta[:combine_type]
|
95
95
|
mappers = [mapper, *names.map { |name| relation.mappers[name] }]
|
96
96
|
mappers.reduce(self) { |a, e| a >> e }
|
97
97
|
else
|
data/rom-repository.gemspec
CHANGED
@@ -1,5 +1,3 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
1
|
require File.expand_path('../lib/rom/repository/version', __FILE__)
|
4
2
|
|
5
3
|
Gem::Specification.new do |gem|
|
@@ -15,7 +13,7 @@ Gem::Specification.new do |gem|
|
|
15
13
|
gem.test_files = `git ls-files -- {spec}/*`.split("\n")
|
16
14
|
gem.license = 'MIT'
|
17
15
|
|
18
|
-
gem.add_runtime_dependency 'rom', '~> 3.
|
16
|
+
gem.add_runtime_dependency 'rom', '~> 3.2'
|
19
17
|
gem.add_runtime_dependency 'rom-mapper', '~> 0.5'
|
20
18
|
gem.add_runtime_dependency 'dry-core', '~> 0.2', '>= 0.2.1'
|
21
19
|
gem.add_runtime_dependency 'dry-struct', '~> 0.1'
|
@@ -1,12 +1,10 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
1
|
RSpec.describe 'Repository with multi-adapters configuration' do
|
4
|
-
|
5
|
-
|
6
|
-
let(:configuration) {
|
7
|
-
ROM::Configuration.new(default: [:sql, uri], memory: [:memory])
|
2
|
+
let!(:configuration) {
|
3
|
+
ROM::Configuration.new(default: [:sql, DB_URI], memory: [:memory])
|
8
4
|
}
|
9
5
|
|
6
|
+
let(:rom) { ROM.container(configuration) }
|
7
|
+
|
10
8
|
let(:users) { rom.relation(:sql_users) }
|
11
9
|
let(:tasks) { rom.relation(:memory_tasks) }
|
12
10
|
|
@@ -1,8 +1,9 @@
|
|
1
1
|
RSpec.describe 'ROM repository' do
|
2
2
|
include_context 'database'
|
3
3
|
include_context 'relations'
|
4
|
-
include_context '
|
4
|
+
include_context 'repo'
|
5
5
|
include_context 'structs'
|
6
|
+
include_context 'seeds'
|
6
7
|
|
7
8
|
it 'loads a single relation' do
|
8
9
|
expect(repo.all_users.to_a).to match_array([jane, joe])
|
@@ -301,6 +302,14 @@ RSpec.describe 'ROM repository' do
|
|
301
302
|
rel.map { |tuple| Hash(tuple).merge(mapped: true) }
|
302
303
|
end
|
303
304
|
end
|
305
|
+
|
306
|
+
define(:posts) do
|
307
|
+
register_as :nested_mapper
|
308
|
+
|
309
|
+
def call(rel)
|
310
|
+
rel.map { |tuple| Hash(tuple).tap { |h| h[:title] = h[:title].upcase } }
|
311
|
+
end
|
312
|
+
end
|
304
313
|
end
|
305
314
|
end
|
306
315
|
|
@@ -308,7 +317,20 @@ RSpec.describe 'ROM repository' do
|
|
308
317
|
jane = repo.users.combine(:posts).map_with(:embed_address, auto_map: true).to_a.first
|
309
318
|
|
310
319
|
expect(jane).
|
311
|
-
to eql(id:1, name: 'Jane', mapped: true, posts: [
|
320
|
+
to eql(id:1, name: 'Jane', mapped: true, posts: [
|
321
|
+
{ id: 1, author_id: 1, title: 'Hello From Jane', body: 'Jane Post' }
|
322
|
+
])
|
323
|
+
end
|
324
|
+
|
325
|
+
it 'applies a custom mapper inside #node' do
|
326
|
+
jane = repo.aggregate(:posts).node(:posts) { |posts| posts.as(:nested_mapper, auto_map: true) }.to_a.first
|
327
|
+
|
328
|
+
expect(jane).to be_a ROM::Struct
|
329
|
+
|
330
|
+
expect(jane.to_h).
|
331
|
+
to eql(id:1, name: 'Jane', posts: [
|
332
|
+
{ id: 1, author_id: 1, title: 'HELLO FROM JANE', body: 'Jane Post' }
|
333
|
+
])
|
312
334
|
end
|
313
335
|
end
|
314
336
|
|
data/spec/shared/database.rb
CHANGED
@@ -1,18 +1,10 @@
|
|
1
1
|
RSpec.shared_context 'database setup' do
|
2
|
-
let(:configuration) { ROM::Configuration.new(:sql,
|
2
|
+
let(:configuration) { ROM::Configuration.new(:sql, DB_URI) }
|
3
3
|
|
4
4
|
let(:conn) { configuration.gateways[:default].connection }
|
5
5
|
|
6
6
|
let(:rom) { ROM.container(configuration) }
|
7
7
|
|
8
|
-
let(:uri) do
|
9
|
-
if defined? JRUBY_VERSION
|
10
|
-
'jdbc:postgresql://localhost/rom_repository'
|
11
|
-
else
|
12
|
-
'postgres://localhost/rom_repository'
|
13
|
-
end
|
14
|
-
end
|
15
|
-
|
16
8
|
before do
|
17
9
|
conn.loggers << LOGGER
|
18
10
|
end
|
data/spec/shared/mappers.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
RSpec.shared_context 'mappers' do
|
2
|
-
let(:
|
3
|
-
let(:
|
4
|
-
let(:
|
2
|
+
let(:user_mappers) { users.mappers[:user] }
|
3
|
+
let(:task_mappers) { tasks.mappers[:task] }
|
4
|
+
let(:tag_mappers) { tags.mappers[:tag] }
|
5
5
|
|
6
6
|
before do
|
7
7
|
configuration.mappers do
|
data/spec/shared/structs.rb
CHANGED
data/spec/spec_helper.rb
CHANGED
@@ -22,14 +22,6 @@ end
|
|
22
22
|
root = Pathname(__FILE__).dirname
|
23
23
|
LOGGER = Logger.new(File.open('./log/test.log', 'a'))
|
24
24
|
|
25
|
-
Dir[root.join('support/*.rb').to_s].each do |f|
|
26
|
-
require f
|
27
|
-
end
|
28
|
-
|
29
|
-
Dir[root.join('shared/*.rb').to_s].each do |f|
|
30
|
-
require f
|
31
|
-
end
|
32
|
-
|
33
25
|
require 'dry/core/deprecations'
|
34
26
|
Dry::Core::Deprecations.set_logger!(root.join('../log/deprecations.log'))
|
35
27
|
|
@@ -47,12 +39,41 @@ module Test
|
|
47
39
|
end
|
48
40
|
end
|
49
41
|
|
42
|
+
warning_api_available = RUBY_VERSION >= '2.4.0'
|
43
|
+
|
44
|
+
module SileneceWarnings
|
45
|
+
def warn(str)
|
46
|
+
if str['/sequel/'] || str['/rspec-core']
|
47
|
+
nil
|
48
|
+
else
|
49
|
+
super
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
DB_URI = if defined? JRUBY_VERSION
|
55
|
+
'jdbc:postgresql://localhost/rom_repository'
|
56
|
+
else
|
57
|
+
'postgres://localhost/rom_repository'
|
58
|
+
end
|
59
|
+
|
60
|
+
Warning.extend(SileneceWarnings) if warning_api_available
|
61
|
+
|
50
62
|
RSpec.configure do |config|
|
63
|
+
config.disable_monkey_patching!
|
64
|
+
config.warnings = true
|
65
|
+
|
51
66
|
config.after do
|
52
67
|
Test.remove_constants
|
53
68
|
end
|
54
69
|
|
55
|
-
|
70
|
+
Dir[root.join('support/*.rb').to_s].each do |f|
|
71
|
+
require f
|
72
|
+
end
|
56
73
|
|
57
|
-
|
74
|
+
Dir[root.join('shared/*.rb').to_s].each do |f|
|
75
|
+
require f
|
76
|
+
end
|
77
|
+
|
78
|
+
config.include(MapperRegistry)
|
58
79
|
end
|
@@ -7,21 +7,21 @@ RSpec.describe 'loading proxy' do
|
|
7
7
|
include_context 'structs'
|
8
8
|
include_context 'seeds'
|
9
9
|
|
10
|
-
let(:
|
11
|
-
ROM::Repository::RelationProxy.new(
|
10
|
+
let(:users_proxy) do
|
11
|
+
ROM::Repository::RelationProxy.new(users, name: :users)
|
12
12
|
end
|
13
13
|
|
14
|
-
let(:
|
15
|
-
ROM::Repository::RelationProxy.new(
|
14
|
+
let(:tasks_proxy) do
|
15
|
+
ROM::Repository::RelationProxy.new(tasks, name: :tasks)
|
16
16
|
end
|
17
17
|
|
18
|
-
let(:
|
19
|
-
ROM::Repository::RelationProxy.new(
|
18
|
+
let(:tags_proxy) do
|
19
|
+
ROM::Repository::RelationProxy.new(tags, name: :tags)
|
20
20
|
end
|
21
21
|
|
22
22
|
describe '#inspect' do
|
23
23
|
specify do
|
24
|
-
expect(
|
24
|
+
expect(users_proxy.inspect).
|
25
25
|
to eql("#<ROM::Relation[Users] name=users dataset=#{users.dataset.inspect}>")
|
26
26
|
end
|
27
27
|
end
|
@@ -30,13 +30,13 @@ RSpec.describe 'loading proxy' do
|
|
30
30
|
it 'yields loaded structs' do
|
31
31
|
result = []
|
32
32
|
|
33
|
-
|
33
|
+
users_proxy.each { |user| result << user }
|
34
34
|
|
35
35
|
expect(result).to eql([jane, joe])
|
36
36
|
end
|
37
37
|
|
38
38
|
it 'returns an enumerator when block is not given' do
|
39
|
-
expect(
|
39
|
+
expect(users_proxy.each.to_a).to eql([jane, joe])
|
40
40
|
end
|
41
41
|
end
|
42
42
|
|
@@ -53,17 +53,17 @@ RSpec.describe 'loading proxy' do
|
|
53
53
|
end
|
54
54
|
|
55
55
|
it 'sends the relation through custom mappers' do
|
56
|
-
expect(
|
56
|
+
expect(users_proxy.map_with(:name_list, :upcase_names).to_a).to match_array(%w(JANE JOE))
|
57
57
|
end
|
58
58
|
|
59
59
|
it 'does not use the default(ROM::Struct) mapper' do
|
60
|
-
expect(
|
60
|
+
expect(users_proxy.map_with(:identity).to_a).to match_array(
|
61
61
|
[{ id: 1, name: 'Jane' }, {id: 2, name: 'Joe' }]
|
62
62
|
)
|
63
63
|
end
|
64
64
|
|
65
65
|
it 'raises error when custom mapper is used with a model class' do
|
66
|
-
expect {
|
66
|
+
expect { users_proxy.map_with(:name_list, Class.new) }.
|
67
67
|
to raise_error(ArgumentError, 'using custom mappers and a model is not supported')
|
68
68
|
end
|
69
69
|
end
|
@@ -76,7 +76,7 @@ RSpec.describe 'loading proxy' do
|
|
76
76
|
end
|
77
77
|
end
|
78
78
|
|
79
|
-
let(:custom_users) {
|
79
|
+
let(:custom_users) { users_proxy.as(user_type) }
|
80
80
|
|
81
81
|
it 'instantiates custom model' do
|
82
82
|
expect(custom_users.where(name: 'Jane').one).to be_instance_of(user_type)
|
@@ -87,59 +87,59 @@ RSpec.describe 'loading proxy' do
|
|
87
87
|
describe 'retrieving a single struct' do
|
88
88
|
describe '#first' do
|
89
89
|
it 'returns exactly one struct' do
|
90
|
-
expect(
|
90
|
+
expect(users_proxy.first).to eql(jane)
|
91
91
|
end
|
92
92
|
end
|
93
93
|
|
94
94
|
describe '#one' do
|
95
95
|
it 'returns exactly one struct' do
|
96
|
-
expect(
|
96
|
+
expect(users_proxy.find(id: 1).one).to eql(jane)
|
97
97
|
|
98
|
-
expect(
|
98
|
+
expect(users_proxy.find(id: 3).one).to be(nil)
|
99
99
|
|
100
|
-
expect {
|
100
|
+
expect { users_proxy.find(id: [1,2]).one }.to raise_error(ROM::TupleCountMismatchError)
|
101
101
|
end
|
102
102
|
end
|
103
103
|
|
104
104
|
describe '#one!' do
|
105
105
|
it 'returns exactly one struct' do
|
106
|
-
expect(
|
106
|
+
expect(users_proxy.find(id: 1).one!).to eql(jane)
|
107
107
|
|
108
|
-
expect {
|
109
|
-
expect {
|
108
|
+
expect { users_proxy.find(id: [1, 2]).one! }.to raise_error(ROM::TupleCountMismatchError)
|
109
|
+
expect { users_proxy.find(id: [3]).one! }.to raise_error(ROM::TupleCountMismatchError)
|
110
110
|
end
|
111
111
|
end
|
112
112
|
end
|
113
113
|
|
114
114
|
describe '#to_ast' do
|
115
115
|
it 'returns valid ast for a single relation' do
|
116
|
-
expect(
|
116
|
+
expect(users_proxy.to_ast).to eql(
|
117
117
|
[:relation, [
|
118
118
|
:users,
|
119
119
|
{ dataset: :users },
|
120
|
-
[:header, [[:attribute,
|
120
|
+
[:header, [[:attribute, users_proxy.schema[:id]], [:attribute, users_proxy.schema[:name]]]]]
|
121
121
|
]
|
122
122
|
)
|
123
123
|
end
|
124
124
|
|
125
125
|
it 'returns valid ast for a combined relation' do
|
126
|
-
relation =
|
126
|
+
relation = users_proxy.combine(many: { user_tasks: [tasks_proxy, id: :user_id] })
|
127
127
|
|
128
128
|
expect(relation.to_ast).to eql(
|
129
129
|
[:relation, [
|
130
130
|
:users,
|
131
131
|
{ dataset: :users },
|
132
132
|
[:header, [
|
133
|
-
[:attribute,
|
134
|
-
[:attribute,
|
133
|
+
[:attribute, users_proxy.schema[:id]],
|
134
|
+
[:attribute, users_proxy.schema[:name]],
|
135
135
|
[:relation, [
|
136
136
|
:tasks,
|
137
137
|
{ dataset: :tasks, keys: { id: :user_id },
|
138
138
|
combine_type: :many, combine_name: :user_tasks },
|
139
139
|
[:header, [
|
140
|
-
[:attribute,
|
141
|
-
[:attribute,
|
142
|
-
[:attribute,
|
140
|
+
[:attribute, tasks_proxy.schema[:id]],
|
141
|
+
[:attribute, tasks_proxy.schema[:user_id]],
|
142
|
+
[:attribute, tasks_proxy.schema[:title]]]]
|
143
143
|
]]
|
144
144
|
]
|
145
145
|
]]]
|
@@ -147,10 +147,10 @@ RSpec.describe 'loading proxy' do
|
|
147
147
|
end
|
148
148
|
|
149
149
|
it 'returns valid ast for a wrapped relation' do
|
150
|
-
relation =
|
150
|
+
relation = tags_proxy.wrap_parent(task: tasks_proxy)
|
151
151
|
|
152
|
-
tags_schema =
|
153
|
-
tasks_schema =
|
152
|
+
tags_schema = tags_proxy.schema.qualified
|
153
|
+
tasks_schema = tasks_proxy.schema.wrap
|
154
154
|
|
155
155
|
expect(relation.to_ast).to eql(
|
156
156
|
[:relation, [
|
@@ -177,19 +177,19 @@ RSpec.describe 'loading proxy' do
|
|
177
177
|
|
178
178
|
describe '#method_missing' do
|
179
179
|
it 'proxies to the underlying relation' do
|
180
|
-
expect(
|
180
|
+
expect(users_proxy.gateway).to be(:default)
|
181
181
|
end
|
182
182
|
|
183
183
|
it 'returns proxy when response was not materialized' do
|
184
|
-
expect(
|
184
|
+
expect(users_proxy.by_pk(1)).to be_instance_of(ROM::Repository::RelationProxy)
|
185
185
|
end
|
186
186
|
|
187
187
|
it 'returns curried proxy when response was curried' do
|
188
|
-
expect(
|
188
|
+
expect(users_proxy.by_pk).to be_instance_of(ROM::Repository::RelationProxy)
|
189
189
|
end
|
190
190
|
|
191
191
|
it 'raises when method is missing' do
|
192
|
-
expect {
|
192
|
+
expect { users_proxy.not_here }.to raise_error(NoMethodError, "undefined method `not_here' for ROM::Relation[Users]")
|
193
193
|
end
|
194
194
|
end
|
195
195
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rom-repository
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.3.
|
4
|
+
version: 1.3.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Piotr Solnica
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-03-
|
11
|
+
date: 2017-03-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rom
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '3.
|
19
|
+
version: '3.2'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '3.
|
26
|
+
version: '3.2'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: rom-mapper
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -191,7 +191,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
191
191
|
version: '0'
|
192
192
|
requirements: []
|
193
193
|
rubyforge_project:
|
194
|
-
rubygems_version: 2.6.
|
194
|
+
rubygems_version: 2.6.10
|
195
195
|
signing_key:
|
196
196
|
specification_version: 4
|
197
197
|
summary: Repository abstraction for rom-rb
|