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

Proposed solution to issue #404 #411

Closed
wants to merge 1 commit into from
Closed

Proposed solution to issue #404 #411

wants to merge 1 commit into from

Conversation

tiagogodinho
Copy link

This is a proposed solution to issue #404.

The problem:

task = Task.find(1)
# => #<Task(tasks/1) title="Test" created_at="2016-08-04T20:03:42.612Z" updated_at="2016-08-06T17:00:35.649Z" id=1>
task.changes
# => {}

task = Task.all[0]
# => #<Task(tasks/1) title="Test" created_at="2016-08-04T20:03:42.612Z" updated_at="2016-08-06T17:00:35.649Z" id=1>
task.changes
# => {"title"=>[nil, "Test"], "created_at"=>[nil, "2016-08-04T20:03:42.612Z"], "updated_at"=>[nil, "2016-08-06T17:00:35.649Z"]} 

Now:

task = Task.find(1)
task.changes
# => {}

task = Task.all[0]
task.changes
# => {}
task.title = 'New title'
task.changes
# => {"title"=>["Test", "New title"]}

@lucasrenan
Copy link

👍

@edtjones
Copy link
Collaborator

hi @tiagogodinho @lucasrenan I've just got commit access on this repo and plan to get back on track with maintenance over time - will be in touch soon!

Copy link
Collaborator

@zacharywelch zacharywelch left a comment

Choose a reason for hiding this comment

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

@tiagogodinho this looks 💯

Before merging do you mind taking care of the specs and rebasing?

@@ -8,6 +8,7 @@
builder.use Her::Middleware::FirstLevelParseJSON
builder.use Faraday::Request::UrlEncoded
builder.adapter :test do |stub|
stub.get("/users") { |env| [200, {}, [{ :id => 1, :fullname => "Lindsay Fünke" }].to_json] }
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can we add multiple users here for consistency?

@@ -25,6 +26,14 @@
end
end

context "for existing resource in a collection" do
Copy link
Collaborator

Choose a reason for hiding this comment

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

how about?

context "for existing collections" do
  let(:users) { Foo::User.all }
  it "has no changes" do
    expect(users).to_not include(be_changed)
  end
end

# Initialize a resource
#
# @private
def self.initialize_resource(klass, item_data)
Copy link
Collaborator

Choose a reason for hiding this comment

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

this should come in handy elsewhere 👍

@zacharywelch
Copy link
Collaborator

Fixed by #298. Thanks for your help on this @tiagogodinho!

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.

None yet

4 participants