factory_girl_remote_strategy 0.0.7 → 0.0.8
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1bd2d2572ab0367269268716ba1a455f7a2fd60d
|
4
|
+
data.tar.gz: f9331007bf708479bbc1d105e3828003097c055a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 49f8a43abee55530a7b84c1f3182e9818d0bb66d253ea47e611f34917e38dc27a1dcc4b10a4dd3dd2831ff5c50ed95d151aae2b356eb6e596edf813feff0e634
|
7
|
+
data.tar.gz: fac74153c6c9f41b5f8ee14ecaa557ea88e21d6f31255bb1b037a8699e7457af55a75bda907db92301f3655e56ca5f858f6e7dde882dc2e98b6f033d9c0a8785
|
@@ -32,7 +32,7 @@ module FactoryGirl
|
|
32
32
|
end
|
33
33
|
|
34
34
|
class << self
|
35
|
-
def entity_hash(entity)
|
35
|
+
def entity_hash(entity, params = {})
|
36
36
|
raise ArgumentError, "cann't construct hash for non ActiveResource::Base object" unless entity.is_a?(ActiveResource::Base)
|
37
37
|
attributes = entity.attributes
|
38
38
|
# Set belongs_to <association>_id instead of each <association>.
|
@@ -54,7 +54,9 @@ module FactoryGirl
|
|
54
54
|
attributes[k] = v.map { |e| entity_hash(e) }
|
55
55
|
end
|
56
56
|
end
|
57
|
-
{ entity.class.element_name => attributes
|
57
|
+
{ entity.class.element_name => attributes }.tap do |h|
|
58
|
+
h[:_metadata] = { abilities: %w(update destroy) } unless params[:metadata] == false
|
59
|
+
end
|
58
60
|
end
|
59
61
|
|
60
62
|
def entity_url(entity)
|
@@ -90,5 +92,5 @@ def remote_search(*args)
|
|
90
92
|
params = args.extract_options!
|
91
93
|
collection = args.flatten
|
92
94
|
FakeWeb.register_uri(:get, FactoryGirl::RemoteStrategy.collection_url(collection, params),
|
93
|
-
body: (collection.first.is_a?(Class) ? "[]" : collection.map { |e| FactoryGirl::RemoteStrategy.entity_hash(e) }.to_json))
|
95
|
+
body: (collection.first.is_a?(Class) ? "[]" : collection.map { |e| FactoryGirl::RemoteStrategy.entity_hash(e, params) }.to_json))
|
94
96
|
end
|
@@ -70,6 +70,17 @@ describe FactoryGirl::RemoteStrategy do
|
|
70
70
|
memberships = Membership.find(:all, params: { search: { premises_id_in: [4] } }).to_a
|
71
71
|
memberships.should eq []
|
72
72
|
end
|
73
|
+
|
74
|
+
context "standard ActiveResource JSON formatter with included root" do
|
75
|
+
it "performs correct search if no metadata required" do
|
76
|
+
remote_search FactoryGirl.remote_list(:staff, 2), metadata: false
|
77
|
+
expect { Staff.find(:all, params: { metadata: false }) }.not_to raise_error
|
78
|
+
staff = Staff.find(:all, params: { metadata: false }).to_a
|
79
|
+
expect(staff).to be_kind_of Array
|
80
|
+
expect(staff.first).to be_kind_of Staff
|
81
|
+
expect(staff.first.group_id).to eq 18
|
82
|
+
end
|
83
|
+
end
|
73
84
|
end
|
74
85
|
|
75
86
|
describe "Search by primary_key" do
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: factory_girl_remote_strategy
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Alex Avoyants
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2015-03-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -128,6 +128,7 @@ files:
|
|
128
128
|
- spec/factories/incident.rb
|
129
129
|
- spec/factories/membership.rb
|
130
130
|
- spec/factories/postcode.rb
|
131
|
+
- spec/factories/staff.rb
|
131
132
|
- spec/factories/user.rb
|
132
133
|
- spec/factories/victim.rb
|
133
134
|
- spec/factory_girl_remote_not_found_strategy_spec.rb
|
@@ -138,6 +139,7 @@ files:
|
|
138
139
|
- spec/support/json_with_metadata_formatter.rb
|
139
140
|
- spec/support/membership.rb
|
140
141
|
- spec/support/postcode.rb
|
142
|
+
- spec/support/staff.rb
|
141
143
|
- spec/support/user.rb
|
142
144
|
- spec/support/victim.rb
|
143
145
|
homepage: ''
|
@@ -169,6 +171,7 @@ test_files:
|
|
169
171
|
- spec/factories/incident.rb
|
170
172
|
- spec/factories/membership.rb
|
171
173
|
- spec/factories/postcode.rb
|
174
|
+
- spec/factories/staff.rb
|
172
175
|
- spec/factories/user.rb
|
173
176
|
- spec/factories/victim.rb
|
174
177
|
- spec/factory_girl_remote_not_found_strategy_spec.rb
|
@@ -179,5 +182,6 @@ test_files:
|
|
179
182
|
- spec/support/json_with_metadata_formatter.rb
|
180
183
|
- spec/support/membership.rb
|
181
184
|
- spec/support/postcode.rb
|
185
|
+
- spec/support/staff.rb
|
182
186
|
- spec/support/user.rb
|
183
187
|
- spec/support/victim.rb
|