Skip to content
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

parse_root_in_json regression introduced in 0.10.2 #508

Closed
espen opened this issue Jul 2, 2018 · 5 comments
Closed

parse_root_in_json regression introduced in 0.10.2 #508

espen opened this issue Jul 2, 2018 · 5 comments

Comments

@espen
Copy link
Contributor

espen commented Jul 2, 2018

I have a JSON which returns a person object but my class is called member so I use parse_root_in_json :person. This has worked up to 0.10.1 but with 0.10.2 the returned object is a Member object with a person object instead of just having the person attributes on the Member object.

So instead of member.name as before, with 0.10.2 I have to do member.person.name.

Looks like df1b82b is the only commit in v.010.2

I'll try to put up a failing test for this.

@zacharywelch
Copy link
Collaborator

See the problem. I'll take a look shortly. Thanks @espen 👍

@zacharywelch
Copy link
Collaborator

zacharywelch commented Jul 2, 2018

Here's a failing spec I think captures the problem. Working on a fix...

    context "to a symbol" do
      before do
        Her::API.default_api.connection.adapter :test do |stub|
          stub.post("/users") { [200, {}, { person: { id: 1, fullname: "Lindsay Fünke" } }.to_json] }
        end

        spawn_model("Foo::User") { parse_root_in_json :person }
      end

      it "parse the data with the symbol" do
        @new_user = Foo::User.create(fullname: "Lindsay Fünke")
        expect(@new_user.id).to eq(1) #=> failing
        expect(@new_user.fullname).to eq("Lindsay Fünke")
      end
    end

@zacharywelch
Copy link
Collaborator

zacharywelch commented Jul 2, 2018

Fixed now by d0b49f1 and published in releases v1.0.2 and v0.10.3. Thanks!

@edtjones
Copy link
Collaborator

edtjones commented Jul 3, 2018

Thanks @zacharywelch ! 😇

@espen
Copy link
Contributor Author

espen commented Jul 4, 2018

Can confirm this works. Thanks for the quick fix @zacharywelch 🎉

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

No branches or pull requests

3 participants