standardapi 1.0.1 → 1.0.2

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: 6353f71131f0c0fad684accfcc6ca5c3dfbf1a9a
4
- data.tar.gz: 0a41e917006d06a9d962c8eacb128d76893dabf5
3
+ metadata.gz: 00a4ca4a08d5ea94b8ac4bd32a3594e788df0ff8
4
+ data.tar.gz: 1e7475c8c767003c8772799c15e2c024b972caed
5
5
  SHA512:
6
- metadata.gz: b7c8bb29581b057ae6866c5d2b1059c5803ffbd23f386b8c2a1107b8d30e2ccfdc59c74d6a0d78b023e3a86a1f026214d8a3f056c1768f653c59d0d9116f3306
7
- data.tar.gz: 15b2f53b35ba5d81775b10e4a151a1126d02ffb7f9ee4081f547c735ac56cf03445e2da5be98f0bf68fd7be0c744ef2d416eb03878ffd0a42b160292e206c2ab
6
+ metadata.gz: 512d98d1856c2652f27556e76077163a8b74fd40979fe1d544e8ee7a8014d92ddf00ebd8a5b7b7957e32e727516f265b624e1ee85f29c3ee71d10ca3d5ab5c4d
7
+ data.tar.gz: b6df1f38fbc139cfd9fa9cfd07dbd50436134fecac245853177ffe5af45cc7a8fc3588b0203f80910afa36fc571d29f82ddb0f9cb9dabe65c6b6dd2425a83490
@@ -25,6 +25,10 @@ module StandardAPI
25
25
  end
26
26
 
27
27
  test '#calculate.json mask' do
28
+ # If #current_mask isn't defined by StandardAPI we don't know how to
29
+ # test other's implementation of #current_mask. Return and don't test.
30
+ return if @controller.method(:current_mask).owner != StandardAPI
31
+
28
32
  m = create_model
29
33
  @controller.current_mask[plural_name] = { id: m.id + 100 }
30
34
  selects = [{ count: :id}, { maximum: :id }, { minimum: :id }, { average: :id }]
@@ -34,11 +38,6 @@ module StandardAPI
34
38
  @controller.current_mask.delete(plural_name)
35
39
  end
36
40
 
37
- test 'route to #calculate.json' do
38
- assert_routing "/#{plural_name}/calculate", path_with_action('calculate')
39
- assert_recognizes(path_with_action('calculate'), "/#{plural_name}/calculate")
40
- end
41
-
42
41
  end
43
42
  end
44
43
  end
@@ -61,11 +61,6 @@ module StandardAPI
61
61
  end
62
62
  end
63
63
 
64
- test 'route to #create.json' do
65
- assert_routing({ method: :post, path: "/#{plural_name}" }, path_with_action('create'))
66
- assert_recognizes(path_with_action('create'), { method: :post, path: "/#{plural_name}" })
67
- end
68
-
69
64
  end
70
65
  end
71
66
  end
@@ -14,6 +14,10 @@ module StandardAPI
14
14
  end
15
15
 
16
16
  test '#destroy.json mask' do
17
+ # If #current_mask isn't defined by StandardAPI we don't know how to
18
+ # test other's implementation of #current_mask. Return and don't test.
19
+ return if @controller.method(:current_mask).owner != StandardAPI
20
+
17
21
  m = create_model
18
22
  @controller.current_mask[plural_name] = { id: m.id + 1 }
19
23
  assert_raises(ActiveRecord::RecordNotFound) do
@@ -22,11 +26,6 @@ module StandardAPI
22
26
  @controller.current_mask.delete(plural_name)
23
27
  end
24
28
 
25
- test 'route to #destroy.json' do
26
- assert_routing({ method: :delete, path: "/#{plural_name}/1" }, path_with_action('destroy', id: '1'))
27
- assert_recognizes(path_with_action('destroy', id: '1'), { method: :delete, path: "/#{plural_name}/1" })
28
- end
29
-
30
29
  end
31
30
  end
32
31
  end
@@ -11,14 +11,6 @@ module StandardAPI
11
11
  assert JSON.parse(response.body).is_a?(Array)
12
12
  end
13
13
 
14
- test '#index.json mask' do
15
- m = create_model
16
- @controller.current_mask[plural_name] = { id: m.id }
17
- get :index, format: 'json'
18
- assert_equal model.where(id: m.id).to_sql, assigns(plural_name).to_sql
19
- @controller.current_mask.delete(plural_name)
20
- end
21
-
22
14
  test '#index.json params[:limit]' do
23
15
  get :index, limit: 1, format: 'json'
