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.
TODO: need to figure out how to do the equivalent of rr_satisfy { |h| h[:url_options].present? }
spec/integration/rspec_spec.rb
Outdated
|
|
||
| # 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.
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.
testing this gem in 5.0.0 for now
lib/rocket_pants/test_helper.rb
Outdated
|
|
||
| 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.
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.
Is this the version of circle or the version number for our project?
There was a problem hiding this comment.
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)
|
|
||
| **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.
We're not going to just call it version 2? :-P
There was a problem hiding this comment.
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 |
| gem 'pry' | ||
| gem 'pry-byebug' | ||
| # stable forked version of active_model_serializers in order to write an integration test | ||
| gem 'active_model_serializers', git: 'git@github.com:indiegogo/active_model_serializers.git', branch: '0-8-stable' |
| byebug (10.0.2) | ||
| coderay (1.1.2) | ||
| concurrent-ruby (1.0.5) | ||
| crack (0.4.3) |
There was a problem hiding this comment.
I thought you were removing crack, according to the comment in the CHANGELOG.md.
There was a problem hiding this comment.
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.
You shouldn't have to use &. since you just used Rails...
| 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.
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.
| # @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.
So Rails 5 requires all the responses to be HTTParty::Response? That seems weird.
There was a problem hiding this comment.
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("start_processing.action_controller", raw_payload.dup) | ||
|
|
||
| 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.
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.
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
| collection object, options | ||
| else | ||
| if Respondable.invalid?(object) | ||
| error! :invalid_resource, object.errors |
There was a problem hiding this comment.
We don't depend on this behavior anywhere, do we?
There was a problem hiding this comment.
other way around -- we depend on rocket pants NOT having this behavior
There was a problem hiding this comment.
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.
What are these circle config changes for?
There was a problem hiding this comment.
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: