-
Notifications
You must be signed in to change notification settings - Fork 1
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
rocket_pants 5 #1
Conversation
011c3ce
to
ff21f39
Compare
5aef625
to
e1c53fc
Compare
mock.proxy(SerializerA).new(fish, rr_satisfy { |h| h[:url_options].present? }) { |r| r } | ||
allow(TestController).to receive(:test_data) { fish } | ||
allow(TestController).to receive(:test_options) { {:serializer => SerializerA} } | ||
# mock.proxy(SerializerA).new(fish, rr_satisfy { |h| h[:url_options].present? }) { |r| r } |
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.
TODO: need to figure out how to do the equivalent of rr_satisfy { |h| h[:url_options].present? }
spec/integration/rspec_spec.rb
Outdated
describe TestController, 'rspec integration', integration: 'true' do | ||
|
||
# TODO: need to rewrite all of this to support Rails 5 | ||
# | ||
# Hack to allow us to include the ActionController::TestCase::Behaviour module |
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.
there's a lot of ugly hacks in this test to mock on TestController, I think I need to switch everything to use ActionDispatch::Integration
if I want these 4 tests to work in Rails 5x
Gemfile
Outdated
gem 'active_model_serializers', ENV['AMS_VERSION'] || '> 0.0' | ||
gem 'railties', '5.0.0' | ||
gem 'actionpack', '5.0.0' | ||
gem 'activerecord', '5.0.0' |
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.
testing this gem in 5.0.0 for now
lib/rocket_pants/test_helper.rb
Outdated
else | ||
parameters = (args[0] ||= {}) | ||
end | ||
|
||
response.recycle_cached_body! | ||
|
||
if _default_version.present? && parameters[:version].blank? && parameters['version'].blank? | ||
parameters[:version] = _default_version | ||
if Rails::VERSION::MAJOR <= 4 |
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 whole test_helper.rb is awful and just garbage. it's trying to prop up test controller implementation details in order to mock a controller.
@@ -0,0 +1,39 @@ | |||
version: 2 |
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.
Is this the version of circle or the version number for our project?
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 is what the circle documentation says to put -- I think it's the version of circle, because everyone on the internet has it set to 2 (circle 2)
@@ -2,6 +2,20 @@ | |||
|
|||
**Please Note**: This change log only covers v1.3 forwards - apologies for anything missing prior to that. | |||
|
|||
## Version 5.0.0 |
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.
We're not going to just call it version 2? :-P
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.
why would we do such a thing???
CHANGELOG.md
Outdated
* Update test dependencies and make sure all tests pass | ||
* Remove TestHelper Rspec mixin | ||
* Removed be_exposed Rspec matcher due to egregious testing patterns | ||
* Removed Proxy Based testing in favore of testing default_serializer_options as unit test |
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.
spelling of favor
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.
that was curtis
gem 'pry' | ||
gem 'pry-byebug' | ||
# stable forked version of active_model_serializers in order to write an integration test | ||
gem 'active_model_serializers', git: '[email protected]:indiegogo/active_model_serializers.git', branch: '0-8-stable' |
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.
Uggghhh
byebug (10.0.2) | ||
coderay (1.1.2) | ||
concurrent-ruby (1.0.5) | ||
crack (0.4.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.
I thought you were removing crack
, according to the comment in the CHANGELOG.md
.
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.
it looks like webmock uses crack unfortunately
env = Rails.env.to_s if defined?(Rails.env) | ||
env ||= ENV['RAILS_ENV'].presence || ENV['RACK_ENV'].presence || "development" | ||
ActiveSupport::StringInquirer.new env | ||
if defined?(Rails.env) && Rails&.env |
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.
You shouldn't have to use &.
since you just used Rails
...
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.
yeah I can remove it, np
if defined?(Rails.env) && Rails&.env | ||
env = Rails.env.to_s | ||
else | ||
env ||= ENV['RAILS_ENV'].presence || ENV['RACK_ENV'].presence || "development" |
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.
You don't really need the ||=
here. Perhaps if you want it to be clearer with the if-else
, maybe do this instead:
env = if defined?(Rails.env) && Rails.env
Rails.env.to_s
else
ENV["RAILS_ENV"].presence || ENV["RACK_ENV"].presence || "development"
end
even though it seems to me that the original structure is fine and just add the addition Rails.env
condition at the end of the original if.
@@ -123,7 +123,7 @@ def unpack(object, options = {}) | |||
# @param [Hash, Object] response the response to check errors on | |||
# @raise [RocketPants::Error] a generic error when the type is wrong, or a registered error subclass otherwise. | |||
def check_response_errors(response) | |||
if !response.is_a?(Hash) | |||
if !response.is_a?(HTTParty::Response) |
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.
So Rails 5 requires all the responses to be HTTParty::Response
? That seems weird.
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.
not exactly -- all responses were always HTTParty::Response
BUT some versions of HTTParty responded true to is_a?(Hash). when I bumped HTTParty I had to update this
|
||
ActiveSupport::Notifications.instrument("process_action.rocket_pants", raw_payload) do |payload| | ||
ActiveSupport::Notifications.instrument("process_action.action_controller", raw_payload) do |payload| |
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.
Why change these to the word action_controller
? Seems like we'd want these to remain rocket_pants
since that's where the notification is coming from?
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.
I'll defer to Curtis for the explanation, but if it's rocket_pants we can't use Skylight instrumentation -- we're currently patching rocket_pants in the monorail to change this to action_controller
@@ -166,11 +164,7 @@ def exposes(object, options = {}) | |||
elsif Respondable.collection?(object) | |||
collection object, options | |||
else | |||
if Respondable.invalid?(object) | |||
error! :invalid_resource, object.errors |
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.
We don't depend on this behavior anywhere, do we?
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.
other way around -- we depend on rocket pants NOT having this behavior
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.
If we open source this project, will people appreciate this change or will e need to generalize it somehow?
Seems mostly fine |
@@ -0,0 +1,39 @@ | |||
version: 2 |
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.
What are these circle config changes for?
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.
oh nvm this is for the fork, ok carry on
LGTM |
- bump rocket pants version to 5.0.0 - remove travis.yml; replace with circleci yml - update ruby to supported version (2.3.5) - replace old mock behavior with newer rspec mock behavior - remove rr gem - get all specs to pass (half were originally failing) - update kaminari integraiton to work with rocket pants again - use pinned stable version of active_model_serializers for integration test - check in Gemfile.lock - remove check that raises if exposed resource returns to invalid and returns true - patch with Rails 5.0 compatible changes - update instrumentation so it works nicely with skylight
f1b4d3f
to
7892ca1
Compare
Pivotal: https://www.pivotaltracker.com/story/show/159012685
Monorail running this branch is green: https://github.com/indiegogo/monorail/pull/11639
Summary of Changes:
Later: