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: cb2bcb0df75b9410634d0fec29e4391a6830ba3e
4
- data.tar.gz: 9ef3bc3fd6e4b4d7d5d704ae09255f20182bb04d
3
+ metadata.gz: 58e5aa906cbdb420349c0ae94d74186ca8191c7f
4
+ data.tar.gz: 8a362d7d2fb5f90921260e93ee04df163c868520
5
5
  SHA512:
6
- metadata.gz: e3ef2868b977624aa84a784020647292d90baa82fc98bf4c34a25fc86c32138b6c6d4c7e902f339f2b54532513ebb9ca4f10c385add0a42a5dfda4031fc02040
7
- data.tar.gz: dbfd5941419c1a41fb27d96407a7e98855e8f790a6132fbefe7f54b27ad68de6f70369ff5c471ef0ea49505b6529fad78aafbf93dc885a3ce1fb4b039f73b806
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, :nested, :invalid).select{|k,v| !model.readonly_attributes.include?(k.to_s) }
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(:nested)
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"
@@ -14,7 +14,7 @@ module StandardAPI
14
14
  end
15
15
 
16
16
  test '#show.json params[:include]' do
17
- m = create_model(:nested)
17
+ m = create_model
18
18
  get :show, id: m.id, include: includes, format: 'json'
19
19
 
20
20
  json = JSON.parse(response.body)
@@ -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(:nested)
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'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: standardapi
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.5
4
+ version: 1.0.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - James Bracy