jsonapi-resources 0.7.0 → 0.7.1.beta1

Sign up to get free protection for your applications and to get access to all the features.
@@ -24,6 +24,9 @@ require File.expand_path('../helpers/functional_helpers', __FILE__)
24
24
 
25
25
  Rails.env = 'test'
26
26
 
27
+ I18n.load_path += Dir[File.expand_path("../../locales/*.yml", __FILE__)]
28
+ I18n.enforce_available_locales = false
29
+
27
30
  JSONAPI.configure do |config|
28
31
  config.json_key_format = :camelized_key
29
32
  end
@@ -349,7 +349,7 @@ class OperationsProcessorTest < Minitest::Test
349
349
  assert_kind_of(JSONAPI::OperationResult, operation_results.results[0])
350
350
  assert_equal(:no_content, operation_results.results[0].code)
351
351
  assert_equal(:no_content, operation_results.results[1].code)
352
- assert_equal(404, operation_results.results[2].code)
352
+ assert_equal('404', operation_results.results[2].code)
353
353
  end
354
354
 
355
355
  def test_show_operation
@@ -520,9 +520,9 @@ class OperationsProcessorTest < Minitest::Test
520
520
  error = StandardError.new
521
521
 
522
522
  callback = ->(error) { nil.explosions}
523
- result = op.send(:safe_run_callback, callback, error)
523
+ result = op.send(:safe_run_callback, callback, error)
524
524
 
525
525
  assert_instance_of(JSONAPI::ErrorsOperationResult, result)
526
- assert_equal(result.code, 500)
526
+ assert_equal(result.code, '500')
527
527
  end
528
528
  end
@@ -264,6 +264,26 @@ class ResourceTest < ActiveSupport::TestCase
264
264
  end
265
265
  end
266
266
 
267
+ def test_filter_on_to_many_relationship_id
268
+ posts = PostResource.find(:comments => 3)
269
+ assert_equal([2], posts.map(&:id))
270
+ end
271
+
272
+ def test_filter_on_aliased_to_many_relationship_id
273
+ # Comment 2 is approved
274
+ books = Api::V2::BookResource.find(:aliased_comments => 2)
275
+ assert_equal([0], books.map(&:id))
276
+
277
+ # However, comment 3 is non-approved, so it won't be accessible through this relationship
278
+ books = Api::V2::BookResource.find(:aliased_comments => 3)
279
+ assert_equal([], books.map(&:id))
280
+ end
281
+
282
+ def test_filter_on_has_one_relationship_id
283
+ people = PreferencesResource.find(:author => 1)
284
+ assert_equal([1], people.map(&:id))
285
+ end
286
+
267
287
  def test_to_many_relationship_filters
268
288
  post_resource = PostResource.new(Post.find(1), nil)
269
289
  comments = post_resource.comments
@@ -1638,12 +1638,6 @@ class SerializerTest < ActionDispatch::IntegrationTest
1638
1638
  self: '/preferences/1/relationships/author',
1639
1639
  related: '/preferences/1/author'
1640
1640
  }
1641
- },
1642
- friends: {
1643
- links: {
1644
- self: '/preferences/1/relationships/friends',
1645
- related: '/preferences/1/friends'
1646
- }
1647
1641
  }
1648
1642
  }
1649
1643
  }
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jsonapi-resources
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.0
4
+ version: 0.7.1.beta1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dan Gebhardt
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2015-12-08 00:00:00.000000000 Z
12
+ date: 2016-02-03 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler
@@ -126,7 +126,9 @@ files:
126
126
  - Rakefile
127
127
  - jsonapi-resources.gemspec
128
128
  - lib/generators/jsonapi/USAGE
129
+ - lib/generators/jsonapi/controller_generator.rb
129
130
  - lib/generators/jsonapi/resource_generator.rb
131
+ - lib/generators/jsonapi/templates/jsonapi_controller.rb
130
132
  - lib/generators/jsonapi/templates/jsonapi_resource.rb
131
133
  - lib/jsonapi-resources.rb
132
134
  - lib/jsonapi/active_record_operations_processor.rb
@@ -153,6 +155,7 @@ files:
153
155
  - lib/jsonapi/resources/version.rb
154
156
  - lib/jsonapi/response_document.rb
155
157
  - lib/jsonapi/routing_ext.rb
158
+ - locales/en.yml
156
159
  - test/config/database.yml
157
160
  - test/controllers/controller_test.rb
158
161
  - test/fixtures/active_record.rb
@@ -197,6 +200,7 @@ files:
197
200
  - test/integration/requests/request_test.rb
198
201
  - test/integration/routes/routes_test.rb
199
202
  - test/integration/sti_fields_test.rb
203
+ - test/lib/generators/jsonapi/controller_generator_test.rb
200
204
  - test/lib/generators/jsonapi/resource_generator_test.rb
201
205
  - test/test_helper.rb
202
206
  - test/unit/formatters/dasherized_key_formatter_test.rb
@@ -225,12 +229,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
225
229
  version: '2.0'
226
230
  required_rubygems_version: !ruby/object:Gem::Requirement
227
231
  requirements:
228
- - - ">="
232
+ - - ">"
229
233
  - !ruby/object:Gem::Version
230
- version: '0'
234
+ version: 1.3.1
231
235
  requirements: []
232
236
  rubyforge_project:
233
- rubygems_version: 2.4.6
237
+ rubygems_version: 2.4.5.1
234
238
  signing_key:
235
239
  specification_version: 4
236
240
  summary: Easily support JSON API in Rails.
@@ -279,6 +283,7 @@ test_files:
279
283
  - test/integration/requests/request_test.rb
280
284
  - test/integration/routes/routes_test.rb
281
285
  - test/integration/sti_fields_test.rb
286
+ - test/lib/generators/jsonapi/controller_generator_test.rb
282
287
  - test/lib/generators/jsonapi/resource_generator_test.rb
283
288
  - test/test_helper.rb
284
289
  - test/unit/formatters/dasherized_key_formatter_test.rb