standardapi 1.0.5 → 1.0.6
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: 58e5aa906cbdb420349c0ae94d74186ca8191c7f
|
4
|
+
data.tar.gz: 8a362d7d2fb5f90921260e93ee04df163c868520
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c89fa1bc6e4e0b2d8165a67dd3bb4d761b6d2681aac2c352fcc4da496f1dd048e4147be27d4193c90858123b7e34730b7e4f670f67cc693cb2941145efb724d0
|
7
|
+
data.tar.gz: e92218bbf59865553d2012606db1071a20310cdf129ed753d24ae78486abd4292b1a381dc8fd757aba24a87763380ea16db8abb0177283630aec870c4ebdd0ec
|
@@ -4,6 +4,23 @@ module StandardAPI
|
|
4
4
|
extend ActiveSupport::Testing::Declarative
|
5
5
|
|
6
6
|
test '#create.json' do
|
7
|
+
attrs = attributes_for(singular_name).select{|k,v| !model.readonly_attributes.include?(k.to_s) }
|
8
|
+
create_webmocks(attrs)
|
9
|
+
|
10
|
+
assert_difference("#{model.name}.count") do
|
11
|
+
post :create, singular_name => attrs, :format => 'json'
|
12
|
+
assert_response :created
|
13
|
+
assert assigns(singular_name)
|
14
|
+
|
15
|
+
json = JSON.parse(response.body)
|
16
|
+
assert json.is_a?(Hash)
|
17
|
+
(model.attribute_names & attrs.keys.map(&:to_s)).each do |test_key|
|
18
|
+
assert_equal normalize_to_json(test_key, attrs[test_key.to_sym]), json[test_key]
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
test '#create.json with nested attributes' do
|
7
24
|
attrs = attributes_for(singular_name, :nested).select{|k,v| !model.readonly_attributes.include?(k.to_s) }
|
8
25
|
create_webmocks(attrs)
|
9
26
|
|
@@ -21,7 +38,7 @@ module StandardAPI
|
|
21
38
|
end
|
22
39
|
|
23
40
|
test '#create.json with invalid attributes' do
|
24
|
-
attrs = attributes_for(singular_name, :
|
41
|
+
attrs = attributes_for(singular_name, :invalid).select{|k,v| !model.readonly_attributes.include?(k.to_s) }
|
25
42
|
create_webmocks(attrs)
|
26
43
|
|
27
44
|
assert_difference("#{model.name}.count", 0) do
|
@@ -43,7 +43,7 @@ module StandardAPI
|
|
43
43
|
end
|
44
44
|
|
45
45
|
test '#index.json params[:include]' do
|
46
|
-
create_model
|
46
|
+
create_model
|
47
47
|
get :index, include: includes, format: 'json'
|
48
48
|
includes.each do |included|
|
49
49
|
assert JSON.parse(response.body)[0].key?(included.to_s), "#{included.inspect} not included in response"
|
@@ -17,6 +17,20 @@ module StandardAPI
|
|
17
17
|
assert JSON.parse(@response.body).is_a?(Hash)
|
18
18
|
end
|
19
19
|
|
20
|
+
test '#update.json with nested attributes' do
|
21
|
+
m = create_model
|
22
|
+
attrs = attributes_for(singular_name, :nested).select{|k,v| !model.readonly_attributes.include?(k.to_s) }
|
23
|
+
create_webmocks(attrs)
|
24
|
+
|
25
|
+
put :update, id: m.id, singular_name => attrs, format: 'json'
|
26
|
+
assert_response :ok
|
27
|
+
|
28
|
+
(m.attribute_names & attrs.keys.map(&:to_s)).each do |test_key|
|
29
|
+
assert_equal normalize_attribute(test_key, attrs[test_key.to_sym]), m.reload.send(test_key)
|
30
|
+
end
|
31
|
+
assert JSON.parse(@response.body).is_a?(Hash)
|
32
|
+
end
|
33
|
+
|
20
34
|
test '#update.json with invalid attributes' do
|
21
35
|
m = create_model
|
22
36
|
attrs = attributes_for(singular_name, :invalid).select{|k,v| !model.readonly_attributes.include?(k.to_s) }
|
@@ -28,8 +42,8 @@ module StandardAPI
|
|
28
42
|
end
|
29
43
|
|
30
44
|
test '#update.json params[:include]' do
|
31
|
-
m = create_model
|
32
|
-
attrs = attributes_for(singular_name).select{|k,v| !model.readonly_attributes.include?(k) }
|
45
|
+
m = create_model
|
46
|
+
attrs = attributes_for(singular_name, :nested).select{|k,v| !model.readonly_attributes.include?(k) }
|
33
47
|
create_webmocks(attrs)
|
34
48
|
|
35
49
|
put :update, id: m.id, include: includes, singular_name => attrs, format: 'json'
|