Skip to content

Expose deserialization reverse mapping in controllers #29

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jul 13, 2017

Conversation

mdeutsch
Copy link
Contributor

@mdeutsch mdeutsch commented Jul 5, 2017

Adds a jsonapi_pointers instance method in the controller to access the json pointers generated during deserialization. See #27.

it 'should fetch the mapping created during deserialization' do
reverse_mapping = {id: "/data/id", type: "/data/type"}
allow(controller).to receive(:request) do
OpenStruct.new(env: {'jsonapi_deserializable.reverse_mapping' => reverse_mapping})

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Space inside { missing.
Line is too long. [90/80]
Space inside } missing.


context 'source pointers' do
it 'should fetch the mapping created during deserialization' do
reverse_mapping = {id: "/data/id", type: "/data/type"}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Space inside { missing.
Prefer single-quoted strings when you don't need string interpolation or special symbols.
Space inside } missing.


RSpec.describe JSONAPI::Rails::ActionController do
class TestController < ActionController::Base
deserializable_resource "things"

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Prefer single-quoted strings when you don't need string interpolation or special symbols.

@@ -0,0 +1,19 @@
require 'rails_helper'

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing magic comment # frozen_string_literal: true.

it 'should fetch the mapping created during deserialization' do
reverse_mapping = {id: "/data/id", type: "/data/type"}
allow(controller).to receive(:request) do
OpenStruct.new(env: {'jsonapi_deserializable.reverse_mapping' => reverse_mapping})

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Space inside { missing.
Line is too long. [90/80]
Space inside } missing.


context 'source pointers' do
it 'should fetch the mapping created during deserialization' do
reverse_mapping = {id: "/data/id", type: "/data/type"}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Space inside { missing.
Prefer single-quoted strings when you don't need string interpolation or special symbols.
Space inside } missing.


RSpec.describe JSONAPI::Rails::ActionController do
class TestController < ActionController::Base
deserializable_resource "things"

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Prefer single-quoted strings when you don't need string interpolation or special symbols.

@@ -0,0 +1,19 @@
require 'rails_helper'

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing magic comment # frozen_string_literal: true.

@beauby
Copy link
Member

beauby commented Jul 13, 2017

Thanks for this @mdeutsch, I'll rebase it, clean it up, and merge 👍.

@beauby beauby force-pushed the expose_reverse_mapping branch from e5fc28c to c7a939c Compare July 13, 2017 16:44
let(:controller) { TestController.new }

it 'should fetch the mapping created during deserialization' do
pointers = { id: "/data/id", type: "/data/type" }

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Prefer single-quoted strings when you don't need string interpolation or special symbols.

@beauby beauby force-pushed the expose_reverse_mapping branch 5 times, most recently from 9dd5b19 to f6a8287 Compare July 13, 2017 17:09
require 'rails_helper'

RSpec.describe ActionController::Base do
it 'should expose the deserialization mapping via the jsonapi_pointers method' do

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Line is too long. [83/80]

@beauby beauby force-pushed the expose_reverse_mapping branch from f6a8287 to 2c91b91 Compare July 13, 2017 17:11
@beauby beauby merged commit 0605a29 into jsonapi-rb:master Jul 13, 2017
@mdeutsch mdeutsch deleted the expose_reverse_mapping branch July 21, 2017 11:33
mdeutsch pushed a commit to patientslikeme/jsonapi-rails that referenced this pull request Jul 21, 2017
* upstream/master:
  Improve specs (jsonapi-rb#33)
  Expose deserialization reverse mapping in controllers (jsonapi-rb#29)
  Update jsonapi-rb to v0.2.1. (jsonapi-rb#32)
  Add dummy app temp files to .gitignore (jsonapi-rb#30)
  Deal with jsonapi-serializable no longer calling to_json (jsonapi-rb#26)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants