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

rocket_pants 5 #1

Merged
merged 4 commits into from
Jul 18, 2018
Merged

Conversation

polinagogo
Copy link

@polinagogo polinagogo commented Jul 14, 2018

Pivotal: https://www.pivotaltracker.com/story/show/159012685
Monorail running this branch is green: https://github.com/indiegogo/monorail/pull/11639

Summary of Changes:

  • update ruby to supported version (2.0)
  • start replacing old mock behavior with supported mock behavior
  • get all specs to pass (half of them were failing)
Finished in 0.65248 seconds (files took 2.27 seconds to load)
186 examples, 0 failures
  • remove travis.yml
  • update kaminari integration to work with rocket_pants again
  • use our pinned version of active_model_serializers for the integration test
  • check in Gemfile.lock file
  • remove the check that throws 422 if exposed resources responds to invalid and returns true
  • update readme
  • cut a 5.0.0 tag, check that the monorail goes green with the updates so far
  • patch with Rails 5 compatible changes
  • confirm monorail is green with latest changes
  • figure out how to replace the proxy rr check in active_model_serializers_spec.rb
  • add ability to run on CI
  • update instrumentation so it works with skylight

Later:

  • fix deprecation warnings
  • make this repo a mirror instead of a fork?
  • update tag

@polinagogo polinagogo self-assigned this Jul 14, 2018
@polinagogo polinagogo force-pushed the ironbank/ps-fix-rocketpants-failing-tests branch from 011c3ce to ff21f39 Compare July 15, 2018 04:50
@polinagogo polinagogo changed the title fix rocketpants failing tests fix rocketpants Jul 16, 2018
@polinagogo polinagogo changed the title fix rocketpants rocketpants 5 Jul 16, 2018
@polinagogo polinagogo changed the title rocketpants 5 rocket_pants 5 Jul 16, 2018
@polinagogo polinagogo force-pushed the ironbank/ps-fix-rocketpants-failing-tests branch from 5aef625 to e1c53fc Compare July 17, 2018 00:40
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 }
Copy link
Author

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? }

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
Copy link
Author

@polinagogo polinagogo Jul 17, 2018

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'
Copy link
Author

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

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
Copy link
Author

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

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?

Copy link
Author

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

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

Copy link
Author

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

Choose a reason for hiding this comment

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

spelling of favor

Copy link
Author

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'

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)

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.

Copy link
Author

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

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...

Copy link
Author

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"

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)

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.

Copy link
Author

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|

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?

Copy link
Author

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

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?

Copy link
Author

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

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?

@IndieBarry
Copy link

Seems mostly fine

@@ -0,0 +1,39 @@
version: 2

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?

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

@sherrygogo
Copy link

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
@polinagogo polinagogo force-pushed the ironbank/ps-fix-rocketpants-failing-tests branch from f1b4d3f to 7892ca1 Compare July 18, 2018 17:28
@polinagogo polinagogo merged commit fb82605 into master Jul 18, 2018
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.

4 participants