24
16
  assert_equal model.limit(1).to_sql, assigns(plural_name).to_sql
@@ -58,11 +50,18 @@ module StandardAPI
58
50
  end
59
51
  end
60
52
 
61
- test 'route to #index.json' do
62
- assert_routing "/#{plural_name}", path_with_action('index')
63
- assert_recognizes path_with_action('index'), "/#{plural_name}"
53
+ test '#index.json mask' do
54
+ # If #current_mask isn't defined by StandardAPI we don't know how to
55
+ # test other's implementation of #current_mask. Return and don't test.
56
+ return if @controller.method(:current_mask).owner != StandardAPI
57
+
58
+ m = create_model
59
+ @controller.current_mask[plural_name] = { id: m.id }
60
+ get :index, format: 'json'
61
+ assert_equal model.where(id: m.id).to_sql, assigns(plural_name).to_sql
62
+ @controller.current_mask.delete(plural_name)
64
63
  end
65
-
64
+
66
65
  end
67
66
  end
68
67
  end
@@ -13,15 +13,6 @@ module StandardAPI
13
13
  assert JSON.parse(response.body).is_a?(Hash)
14
14
  end
15
15
 
16
- test '#show.json mask' do
17
- m = create_model
18
- @controller.current_mask[plural_name] = { id: m.id + 1 }
19
- assert_raises(ActiveRecord::RecordNotFound) do
20
- get :show, id: m.id, format: 'json'
21
- end
22
- @controller.current_mask.delete(plural_name)
23
- end
24
-
25
16
  test '#show.json params[:include]' do
26
17
  m = create_model(:nested)
27
18
  get :show, id: m.id, include: includes, format: 'json'
@@ -43,9 +34,17 @@ module StandardAPI
43
34
  end
44
35
  end
45
36
 
46
- test 'route to #show.json' do
47
- assert_routing "/#{plural_name}/1", path_with_action('show', id: '1')
48
- assert_recognizes(path_with_action('show', id: '1'), "/#{plural_name}/1")
37
+ test '#show.json mask' do
38
+ # If #current_mask isn't defined by StandardAPI we don't know how to
39
+ # test other's implementation of #current_mask. Return and don't test.
40
+ return if @controller.method(:current_mask).owner != StandardAPI
41
+
42
+ m = create_model
43
+ @controller.current_mask[plural_name] = { id: m.id + 1 }
44
+ assert_raises(ActiveRecord::RecordNotFound) do
45
+ get :show, id: m.id, format: 'json'
46
+ end
47
+ @controller.current_mask.delete(plural_name)
49
48
  end
50
49
 
51
50
  end
@@ -52,6 +52,10 @@ module StandardAPI
52
52
  end
53
53
 
54
54
  test '#update.json mask' do
55
+ # If #current_mask isn't defined by StandardAPI we don't know how to
56
+ # test other's implementation of #current_mask. Return and don't test.
57
+ return if @controller.method(:current_mask).owner != StandardAPI
58
+
55
59
  m = create_model
56
60
  @controller.current_mask[plural_name] = { id: m.id + 1 }
57
61
  assert_raises(ActiveRecord::RecordNotFound) do
@@ -60,13 +64,6 @@ module StandardAPI
60
64
  @controller.current_mask.delete(plural_name)
61
65
  end
62
66
 
63
- test 'route to #update.json' do
64
- assert_routing({ method: :put, path: "#{plural_name}/1" }, path_with_action('update', id: '1'))
65
- assert_recognizes(path_with_action('update', id: '1'), { method: :put, path: "/#{plural_name}/1" })
66
- assert_routing({ method: :patch, path: "/#{plural_name}/1" }, path_with_action('update', id: '1'))
67
- assert_recognizes(path_with_action('update', id: '1'), { method: :patch, path: "/#{plural_name}/1" })
68
- end
69
-
70
67
  end
71
68
  end
72
69
  end
@@ -26,6 +26,9 @@ module StandardAPI::TestCase
26
26
 
27
27
  klass.controller_class.action_methods.each do |action|
28
28
  if const_defined?("StandardAPI::TestCase::#{action.capitalize}Tests")
29
+ # Include the test if there is a route
30
+ # if Rails.application.routes.url_for(controller: @controller.controller_path, action: 'destroy', only_path: true)
31
+
29
32
  klass.include("StandardAPI::TestCase::#{action.capitalize}Tests".constantize)
30
33
  end
31
34
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: standardapi
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - James Bracy
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-08-04 00:00:00.000000000 Z
11
+ date: 2015-08-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord-sort