-
Notifications
You must be signed in to change notification settings - Fork 25
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
WpApiClient::Collection: Added accessor to get total pages for a cust… #11
base: master
Are you sure you want to change the base?
Conversation
…om post_type posts
@duncanjbrown Could review ? |
Thank you! Would you mind adding a spec? |
@duncanjbrown added spec please review.. |
|
@duncanjbrown Please find rspec result in https://travis-ci.org/gadikotamohan/wp-api-client |
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.
Thank you so much — Travis too! 🙌
Couple of minor comments.
it "should respond to total_pages and total_available" do | ||
expect(@collection).to respond_to(:total_pages) | ||
expect(@collection).to respond_to(:total_available) | ||
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.
This spec has the same name as the below one and I think it's redundant?
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.
@duncanjbrown yeah I will correct this.
it "should respond to total_pages and total_available" do | ||
expect(@collection.total_pages).to eq(@api.instance_variable_get("@headers")["X-Wp-Totalpages"].to_i) | ||
expect(@collection.total_available).to eq(@api.instance_variable_get("@headers")["X-Wp-Total"].to_i) | ||
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.
The right hand side is quite magical here. These values are hardcoded in the VCR cassettes: I believe X-WP-TOTAL is 100 and X-WP-TOTALPAGES is 10.
My whole testing approach here was flawed, but I think the least worst thing would be to put literals on the right hand side here, like this?
expect(@collection.total_pages).to eq(10)
expect(@collection.total_available).to eq(100)
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.
@duncanjbrown making this change.
@duncanjbrown made suggested changes to code and please find rpsec status in https://travis-ci.org/gadikotamohan/wp-api-client/builds/556100532 (all specs are green) |
Hi @duncanjbrown got a chance to look into this ? |
hi @duncanjbrown, have you got a chance to look into this PR ? |
WpApiClient::Collection: Added accessor to get total pages for a custom post_type posts