-
Notifications
You must be signed in to change notification settings - Fork 18
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
Dynamic parameter persistence #59
base: master
Are you sure you want to change the base?
Dynamic parameter persistence #59
Conversation
before(:each) { expect(parameters).to be_empty } | ||
it "returns the persisted params" do | ||
persisted_params = connection.parameters | ||
persisted_params.each do |key, value| |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use each_key instead of each.
Unused block argument - value. If it's necessary, use _ or _value as an argument name to indicate that it won't be used.
context "empty param values" do | ||
let(:parameters) { {"a" => nil, "b" => 3, "c" => ""} } | ||
it "removes them" do | ||
expect(subject.send(:request_params)).to eq({"b" => 3}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Space inside { missing.
Redundant curly braces around a hash parameter.
Space inside } missing.
expect(subject.send(:request_params)).to eq({}) | ||
end | ||
context "empty param values" do | ||
let(:parameters) { {"a" => nil, "b" => 3, "c" => ""} } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Space inside { missing.
Space inside } missing.
end | ||
it 'does not update the DB if there are no request params' do | ||
expect(parameters).to be_empty | ||
expect{ subject.call }.to_not change{ connection.reload.parameters } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Parenthesize the param change{ connection.reload.parameters } to make sure that the block will be associated with the change method call.
end | ||
|
||
def request_params | ||
context.parameters.to_h.select{|k,v| v.present?} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Space between { and | missing.
Unused block argument - k. If it's necessary, use _ or _k as an argument name to indicate that it won't be used.
Space missing after comma.
Space missing inside }.
7162aaa
to
bef1882
Compare
connection.reload.parameters | ||
}.from({}) | ||
end | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Extra empty line detected at block body end.
connection.reload.parameters | ||
}.from({}) | ||
end | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Extra empty line detected at block body end.
connection.reload.parameters | ||
}.from({}) | ||
end | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Extra empty line detected at block body end.
bef1882
to
9a5cdfd
Compare
spec/support/compatible_http.rb
Outdated
def compatible_http(method, path, args) | ||
case Rails::VERSION::MAJOR | ||
when 4 then self.send(method, path, args[:params], args[:headers]) | ||
when 5 then self.send(method, path, args) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Redundant self detected.
spec/support/compatible_http.rb
Outdated
# See https://github.com/nebulab/cangaroo/pull/60#issue-175032794 | ||
def compatible_http(method, path, args) | ||
case Rails::VERSION::MAJOR | ||
when 4 then self.send(method, path, args[:params], args[:headers]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Redundant self detected.
let(:parameters) { { "different" => "param" } } | ||
it 'does not update the DB' do | ||
expect(connection.parameters.keys).to_not include(parameters.keys.first) | ||
expect{ subject.call }.to_not change{ connection.reload.parameters.with_indifferent_access } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Parenthesize the param change{ connection.reload.parameters.with_indifferent_access } to make sure that the block will be associated with the change method call.
6377df2
to
5e38aff
Compare
Have you guys had a chance to look at this? I've had it running in production for a couple months now without issue. Anything I can do to help keep this moving along? |
@bricesanchez it seems ok for me, what do you think? |
Back in the days of Wombat, some endpoints depended on being able to pass parameters back to the system, e.g. a timestamp of the most recently updated item. This was the point behind the
#add_parameter
method in spree'sEndpointBase
, which most of the endpoints have as a dependency. Many of them require the#add_parameter
method to function properly, for example:to name a few.
This attempts to add this functionality to cangaroo, so that anyone using these endpoints really would find cangaroo to be backwards compatible with Wombat.